From fd61d44ad8a8032a9583fce5807337f20dddce26 Mon Sep 17 00:00:00 2001 From: Georg Hopp Date: Sun, 12 Jan 2020 00:54:22 +0100 Subject: [PATCH] split easel into multiple files --- Cargo.toml | 24 +----------------------- src/easel/canvas.rs | 6 +++--- src/easel/polygon.rs | 2 +- src/lib.rs | 2 -- 4 files changed, 5 insertions(+), 29 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index dcf18a8..61b7d44 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,35 +1,13 @@ [package] -name = "wasm-game-of-life" +name = "easel3d" version = "0.1.0" authors = ["hopp@silpion.de"] edition = "2018" -[lib] -crate-type = ["cdylib", "rlib"] - -[features] -default = ["console_error_panic_hook"] - [dependencies] -wasm-bindgen = "0.2" lazy_static = "1.4.0" -# The `console_error_panic_hook` crate provides better debugging of panics by -# logging them with `console.error`. This is great for development, but requires -# all the `std::fmt` and `std::panicking` infrastructure, so isn't great for -# code size when deploying. -console_error_panic_hook = { version = "0.1.1", optional = true } - -# `wee_alloc` is a tiny allocator for wasm that is only ~1K in code size -# compared to the default allocator's ~10K. It is slower than the default -# allocator, however. -# -# Unfortunately, `wee_alloc` requires nightly Rust when targeting wasm for now. -wee_alloc = { version = "0.4.2", optional = true } - [dev-dependencies] -wasm-bindgen-test = "0.2" [profile.release] -# Tell `rustc` to optimize for small code size. opt-level = "s" diff --git a/src/easel/canvas.rs b/src/easel/canvas.rs index 849c13a..a23eafc 100644 --- a/src/easel/canvas.rs +++ b/src/easel/canvas.rs @@ -63,18 +63,18 @@ where T: Add + Sub + Div } #[inline] - pub fn same_x(&self, b :&Self) -> bool { + pub fn same_column(&self, b :&Self) -> bool { self.x == b.x } #[inline] - pub fn same_y(&self, b :&Self) -> bool { + pub fn same_line(&self, b :&Self) -> bool { self.y == b.y } #[inline] pub fn same_position(&self, b :&Self) -> bool { - self.same_x(b) && self.same_y(b) + self.same_column(b) && self.same_line(b) } fn iter(self, b :Self, only_edges :bool) -> LineIterator { diff --git a/src/easel/polygon.rs b/src/easel/polygon.rs index e26a730..74c8a39 100644 --- a/src/easel/polygon.rs +++ b/src/easel/polygon.rs @@ -57,7 +57,7 @@ where T: Add + Sub + Div let mut min = cs.iter().enumerate().fold(None, fold).unwrap().0; let mut next = self.step(min, d); - while self.vertex(min).same_y(&self.vertex(next)) { + while self.vertex(min).same_line(&self.vertex(next)) { min = next; next = self.step(min, d); } diff --git a/src/lib.rs b/src/lib.rs index 336c784..2e2eb49 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -40,6 +40,4 @@ pub mod trigonometry; pub mod vector; pub mod geometry; -mod utils; - use vector::Vector;