fix(renderer): clip text to shape outline on circle / parallelogram cards - #65
Merged
Conversation
…ards (#53a) Text on circle and parallelogram cards clipped only to the bounding rect, so long body content (and side labels) could spill past the curved or slanted edge into the card's empty corners. Clip to the actual shape path instead. The top-level `<Group clip>` mechanism (#167) already works for rects; this swaps the clip region to the shape's SVG path when the node is a circle / parallelogram, falling back to the bounding rect otherwise. Mirrored in the Picture path (`drawTextNode`) via `canvas.clipPath` so pinch-overlay output stays pixel-identical to the live tree (two-paths-in-sync rule). Extracts the shape geometry into a shared `nodes/shapes.ts` (parallelogram + oval SVG paths, `shapeClipPath` dispatcher). This is the single source of truth for the outline — previously the parallelogram maths was duplicated in SkiaCardRenderer and useCanvasPicture; both now delegate here, so a clip outline can never drift from the fill outline. Pure string in/out, no Skia/ESM deps, so it unit-tests cleanly (10 tests). Scope: shape clipping only (#53 item 1). The remaining #53 item — rotated labels on mixed-zone cards (label + body/header/footer) — is a separate renderer-extraction refactor, tracked as its own follow-up. Co-Authored-By: Claude Opus 4.8 (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.
Summary
Text on circle and parallelogram cards clipped only to the bounding rect, so long body content (and side labels) could spill past the curved / slanted edge into the card's empty corners. Now clips to the actual shape outline.
Addresses item 1 of #53. (Item 2 — rotated labels on mixed-zone cards — split into #64.)
Approach
<Group clip>mechanism (#167) already works for rects. This swaps the clip region to the shape's SVG path when the node is circle / parallelogram, falling back to the bounding rect otherwise.drawTextNode) viacanvas.clipPathso pinch-overlay output stays pixel-identical to the live tree (two-paths-in-sync rule).nodes/shapes.ts(parallelogramPath,ovalPath,shapeClipPath). Previously the parallelogram maths was duplicated inSkiaCardRendereranduseCanvasPicture; both now delegate here, so the clip outline can never drift from the fill outline. Net: removes duplication rather than adding a third copy.Why this is low-risk
shapes.tsis pure string in/out — no Skia/ESM deps — so it unit-tests cleanly (10 new tests), unlike the markdown chain.Test plan
shapes.test.ts— geometry + dispatch)Closes #53 (item 1). Item 2 tracked in #64.
🤖 Generated with Claude Code