Skip to content

painter: add Clipper (PushClip/PopClip) + fix StrokeRect double-corner - #5

Merged
tannevaled merged 1 commit into
mainfrom
add-clip
Jul 27, 2026
Merged

painter: add Clipper (PushClip/PopClip) + fix StrokeRect double-corner#5
tannevaled merged 1 commit into
mainfrom
add-clip

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

Two audit findings, both rooted here.

Clip primitive (the architectural gap). Painter had no way to confine drawing to a sub-rect, so toolkit.ScrollView (and any overflowing ListBox/TextView/Table) could only clip at the whole-surface edge and overdrew neighbours. Adds an optional Clipper interface (PushClip/PopClip) — non-breaking, since it's separate from Painter; widgets type-assert it. PushClip(r) intersects with any enclosing clip; every write is dropped outside the active clip. Both PixelPainter (via PutPixel) and CellPainter (via set/setFg) implement it — all primitives funnel through those, so one guard covers fills, strokes, text, and round-rects.

StrokeRect double-corner (Low, latent). PixelPainter.StrokeRect painted the four corners twice (horizontal + vertical runs), so a translucent border composited the corners darker than the edges. The vertical runs now skip the corner rows.

100% coverage; go vet clean; 6 arches + wasm build.

🤖 Generated with Claude Code

Adds an optional Clipper capability so a scrollable/overflowing widget can
confine a child to its bounds — the missing primitive behind toolkit ScrollView
overdrawing its neighbours. PushClip(r) intersects r with any enclosing clip;
every write (PixelPainter.PutPixel, CellPainter.set/setFg — all primitives
funnel through these) is dropped outside the active clip. Non-breaking: it's a
separate interface, not a change to Painter; widgets type-assert it.

Also fixes PixelPainter.StrokeRect painting its 4 corners twice (the vertical
runs now skip the corner rows the horizontal runs already covered) — a
translucent border no longer composites the corners darker than the edges.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@tannevaled
tannevaled merged commit 806e940 into main Jul 27, 2026
1 check passed
@tannevaled
tannevaled deleted the add-clip branch July 27, 2026 14:47
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