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

Function addMotionPathPointInScript

packages/parsers/src/gsapParser.ts:2969–2990  ·  view source on GitHub ↗
(
  script: string,
  animationId: string,
  index: number,
  point: { x: number; y: number },
)

Source from the content-addressed store, hash-verified

2967 * No-op for missing animation/arc, out-of-range index, or cubic paths.
2968 */
2969export function addMotionPathPointInScript(
2970 script: string,
2971 animationId: string,
2972 index: number,
2973 point: { x: number; y: number },
2974): string {
2975 const loc = locateAnimation(script, animationId);
2976 if (!loc) return script;
2977 const anim = loc.target.animation;
2978 if (!anim.arcPath?.enabled || hasCubicSegments(anim.arcPath.segments)) return script;
2979
2980 const waypoints = extractArcWaypoints(anim);
2981 // Insert strictly between two anchors: index 1..length-1.
2982 if (index < 1 || index > waypoints.length - 1) return script;
2983
2984 const segments = [...anim.arcPath.segments];
2985 waypoints.splice(index, 0, { x: point.x, y: point.y });
2986 const splitCurviness = segments[index - 1]?.curviness ?? 1;
2987 segments.splice(index - 1, 0, { curviness: splitCurviness });
2988
2989 return writeMotionPathValue(loc, waypoints, segments, anim.arcPath.autoRotate);
2990}
2991
2992/**
2993 * Remove the waypoint at `index`. Refuses to drop below two anchors (a path

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