convex-polygon-scaler
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

Convex polygon scaler

Scale a convex polygon by a fixed amount.

Screenshot

(demo)

How does it differs from scale?

This method is area independent.

Such as the distance between the middle point of an edge of the original quad and the middle point of the respective edge of the scaled polygon is always fixed and is not dependent by the area of the polygon.

Usage example

Works in node.js and in the browser.

Polygon is a list of 2D vectors [x,y] in clockwise or counter-clockwise order.

const _polygon = [[100, 100], [100, 200], [200, 200], [200, 100]]
const dwarf = polygonScaler(polygon, -10)
// [[110,190],[190,190],[190,110],[110,110]]

Credits

Written in Typescript with @thi.ng umbrella library.

Package Sidebar

Install

npm i convex-polygon-scaler

Weekly Downloads

27

Version

1.0.2

License

ISC

Unpacked Size

1.69 MB

Total Files

16

Last publish

Collaborators

  • nkint