aboutsummaryrefslogtreecommitdiffstats
path: root/src/state.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/state.rs')
-rw-r--r--src/state.rs13
1 files changed, 7 insertions, 6 deletions
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);