Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README-zh.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# `skr canvas`

![CI](https://github.com/Brooooooklyn/canvas/workflows/CI/badge.svg)
![Skia Version](https://img.shields.io/badge/Skia-chrome%2Fm143-hotpink)
![Skia Version](https://img.shields.io/badge/Skia-chrome%2Fm144-hotpink)
[![install size](https://packagephobia.com/badge?p=@napi-rs/canvas)](https://packagephobia.com/result?p=@napi-rs/canvas)
[![Downloads](https://img.shields.io/npm/dm/@napi-rs/canvas.svg?sanitize=true)](https://npmcharts.com/compare/@napi-rs/canvas?minimal=true)

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# `skr canvas`

[![CI](https://github.com/Brooooooklyn/canvas/actions/workflows/CI.yaml/badge.svg)](https://github.com/Brooooooklyn/canvas/actions/workflows/CI.yaml)
![Skia Version](https://img.shields.io/badge/Skia-chrome%2Fm143-hotpink)
![Skia Version](https://img.shields.io/badge/Skia-chrome%2Fm144-hotpink)
[![install size](https://packagephobia.com/badge?p=@napi-rs/canvas)](https://packagephobia.com/result?p=@napi-rs/canvas)
[![Downloads](https://img.shields.io/npm/dm/@napi-rs/canvas.svg?sanitize=true)](https://npmcharts.com/compare/@napi-rs/canvas?minimal=true)

Expand Down
6 changes: 5 additions & 1 deletion npm/android-arm64/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,9 @@
"repository": {
"type": "git",
"url": "git+https://github.com/Brooooooklyn/canvas.git"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/Brooooooklyn"
}
}
}
6 changes: 5 additions & 1 deletion npm/darwin-arm64/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,9 @@
"repository": {
"type": "git",
"url": "git+https://github.com/Brooooooklyn/canvas.git"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/Brooooooklyn"
}
}
}
6 changes: 5 additions & 1 deletion npm/darwin-x64/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,9 @@
"repository": {
"type": "git",
"url": "git+https://github.com/Brooooooklyn/canvas.git"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/Brooooooklyn"
}
}
}
6 changes: 5 additions & 1 deletion npm/linux-arm-gnueabihf/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,9 @@
"repository": {
"type": "git",
"url": "git+https://github.com/Brooooooklyn/canvas.git"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/Brooooooklyn"
}
}
}
8 changes: 6 additions & 2 deletions npm/linux-arm64-gnu/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,9 @@
},
"libc": [
"glibc"
]
}
],
"funding": {
"type": "github",
"url": "https://github.com/sponsors/Brooooooklyn"
}
}
8 changes: 6 additions & 2 deletions npm/linux-arm64-musl/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,9 @@
},
"libc": [
"musl"
]
}
],
"funding": {
"type": "github",
"url": "https://github.com/sponsors/Brooooooklyn"
}
}
8 changes: 6 additions & 2 deletions npm/linux-riscv64-gnu/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,9 @@
},
"libc": [
"glibc"
]
}
],
"funding": {
"type": "github",
"url": "https://github.com/sponsors/Brooooooklyn"
}
}
8 changes: 6 additions & 2 deletions npm/linux-x64-gnu/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,9 @@
},
"libc": [
"glibc"
]
}
],
"funding": {
"type": "github",
"url": "https://github.com/sponsors/Brooooooklyn"
}
}
8 changes: 6 additions & 2 deletions npm/linux-x64-musl/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,9 @@
},
"libc": [
"musl"
]
}
],
"funding": {
"type": "github",
"url": "https://github.com/sponsors/Brooooooklyn"
}
}
6 changes: 5 additions & 1 deletion npm/win32-arm64-msvc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,9 @@
"repository": {
"type": "git",
"url": "git+https://github.com/Brooooooklyn/canvas.git"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/Brooooooklyn"
}
}
}
6 changes: 5 additions & 1 deletion npm/win32-x64-msvc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,9 @@
"repository": {
"type": "git",
"url": "git+https://github.com/Brooooooklyn/canvas.git"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/Brooooooklyn"
}
}
}
2 changes: 1 addition & 1 deletion skia
Submodule skia updated 629 files
38 changes: 36 additions & 2 deletions skia-c/skia_c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1201,14 +1201,48 @@ void skiac_path_add_circle(skiac_path* c_path, float x, float y, float r) {
}

skiac_path* skiac_path_transform(skiac_path* c_path, skiac_matrix* c_matrix) {
SkPath transformed = c_path->path().makeTransform(*MATRIX_CAST);
return new skiac_path(transformed);
SkMatrix matrix = *MATRIX_CAST;

// Check for trailing moveTo (Skia trims these during SkPath creation)
SkSpan<const SkPathVerb> verbs = c_path->builder.verbs();
bool hasTrailingMove = !verbs.empty() && verbs.back() == SkPathVerb::kMove;
SkPoint trailingMovePoint = hasTrailingMove ? c_path->builder.points().back() : SkPoint{0, 0};

// Transform the path (this will lose trailing moveTo)
SkPath transformed = c_path->path().makeTransform(matrix);
skiac_path* result = new skiac_path(transformed);

// Restore trailing moveTo with transformed coordinates
if (hasTrailingMove) {
SkPoint transformedPoint = matrix.mapPoint(trailingMovePoint);
result->builder.moveTo(transformedPoint);
result->invalidate();
}

return result;
}

void skiac_path_transform_self(skiac_path* c_path, skiac_matrix* c_matrix) {
SkMatrix matrix = *reinterpret_cast<SkMatrix*>(c_matrix);

// Check for trailing moveTo before transform (Skia trims these during SkPath creation)
SkSpan<const SkPathVerb> verbs = c_path->builder.verbs();
bool hasTrailingMove = !verbs.empty() && verbs.back() == SkPathVerb::kMove;
SkPoint trailingMovePoint = {0, 0};
if (hasTrailingMove) {
trailingMovePoint = c_path->builder.points().back();
}

// Transform the path (this will lose trailing moveTo)
SkPath transformed = c_path->path().makeTransform(matrix);
c_path->replace_from_path(transformed);

// Restore trailing moveTo with transformed coordinates
if (hasTrailingMove) {
SkPoint transformedPoint = matrix.mapPoint(trailingMovePoint);
c_path->builder.moveTo(transformedPoint);
c_path->invalidate();
}
}

bool skiac_path_is_empty(skiac_path* c_path) {
Expand Down
Loading