MCPcopy Create free account
hub / github.com/heygen-com/hyperframes / removeMotionPathPointInScript

Function removeMotionPathPointInScript

packages/parsers/src/gsapParser.ts:2997–3016  ·  view source on GitHub ↗
(
  script: string,
  animationId: string,
  index: number,
)

Source from the content-addressed store, hash-verified

2995 * out-of-range index, cubic paths, or a 2-point path.
2996 */
2997export function removeMotionPathPointInScript(
2998 script: string,
2999 animationId: string,
3000 index: number,
3001): string {
3002 const loc = locateAnimation(script, animationId);
3003 if (!loc) return script;
3004 const anim = loc.target.animation;
3005 if (!anim.arcPath?.enabled || hasCubicSegments(anim.arcPath.segments)) return script;
3006
3007 const waypoints = extractArcWaypoints(anim);
3008 if (waypoints.length <= 2 || index < 0 || index >= waypoints.length) return script;
3009
3010 const segments = [...anim.arcPath.segments];
3011 waypoints.splice(index, 1);
3012 // Drop the segment on the side that still exists (last anchor → preceding segment).
3013 segments.splice(Math.min(index, segments.length - 1), 1);
3014
3015 return writeMotionPathValue(loc, waypoints, segments, anim.arcPath.autoRotate);
3016}
3017
3018/**
3019 * Author a fresh 2-anchor motionPath tween on a target element: a straight line

Callers 2

gsapParser.test.tsFile · 0.85

Calls 4

locateAnimationFunction · 0.85
hasCubicSegmentsFunction · 0.85
writeMotionPathValueFunction · 0.85
extractArcWaypointsFunction · 0.70

Tested by

no test coverage detected