Skip to content

feat(wasm): render sprites, variants and compositions by name - #36

Merged
scbrown merged 3 commits into
mainfrom
hammond/wasm-render-named
Nov 15, 2026
Merged

scbrown merged 3 commits into
mainfrom
hammond/wasm-render-named

Conversation

@scbrown

@scbrown scbrown commented Nov 11, 2026

Copy link
Copy Markdown
Owner

The WASM API rendered only the first sprite in the input and skipped compositions and variants, so a browser could not show a scene built from several sprites.

Adds

  • render_named_to_rgba(jsonl, name) and render_named_to_png(jsonl, name): render a sprite, variant or composition by name. Variants, derived sprites (source + transform) and compositions resolve the way pxl render --sprite / --composition do. Lenient: problems come back in warnings; an unknown name gives a 0 x 0 result.
  • list_renderables(jsonl): "sprite:<name>", "variant:<name>", "composition:<name>" in definition order.

The existing render_to_png, render_to_rgba, list_sprites and validate are unchanged.

Docs: integrations/wasm.md listed an optional spriteName argument on render_to_png / render_to_rgba that the bindings never had. Corrected, and the new functions documented.

Checked

  • cargo test --features wasm --lib wasm::: 14 pass, 6 new (named sprite is not just the first, variant, derived sprite with mirror-h, composition placing a sprite and a variant, unknown name, PNG magic).
  • wasm-pack build --target web: a 2.1 MB .wasm. Loaded in Node, five tile-map compositions of 20 or so sprites each (up to 480x270) render in 20 to 40 ms, and every one is pixel-identical to pxl render -c on the same source.

Not included: no version bump or npm publish, and @include palettes are not resolved (there is no filesystem in the browser).

🤖 Generated with Claude Code

https://claude.ai/code/session_014TTLD9BXsReLisPj4eMGeJ

scbrown and others added 2 commits November 11, 2026 15:25
The WASM API rendered only the first sprite in the input and skipped
compositions and variants, so a browser could not show a scene. Adds
render_named_to_rgba, render_named_to_png and list_renderables, which resolve
variants, derived sprites and compositions the way pxl render does. The
existing first-sprite functions are unchanged. The docs listed an optional
spriteName argument that never existed; corrected.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014TTLD9BXsReLisPj4eMGeJ
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014TTLD9BXsReLisPj4eMGeJ
@scbrown
scbrown merged commit ba7bf5c into main Nov 15, 2026
19 checks passed
@github-actions github-actions Bot mentioned this pull request Nov 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant