sdf-polygon-2d
在二维空间中对多边形的有符号距离场进行采样
安装
npm install sdf-polygon-2d
用
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
更多示例
执照
1