Skip to content

[shapes] feat: offscreen canvas compositing for group-aware text area rendering#705

Merged
Yonava merged 2 commits into
mainfrom
yva/canvas-background
Jun 18, 2026
Merged

[shapes] feat: offscreen canvas compositing for group-aware text area rendering#705
Yonava merged 2 commits into
mainfrom
yva/canvas-background

Conversation

@Yonava

@Yonava Yonava commented Jun 18, 2026

Copy link
Copy Markdown
Owner

Replaces index-based draw ordering with a priority-group compositing model. Shapes now declare a static priority tier (edges = 1, nodes = 2) and drawGroup handles layering within each tier using a shared offscreen canvas.

The core problem this solves: when edges cross each other's text area bounds, the matte from one edge would clip the line of another. By drawing all shapes in a group to a single offscreen canvas and punching text area holes with destination-out compositing before flattening to the main canvas, crossing lines are preserved correctly.

Changes:

New drawGroup in @magic/shapes — offscreen compositing pipeline for a set of shapes
color: 'none' on a text area opts the shape into no-matte rendering via drawWithNoMatte
drawTextAreaHole added to ShapeTextProps for use by drawGroup's punch pass
getShapeTextProps now accepts the shape's own drawShape fn and returns an optional drawOverride for single-shape no-matte cases
Priority tiers replace the old i * 10 / i * 10 + 1000 index arithmetic in the canvas plugin

@Yonava Yonava merged commit 129674e into main Jun 18, 2026
1 check failed
@Yonava Yonava deleted the yva/canvas-background branch June 18, 2026 13:29
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