TwoRS
Easily render 2D graphics in a canvas - entirely powered by Rust!!! :crab:
:sunglasses: Why Rust/WASM?
It's use case is either the reuse of code written in another language or to offload heavy computations to the near-native execution speeds of WASM.
However this is not free - traversing the WASM boundary means going trough some glue code and copying data from JS to the WASM module memory and back. In the case of strings it's even more expensive - because JS strings are UTF-16 and Rust strings use UTF-8 any string passtrough needs to go trough a copy AND a re-encode.
twors doesn't have any complicated physics to offload to WASM at this point in time - neither
is it making use of some advanced pre-existing Rust library. So why Rust then?
Simply because Rust is the best!!!
:zap: Quick start
- Here's how to quickly render a moving rectangle
- Check out lib.rs for a sneak peek!
:pencil: Roadmap
- Adaptive canvas resolution on resize
- Delta time
- Keyboard & mouse inputs
- Component system (with
init()andupdate()lifecycle methods) - Transform (with inheritance) - translate, scale
- Collision detection
- Bezier curves
- FPS benchmark
:computer: Development
Experiments and manual testing are to be done in the examples/playground crate.
# convenience scripts - see "Makefile.toml" for full list of commands
# run local pre-commit checks - will be run on "build" automatically
# other commands