Skip to content

Commit

Permalink
fix(path): wrong Stroke type cast and miterLimit default value
Browse files Browse the repository at this point in the history
  • Loading branch information
Brooooooklyn committed Apr 30, 2021
1 parent 6e7cc5a commit 5f1761b
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 37 deletions.
27 changes: 17 additions & 10 deletions __test__/pathkit.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ test('Convert stroke to path 2', (t) => {
})

// 直角
test.only('StrokeJoin.Miter', (t) => {
test('StrokeJoin.Miter', (t) => {
const box = new Path2D()
box.rect(0, 0, 100, 100)
box.stroke({ width: 20, join: StrokeJoin.Miter })
Expand All @@ -195,21 +195,27 @@ test.only('StrokeJoin.Miter', (t) => {
})

// 45度斜角
test.only('StrokeJoin.Bevel', (t) => {
test('StrokeJoin.Bevel', (t) => {
const box = new Path2D()
box.rect(0, 0, 100, 100)
box.stroke({ width: 20, join: StrokeJoin.Bevel })

t.is(box.toSVGString(), 'M0 -10L100 -10L110 0L110 100L100 110L0 110L-10 100L-10 0L0 -10ZM10 10L10 90L90 90L90 10L10 10Z')
t.is(
box.toSVGString(),
'M0 -10L100 -10L110 0L110 100L100 110L0 110L-10 100L-10 0L0 -10ZM10 10L10 90L90 90L90 10L10 10Z',
)
})

// 圆角
test.only('StrokeJoin.Round', (t) => {
test('StrokeJoin.Round', (t) => {
const box = new Path2D()
box.rect(0, 0, 100, 100)
box.stroke({ width: 20, join: StrokeJoin.Round })

t.is(box.toSVGString(), 'M-10 100L-10 0Q-10 -0.245486 -9.98795 -0.490677Q-9.97591 -0.735867 -9.95185 -0.980171Q-9.92778 -1.22448 -9.89176 -1.4673Q-9.85574 -1.71013 -9.80785 -1.9509Q-9.75996 -2.19167 -9.70031 -2.4298Q-9.64066 -2.66793 -9.5694 -2.90285Q-9.49814 -3.13776 -9.41544 -3.3689Q-9.33274 -3.60003 -9.23879 -3.82683Q-9.14485 -4.05363 -9.03989 -4.27555Q-8.93493 -4.49747 -8.81921 -4.71397Q-8.70349 -4.93047 -8.57729 -5.14103Q-8.45108 -5.35159 -8.31469 -5.5557Q-8.17831 -5.75982 -8.03207 -5.95699Q-7.88584 -6.15417 -7.7301 -6.34393Q-7.57437 -6.5337 -7.40951 -6.71559Q-7.24465 -6.89748 -7.07107 -7.07107Q-6.89748 -7.24465 -6.71559 -7.40951Q-6.5337 -7.57437 -6.34393 -7.7301Q-6.15417 -7.88584 -5.95699 -8.03207Q-5.75982 -8.17831 -5.5557 -8.3147Q-5.35159 -8.45108 -5.14103 -8.57729Q-4.93047 -8.70349 -4.71397 -8.81921Q-4.49747 -8.93493 -4.27555 -9.03989Q-4.05363 -9.14485 -3.82683 -9.23879Q-3.60003 -9.33274 -3.3689 -9.41544Q-3.13776 -9.49814 -2.90285 -9.5694Q-2.66793 -9.64066 -2.4298 -9.70031Q-2.19167 -9.75996 -1.9509 -9.80785Q-1.71013 -9.85574 -1.4673 -9.89176Q-1.22448 -9.92778 -0.980171 -9.95185Q-0.735867 -9.97591 -0.490677 -9.98795Q-0.245486 -10 0 -10L100 -10Q100.245 -10 100.491 -9.98795Q100.736 -9.97591 100.98 -9.95185Q101.224 -9.92778 101.467 -9.89176Q101.71 -9.85574 101.951 -9.80785Q102.192 -9.75996 102.43 -9.70031Q102.668 -9.64066 102.903 -9.5694Q103.138 -9.49814 103.369 -9.41544Q103.6 -9.33274 103.827 -9.23879Q104.054 -9.14485 104.276 -9.03989Q104.497 -8.93493 104.714 -8.81921Q104.93 -8.70349 105.141 -8.57729Q105.352 -8.45108 105.556 -8.31469Q105.76 -8.17831 105.957 -8.03207Q106.154 -7.88584 106.344 -7.7301Q106.534 -7.57437 106.716 -7.40951Q106.897 -7.24465 107.071 -7.07107Q107.245 -6.89748 107.41 -6.71559Q107.574 -6.5337 107.73 -6.34393Q107.886 -6.15417 108.032 -5.95699Q108.178 -5.75982 108.315 -5.5557Q108.451 -5.35159 108.577 -5.14103Q108.703 -4.93047 108.819 -4.71397Q108.935 -4.49747 109.04 -4.27555Q109.145 -4.05363 109.239 -3.82683Q109.333 -3.60003 109.415 -3.3689Q109.498 -3.13776 109.569 -2.90285Q109.641 -2.66793 109.7 -2.4298Q109.76 -2.19167 109.808 -1.9509Q109.856 -1.71013 109.892 -1.4673Q109.928 -1.22448 109.952 -0.980171Q109.976 -0.735867 109.988 -0.490677Q110 -0.245486 110 0L110 100Q110 100.245 109.988 100.491Q109.976 100.736 109.952 100.98Q109.928 101.224 109.892 101.467Q109.856 101.71 109.808 101.951Q109.76 102.192 109.7 102.43Q109.641 102.668 109.569 102.903Q109.498 103.138 109.415 103.369Q109.333 103.6 109.239 103.827Q109.145 104.054 109.04 104.276Q108.935 104.497 108.819 104.714Q108.703 104.93 108.577 105.141Q108.451 105.352 108.315 105.556Q108.178 105.76 108.032 105.957Q107.886 106.154 107.73 106.344Q107.574 106.534 107.41 106.716Q107.245 106.897 107.071 107.071Q106.897 107.245 106.716 107.41Q106.534 107.574 106.344 107.73Q106.154 107.886 105.957 108.032Q105.76 108.178 105.556 108.315Q105.352 108.451 105.141 108.577Q104.93 108.703 104.714 108.819Q104.497 108.935 104.276 109.04Q104.054 109.145 103.827 109.239Q103.6 109.333 103.369 109.415Q103.138 109.498 102.903 109.569Q102.668 109.641 102.43 109.7Q102.192 109.76 101.951 109.808Q101.71 109.856 101.467 109.892Q101.224 109.928 100.98 109.952Q100.736 109.976 100.491 109.988Q100.245 110 100 110L0 110Q-0.245486 110 -0.490677 109.988Q-0.735867 109.976 -0.980171 109.952Q-1.22448 109.928 -1.4673 109.892Q-1.71013 109.856 -1.9509 109.808Q-2.19167 109.76 -2.4298 109.7Q-2.66793 109.641 -2.90285 109.569Q-3.13776 109.498 -3.3689 109.415Q-3.60003 109.333 -3.82683 109.239Q-4.05363 109.145 -4.27555 109.04Q-4.49747 108.935 -4.71397 108.819Q-4.93047 108.703 -5.14103 108.577Q-5.35159 108.451 -5.5557 108.315Q-5.75982 108.178 -5.95699 108.032Q-6.15417 107.886 -6.34393 107.73Q-6.5337 107.574 -6.71559 107.41Q-6.89748 107.245 -7.07107 107.071Q-7.24465 106.897 -7.40951 106.716Q-7.57437 106.534 -7.7301 106.344Q-7.88584 106.154 -8.03207 105.957Q-8.17831 105.76 -8.3147 105.556Q-8.45108 105.352 -8.57729 105.141Q-8.70349 104.93 -8.81921 104.714Q-8.93493 104.497 -9.03989 104.276Q-9.14485 104.054 -9.23879 103.827Q-9.33274 103.6 -9.41544 103.369Q-9.49814 103.138 -9.5694 102.903Q-9.64066 102.668 -9.70031 102.43Q-9.75996 102.192 -9.80785 101.951Q-9.85574 101.71 -9.89176 101.467Q-9.92778 101.224 -9.95185 100.98Q-9.97591 100.736 -9.98795 100.491Q-10 100.245 -10 100ZM10 10L10 90L90 90L90 10L10 10Z')
t.is(
box.toSVGString(),
'M-10 100L-10 0Q-10 -0.245486 -9.98795 -0.490677Q-9.97591 -0.735867 -9.95185 -0.980171Q-9.92778 -1.22448 -9.89176 -1.4673Q-9.85574 -1.71013 -9.80785 -1.9509Q-9.75996 -2.19167 -9.70031 -2.4298Q-9.64066 -2.66793 -9.5694 -2.90285Q-9.49814 -3.13776 -9.41544 -3.3689Q-9.33274 -3.60003 -9.23879 -3.82683Q-9.14485 -4.05363 -9.03989 -4.27555Q-8.93493 -4.49747 -8.81921 -4.71397Q-8.70349 -4.93047 -8.57729 -5.14103Q-8.45108 -5.35159 -8.31469 -5.5557Q-8.17831 -5.75982 -8.03207 -5.95699Q-7.88584 -6.15417 -7.7301 -6.34393Q-7.57437 -6.5337 -7.40951 -6.71559Q-7.24465 -6.89748 -7.07107 -7.07107Q-6.89748 -7.24465 -6.71559 -7.40951Q-6.5337 -7.57437 -6.34393 -7.7301Q-6.15417 -7.88584 -5.95699 -8.03207Q-5.75982 -8.17831 -5.5557 -8.3147Q-5.35159 -8.45108 -5.14103 -8.57729Q-4.93047 -8.70349 -4.71397 -8.81921Q-4.49747 -8.93493 -4.27555 -9.03989Q-4.05363 -9.14485 -3.82683 -9.23879Q-3.60003 -9.33274 -3.3689 -9.41544Q-3.13776 -9.49814 -2.90285 -9.5694Q-2.66793 -9.64066 -2.4298 -9.70031Q-2.19167 -9.75996 -1.9509 -9.80785Q-1.71013 -9.85574 -1.4673 -9.89176Q-1.22448 -9.92778 -0.980171 -9.95185Q-0.735867 -9.97591 -0.490677 -9.98795Q-0.245486 -10 0 -10L100 -10Q100.245 -10 100.491 -9.98795Q100.736 -9.97591 100.98 -9.95185Q101.224 -9.92778 101.467 -9.89176Q101.71 -9.85574 101.951 -9.80785Q102.192 -9.75996 102.43 -9.70031Q102.668 -9.64066 102.903 -9.5694Q103.138 -9.49814 103.369 -9.41544Q103.6 -9.33274 103.827 -9.23879Q104.054 -9.14485 104.276 -9.03989Q104.497 -8.93493 104.714 -8.81921Q104.93 -8.70349 105.141 -8.57729Q105.352 -8.45108 105.556 -8.31469Q105.76 -8.17831 105.957 -8.03207Q106.154 -7.88584 106.344 -7.7301Q106.534 -7.57437 106.716 -7.40951Q106.897 -7.24465 107.071 -7.07107Q107.245 -6.89748 107.41 -6.71559Q107.574 -6.5337 107.73 -6.34393Q107.886 -6.15417 108.032 -5.95699Q108.178 -5.75982 108.315 -5.5557Q108.451 -5.35159 108.577 -5.14103Q108.703 -4.93047 108.819 -4.71397Q108.935 -4.49747 109.04 -4.27555Q109.145 -4.05363 109.239 -3.82683Q109.333 -3.60003 109.415 -3.3689Q109.498 -3.13776 109.569 -2.90285Q109.641 -2.66793 109.7 -2.4298Q109.76 -2.19167 109.808 -1.9509Q109.856 -1.71013 109.892 -1.4673Q109.928 -1.22448 109.952 -0.980171Q109.976 -0.735867 109.988 -0.490677Q110 -0.245486 110 0L110 100Q110 100.245 109.988 100.491Q109.976 100.736 109.952 100.98Q109.928 101.224 109.892 101.467Q109.856 101.71 109.808 101.951Q109.76 102.192 109.7 102.43Q109.641 102.668 109.569 102.903Q109.498 103.138 109.415 103.369Q109.333 103.6 109.239 103.827Q109.145 104.054 109.04 104.276Q108.935 104.497 108.819 104.714Q108.703 104.93 108.577 105.141Q108.451 105.352 108.315 105.556Q108.178 105.76 108.032 105.957Q107.886 106.154 107.73 106.344Q107.574 106.534 107.41 106.716Q107.245 106.897 107.071 107.071Q106.897 107.245 106.716 107.41Q106.534 107.574 106.344 107.73Q106.154 107.886 105.957 108.032Q105.76 108.178 105.556 108.315Q105.352 108.451 105.141 108.577Q104.93 108.703 104.714 108.819Q104.497 108.935 104.276 109.04Q104.054 109.145 103.827 109.239Q103.6 109.333 103.369 109.415Q103.138 109.498 102.903 109.569Q102.668 109.641 102.43 109.7Q102.192 109.76 101.951 109.808Q101.71 109.856 101.467 109.892Q101.224 109.928 100.98 109.952Q100.736 109.976 100.491 109.988Q100.245 110 100 110L0 110Q-0.245486 110 -0.490677 109.988Q-0.735867 109.976 -0.980171 109.952Q-1.22448 109.928 -1.4673 109.892Q-1.71013 109.856 -1.9509 109.808Q-2.19167 109.76 -2.4298 109.7Q-2.66793 109.641 -2.90285 109.569Q-3.13776 109.498 -3.3689 109.415Q-3.60003 109.333 -3.82683 109.239Q-4.05363 109.145 -4.27555 109.04Q-4.49747 108.935 -4.71397 108.819Q-4.93047 108.703 -5.14103 108.577Q-5.35159 108.451 -5.5557 108.315Q-5.75982 108.178 -5.95699 108.032Q-6.15417 107.886 -6.34393 107.73Q-6.5337 107.574 -6.71559 107.41Q-6.89748 107.245 -7.07107 107.071Q-7.24465 106.897 -7.40951 106.716Q-7.57437 106.534 -7.7301 106.344Q-7.88584 106.154 -8.03207 105.957Q-8.17831 105.76 -8.3147 105.556Q-8.45108 105.352 -8.57729 105.141Q-8.70349 104.93 -8.81921 104.714Q-8.93493 104.497 -9.03989 104.276Q-9.14485 104.054 -9.23879 103.827Q-9.33274 103.6 -9.41544 103.369Q-9.49814 103.138 -9.5694 102.903Q-9.64066 102.668 -9.70031 102.43Q-9.75996 102.192 -9.80785 101.951Q-9.85574 101.71 -9.89176 101.467Q-9.92778 101.224 -9.95185 100.98Q-9.97591 100.736 -9.98795 100.491Q-10 100.245 -10 100ZM10 10L10 90L90 90L90 10L10 10Z',
)
})

test('computeTightBounds', (t) => {
Expand All @@ -231,11 +237,9 @@ test('Transform', (t) => {
test('trim', (t) => {
const box = new Path2D()
box.rect(0, 0, 100, 100)
// box is now the 3 segments that look like a U.
// box is now the 3 segments that look like a U.
// (the top segment has been removed).
box.trim(0.25, 1)
.stroke({ width: 10 })
.simplify()
box.trim(0.25, 1).stroke({ width: 10 }).simplify()

const svg = `<svg width="100" height="100" viewBox="0 0 100 100"><path fill="blue" d="${box.toSVGString()}"></path></svg>`

Expand All @@ -246,7 +250,10 @@ test('dash', (t) => {
const box = new Path2D()
box.rect(0, 0, 100, 100)
box.dash(20, 10, 3)
t.is(box.toSVGString(), 'M20 0L40 0M50 0L70 0M80 0L100 0M100 10L100 30M100 40L100 60M100 70L100 90M100 100L100 100L80 100M70 100L50 100M40 100L20 100M10 100L0 100L0 90M0 80L0 60M0 50L0 30M0 20L0 0L10 0')
t.is(
box.toSVGString(),
'M20 0L40 0M50 0L70 0M80 0L100 0M100 10L100 30M100 40L100 60M100 70L100 90M100 100L100 100L80 100M70 100L50 100M40 100L20 100M10 100L0 100L0 90M0 80L0 60M0 50L0 30M0 20L0 0L10 0',
)
})

function drawSimplePath() {
Expand Down
2 changes: 1 addition & 1 deletion __test__/pathkit.spec.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ Generated by [AVA](https://avajs.dev).

> Snapshot 1
'<svg width="100" height="100" viewBox="0 0 100 100"><path fill="blue" d="M105 100L105 0L95 0L95 95L5 95L5 0L-5 0L-5 100L0 105L100 105L105 100Z"></path></svg>'
'<svg width="100" height="100" viewBox="0 0 100 100"><path fill="blue" d="M105 105L105 0L95 0L95 95L5 95L5 0L-5 0L-5 105L105 105Z"></path></svg>'
Binary file modified __test__/pathkit.spec.ts.snap
Binary file not shown.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ CanvasRenderingContext2D.prototype.getImageData = function getImageData(x, y, w,

Path2D.prototype.stroke = function stroke(strokeOptions = {}) {
const width = typeof strokeOptions.width === 'undefined' ? 1 : strokeOptions.width
const miterLimit = typeof strokeOptions.miterLimit === 'undefined' ? 1 : strokeOptions.miterLimit
const miterLimit = typeof strokeOptions.miterLimit === 'undefined' ? 4 : strokeOptions.miterLimit
const join = typeof strokeOptions.join === 'undefined' ? StrokeJoin.Miter : strokeOptions.join
const cap = typeof strokeOptions.cap === 'undefined' ? StrokeCap.Butt : strokeOptions.cap

Expand Down
9 changes: 5 additions & 4 deletions skia-c/skia_c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -425,12 +425,12 @@ extern "C"
return PAINT_CAST->getStrokeCap();
}

void skiac_paint_set_stroke_join(skiac_paint *c_paint, int join)
void skiac_paint_set_stroke_join(skiac_paint *c_paint, uint8_t join)
{
PAINT_CAST->setStrokeJoin((SkPaint::Join)join);
}

int skiac_paint_get_stroke_join(skiac_paint *c_paint)
uint8_t skiac_paint_get_stroke_join(skiac_paint *c_paint)
{
return PAINT_CAST->getStrokeJoin();
}
Expand Down Expand Up @@ -496,16 +496,17 @@ extern "C"
return AsWinding(*PATH_CAST, PATH_CAST);
}

bool skiac_path_stroke(skiac_path *c_path, int cap, int join, float width, float miter_limit)
bool skiac_path_stroke(skiac_path *c_path, int cap, uint8_t join, float width, float miter_limit)
{
auto path = PATH_CAST;
SkPaint p;
p.setStyle(SkPaint::kStroke_Style);
p.setStrokeCap((SkPaint::Cap)cap);
p.setStrokeJoin((SkPaint::Join)join);
p.setStrokeWidth(width);
p.setStrokeMiter(miter_limit);

return p.getFillPath(*PATH_CAST, PATH_CAST);
return p.getFillPath(*path, path);
}

void skiac_path_compute_tight_bounds(skiac_path *c_path, skiac_rect *c_rect)
Expand Down
6 changes: 3 additions & 3 deletions skia-c/skia_c.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ extern "C"
float skiac_paint_get_stroke_width(skiac_paint *c_paint);
void skiac_paint_set_stroke_cap(skiac_paint *c_paint, int cap);
int skiac_paint_get_stroke_cap(skiac_paint *c_paint);
void skiac_paint_set_stroke_join(skiac_paint *c_paint, int join);
int skiac_paint_get_stroke_join(skiac_paint *c_paint);
void skiac_paint_set_stroke_join(skiac_paint *c_paint, uint8_t join);
uint8_t skiac_paint_get_stroke_join(skiac_paint *c_paint);
void skiac_paint_set_stroke_miter(skiac_paint *c_paint, float miter);
float skiac_paint_get_stroke_miter(skiac_paint *c_paint);
void skiac_paint_set_path_effect(skiac_paint *c_paint, skiac_path_effect *c_path_effect);
Expand All @@ -172,7 +172,7 @@ extern "C"
bool skiac_path_op(skiac_path *c_path_one, skiac_path *c_path_two, int op);
void skiac_path_to_svg_string(skiac_path *c_path, skiac_string *c_string);
bool skiac_path_simplify(skiac_path *c_path);
bool skiac_path_stroke(skiac_path *c_path, int cap, int join, float width, float miter_limit);
bool skiac_path_stroke(skiac_path *c_path, int cap, uint8_t join, float width, float miter_limit);
void skiac_path_get_bounds(skiac_path *c_path, skiac_rect *c_rect);
void skiac_path_compute_tight_bounds(skiac_path *c_path, skiac_rect *c_rect);
bool skiac_path_trim(skiac_path *c_path, float start_t, float stop_t, bool is_complement);
Expand Down
6 changes: 3 additions & 3 deletions src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ fn stroke(ctx: CallContext) -> Result<JsObject> {

path_2d.stroke(
StrokeCap::from_raw(cap.get_int32()?)?,
StrokeJoin::from_raw(join.get_int32()?)?,
StrokeJoin::from_raw(join.get_uint32()? as u8)?,
stroke_width.get_double()? as f32,
miter_limit.get_double()? as f32,
);
Expand Down Expand Up @@ -426,8 +426,8 @@ fn dash(ctx: CallContext) -> Result<JsObject> {
let on = ctx.get::<JsNumber>(0)?.get_double()?;
let off = ctx.get::<JsNumber>(1)?.get_double()?;
let phase = ctx.get::<JsNumber>(1)?.get_double()?;
path_2d.dash(on as f32, off as f32, phase as f32,);

path_2d.dash(on as f32, off as f32, phase as f32);
Ok(this)
}

Expand Down
26 changes: 11 additions & 15 deletions src/sk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,9 @@ mod ffi {

pub fn skiac_paint_get_stroke_cap(paint: *mut skiac_paint) -> i32;

pub fn skiac_paint_set_stroke_join(paint: *mut skiac_paint, join: i32);
pub fn skiac_paint_set_stroke_join(paint: *mut skiac_paint, join: u8);

pub fn skiac_paint_get_stroke_join(paint: *mut skiac_paint) -> i32;
pub fn skiac_paint_get_stroke_join(paint: *mut skiac_paint) -> u8;

pub fn skiac_paint_set_stroke_miter(paint: *mut skiac_paint, miter: f32);

Expand Down Expand Up @@ -351,7 +351,7 @@ mod ffi {
pub fn skiac_path_stroke(
c_path: *mut skiac_path,
cap: i32,
join: i32,
join: u8,
width: f32,
miter_limit: f32,
) -> bool;
Expand All @@ -367,12 +367,7 @@ mod ffi {
is_complement: bool,
) -> bool;

pub fn skiac_path_dash(
path: *mut skiac_path,
on: f32,
off: f32,
phase: f32,
) -> bool;
pub fn skiac_path_dash(path: *mut skiac_path, on: f32, off: f32, phase: f32) -> bool;

pub fn skiac_path_equals(path: *mut skiac_path, other: *mut skiac_path) -> bool;

Expand Down Expand Up @@ -670,15 +665,16 @@ impl FromStr for StrokeCap {
}
}

#[repr(u8)]
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
pub enum StrokeJoin {
Miter = 0,
Round = 1,
Bevel = 2,
Miter,
Round,
Bevel,
}

impl StrokeJoin {
pub fn from_raw(join: i32) -> Result<Self, SkError> {
pub fn from_raw(join: u8) -> Result<Self, SkError> {
match join {
0 => Ok(Self::Miter),
1 => Ok(Self::Round),
Expand Down Expand Up @@ -1626,7 +1622,7 @@ impl Paint {
#[inline]
pub fn set_stroke_join(&mut self, join: StrokeJoin) {
unsafe {
ffi::skiac_paint_set_stroke_join(self.0, join as i32);
ffi::skiac_paint_set_stroke_join(self.0, join as u8);
}
}

Expand Down Expand Up @@ -1962,7 +1958,7 @@ impl Path {

#[inline]
pub fn stroke(&mut self, cap: StrokeCap, join: StrokeJoin, width: f32, miter_limit: f32) -> bool {
unsafe { ffi::skiac_path_stroke(self.0, cap as i32, join as i32, width, miter_limit) }
unsafe { ffi::skiac_path_stroke(self.0, cap as i32, join as u8, width, miter_limit) }
}

#[inline]
Expand Down

1 comment on commit 5f1761b

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Benchmark suite Current: 5f1761b Previous: d6e6c43 Ratio
Draw house#@napi-rs/skia 21.7 ops/sec (±1.58%) 21 ops/sec (±0.28%) 0.97
Draw house#node-canvas 21.6 ops/sec (±1.78%) 18 ops/sec (±0.9%) 0.83
Draw gradient#@napi-rs/skia 22 ops/sec (±1.6%) 20 ops/sec (±0.21%) 0.91
Draw gradient#node-canvas 20 ops/sec (±2.85%) 17 ops/sec (±0.31%) 0.85

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.