mirror of
https://github.com/italicsjenga/vello.git
synced 2025-01-08 20:01:30 +11:00
Combine tiger and splash screen
Always show the tiger, and include key bindings.
This commit is contained in:
parent
152fa00843
commit
495229bf10
|
@ -24,10 +24,15 @@ macro_rules! scene {
|
|||
}
|
||||
|
||||
pub fn test_scenes() -> SceneSet {
|
||||
// For WASM below, must be mutable
|
||||
#[allow(unused_mut)]
|
||||
let mut scenes = vec![
|
||||
scene!(splash_screen),
|
||||
let splash_scene = ExampleScene {
|
||||
config: SceneConfig {
|
||||
animated: false,
|
||||
name: "splash_with_tiger".to_owned(),
|
||||
},
|
||||
function: Box::new(splash_with_tiger()),
|
||||
};
|
||||
let scenes = vec![
|
||||
splash_scene,
|
||||
scene!(funky_paths),
|
||||
scene!(cardioid_and_friends),
|
||||
scene!(animated_text: animated),
|
||||
|
@ -37,14 +42,6 @@ pub fn test_scenes() -> SceneSet {
|
|||
scene!(labyrinth),
|
||||
scene!(base_color_test: animated),
|
||||
];
|
||||
#[cfg(any(target_arch = "wasm32", target_os = "android"))]
|
||||
scenes.push(ExampleScene {
|
||||
config: SceneConfig {
|
||||
animated: false,
|
||||
name: "included_tiger".to_owned(),
|
||||
},
|
||||
function: Box::new(included_tiger()),
|
||||
});
|
||||
|
||||
SceneSet { scenes }
|
||||
}
|
||||
|
@ -278,15 +275,6 @@ fn blend_grid(sb: &mut SceneBuilder, _: &mut SceneParams) {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(any(target_arch = "wasm32", target_os = "android"))]
|
||||
fn included_tiger() -> impl FnMut(&mut SceneBuilder, &mut SceneParams) {
|
||||
let contents = include_str!(concat!(
|
||||
env!("CARGO_MANIFEST_DIR"),
|
||||
"/../assets/Ghostscript_Tiger.svg"
|
||||
));
|
||||
crate::svg::svg_function_of("Ghostscript Tiger".to_string(), move || contents)
|
||||
}
|
||||
|
||||
// Support functions
|
||||
|
||||
fn render_cardioid(sb: &mut SceneBuilder) {
|
||||
|
@ -632,13 +620,14 @@ fn make_diamond(cx: f64, cy: f64) -> [PathEl; 5] {
|
|||
fn splash_screen(sb: &mut SceneBuilder, params: &mut SceneParams) {
|
||||
let strings = [
|
||||
"Vello test",
|
||||
"key bindings:",
|
||||
" Arrow keys: switch scenes",
|
||||
" Space: reset transform",
|
||||
" S: toggle stats",
|
||||
" V: toggle vsync",
|
||||
" Q, E: rotate",
|
||||
" Space: reset transform",
|
||||
];
|
||||
// Tweak to make it fit with tiger
|
||||
let a = Affine::scale(0.12) * Affine::translate((-90.0, -50.0));
|
||||
for (i, s) in strings.iter().enumerate() {
|
||||
let text_size = if i == 0 { 60.0 } else { 40.0 };
|
||||
params.text.add(
|
||||
|
@ -646,8 +635,20 @@ fn splash_screen(sb: &mut SceneBuilder, params: &mut SceneParams) {
|
|||
None,
|
||||
text_size,
|
||||
None,
|
||||
Affine::translate((100.0, 100.0 + 60.0 * i as f64)),
|
||||
a * Affine::translate((100.0, 100.0 + 60.0 * i as f64)),
|
||||
s,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
fn splash_with_tiger() -> impl FnMut(&mut SceneBuilder, &mut SceneParams) {
|
||||
let contents = include_str!(concat!(
|
||||
env!("CARGO_MANIFEST_DIR"),
|
||||
"/../assets/Ghostscript_Tiger.svg"
|
||||
));
|
||||
let mut tiger = crate::svg::svg_function_of("Ghostscript Tiger".to_string(), move || contents);
|
||||
move |sb, params| {
|
||||
tiger(sb, params);
|
||||
splash_screen(sb, params);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue