Skip to content
Draft
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
105 changes: 104 additions & 1 deletion examples/scenes/src/test_scenes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export_scenes!(
brush_transform(brush_transform: animated),
blend_grid(blend_grid),
deep_blend(deep_blend),
clipped_blend(clipped_blend),
many_clips(many_clips),
conflation_artifacts(conflation_artifacts),
labyrinth(labyrinth),
Expand Down Expand Up @@ -100,7 +101,8 @@ mod impls {
use rand::Rng;
use rand::{SeedableRng, rngs::StdRng};
use vello::kurbo::{
Affine, BezPath, Cap, Circle, Ellipse, Join, PathEl, Point, Rect, Shape, Stroke, Vec2,
Affine, BezPath, Cap, Circle, Ellipse, Join, PathEl, Point, Rect, Shape, Stroke, Triangle,
Vec2,
};
use vello::peniko::color::{AlphaColor, Lch, palette};
use vello::peniko::*;
Expand Down Expand Up @@ -1111,6 +1113,107 @@ mod impls {
}
}

pub(super) fn clipped_blend(scene: &mut Scene, params: &mut SceneParams<'_>) {
params.resolution = Some(Vec2::new(1000., 1200.));
let transform = Affine::translate((10., 100.));
params.text.add_run(
&mut *scene,
None,
32.,
Color::WHITE,
transform.then_translate((10., -30.).into()),
None,
&Style::Fill(Fill::EvenOdd),
"No Clip",
);

scene.fill(
Fill::EvenOdd,
transform,
palette::css::BLUE,
None,
&Rect::from_origin_size((0., 0.), (400., 400.)),
);
scene.push_layer(
Mix::Multiply,
1.0,
transform,
&Triangle::from_coords((200., 0.), (0., 400.), (400., 400.)),
);
scene.fill(
Fill::EvenOdd,
transform,
palette::css::AQUAMARINE,
None,
&Rect::from_origin_size((0., 0.), (400., 400.)),
);
scene.pop_layer();

let transform = Affine::translate((0., 600.));
params.text.add_run(
&mut *scene,
None,
32.,
Color::WHITE,
transform.then_translate((10., -30.).into()),
None,
&Style::Fill(Fill::EvenOdd),
"Mix::Normal",
);

scene.fill(
Fill::EvenOdd,
transform,
palette::css::BLUE,
None,
&Rect::from_origin_size((0., 0.), (400., 400.)),
);
let layer_shape = Triangle::from_coords((200., 0.), (0., 400.), (400., 400.));
scene.push_layer(Mix::Normal, 1.0, transform, &layer_shape);
scene.push_layer(Mix::Multiply, 1.0, transform, &layer_shape);
scene.fill(
Fill::EvenOdd,
transform,
palette::css::AQUAMARINE,
None,
&Rect::from_origin_size((0., 0.), (400., 400.)),
);
scene.pop_layer();
scene.pop_layer();

let transform = Affine::translate((500., 600.));
params.text.add_run(
&mut *scene,
None,
32.,
Color::WHITE,
transform.then_translate((10., -30.).into()),
None,
&Style::Fill(Fill::EvenOdd),
"Mix::Clip",
);

scene.fill(
Fill::EvenOdd,
transform,
palette::css::BLUE,
None,
&Rect::from_origin_size((0., 0.), (400., 400.)),
);
let layer_shape = Triangle::from_coords((200., 0.), (0., 400.), (400., 400.));
scene.push_layer(Mix::Clip, 1.0, transform, &layer_shape);
scene.push_layer(Mix::Multiply, 1.0, transform, &layer_shape);
scene.fill(
Fill::EvenOdd,
transform,
palette::css::AQUAMARINE,
None,
&Rect::from_origin_size((0., 0.), (400., 400.)),
);
scene.pop_layer();
scene.pop_layer();
}

pub(super) fn many_clips(scene: &mut Scene, params: &mut SceneParams<'_>) {
params.resolution = Some(Vec2::new(1000., 1000.));
let mut rng = StdRng::seed_from_u64(42);
Expand Down
3 changes: 3 additions & 0 deletions vello_tests/snapshots/clipped_blend.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions vello_tests/tests/snapshot_test_scenes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ fn snapshot_deep_blend() {
snapshot_test_scene(test_scene, params);
}

#[test]
#[cfg_attr(skip_gpu_tests, ignore)]
fn snapshot_clipped_blend() {
let test_scene = test_scenes::clipped_blend();
let params = TestParams::new("clipped_blend", 400, 400);
snapshot_test_scene(test_scene, params);
}

#[test]
#[cfg_attr(skip_gpu_tests, ignore)]
fn snapshot_gradient_extend() {
Expand Down
Loading