Add fill support to rectangles - #10
Open
nagieeb0 wants to merge 1 commit into
Open
Conversation
Rectangles currently always emit `re` followed by `S`, so shapes can only be outlined. That rules out anything built from solid colour: table header backgrounds, status badges, bar charts, and QR codes — a QR drawn as stroked outlines is unscannable. Adds `:fill` to Path.Rectangle. With it, `rg` sets the non-stroking colour and `f` paints the interior. `stroke: true` alongside it emits `B` instead, filling and stroking in one operation so the two stay aligned. Default behaviour is unchanged: without `:fill`, rectangles stroke exactly as before. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Rectangles currently always emit
refollowed byS, so shapes can only be outlined:That rules out anything built from solid colour — table header backgrounds, status badges, bar charts, and QR codes. A QR drawn as stroked outlines is unscannable, which is what led me here: I needed ZATCA (Saudi VAT) QR codes on invoices.
Changes
Path.Rectanglegains:fill:rgsets the non-stroking colour,fpaints the interior. Addingstroke: trueemitsBinstead, filling and stroking in one operation so the two stay aligned:strokeis an explicit flag rather than inferred from:colour, since:colouralready defaults to black and there would be no way to tell "fill only" from "fill and outline in black".Default behaviour is unchanged — without
:fill, rectangles stroke exactly as before, and there is a test asserting that.Verification
Four new tests in
drawing_test.exscovering fill-only, fill+stroke, the unchanged stroke-only path, and many filled rectangles composing (the QR / bar-chart shape).test/drawing_test.exsis green: 12 tests, 0 failures.The wider suite shows 21 failures both with and without this change on my machine — I am outside the Nix shell and substituted Google Fonts builds of Libre Bodoni/Franklin, whose metrics differ from the pinned ones. No new failures are introduced.
Happy to add
Path.Linefill or a generalclose-and-fillin a follow-up if you would like the shape of it to be different.🤖 Generated with Claude Code