diff --git a/examples/scenes/src/test_scenes.rs b/examples/scenes/src/test_scenes.rs index 982076f29..d76a16811 100644 --- a/examples/scenes/src/test_scenes.rs +++ b/examples/scenes/src/test_scenes.rs @@ -32,10 +32,10 @@ macro_rules! scene { pub fn test_scenes() -> SceneSet { let scenes = vec![ scene!(splash_with_tiger(), "splash_with_tiger", false), - scene!(crate::mmark::MMark::new(80_000), "mmark", false), scene!(funky_paths), scene!(stroke_styles), scene!(tricky_strokes), + scene!(fill_types), scene!(cardioid_and_friends), scene!(animated_text: animated), scene!(gradient_extend), @@ -48,6 +48,7 @@ pub fn test_scenes() -> SceneSet { scene!(clip_test: animated), scene!(longpathdash(Cap::Butt), "longpathdash (butt caps)", false), scene!(longpathdash(Cap::Round), "longpathdash (round caps)", false), + scene!(crate::mmark::MMark::new(80_000), "mmark", false), ]; SceneSet { scenes } @@ -287,6 +288,54 @@ fn tricky_strokes(sb: &mut SceneBuilder, _: &mut SceneParams) { } } +fn fill_types(sb: &mut SceneBuilder, params: &mut SceneParams) { + use PathEl::*; + let rect = Rect::from_origin_size(Point::new(0., 0.), (500., 500.)); + let star = [ + MoveTo((250., 0.).into()), + LineTo((105., 450.).into()), + LineTo((490., 175.).into()), + LineTo((10., 175.).into()), + LineTo((395., 450.).into()), + ClosePath, + ]; + let arcs = [ + MoveTo((0., 480.).into()), + CurveTo((500., 480.).into(), (500., -10.).into(), (0., -10.).into()), + ClosePath, + MoveTo((500., -10.).into()), + CurveTo((0., -10.).into(), (0., 480.).into(), (500., 480.).into()), + ClosePath, + ]; + let scale = Affine::scale(0.6); + let t = Affine::translate((10., 25.)); + let rules = [ + (Fill::NonZero, "Non-Zero", star.as_slice()), + (Fill::EvenOdd, "Even-Odd", &star), + (Fill::NonZero, "Non-Zero", &arcs), + (Fill::EvenOdd, "Even-Odd", &arcs), + ]; + for (i, rule) in rules.iter().enumerate() { + let t = Affine::translate(((i % 2) as f64 * 306., (i / 2) as f64 * 340.)) * t; + params.text.add(sb, None, 24., None, t, rule.1); + let t = Affine::translate((0., 5.)) * t * scale; + sb.fill( + Fill::NonZero, + t, + &Brush::Solid(Color::rgb8(128, 128, 128)), + None, + &rect, + ); + sb.fill( + rule.0, + Affine::translate((0., 10.)) * t, + Color::BLACK, + None, + &rule.2, + ); + } +} + fn cardioid_and_friends(sb: &mut SceneBuilder, _: &mut SceneParams) { render_cardioid(sb); render_clip_test(sb);