@technobuddha > library > Geometry > Polygon
Function: translate()
Translate a point or polygon by a specified amount.
Call Signature
ts
function translate(point: Cartesian, amount: XY): Cartesian;Defined in: translate.ts:24
Translate a point by a specified amount.
Parameters
| Parameter | Type | Description |
|---|---|---|
point | Cartesian | The point or array of points to translate. |
amount | XY | The amount to move the point by. |
Returns
The translated point.
Example
typescript
translate({ x: 1, y: 0 }t, { x: 1, y: 2 }); // { x: 2, y: 2 }Call Signature
ts
function translate(polygon: Polygon, amount: Cartesian): Polygon;Defined in: src/translate.ts:39
Translate a polygon by a specified amount.
Parameters
| Parameter | Type | Description |
|---|---|---|
polygon | Polygon | The polygon to translate. |
amount | Cartesian | The amount to move the polygon by. |
Returns
The translated polygon.
Example
typescript
translate([{ x: 0, y: 0 }, { x: 1, y: 1 }, { x: 0, y: 1}], { x: 1, y: 2 });
// [{ x: 1, y: 2 }, { x: 2, y: 3 }, { x: 1, y: 3 }]