Skip to content
Shapemetry

@huukhanhnguyen/types / geometry/curve2d

geometry/curve2d

ArcCurve2d

ArcCurve2d = { center: Point2d; radius: number; startAngle: number; sweepAngle: number; }

The plane twin of ArcCurve (curve.ts): a circular arc about center.

Same startAngle + sweepAngle as its space twin.

center

center: Point2d

radius

radius: number

startAngle

startAngle: number

sweepAngle

sweepAngle: number


CubicBezier2d

CubicBezier2d = { control1: Point2d; control2: Point2d; end: Point2d; start: Point2d; }

Cubic Bezier in the plane. Discriminated by control1 (and control2) when untagged. Folded into degree-3 NURBS on Curve2d write.

control1

control1: Point2d

control2

control2: Point2d

end

end: Point2d

start

start: Point2d


Curve2d

Curve2d = { curves: PolyCurve2d[]; transformation?: Transformation; }

2D curve document — fill/stroke collection of ordered plane chains.

Same stem as the geometry Curve2d ops namespace (type/value dual). Each entry of curves is one PolyCurve2d (closed ring or open stroke). Optional transformation is a length-16 4×4 placing the planar document into world space (plane-in-world embed — not Transformation2d (core2d.ts), which is a 6-number in-plane affine). Omitted when identity.

Wire write uses tagged Segment2d segments. The Curve2d.addShape wasm door additionally accepts the UNTAGGED segment bag the text kernel's glyph outliner emits, and tags it on the way in; that bag is not a public TypeScript type.

curves

curves: PolyCurve2d[]

transformation?

optional transformation?: Transformation


EllipseCurve2d

EllipseCurve2d = { center: Point2d; majorRadius: number; minorRadius: number; startAngle: number; sweepAngle: number; xAxis: Vector2d; }

The plane twin of EllipseCurve (curve.ts): an elliptical arc. Circular arcs are the equal-radius case of this on the contour wire.

xAxis is a direction, not necessarily unit — the kernel normalizes where it needs to.

center

center: Point2d

majorRadius

majorRadius: number

minorRadius

minorRadius: number

startAngle

startAngle: number

sweepAngle

sweepAngle: number

xAxis

xAxis: Vector2d


LineCurve2d

LineCurve2d = { end: Point2d; start: Point2d; }

The plane twin of LineCurve (curve.ts): a bounded straight segment in uv / xy.

Untagged on the contour wire, where a segment is discriminated by field presence — this is the fallback, the one with neither control, control1 nor sweepAngle.

end

end: Point2d

start

start: Point2d


NurbsCurve2d

NurbsCurve2d = { controlPoints: Point2d[]; degree: number; knots: number[]; weights: number[]; }

The plane twin of NurbsCurve (curve.ts) — the closure in uv, and the exact carrier of a composite uv curve on a face.

controlPoints

controlPoints: Point2d[]

degree

degree: number

knots

knots: number[]

weights

weights: number[]


PolyCurve2d

PolyCurve2d = { segments: Segment2d[]; }

Ordered chain of 2D curve segments (endpoint-welded).

Plane twin of PolyCurve (curve.ts). Wire: { segments: Segment2d[] }. One ring / open stroke is one polycurve; multi-ring fill is Curve2d.

segments

segments: Segment2d[]


QuadraticBezier2d

QuadraticBezier2d = { control: Point2d; end: Point2d; start: Point2d; }

Quadratic Bezier in the plane. Discriminated by control when untagged — the shape a glyph outline arrives in from the text kernel. Not a Segment2d kind: Curve2d write folds these into degree-2 NURBS.

control

control: Point2d

end

end: Point2d

start

start: Point2d


Segment2d

Segment2d = { type: "line"; } & LineCurve2d | { type: "arc"; } & ArcCurve2d | { type: "ellipse"; } & EllipseCurve2d | { type: "nurbs"; } & NurbsCurve2d

The plane twin of Segment (curve.ts): one of the four 2D curve geometries wearing its type tag. Same tag spelling and flattened fields as the space union — not the nested { type, data } envelope the curve2d wasm door uses internally for Offset/Trimmed wrappers.

Circular arcs are tagged arc (not circle), matching ArcCurve2d.

Last updated: 📖 4 min readEdit on GitHub