JSPM

polygon-centroid

1.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2285
  • Score
    100M100P100Q122010F
  • License MIT

Return the centroid for a given convex polygon.

Package Exports

  • polygon-centroid

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (polygon-centroid) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

polygon-centroid

Return the centroid for a given convex polygon.

Installation

npm i polygon-centroid --save

Usage

centroid(points) Return the point {x, y} which is the centroid of the given set of points (convex polygon).

Example

var centroid = require('polygon-centroid');
var center = centroid(this.polygon.points);
this.polygon.anchor.set(center.x, center.y);
this.polygon.rotation = Math.PI * 0.5;