curve2.offset
The offset of a 2D curve, chain or region by a signed distance, keeping lines, arcs and circles, with round, miter or bevel corners.
Usage
Curve2.offset(geom: Geom2, distance: number, options?: Curve2OffsetOptions): Result<Curve2Offset>Parameters
geomGeom2A curve, a chain or a region. Required. In model.
distancenumberPositive to the left of the direction of travel (inwards for a counter-clockwise loop or a circle); a region grows for a positive one. Required. In model.
options.join'round' | 'miter' | 'bevel'How the pieces meet at a convex corner. Default
'round'.options.miterLimitnumberA miter farther than this many distances from the vertex bevels; at least 1. Default
4.options.cap'butt' | 'round'An open chain: return its closed outline, both sides joined by these caps.
options.scopestringThe node id minted ids are keyed under.
options.dryRunbooleanReturn the outline only. Default
false.options.tolerancenumberA cubic’s offset is fitted within it. Default
1e-9 × the bounds diagonal. In model.
Returns
Ok with { outline, curves | chain | region, fitted? }: a line’s offset is a line, an arc’s a concentric arc with the same centre, a cubic’s cubics fitted within the tolerance (their ids in fitted); concave corners are cut where the pieces cross.
Errors
Guarantees
- every output point lies the distance from the input (fitted pieces within the tolerance)
- ids are keyed by source and side, never by position
- The same result on every machine.
Example
const r = Curve2.offset({ id: 1, minter: 0, kind: 'line', a: Point2.of(0, 0), b: Point2.of(10, 0) }, 1)
r.ok ? r.value.outline : Result.error(r).code // → ok once loadGeometryKernel() has run; CAPABILITY_UNAVAILABLE before