From 65d1301072a7f9223ce2ffe420b6f2784b8bbe04 Mon Sep 17 00:00:00 2001 From: brian cully Date: Mon, 29 Dec 2025 14:32:30 -0500 Subject: wasm: hook up dot count to html input --- src/state.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/state.rs') diff --git a/src/state.rs b/src/state.rs index 592f26e..1793388 100644 --- a/src/state.rs +++ b/src/state.rs @@ -11,7 +11,6 @@ use crate::point::Point; pub const TAU: f64 = PI * 2.0; pub const MAX_SPEED: f64 = 0.01; -const NUM_POINTS: usize = 40; const VELVEC_SCALE: f64 = 3.0; #[derive(Debug)] @@ -33,15 +32,11 @@ impl State { .dyn_into()?; ctx.scale(canvas.width().into(), canvas.height().into())?; - let points = (0..NUM_POINTS) - .map(|_| Point::new(fastrand::f64(), fastrand::f64())) - .collect(); - Ok(Self { canvas, ctx, fps, - points, + points: vec![], last_time: None, inter_count: 1, }) @@ -104,6 +99,12 @@ impl State { Ok(()) } + pub fn set_dot_count(&mut self, n: usize) { + self.points = (0..n) + .map(|_| Point::new(fastrand::f64(), fastrand::f64())) + .collect(); + } + fn render_points(&self) -> JSResult<()> { for p in &self.points { self.ctx.set_fill_style_str(&p.color); -- cgit v1.3