this repo has no description
3
fork

Configure Feed

Select the types of activity you want to include in your feed.

🍱 Continue schedule hell

+29 -18
+7 -4
examples/schedule-hell/src/main.rs
··· 9 9 bass_pattern_at: Region, 10 10 kick_color: Color, 11 11 rng: SmallRng, 12 + kick_counter: u32, 12 13 } 13 14 14 15 impl Default for State { ··· 17 18 bass_pattern_at: Region::from_topleft(Point(1, 1), (2, 2)).unwrap(), 18 19 kick_color: Color::White, 19 20 rng: SmallRng::seed_from_u64(0), 21 + kick_counter: 0, 20 22 } 21 23 } 22 24 } ··· 64 66 65 67 video.audiofile = PathBuf::from("schedule-hell.wav"); 66 68 video = video 69 + // Sync inputs // 67 70 .sync_audio_with("schedule-hell.midi") 68 71 .sync_audio_with("schedule-hell.wav") 72 + // Scenes // 69 73 .with_scene(scenes::starry_sky()) 70 74 .with_init_scene(scenes::intro()) 71 75 .with_marked_scene(scenes::first_break()) 72 - .on("end of first break", &|_, ctx| { 73 - ctx.switch_scene("starry sky"); 74 - Ok(()) 75 - }) 76 + .assign_scene_to("end of first break", "starry sky") 77 + .assign_scene_to("second break", "intro") 78 + // Credits // 76 79 .when_remaining(10, &|canvas, _| { 77 80 let world = canvas.world_region; 78 81 canvas.root().set(
+1
examples/schedule-hell/src/scenes/intro.rs
··· 5 5 pub fn intro() -> Scene<State> { 6 6 Scene::<State>::new("intro") 7 7 .init(&|canvas, _| { 8 + canvas.clear(); 8 9 canvas.set_background(Color::Black); 9 10 10 11 let mut kicks = Layer::new("anchor kick");
+21 -14
examples/schedule-hell/src/scenes/starry_sky.rs
··· 1 - use shapemaker::{synchronization::audio::MusicalDurationUnit, *}; 1 + use anyhow::Result; 2 + use shapemaker::*; 2 3 3 4 use crate::State; 4 5 5 6 pub fn starry_sky() -> Scene<State> { 6 - Scene::new("starry sky") 7 - .init(&|canvas, _| { 8 - canvas.clear(); 9 - sky(Angle::default(), canvas); 10 - Ok(()) 7 + Scene::<State>::new("starry sky") 8 + .init(&|canvas, ctx| { 9 + ctx.extra.kick_counter = 0; 10 + sky(ctx.extra.kick_counter, canvas) 11 + }) 12 + .on_note("anchor kick", &|canvas, ctx| { 13 + // Move spacecraft on each kick 14 + ctx.extra.kick_counter += 1; 15 + sky(ctx.extra.kick_counter, canvas) 11 16 }) 12 - .every(1.0, MusicalDurationUnit::Eighths, &|canvas, ctx| { 13 - canvas.clear(); 14 - sky( 15 - Angle::from_degrees(ctx.scene_started_at_ms.unwrap() as _), 16 - canvas, 17 - ); 18 - Ok(()) 17 + .each_n_frame(3, &|canvas, ctx| { 18 + // Keep spacecraft alive, by animating on threes 19 + sky(ctx.extra.kick_counter, canvas) 19 20 }) 20 21 } 21 22 22 - fn sky(theta: Angle, canvas: &mut Canvas) -> () { 23 + fn sky(kick_hits_count: u32, canvas: &mut Canvas) -> Result<()> { 24 + // Make a full rotation every 32 kicks 25 + let theta = Angle::from_ratio(kick_hits_count as f32, 32.0); 26 + 27 + canvas.clear(); 23 28 canvas.colormap = ColorMapping { 24 29 black: "#000000".to_string(), 25 30 white: "#FFFFFF".to_string(), ··· 61 66 }), 62 67 ))); 63 68 } 69 + 70 + Ok(()) 64 71 } 65 72 66 73 fn cluster(world: Region, rotation: Angle, at: Point) -> Layer {