Repository navigation
feat(wasm): render sprites, variants and compositions by name - #36
Merged
Merged
Conversation
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
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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)andrender_named_to_png(jsonl, name): render a sprite, variant or composition by name. Variants, derived sprites (source+transform) and compositions resolve the waypxl render --sprite/--compositiondo. Lenient: problems come back inwarnings; 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_spritesandvalidateare unchanged.Docs:
integrations/wasm.mdlisted an optionalspriteNameargument onrender_to_png/render_to_rgbathat 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 withmirror-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 topxl render -con the same source.Not included: no version bump or npm publish, and
@includepalettes are not resolved (there is no filesystem in the browser).🤖 Generated with Claude Code
https://claude.ai/code/session_014TTLD9BXsReLisPj4eMGeJ