Skip to content

Documentation / @ripl/terminal / flattenEllipse

Function: flattenEllipse() ​

flattenEllipse(cx, cy, rx, ry, rotation?, startAngle?, endAngle?, counterclockwise?, steps?): Vertex[]

Defined in: terminal/src/algorithms.ts:436

Samples an ellipse outline into a polyline of points.

Parameters ​

ParameterTypeDefault valueDescription
cxnumberundefinedX coordinate of the ellipse center.
cynumberundefinedY coordinate of the ellipse center.
rxnumberundefinedRadius along the ellipse's own x axis.
rynumberundefinedRadius along the ellipse's own y axis.
rotationnumber0Rotation of the ellipse about its center, in radians.
startAnglenumber0Angle the sweep starts at, in radians.
endAnglenumberTAUAngle the sweep ends at, in radians.
counterclockwisebooleanfalseWhether the sweep runs counterclockwise.
steps?numberundefinedSegment count to sample with. Pass it when the sampled points are about to be transformed into a larger space, which the radius-derived default would under-segment for.

Returns ​

Vertex[]

The sampled points. A full sweep omits the duplicate closing point (the curve is closed implicitly); a partial sweep includes both endpoints, so filling it closes the segment with a chord exactly as canvas does.