clean up test scene code

This commit is contained in:
Chad Brokaw 2023-05-03 15:29:45 -04:00
parent e9c2ce1623
commit 2db555145e

View file

@ -251,16 +251,10 @@ fn brush_transform(sb: &mut SceneBuilder, params: &mut SceneParams) {
} }
fn gradient_extend(sb: &mut SceneBuilder, params: &mut SceneParams) { fn gradient_extend(sb: &mut SceneBuilder, params: &mut SceneParams) {
fn square( fn square(sb: &mut SceneBuilder, is_radial: bool, transform: Affine, extend: Extend) {
sb: &mut SceneBuilder,
is_radial: bool,
transform: Affine,
brush_transform: Option<Affine>,
extend: Extend,
) {
let colors = [Color::RED, Color::GREEN, Color::BLUE]; let colors = [Color::RED, Color::GREEN, Color::BLUE];
let width = 400f64; let width = 300f64;
let height = 400f64; let height = 300f64;
let gradient: Brush = if is_radial { let gradient: Brush = if is_radial {
Gradient::new_radial((width * 0.5, height * 0.5), (width * 0.25) as f32) Gradient::new_radial((width * 0.5, height * 0.5), (width * 0.25) as f32)
.with_stops(colors) .with_stops(colors)
@ -276,7 +270,7 @@ fn gradient_extend(sb: &mut SceneBuilder, params: &mut SceneParams) {
Fill::NonZero, Fill::NonZero,
transform, transform,
&gradient, &gradient,
brush_transform, None,
&Rect::new(0.0, 0.0, width, height), &Rect::new(0.0, 0.0, width, height),
); );
} }
@ -285,35 +279,21 @@ fn gradient_extend(sb: &mut SceneBuilder, params: &mut SceneParams) {
let extend = extend_modes[x]; let extend = extend_modes[x];
for y in 0..2 { for y in 0..2 {
let is_radial = y & 1 != 0; let is_radial = y & 1 != 0;
let transform = Affine::translate((x as f64 * 450.0 + 50.0, y as f64 * 450.0 + 100.0)); let transform = Affine::translate((x as f64 * 350.0 + 50.0, y as f64 * 350.0 + 100.0));
square(sb, is_radial, transform, None, extend); square(sb, is_radial, transform, extend);
} }
} }
let white = Color::WHITE.into(); for (i, label) in ["Pad", "Repeat", "Reflect"].iter().enumerate() {
let x = i as f64 * 350.0 + 50.0;
params.text.add( params.text.add(
sb, sb,
None, None,
32.0, 32.0,
Some(&white), Some(&Color::WHITE.into()),
Affine::translate((50.0, 70.0)), Affine::translate((x, 70.0)),
"Pad", label,
);
params.text.add(
sb,
None,
32.0,
Some(&white),
Affine::translate((500.0, 70.0)),
"Repeat",
);
params.text.add(
sb,
None,
32.0,
Some(&white),
Affine::translate((950.0, 70.0)),
"Reflect",
); );
}
} }
fn blend_grid(sb: &mut SceneBuilder, _: &mut SceneParams) { fn blend_grid(sb: &mut SceneBuilder, _: &mut SceneParams) {