mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-04-01 18:01:06 +00:00
Merge pull request #1108 from elpiel/port-examples-julia_set-no_modules-paint-performance-to-rust-2018
Port `julia_set`, `no_modules`, `paint` and `performance` to Rust 2018
This commit is contained in:
commit
df09df42d1
@ -2,6 +2,7 @@
|
|||||||
name = "julia_set"
|
name = "julia_set"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["The wasm-bindgen Developers"]
|
authors = ["The wasm-bindgen Developers"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
crate-type = ["cdylib"]
|
crate-type = ["cdylib"]
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
extern crate wasm_bindgen;
|
|
||||||
extern crate web_sys;
|
|
||||||
|
|
||||||
use std::ops::Add;
|
use std::ops::Add;
|
||||||
use wasm_bindgen::prelude::*;
|
use wasm_bindgen::prelude::*;
|
||||||
use wasm_bindgen::Clamped;
|
use wasm_bindgen::Clamped;
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
name = "no_modules"
|
name = "no_modules"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["The wasm-bindgen Developers"]
|
authors = ["The wasm-bindgen Developers"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
crate-type = ["cdylib"]
|
crate-type = ["cdylib"]
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
extern crate wasm_bindgen;
|
|
||||||
extern crate web_sys;
|
|
||||||
|
|
||||||
use wasm_bindgen::prelude::*;
|
use wasm_bindgen::prelude::*;
|
||||||
|
|
||||||
// Called by our JS entry point to run the example
|
// Called by our JS entry point to run the example
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
name = "wasm-bindgen-paint"
|
name = "wasm-bindgen-paint"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["The wasm-bindgen Developers"]
|
authors = ["The wasm-bindgen Developers"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
crate-type = ["cdylib"]
|
crate-type = ["cdylib"]
|
||||||
|
@ -1,7 +1,3 @@
|
|||||||
extern crate js_sys;
|
|
||||||
extern crate wasm_bindgen;
|
|
||||||
extern crate web_sys;
|
|
||||||
|
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use wasm_bindgen::prelude::*;
|
use wasm_bindgen::prelude::*;
|
||||||
@ -30,7 +26,7 @@ pub fn start() -> Result<(), JsValue> {
|
|||||||
context.begin_path();
|
context.begin_path();
|
||||||
context.move_to(event.offset_x() as f64, event.offset_y() as f64);
|
context.move_to(event.offset_x() as f64, event.offset_y() as f64);
|
||||||
pressed.set(true);
|
pressed.set(true);
|
||||||
}) as Box<FnMut(_)>);
|
}) as Box<dyn FnMut(_)>);
|
||||||
canvas.add_event_listener_with_callback("mousedown", closure.as_ref().unchecked_ref())?;
|
canvas.add_event_listener_with_callback("mousedown", closure.as_ref().unchecked_ref())?;
|
||||||
closure.forget();
|
closure.forget();
|
||||||
}
|
}
|
||||||
@ -44,7 +40,7 @@ pub fn start() -> Result<(), JsValue> {
|
|||||||
context.begin_path();
|
context.begin_path();
|
||||||
context.move_to(event.offset_x() as f64, event.offset_y() as f64);
|
context.move_to(event.offset_x() as f64, event.offset_y() as f64);
|
||||||
}
|
}
|
||||||
}) as Box<FnMut(_)>);
|
}) as Box<dyn FnMut(_)>);
|
||||||
canvas.add_event_listener_with_callback("mousemove", closure.as_ref().unchecked_ref())?;
|
canvas.add_event_listener_with_callback("mousemove", closure.as_ref().unchecked_ref())?;
|
||||||
closure.forget();
|
closure.forget();
|
||||||
}
|
}
|
||||||
@ -55,7 +51,7 @@ pub fn start() -> Result<(), JsValue> {
|
|||||||
pressed.set(false);
|
pressed.set(false);
|
||||||
context.line_to(event.offset_x() as f64, event.offset_y() as f64);
|
context.line_to(event.offset_x() as f64, event.offset_y() as f64);
|
||||||
context.stroke();
|
context.stroke();
|
||||||
}) as Box<FnMut(_)>);
|
}) as Box<dyn FnMut(_)>);
|
||||||
canvas.add_event_listener_with_callback("mouseup", closure.as_ref().unchecked_ref())?;
|
canvas.add_event_listener_with_callback("mouseup", closure.as_ref().unchecked_ref())?;
|
||||||
closure.forget();
|
closure.forget();
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
name = "performance"
|
name = "performance"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["The wasm-bindgen Developers"]
|
authors = ["The wasm-bindgen Developers"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
crate-type = ["cdylib"]
|
crate-type = ["cdylib"]
|
||||||
|
@ -1,7 +1,3 @@
|
|||||||
extern crate humantime;
|
|
||||||
extern crate wasm_bindgen;
|
|
||||||
extern crate web_sys;
|
|
||||||
|
|
||||||
use std::time::{Duration, SystemTime, UNIX_EPOCH};
|
use std::time::{Duration, SystemTime, UNIX_EPOCH};
|
||||||
|
|
||||||
use wasm_bindgen::prelude::*;
|
use wasm_bindgen::prelude::*;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user