I've been trying to understand how to drive a web canvas 2D animation from Rust and WASM. I think I've got a decent sense for what wasm-bindgen
and web-sys
do: providing low-level FFI and interaction between Rust and JS/DOM elements. But I think much of that capability is aimed at a much lower-level use case than mine, which is just to run a small simulation and clear and redraw a few pieces to a fixed canvas each iteration.
Based on that, it seems like stdweb
can do everything I want a whole lot simpler (path, stroke, fill, etc.). If I have zero need to make a Rust struct available in JS and stdweb
has methods to access every JS version I need, then I believe the only thing wasm-bindgen
is needed for is the run entry point:
#[wasm_bindgen(start)]
pub fn run() -> Result<(), JsValue> {
/* setup and run loop, use stdweb to draw */
}
Am I missing anything? In my searching on the topic I feel like I've come across more implementations using web-sys
(such as here or here), but that stdweb
versions seem equally capable (as seen here). Is web-sys
just lower-level (and/or perhaps older)?