Rust owns the math
Rotation happens in `rotate_z`, using the rectangle center as the pivot. Positive degrees rotate clockwise so the browser controls match what the user sees.
Rust + WebAssembly geometry
A browser-based rectangle transform demo where Rust owns the geometry, WebAssembly exposes the runtime API, and JavaScript only handles canvas rendering.
Loading WASM...
Project logic
The rectangle starts as a single Rust vertex array. The browser reads those vertices from WebAssembly memory, draws them to canvas, and requests transforms through exported Rust functions.
Rotation happens in `rotate_z`, using the rectangle center as the pivot. Positive degrees rotate clockwise so the browser controls match what the user sees.
JavaScript calls exported functions for reset, rotation, vertex count, and memory pointers. It never duplicates the transform formulas.
The canvas maps world coordinates to pixels, marks the original top edge, and prints the current vertex buffer for inspection.
Implementation
The interaction is intentionally simple, which makes the data flow easy to inspect from UI event to Rust memory mutation.
Quality
Unit and integration tests verify bounds, closed geometry, clockwise rotation, center stability, and repeated rotations.
Node tests instantiate the compiled WASM module, validate exports, rotate the runtime buffer, and confirm negative zero is hidden.
GitHub Actions run formatting and the full test suite, then build the static `web/` artifact for GitHub Pages deployment.