Parity and tests
Two checks keep the pixels honest: parity compares ports with pixelfx itself, and the determinism test pins native and wasm builds to one set of frame hashes.
Parity against pixelfx
Parity renders an effect with pixelfx (under Node) and with its pixfx port, then compares every pixel of every frame of both layers. It needs Node and a pixelfx checkout:
git clone https://github.com/patch-gg/pixelfx /tmp/pixelfx
git -C /tmp/pixelfx checkout 044e12a
cargo run -p pixfx-cli -- parity fire/candle --pixelfx /tmp/pixelfx --out target/parity
Output:
fire/candle: colour 0.00% differ, light 0.00% differ → PASS
- The gate: colour and light each differ on at most 0.5% of pixels. Exit code 0 is PASS, 1 is FAIL, 2 means the comparison could not run.
target/parity/<id>.side.gifshows pixelfx on the left and pixfx on the right.- If the two renders differ in frame count or size, it says so on stderr.
- Without
--pixelfx, it uses$PIXELFX, then./pixelfx.
The reference render comes from tools/pixelfx-ref.mjs, which runs pixelfx's own renderFrames with no backdrop and no stand-in actor, at the effect's default options, edge fade applied.
Current results
Against pixelfx commit 044e12a (version 0.3.1). A later pixelfx may have changed an effect.
| Effect | Colour | Light | Result |
|---|---|---|---|
fire/candle | 0 pixels | 0 pixels | PASS |
fire/campfire | 0 pixels | 0 pixels | PASS |
fire/brazier | 0 pixels | 0 pixels | PASS |
The ledger
An effect that ships below the gate must be listed in parity/LEDGER.md, one line each: <id> · <date> · colour x% light y% · approved by owner, after the owner has approved it by eye. The ledger is empty.
Determinism
Frame hashes of each effect, for seeds 1, 2 and 7 and frames first, second, middle and last, are checked against crates/pixfx-effects/tests/goldens/frame_hashes.json, natively and in wasm. A hash is FNV-1a 64 over every colour word then every light word.
cargo test -p pixfx-effects --test determinism
wasm-pack test --node crates/pixfx-effects --test determinism
Record new goldens on a native target only, after a deliberate change:
PIXFX_BLESS=1 cargo test -p pixfx-effects --test determinism
A failure prints the first line that differs.
Other tests
| Where | Covers |
|---|---|
crates/pixfx-core/tests | Painter, instances and time steps, compositing, simulation helpers. |
crates/pixfx-effects/tests/fire.rs | Fire effects' behaviour. |
crates/pixfx-export/tests | Sheet layout and JSON, GIF output. |
crates/pixfx-cli/tests | Commands, exit codes, the parity comparison. |
crates/pixfx-wasm/tests/web.rs, crates/pixfx-canvas/tests | The JS bindings and stage, under wasm-pack test --node, plus the stage's decisions natively. |
packages/pixfx-phaser/tests | The Phaser plugin under bun test, including pixel checks against the engine. |
Whole-repo check
cargo fmt --check && cargo clippy --workspace --all-targets -- -D warnings && cargo test --workspace
wasm-pack test --node crates/pixfx-wasm
wasm-pack test --node crates/pixfx-canvas
cd packages/pixfx-phaser && bun run check