
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
nodejs
npm install polygon
Create a new polygon:
var p = new Polygon([
Vec2(0, 0),
Vec2(10, 0),
Vec2(0, 10)
]);
You can pass an array of Vec2s, arrays [x, y], or objects { x: 10, y: 20 }
each(function(prev, current, next, idx) {})point(idx) - returns the point at index idx. note: this will wrap in both directionsdedupe(returnNew) - ensure all of the points are uniqueinsert(vec2, index) - insert vec2 at the specified indexremove(vecOrIndex) - remove the specified vec2 or numeric index from this polygonclean(returnNew) - removes contiguous points that are the samewinding() - returns the direction in which a polygon is wound (true === clockwise)rewind(bool) - rewinds the polygon in the specified direction (true === clockwise)area() - computes the area of the polygonclosestPointTo(vec2) - finds the closest point in this polygon to vec2center() - returns a Vec2 at the center of the AABBscale(amount, origin, returnNew) - scales this polygon around origin (default is this.center()) and will return a new polygon if requested with returnNewcontainsPoint(vec2) - returns true if vec2 is inside the polygoncontainsPolygon(poly) - returns true if poly is completely contained in this polygonaabb() - returns an object {x:_, y:_, w:_, h:_} representing the axis-aligned bounding box of this polygyonoffset(amount) - performs an offset/buffering operation on this polygon and returns a new oneline(index) - return an array [startpoint, endpoint] representing the line at the specified indexlines(function(start, end, index) {}) - iterate over the lines in this polygonselfIntersections - find self-intersections and return them as a new polygonpruneSelfIntersections - remove self intersections from this polygon. returns an array of polygonslength - returns the number of points in this polygonclone - return a new instance of this polygonrotate(rads, vec2, returnNew) - rotate by origin vec2 (default this.center()) by radians rads and return a clone if returnNew is specifiedtranslate(vec2, returnNew) - translate by vec2 and return a clone if returnNew is specifiedequal(poly) - return true if this polygon has the same components and the incoming polycontains(thing) - works with an array of vec2's, an object containing a .position and .radius, an object populated with x1,y1,x2,y2, an object populated with x,y,w,h, and an object populated with x,y,width,height. See the tests for more infounion(polygon) returns a new polygon representing the boolean union of this and the incoming polygoncut(polygon) returns a new polygon representing the boolean cut of polygon from thistoArray() convert this polygon into an array of arrays ([[x, y]])MIT
FAQs
utility for working with polygons (arrays of vec2s)
We found that polygon demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.