Browse Source

split easel into multiple files

master
Georg Hopp 6 years ago
parent
commit
fd61d44ad8
Signed by: ghopp GPG Key ID: 4C5D226768784538
  1. 24
      Cargo.toml
  2. 6
      src/easel/canvas.rs
  3. 2
      src/easel/polygon.rs
  4. 2
      src/lib.rs

24
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"

6
src/easel/canvas.rs

@ -63,18 +63,18 @@ where T: Add<Output = T> + Sub<Output = T> + Div<Output = T>
}
#[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<T> {

2
src/easel/polygon.rs

@ -57,7 +57,7 @@ where T: Add<Output = T> + Sub<Output = T> + Div<Output = T>
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);
}

2
src/lib.rs

@ -40,6 +40,4 @@ pub mod trigonometry;
pub mod vector;
pub mod geometry;
mod utils;
use vector::Vector;
Loading…
Cancel
Save