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

Function pointAtLength

libraries/p5.js:29797–29830  ·  view source on GitHub ↗
(path, length, istotal)

Source from the content-addressed store, hash-verified

29795}
29796
29797function pointAtLength(path, length, istotal) {
29798 path = path2curve(path);
29799 var x, y, p, l, sp = '', subpaths = {}, point, len = 0;
29800 for (var i = 0, ii = path.length; i < ii; i++) {
29801 p = path[i];
29802 if (p[0] === 'M') {
29803 x = +p[1];
29804 y = +p[2];
29805 } else {
29806 l = getPointAtSegmentLength(x, y, p[1], p[2], p[3], p[4], p[5], p[6]);
29807 if (len + l > length) {
29808 if (!istotal) {
29809 point = getPointAtSegmentLength(x, y, p[1], p[2], p[3], p[4], p[5],
29810 p[6], length - len);
29811 return { x: point.x, y: point.y, alpha: point.alpha };
29812 }
29813 }
29814 len += l;
29815 x = +p[5];
29816 y = +p[6];
29817 }
29818 sp += p.shift() + p;
29819 }
29820 subpaths.end = sp;
29821
29822 point = istotal ? len : findDotsAtSegment
29823 (x, y, p[0], p[1], p[2], p[3], p[4], p[5], 1);
29824
29825 if (point.alpha) {
29826 point = { x: point.x, y: point.y, alpha: point.alpha };
29827 }
29828
29829 return point;
29830}
29831
29832function pathToAbsolute(pathArray) {
29833

Callers 1

pathToPointsFunction · 0.85

Calls 3

path2curveFunction · 0.85
getPointAtSegmentLengthFunction · 0.85
findDotsAtSegmentFunction · 0.85

Tested by

no test coverage detected