Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 5 additions & 1 deletion sparse_strips/vello_common/src/flatten.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions sparse_strips/vello_sparse_tests/snapshots/stroke_scaled.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions sparse_strips/vello_sparse_tests/tests/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Loading