Skip to content

feat: recolour art and text at runtime from a named palette - #105

Merged
oglassdev merged 10 commits into
feat/previewsfrom
feat/tints
Oct 11, 2026
Merged

oglassdev merged 10 commits into
feat/previewsfrom
feat/tints

Conversation

@oglassdev

@oglassdev oglassdev commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

A UI could only change colour by swapping whole sprites: a "warning" state needed its own copy of every piece of art, and text colour was fixed at build time. Now art and text can take a colour from a small named palette that the server picks at runtime, so one set of art serves every state.

const tone = tint("tone", { ok: "#3ddc84", warn: "#ffb020", danger: "#ff4d4d" });

<Box frame="pill" tint={tone}>
  <Text color={tone}>Wave incoming</Text>
</Box>
hud.tone(StatusHud.Tone.DANGER)
  • tint(id, palette) declares a handle with a fixed palette. tint on a <Box> or <Case> frame and on <Image> takes the handle or a literal hex; color on text takes the handle.
  • Tinted art multiplies the art's pixels by the palette colour, so white art shows the colour exactly and shaded art keeps its shading.
  • The Kotlin binding is an enum nested in the view, one constant per palette entry. The first entry is the initial colour.
  • Previews take [tone, "danger"] as state and draw the chosen entry; the default is the first entry.
  • A literal hex tint is baked at build time and costs nothing at runtime.

Cost: each tinted piece of art becomes its own font glyph instead of joining the static background glyph. In shader-placed HUDs each tinted segment also uses one marker colour per palette entry.

A shader-placed HUD that needs more than 65,535 marker colours fails the build with a message.

The example adds a /tone command that tints the wave hint HUD and a status lamp in the shop.

Checked in a real 26.2 client: the HUD pill's rim, fill and text and the shop lamp show the exact palette colours and multiply products in all three tones, and the previews of the HUD match the client pixel for pixel in each tone. That comparison found the preview's HUD text shadow one step dark in some colours; previews now round it as the shader does, which applies to every shader-placed HUD preview.

Not included:

Not checked against a client: tinted runtime sprite slots (<Image bind tint>) and previews of tinted non-shader HUDs.

Closes #91. Closes #92.

Checks: just test-rust -p window-core, just gradle :runtime:test --rerun, just check-ts, just test-ts, just golden, just lint, just fmt-check.

Stacked on #104.

🤖 Generated with Claude Code

A tint handle names a palette of colors. Art tinted by one leaves the static composite and becomes an art layer drawn at its authored place, with untinted art authored over it; text takes the palette color. Shader-placed HUDs get one marker per palette entry per tinted segment. A hex tint is multiplied into the art at build time.

Refs #91, #92
tint(id, palette) from plugin:window/bind goes on a Box, Case, or Image tint and on a text color, in JSX and raw.

Refs #91, #92
…ntry

WindowScope.tint and HudScope.tint bind a palette; art layers, slots, and sprite slots take its color, or its marker in a shader-placed HUD.

Refs #91, #92
/tone <ok|warn|danger|auto> pins the tone for debugging.
Preview state takes a tint handle with one of its palette entry names, defaulting to the first. Art layers draw at
their authored place multiplied by that color, tinted text and runtime sprites take it, and art layers count toward
the canvas bounds and the pixel limit.
…hader does

The generated shader scales the display color by 0.25 without truncating, so truncating each channel drew some
shadows one step darker than the client.
@oglassdev
oglassdev added this pull request to stack #101 October 11, 2026 06:19
…nd runtime layers

Report an error instead of looping when shader HUD segments outnumber marker
IDs, reuse an untinted art layer only while it is the last runtime layer, and
carry a switch case's art coverage into the enclosing run.
@oglassdev
oglassdev merged commit 36f5a78 into main Oct 11, 2026
11 checks passed
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.

Let HUD text color vary by switch case Tint frames and sprites from state at runtime

1 participant