pixfx

pixfx

Pixel-art effects written once in Rust. Render them to sprite sheets, or play the same effects live in the browser, Phaser and gpui. The pixels are identical everywhere.

Click the ground to light a candle.

The same pixels on every target

Each effect is plain Rust drawing into a frame with two layers: colour, and additive light. The engine reproduces JavaScript's number rules, so a port of a pixelfx effect draws exactly what pixelfx draws.

The scene above is that engine compiled to WebAssembly. A native build writes the same frames to PNG sheets and GIFs, and a frame-hash test checks native and wasm against one set of goldens.

How parity and determinism are checked

Differing pixels against pixelfx commit 044e12a, every frame of one loop, colour and light layers.
EffectFramesDiffering pixels
fire/candle1200
fire/campfire900
fire/brazier900

Effects

Every effect takes the same options: a seed, a glow strength, a palette, and options of its own. Change them here; the call below each effect updates to match.

Where it runs

Pick the layer that fits your project. All of them share one engine and one effect registry.

Write a sprite sheet (composite, colour and light PNGs plus beanfx-layout JSON), or a looping GIF.

cargo run -p pixfx-cli -- sheet fire/campfire --out out
cargo run -p pixfx-cli -- render fire/campfire --gif --scale 4 --out out

Command line reference ยท Sprite sheet format

Try it in a minute

  1. Clone the repository. rust-toolchain.toml pins the nightly and the wasm target, so rustup fetches them on first build.

  2. Render the campfire to a GIF:

    cargo run -p pixfx-cli -- render fire/campfire --gif --out out
  3. Or play it in the browser through the canvas demo:

    wasm-pack build crates/pixfx-canvas --target web --out-dir demo/pkg
    cd crates/pixfx-canvas/demo && python3 -m http.server 8766 --bind 127.0.0.1

Full getting-started guide