Skip to content

@technobuddha > library > Geometry > Polygon

Function: scale()

Scales a point or a polygon of points around a given origin by a specified amount.

Call Signature

ts
function scale(
   point: Cartesian, 
   amount: number | XY, 
   options?: OriginOptions): Cartesian;

Defined in: scale.ts:34

Scales a point around a given origin by a specified amount.

Parameters

ParameterTypeDescription
pointCartesianThe point to rotate.
amountnumber | XYThe amount to scale the point(s) by. This can be a number (uniform scaling) or a Cartesian object (non-uniform scaling).
options?OriginOptionssee OriginOptions

Returns

Cartesian

The rotated point.

Example

typescript
scale({ x: 1, y: 0 }, 2); // { x: 2, y: 0 }

Call Signature

ts
function scale(
   polygon: Polygon, 
   amount: number | XY, 
   options?: OriginOptions): Cartesian[];

Defined in: src/scale.ts:47

Scales a polygon around a given origin by a specified amount.

Parameters

ParameterTypeDescription
polygonPolygonThe polygon to rotate
amountnumber | XYThe amount to scale the point(s) by. This can be a number (uniform scaling) or a Cartesian object (non-uniform scaling).
options?OriginOptionssee OriginOptions

Returns

Cartesian[]

The rotated polygon

Example

typescript
scale([{ x: 0, y: 0 }, { x: 2, y: 0 }, { x: 1, y: 2}], 2);
// [{ x: 0, y: 0 }, { x: 4, y: 0 }, { x: 2, y: 4 }]