MCPcopy Index your code
hub / github.com/processing/p5.js / simplify

Function simplify

src/type/p5.Font.js:1136–1146  ·  view source on GitHub ↗
(pts, angle)

Source from the content-addressed store, hash-verified

1134 };
1135
1136 const simplify = (pts, angle) => {
1137 angle = angle || 0;
1138 let num = 0;
1139 for (let i = pts.length - 1; pts.length > 3 && i >= 0; --i) {
1140 if (collinear(at(pts, i - 1), at(pts, i), at(pts, i + 1), angle)) {
1141 pts.splice(i % pts.length, 1); // Remove middle point
1142 num++;
1143 }
1144 }
1145 return num;
1146 };
1147
1148 const collinear = (a, b, c, thresholdAngle) => {
1149 if (!thresholdAngle) {

Callers 1

pathToPointsFunction · 0.85

Calls 2

collinearFunction · 0.85
atFunction · 0.70

Tested by

no test coverage detected