Skip to content

publicclass/geom-poly

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

77 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

geom-poly

Build Status

A collection of terse polygon utilities. A part of geom.

Features

  • Memory managed each utility has a pool of instances accessable using _X_.make() and _X_.free(). If you don't need pooled instances, simply pass in your own object instead.

  • State less no state is kept within the utilities, it's up to you.

Example

var poly = require('geom-poly');

// in steps
var rect = poly.make()
poly.add(rect,10,10)
poly.add(rect,20,10)
poly.add(rect,20,20)
poly.add(rect,10,20)
poly.close(rect)

// directly in make() (will auto-close)
var rect = poly.make(
    10,10,
    20,10,
    20,20,
    10,20
)

API

poly.make([x1,y1,x2,y2...])

poly.add(a,x,y[,c])

poly.close(a)

poly.area(a)

poly.centroid(a)

poly.translate(a,x,y[,c])

poly.transform(a,mat[,c])

poly.aabb(a[,c])

poly.collides(a,b,v)

License

MIT

About

A collection of terse, efficient polygon tools.

Resources

Stars

Watchers

Forks

Packages

No packages published