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

Function sampleTimes

packages/cli/src/commands/motionShotLayout.ts:85–99  ·  view source on GitHub ↗
(
  dur: number,
  n: number,
  from: number | null,
  to: number | null,
)

Source from the content-addressed store, hash-verified

83
84/** N equal-time sample points across [from?, to?] within [0, dur]. */
85export function sampleTimes(
86 dur: number,
87 n: number,
88 from: number | null,
89 to: number | null,
90): number[] {
91 const t0 = from != null ? Math.max(0, Math.min(from, dur)) : 0;
92 const t1 = to != null ? Math.max(0, Math.min(to, dur)) : dur;
93 const count = Math.max(1, Math.floor(n));
94 if (count === 1) return [t0];
95 return Array.from({ length: count }, (_, i) => {
96 const t = t0 + (i / (count - 1)) * (t1 - t0);
97 return Math.round(t * 1000) / 1000;
98 });
99}
100
101/** Opacity ramp for the rendered ("ghost") onion-skin: older frames fainter,
102 * the newest frame solid, so the composite of real painted frames reads as a

Callers 2

captureMotionPathShotFunction · 0.85

Calls 1

fromMethod · 0.80

Tested by

no test coverage detected