Skip to content

Commit

Permalink
[test_scenes] Add stroke test cases for miter limit
Browse files Browse the repository at this point in the history
  • Loading branch information
armansito committed Oct 18, 2023
1 parent adcb50b commit d538f65
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions examples/scenes/src/test_scenes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,10 @@ fn stroke_styles(sb: &mut SceneBuilder, params: &mut SceneParams) {
CurveTo((20., 0.).into(), (42.5, 5.).into(), (50., 25.).into()),
CurveTo((57.5, 5.).into(), (80., 0.).into(), (100., 0.).into()),
];
let miter_stroke = [LineTo((90., 21.).into()), LineTo((0., 42.).into())];
let cap_styles = [Cap::Butt, Cap::Square, Cap::Round];
let join_styles = [Join::Bevel, Join::Miter, Join::Round];
let miter_limits = [4., 5., 0.1, 10.];

// Simple strokes with cap combinations
let t = Affine::translate((60., 40.)) * Affine::scale(2.);
Expand Down Expand Up @@ -162,6 +164,32 @@ fn stroke_styles(sb: &mut SceneBuilder, params: &mut SceneParams) {
color_idx = (color_idx + 1) % colors.len();
}
}

// Miter limit
let t = Affine::translate((500., 0.)) * t;
y = 0.;
for ml in miter_limits {
params.text.add(
sb,
None,
12.,
None,
Affine::translate((0., y)) * t,
&format!("Miter limit: {}", ml),
);
sb.stroke(
&Stroke::new(10.)
.with_caps(Cap::Butt)
.with_join(Join::Miter)
.with_miter_limit(ml),
Affine::translate((0., y + 30.)) * t,
colors[color_idx],
None,
&miter_stroke,
);
y += 180.;
color_idx = (color_idx + 1) % colors.len();
}
}

// This test has been adapted from Skia's "trickycubicstrokes" GM slide which can be found at
Expand Down

0 comments on commit d538f65

Please sign in to comment.