diff --git a/sparse_strips/vello_common/src/flatten.rs b/sparse_strips/vello_common/src/flatten.rs index 61bf66220..713da45bb 100644 --- a/sparse_strips/vello_common/src/flatten.rs +++ b/sparse_strips/vello_common/src/flatten.rs @@ -134,7 +134,11 @@ pub fn stroke( flatten_ctx: &mut FlattenCtx, ) { // TODO: Temporary hack to ensure that strokes are scaled properly by the transform. - let tolerance = TOL / affine.as_coeffs()[0].abs().max(affine.as_coeffs()[3].abs()); + let tolerance = TOL + / affine.as_coeffs()[0] + .abs() + .max(affine.as_coeffs()[3].abs()) + .max(1.); let expanded = expand_stroke(path, style, tolerance); fill(level, &expanded, affine, line_buf, flatten_ctx); diff --git a/sparse_strips/vello_sparse_tests/snapshots/stroke_scaled.png b/sparse_strips/vello_sparse_tests/snapshots/stroke_scaled.png new file mode 100644 index 000000000..3cfbf2b33 --- /dev/null +++ b/sparse_strips/vello_sparse_tests/snapshots/stroke_scaled.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:45878ddec36543e52eb8a6295fa4c02e19d90e538f70f4d18ee85b21d83a38b9 +size 1385 diff --git a/sparse_strips/vello_sparse_tests/tests/basic.rs b/sparse_strips/vello_sparse_tests/tests/basic.rs index e1b0916af..4ce25e12f 100644 --- a/sparse_strips/vello_sparse_tests/tests/basic.rs +++ b/sparse_strips/vello_sparse_tests/tests/basic.rs @@ -414,3 +414,23 @@ fn no_anti_aliasing_clip_path(ctx: &mut impl Renderer) { ctx.fill_rect(&rect); ctx.pop_layer(); } + +#[vello_test(diff_pixels = 1)] +fn stroke_scaled(ctx: &mut impl Renderer) { + let mut path = BezPath::new(); + path.move_to((0.0, 0.0)); + path.curve_to((0.25, 1.0), (0.75, 1.0), (1.0, 0.0)); + + // This path should be more or less completely covered. + let mut stroke = Stroke::new(10.0); + ctx.set_transform(Affine::IDENTITY); + ctx.set_stroke(stroke); + ctx.set_paint(RED); + ctx.stroke_path(&(Affine::scale(100.0) * path.clone())); + + stroke = Stroke::new(0.1); + ctx.set_transform(Affine::scale(100.0)); + ctx.set_stroke(stroke); + ctx.set_paint(LIME); + ctx.stroke_path(&path); +}