[shapes] feat: offscreen canvas compositing for group-aware text area rendering#705
Merged
Conversation
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.
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