MCPcopy
hub / github.com/greensock/GSAP / rawPathToString

Function rawPathToString

esm/utils/paths.js:1468–1496  ·  view source on GitHub ↗
(rawPath)

Source from the content-addressed store, hash-verified

1466*/
1467
1468export function rawPathToString(rawPath) {
1469 if (_isNumber(rawPath[0])) {
1470 //in case a segment is passed in instead
1471 rawPath = [rawPath];
1472 }
1473
1474 var result = "",
1475 l = rawPath.length,
1476 sl,
1477 s,
1478 i,
1479 segment;
1480
1481 for (s = 0; s < l; s++) {
1482 segment = rawPath[s];
1483 result += "M" + _round(segment[0]) + "," + _round(segment[1]) + " C";
1484 sl = segment.length;
1485
1486 for (i = 2; i < sl; i++) {
1487 result += _round(segment[i++]) + "," + _round(segment[i++]) + " " + _round(segment[i++]) + "," + _round(segment[i++]) + " " + _round(segment[i++]) + "," + _round(segment[i]) + " ";
1488 }
1489
1490 if (segment.closed) {
1491 result += "z";
1492 }
1493 }
1494
1495 return result;
1496}
1497/*
1498// takes a segment with coordinates [x, y, x, y, ...] and converts the control points into angles and lengths [x, y, angle, length, angle, length, x, y, angle, length, ...] so that it animates more cleanly and avoids odd breaks/kinks. For example, if you animate from 1 o'clock to 6 o'clock, it'd just go directly/linearly rather than around. So the length would be very short in the middle of the tween.
1499export function cpCoordsToAngles(segment, copy) {

Callers 5

_pathFilterFunction · 0.90
MorphSVGPlugin.jsFile · 0.90
CustomEase.jsFile · 0.90
PathEditor.jsFile · 0.90
convertToPathFunction · 0.70

Calls 2

_isNumberFunction · 0.70
_roundFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…