Path2d offset, stroke, and intersection operations#2390
Merged
andrewfb merged 5 commits intocinder:masterfrom Dec 26, 2025
Merged
Path2d offset, stroke, and intersection operations#2390andrewfb merged 5 commits intocinder:masterfrom
andrewfb merged 5 commits intocinder:masterfrom
Conversation
Adds numerically stable quadratic and cubic polynomial solvers (citardauq and Blinn's method), ITP root-finding algorithm, line-bezier intersection functions, bezier evaluation/subdivision helpers, and arc length utilities for path offsetting and stroke operations.
Adds findIntersections() for detecting intersections between two paths, findSelfIntersections() with sweep-and-prune spatial indexing for efficient self-intersection detection, and removeSelfIntersections() for planar graph decomposition. Also adds isCoincident() for detecting overlapping paths.
Implements offset() for parallel curve generation with join styles (bevel/miter/round), stroke() for expanding paths into filled stroke shapes with configurable caps and joins, and calcDashed() for dash pattern application. Adds StrokeStyle class for configuring stroke parameters. Shape2d gains matching offset/stroke/calcDashed methods that operate on all contours. Uses tolerance-based arc-to-cubic subdivision for round joins and caps.
Interactive sample demonstrating path offset and stroke APIs with configurable join styles, cap styles, miter limits, and tolerances. Supports multiple shapes, preset shapes including glyphs, shape-to-shape intersection display, and tangent visualization.
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
Adds path offsetting, stroking, and intersection detection to
Path2dandShape2d.calcOffset()functioncalcStroke()functioncalcDashed()findIntersections()between two paths,findSelfIntersections()andremoveSelfIntersections()Includes BezierOffset sample demonstrating the new APIs with interactive controls for all parameters.

Here's a video of the sample in action:
https://vimeo.com/1147501490
The real heavy lifting for this code was done by Raph Levien, and is described in this blog article, and his implementation in the Kurbo library is the foundation of this Cinder implementation.