polygon2.rectangle
An axis-aligned rectangle, counter-clockwise from its lower-left corner.
Usage
Polygon2.rectangle(width: number, height: number, center?: Point2): Result<Polygon2>Parameters
widthnumberExtent along x; must be positive. Required. In model.
heightnumberExtent along y; must be positive. Required. In model.
centerPoint2The rectangle’s centre. Default
Point2.origin. In model.
Returns
Ok with a four-corner counter-clockwise polygon.
Errors
Guarantees
- area() equals width · height
- isCounterClockwise() is true
- its bounding box is centred on center
- The same result on every machine.
Example
Polygon2.rectangle(4, 2).value.signedArea() // → 8