Skip to content

Commit

Permalink
chore: readme
Browse files Browse the repository at this point in the history
  • Loading branch information
lencx committed Jan 31, 2021
1 parent 34f4382 commit c0c5b96
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 25 deletions.
15 changes: 0 additions & 15 deletions @rsw/chasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@ fn window() -> web_sys::Window {
web_sys::window().expect("no global `window` exists")
}

// fn request_animation_frame(f: &Closure<dyn FnMut()>) {
// window()
// .request_animation_frame(f.as_ref().unchecked_ref())
// .expect("should register `requestAnimationFrame` OK");
// }

fn document() -> web_sys::Document {
window()
.document()
Expand Down Expand Up @@ -77,12 +71,6 @@ pub fn chasm() -> Result<(), JsValue> {
let win_width = window.inner_width()?.as_f64().ok_or(JsValue::NULL)?;
let win_height = window.inner_height()?.as_f64().ok_or(JsValue::NULL)?;

// get canvas width & height
// let canvas_width: JsValue = canvas.width().into();
// let canvas_height: JsValue = canvas.height().into();
// console::log_2(&"canvas_width => ".into(), &canvas_width);
// console::log_2(&"canvas_height => ".into(), &canvas_height);

// fit the canvas to the viewport
canvas.set_width(win_width as u32);
canvas.set_height(win_height as u32);
Expand Down Expand Up @@ -168,12 +156,9 @@ pub fn chasm() -> Result<(), JsValue> {
gl.uniform2f(Some(val), x, y);
}

// tell webgl where to look for vertex data inside the vertex buffer
gl.vertex_attrib_pointer_with_i32(vertex_position_location, 2, GL::FLOAT, false, 0, 0);
// draw two triangle strips (will form a rectangle)
gl.draw_arrays(GL::TRIANGLE_STRIP, 0, 4);
}) as Box<dyn FnMut(_)>);
// request_animation_frame(mousemove_cb);
canvas.add_event_listener_with_callback("mousemove", mousemove_cb.as_ref().unchecked_ref())?;
mousemove_cb.forget();
}
Expand Down
17 changes: 7 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,13 @@
npm init xc-app learn-wasm -t wasm-react
```

## Related List
## [Awesome Lists](./awesome-lists.md)

* [Compiling from Rust to WebAssembly](https://developer.mozilla.org/en-US/docs/WebAssembly/Rust_to_wasm)
* [Rust and WebAssembly](https://rustwasm.github.io)
## Examples

---
### @rsw/chasm

* [Reading files in WASM](https://github.com/rustwasm/wasm-bindgen/issues/1727)

---

* [Replacing a hot path in your app's JavaScript with WebAssembly](https://developers.google.com/web/updates/2019/02/hotpath-with-wasm)
* [译: 如何使用 WebAssembly 提升性能](https://www.infoq.cn/article/2IHWa2Ivbvw*hFw6fvk6)
<img src="./assets/chasm/1.png" width="200" />
<img src="./assets/chasm/2.png" width="200" />
<img src="./assets/chasm/3.png" width="200" />
<img src="./assets/chasm/4.png" width="200" />
Binary file added assets/chasm/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/chasm/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/chasm/3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/chasm/4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions awesome-lists.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Awesome Lists

* [Compiling from Rust to WebAssembly](https://developer.mozilla.org/en-US/docs/WebAssembly/Rust_to_wasm)
* [Rust and WebAssembly](https://rustwasm.github.io)
* [Replacing a hot path in your app's JavaScript with WebAssembly](https://developers.google.com/web/updates/2019/02/hotpath-with-wasm)
* [译: 如何使用 WebAssembly 提升性能](https://www.infoq.cn/article/2IHWa2Ivbvw*hFw6fvk6)

<!-- * [Reading files in WASM](https://github.com/rustwasm/wasm-bindgen/issues/1727) -->

0 comments on commit c0c5b96

Please sign in to comment.