Skip to content

Commit

Permalink
Commit rest of the code..
Browse files Browse the repository at this point in the history
  • Loading branch information
StarArawn committed Aug 5, 2024
1 parent 9b99cdc commit 0c3b0db
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
Binary file added examples/assets/image1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/assets/image2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion examples/scenes/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ workspace = true
vello = { workspace = true }
anyhow = { workspace = true }
clap = { workspace = true, features = ["derive"] }
image = { workspace = true, features = ["jpeg"] }
image = { workspace = true, features = ["jpeg", "png"] }
rand = "0.8.5"

# for pico_svg
Expand Down
31 changes: 31 additions & 0 deletions examples/scenes/src/test_scenes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ macro_rules! scene {
}

export_scenes!(
images(images),
splash_with_tiger(impls::splash_with_tiger(), "splash_with_tiger", false),
funky_paths(funky_paths),
stroke_styles(impls::stroke_styles(Affine::IDENTITY), "stroke_styles", false),
Expand Down Expand Up @@ -89,6 +90,8 @@ mod impls {
use vello::*;

const FLOWER_IMAGE: &[u8] = include_bytes!("../../assets/splash-flower.jpg");
const IMAGE_1: &[u8] = include_bytes!("../../assets/image1.png");
const IMAGE_2: &[u8] = include_bytes!("../../assets/image2.png");

pub(super) fn emoji(scene: &mut Scene, params: &mut SceneParams) {
let text_size = 120. + 20. * (params.time * 2.).sin() as f32;
Expand Down Expand Up @@ -646,6 +649,34 @@ mod impls {
}
}

pub(super) fn images(scene: &mut Scene, params: &mut SceneParams) {
let image1 = params
.images
.from_bytes(IMAGE_1.as_ptr() as usize, IMAGE_1)
.unwrap();
let image2 = params
.images
.from_bytes(IMAGE_2.as_ptr() as usize, IMAGE_2)
.unwrap();

scene.draw_image(
&image1,
Affine::scale(0.5) * Affine::translate((0.0, 0.0)) * Affine::rotate(0f64.to_radians()),
);
scene.draw_image(
&image2,
Affine::scale(0.5) * Affine::translate((135.0, 0.0)) * Affine::rotate(0f64.to_radians()),
);
scene.draw_image(
&image2,
Affine::scale(0.5) * Affine::translate((182.0, 0.0)) * Affine::rotate(0f64.to_radians()),
);
scene.draw_image(
&image2,
Affine::scale(0.5) * Affine::translate((229.0, 0.0)) * Affine::rotate(0f64.to_radians()),
);
}

pub(super) fn animated_text(scene: &mut Scene, params: &mut SceneParams) {
// Uses the static array address as a cache key for expedience. Real code
// should use a better strategy.
Expand Down

0 comments on commit 0c3b0db

Please sign in to comment.