Skip to content

toolkit: a system symbol is a stencil, not a photograph - #436

Merged
tannevaled merged 1 commit into
mainfrom
a-stencil-is-an-icon
Aug 30, 2026
Merged

toolkit: a system symbol is a stencil, not a photograph#436
tannevaled merged 1 commit into
mainfrom
a-stencil-is-an-icon

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

A platform's own symbols arrive as pictures whose alpha is the shape and whose colour means nothing — what a platform calls a template image. The toolkit could take one only as an Image, which paints the pixels as they are: a black glyph that disappears on a dark card and never picks up the accent colour when its cell is selected. The alternatives were to rasterise the artwork a second time, or to blit it beside the widget by hand — and hand-blitting beside a widget is exactly what a consumer's "no hand-drawn UI" rule forbids.

StencilIcon(pix, w, h) reads the alpha and takes the colour from the caller, which makes it an IconFunc like every stock DrawIcon***: it drops into an IconCell, a TreeTableNode, or anywhere else that draws one, and follows the theme and the selection for free.

  • The tinted copy is kept until the ink changes, so a grid redrawing every frame tints once, not once a frame.
  • The source is neither modified nor retained beyond the drawer.
  • The picture keeps its aspect ratio inside its box, centred: a system symbol is rarely square, and stretching one is what makes it look like somebody else's icon.
  • An ink that is itself see-through thins the stencil rather than replacing its coverage.

Tests use a source whose own colours are red and blue on purpose, so anything reading them instead of the ink shows up: a 40×10 picture asserted not to come out square in a square box, the source asserted byte-for-byte unmodified, a half-transparent ink asserted to draw a different picture from an opaque one, and the result asserted identical on a back end without the image primitive — which draws it a pixel at a time, since that primitive is a speed-up and not a requirement.

Coverage stays at 100.0%.

A platform's own symbols come as pictures whose ALPHA is the shape and
whose colour means nothing -- what a platform calls a template image.
The toolkit could take one only as an Image, which paints the pixels as
they are: a black glyph that disappears on a dark card and never picks
up the accent colour when its cell is selected. The alternatives were to
rasterise the artwork a second time or to blit it beside the widget by
hand, and hand-blitting beside a widget is the thing the fleet's UI rule
exists to forbid.

StencilIcon reads the alpha and takes the colour from the caller, which
makes it an IconFunc like every stock DrawIcon***: it drops into an
IconCell, a TreeTableNode, or anywhere else that draws one, and follows
the theme and the selection for free.

The tinted copy is kept until the ink changes, so a grid redrawing every
frame tints once rather than once a frame, and the source is neither
modified nor retained. The picture keeps its aspect inside its box --
a system symbol is rarely square, and stretching one is what makes it
look like somebody else's icon.

Tested with a source whose own colours are red and blue on purpose, so
anything reading them instead of the ink shows: a 40x10 picture asserted
not to come out square in a square box, the source asserted unmodified,
a half-transparent ink asserted to thin the stencil, and the picture
asserted identical on a back end without the image primitive -- which
draws it a pixel at a time, since the primitive is a speed-up and not a
requirement.
@tannevaled
tannevaled merged commit 470f383 into main Aug 30, 2026
1 check passed
@tannevaled
tannevaled deleted the a-stencil-is-an-icon branch August 30, 2026 21:07
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