npm

Bring the best of OSS JavaScript development to your projects with npm Orgs - private packages & team management tools.Learn more »

sdf-polygon-2d

2.0.0 • Public • Published

sdf-polygon-2d

sample the signed distance field of a polygon in 2d space

install

npm install sdf-polygon-2d

use

var createSDF = require('sdf-polygon-2d');
var points = [
  [-10, -10],
  [-10,  10],
  [ 10,  10],
  [ 10, -10]
];

// pass an array of polygons, including polygons with holes
var sample = createSDF([points]);
console.log(sample(0, 0)) // -10
console.log(sample({ x: 10, y: 0 })) // 0
console.log(sample([20, 0])) // 10

more examples in test.js

license

MIT

install

npm i sdf-polygon-2d

Downloadsweekly downloads

9

version

2.0.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability