diff --git a/src/main.rs b/src/main.rs index 8c6fa6b..97a0a7f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,56 +5,41 @@ use std::ops::DerefMut; const JITTER: f64 = 0.5; -#[derive(Component)] -struct Grid { - points: Vec, -} - fn main() { App::new() .add_plugins(DefaultPlugins) .add_plugins(VelloPlugin::default()) .add_systems(Startup, setup_vector_graphics) - .add_systems(Update, simple_animation) + .add_systems(PostStartup, draw_map) .run(); } fn setup_vector_graphics(mut commands: Commands) { commands.spawn((Camera2d, VelloView)); commands.spawn(VelloScene::new()); - - let mut rng = rand::rng(); - let mut points = Vec::new(); - for x in -20..=20 { - for y in -10..=10 { - points.push(Point::new( - (x as f64) + rng.random_range(-JITTER..=JITTER), - (y as f64) + rng.random_range(-JITTER..=JITTER), - )); - } - } - commands.spawn(Grid { points }); } -fn simple_animation( - mut query_scene: Single<(&mut Transform, &mut VelloScene)>, - query_grid: Query<&Grid>, -) { +fn draw_map(mut query_scene: Single<(&mut Transform, &mut VelloScene)>) { let (transform, scene) = query_scene.deref_mut(); // Reset scene every frame scene.reset(); - for point in &query_grid.single().points { - scene.fill( - peniko::Fill::NonZero, - kurbo::Affine::default(), - peniko::Color::WHITE, - None, - &kurbo::Circle::new(*point, 0.1), - ); + let mut rng = rand::rng(); + for x in -20..=20 { + for y in -10..=10 { + let point = Point::new( + (x as f64) + rng.random_range(-JITTER..=JITTER), + (y as f64) + rng.random_range(-JITTER..=JITTER), + ); + scene.fill( + peniko::Fill::NonZero, + kurbo::Affine::default(), + peniko::Color::WHITE, + None, + &kurbo::Circle::new(point, 0.1), + ); + } } transform.scale = Vec3::ONE * 25.0; - //transform.translation = Vec3::lerp(Vec3::X * -100.0, Vec3::X * 100.0, sin_time); - //transform.rotation = Quat::from_rotation_z(-std::f32::consts::TAU * sin_time); }