aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs14
-rw-r--r--src/point.rs7
-rw-r--r--src/state.rs6
3 files changed, 22 insertions, 5 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 223e28a..f43b2ad 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,5 +1,5 @@
-use std::rc::Rc;
use std::cell::RefCell;
+use std::rc::Rc;
use log::{Level, info};
use wasm_bindgen::prelude::*;
@@ -49,7 +49,11 @@ pub fn init() -> Result<(), JsValue> {
if !s.paused {
let mut render_loop = render_loop.borrow_mut();
render_loop.animation_id = if let Some(ref closure) = render_loop.closure {
- Some(window().request_animation_frame(closure.as_ref().unchecked_ref()).expect("req anim frame"))
+ Some(
+ window()
+ .request_animation_frame(closure.as_ref().unchecked_ref())
+ .expect("req anim frame"),
+ )
} else {
None
}
@@ -57,7 +61,11 @@ pub fn init() -> Result<(), JsValue> {
}))
};
let mut render_loop = render_loop.borrow_mut();
- render_loop.animation_id = Some(window().request_animation_frame(closure.as_ref().unchecked_ref()).expect("req anim frame"));
+ render_loop.animation_id = Some(
+ window()
+ .request_animation_frame(closure.as_ref().unchecked_ref())
+ .expect("req anim frame"),
+ );
render_loop.closure = Some(closure);
}
diff --git a/src/point.rs b/src/point.rs
index 76f9ced..18d3d5f 100644
--- a/src/point.rs
+++ b/src/point.rs
@@ -3,7 +3,12 @@ use crate::state::{MAX_SPEED, TAU};
const POINT_RADIUS: f64 = 0.01;
fn rand_color() -> String {
- format!("rgb({} {} {})", fastrand::u8(0..255), fastrand::u8(0..255), fastrand::u8(0..255))
+ format!(
+ "rgb({} {} {})",
+ fastrand::u8(0..255),
+ fastrand::u8(0..255),
+ fastrand::u8(0..255)
+ )
}
#[derive(Clone, Debug)]
diff --git a/src/state.rs b/src/state.rs
index 8941a3b..4adb952 100644
--- a/src/state.rs
+++ b/src/state.rs
@@ -48,7 +48,11 @@ impl State {
.expect("2d context on canvas")
.dyn_into()?;
ctx.scale(canvas.width().into(), canvas.height().into())?;
- let fps = document().query_selector("#fps")?.expect("fps counter exists").dyn_into::<HtmlElement>().expect("is html element");
+ let fps = document()
+ .query_selector("#fps")?
+ .expect("fps counter exists")
+ .dyn_into::<HtmlElement>()
+ .expect("is html element");
let points = (0..NUM_POINTS)
.map(|_| Point::new(fastrand::f64(), fastrand::f64()))