MCPcopy Create free account
hub / github.com/Code-Bullet/Jump-King / simplify

Function simplify

libraries/p5.js:29670–29685  ·  view source on GitHub ↗
(pts, angle)

Source from the content-addressed store, hash-verified

29668}
29669
29670function simplify(pts, angle) {
29671
29672 angle = (typeof angle === 'undefined') ? 0 : angle;
29673
29674 var num = 0;
29675 for (var i = pts.length - 1; pts.length > 3 && i >= 0; --i) {
29676
29677 if (collinear(at(pts, i - 1), at(pts, i), at(pts, i + 1), angle)) {
29678
29679 // Remove the middle point
29680 pts.splice(i % pts.length, 1);
29681 num++;
29682 }
29683 }
29684 return num;
29685}
29686
29687function splitPaths(cmds) {
29688

Callers 1

pathToPointsFunction · 0.85

Calls 2

collinearFunction · 0.85
atFunction · 0.85

Tested by

no test coverage detected