region2.fromParts

A region of several parts, each an outline with holes, wound as Region2.of winds them.

GeometricSince 0.4.0

Usage

TypeScript
Region2.fromParts(parts: readonly RegionPart[]): Region2

Parameters

  • partsreadonly RegionPart[]

    Each part as { outer, holes }; disjoint outlines. Required. In model.

Returns

A frozen region; Region2.empty’s shape (no parts) for an empty list.

Guarantees

  • outlines wind counter-clockwise and holes clockwise (part.outer.isCounterClockwise(), !hole.isCounterClockwise())
  • parts.length equals the input’s
  • The same result on every machine.

Example

TypeScript
const p = (x) => ({ outer: Polygon2.rectangle(1, 1, Point2.of(x, 0)).value, holes: [] })
Region2.fromParts([p(0), p(3)]).area() // → 2

See also