ThisIsStellar

← All animations

Hello, toon

The first ThisIsStellar sketch: a Rust starfield compiled to WebAssembly, drawn straight to a canvas.

A field of stars that twinkle, a comet on a slow ellipse, and a wordmark. No game engine: it is Rust compiled to WebAssembly talking to a 2D canvas through wasm-bindgen and web-sys, which makes it the smallest thing that still exercises the whole pipeline.

The whole artifact is about 58 KB of WebAssembly, 25 KB of that over the wire, plus 17 KB of glue. It streams in only when you press play, so a gallery full of toons costs nothing until you ask for one.

Two things about the build are worth knowing. dodeca content-hashes every file in static/, and wasm-bindgen resolves its own .wasm sibling through a string literal that dodeca does not rewrite, so scripts/sketch-manifest.rs publishes a small manifest.json mapping the original names to the hashed ones; the embed shell reads that instead of guessing. And the shell unhides the canvas before instantiating the module, because a hidden element has no layout, and a sketch that measures itself at startup would size its canvas to nothing.

I wrote the sizing loop wrong the first time in a way worth recording: a <canvas> with no CSS width of its own takes its layout size from its width attribute, so measuring the canvas to set the canvas doubles the box every frame until the tab runs out of memory. It measured the shell instead.