Skip to content

Conversation

@andrewfb
Copy link
Owner

Summary

Adds path offsetting, stroking, and intersection detection to Path2d and Shape2d.

  • Path offset: Generate parallel curves at a specified distance with configurable join styles (bevel/miter/round)
  • Path stroke: Expand paths into filled stroke shapes with configurable caps (butt/square/round) and joins
  • Dash patterns: Apply dash patterns to paths via calcDashed()
  • Intersection detection: findIntersections() between two paths, findSelfIntersections() with sweep-and-prune spatial indexing, and removeSelfIntersections() for planar graph decomposition
  • CinderMath additions: Numerically stable polynomial solvers, ITP root-finding, line-bezier intersections, and bezier evaluation utilities

Includes BezierOffset sample demonstrating the new APIs with interactive controls for all parameters.

Test plan

  • Builds on Windows (vc2022)
  • Builds on macOS (xcode)
  • BezierOffset sample runs correctly
  • Unit tests pass

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.
@andrewfb andrewfb closed this Jan 13, 2026
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.

2 participants