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

Function pathBody

packages/cli/src/commands/motionShotLayout.ts:202–220  ·  view source on GitHub ↗
(elements: OnionElement[], fit: boolean, W: number, H: number)

Source from the content-addressed store, hash-verified

200}
201
202function pathBody(elements: OnionElement[], fit: boolean, W: number, H: number): string {
203 const all = elements.flatMap((e) => e.samples.flatMap((s) => [...s.q, s.c]));
204 const { k, cx, cy } = fit ? fitTransform(all, W, H) : { k: 1, cx: W / 2, cy: H / 2 };
205 const M = (p: Pt): Pt => ({ x: (p.x - cx) * k + W / 2, y: (p.y - cy) * k + H / 2 });
206 let out = "";
207 for (const el of elements) {
208 const last = el.samples.length - 1;
209 const fOf = (i: number) => (last <= 0 ? 0 : i / last);
210 el.samples.forEach((s, i) => (out += ghost(s.q.map(M), M(s.c), s.color, s.opacity, fOf(i))));
211 for (let i = 0; i < last; i++)
212 out += line(M(el.samples[i]!.c), M(el.samples[i + 1]!.c), timeColor(fOf(i)), 3.5, 0.85);
213 el.samples.forEach((s, i) => {
214 const c = M(s.c);
215 out += circle(c, 4, timeColor(fOf(i)));
216 out += text({ x: c.x + 10, y: c.y + (i % 2 === 0 ? -10 : 18) }, `${s.t}s`, timeColor(fOf(i)));
217 });
218 }
219 return out;
220}
221
222function stripBody(samples: OnionSample[], W: number, H: number): string {
223 if (samples.length === 0) return "";

Callers 1

buildOnionSvgFunction · 0.85

Calls 8

fitTransformFunction · 0.85
ghostFunction · 0.85
MFunction · 0.85
fOfFunction · 0.85
lineFunction · 0.85
timeColorFunction · 0.85
circleFunction · 0.85
textFunction · 0.85

Tested by

no test coverage detected