Repository navigation
feat: add a Bar element that fills to a bound fraction - #106
Merged
Merged
Conversation
A bar's fill is an art layer cut into clips of 1, 2, 4, ... columns, each a glyph, so the runtime draws any column count from one clip per set bit. Clips with the same pixels share a glyph. Adds the fraction handle kind, the bar manifest entry, Kotlin codegen, and preview state.
Windows and HUDs bind each bar to a lambda returning a fraction, compose the clips for its column count, and recompose only when that count changes.
…tus HUD The /bar debug command pins the fraction both draw.
oglassdev
added this pull request to stack #101
October 11, 2026 06:54
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.
A smooth progress bar had to be built by hand: generate a dozen tile textures per colour, then work out value → columns → per-tile case in consumer Kotlin. Now a bar is one element that takes a fraction, and the compiler generates the rest.
widthandheightare 1 to 256 px.filland the optionaltrackare ordinary art.tintis a hex colour or a tint handle.round(fraction × width)columns, with the fraction clamped to 0..1.[health, 0.42]. A fraction without preview state draws full.Cost: the fill is cut into clips of 1, 2, 4, … columns and a value is drawn as one clip per set bit, so at most log2(width)+1 glyphs are sent. Clips with identical pixels share a glyph: a uniform 100 px fill costs 7 glyphs, while art that differs in every column can cost up to one per column. The example's two bars (100 px uniform, 152 px rimmed) add 22 glyph textures and take the compiler output from 515.2 KB to 536.1 KB.
The example adds a budget bar to the shop, a wave bar to the status HUD, and a
/bar <0..1|auto>command that pins both.Checked in a real 26.2 client: the shader-placed HUD bar drew exactly 0, 3, 37, 50 and 100 columns for 0, 0.03, 0.37, 0.5 and 1, in the exact palette colour for each tone; the shop bar drew 0, 5, 64, 76 and 152 columns with the right rim only at 152; previews matched the client's bar pixels at three values.
Not checked in a client: a bar redrawing in an open window (covered by a runtime test), bars inside switch cases or indexed families, bars in anvil windows and non-shader HUDs, and fill art with transparent columns or gradients.
Closes #95.
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 #105.
🤖 Generated with Claude Code