Expand description
Adaptive Bezier curve flattening via De Casteljau subdivision.
Mirrors SplashXPath::addCurve from splash/SplashXPath.cc exactly,
including the cx/cy/cNext stack representation and the
MAX_CURVE_SPLITS = 1024 hard limit.
§Algorithm
The curve is stored as a linked list of pending segments in the CurveData
array. Each segment [p1, p2] covers control points cx[p1*3..p1*3+3] and
endpoint cx[p2*3]. The loop advances p1 rightward, either emitting a
line segment when the chord deviation is within flatness_sq, or splitting
via De Casteljau and inserting a midpoint p3.
§Output convention
p0 (the curve start) is implicit — it is the caller’s current point and
is not included in out. The first point appended to out is the
endpoint of the first emitted sub-segment, and the last point appended is
always p3 (the curve endpoint).
Structs§
- Curve
Data - Stack storage for the De Casteljau subdivision loop.
Functions§
- flatten_
curve - Flatten a cubic Bezier curve into a sequence of line endpoints.