Skip to content

Region paint order is random unless every region sets z #14

Open

Description

@scbrown
{ type: "palette", name: "p", colors: { _: "transparent", a: "#ff0000", b: "#0000ff", c: "#00ff00", d: "#ffff00" } }
{ type: "sprite", name: "order", size: [4, 4], palette: "p", regions: {
    a: { rect: [0, 0, 4, 4] },
    b: { rect: [1, 1, 3, 3] },
    c: { rect: [2, 2, 2, 2] },
    d: { points: [[3, 3]] },
} }

The docs (format/regions.md, "Z-Order") say the default is definition order.
Sprite.regions is a HashMap, though, and render_structured stable-sorts
by z, so equal-z regions paint in hash order. That order changes from process
to process: rendering the repro 6 times gave 3 different PNGs. Workaround:
every region in skull.pxl has an explicit, unique z. The fix is probably an
IndexMap for regions, which would also make fill/except dependency
order match the source.

Found while drawing examples/skull (#13). The repro is checked against main.

🤖 Generated with Claude Code

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions