Add Path2d offset, stroke, and intersection operations#9
Closed
Add Path2d offset, stroke, and intersection operations#9
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 Path2d and Shape2d.
calcDashed()findIntersections()between two paths,findSelfIntersections()with sweep-and-prune spatial indexing, andremoveSelfIntersections()for planar graph decompositionIncludes
BezierOffsetsample demonstrating the new APIs with interactive controls for all parameters.Test plan