( dur: number, n: number, from: number | null, to: number | null, )
| 83 | |
| 84 | /** N equal-time sample points across [from?, to?] within [0, dur]. */ |
| 85 | export 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 |
no test coverage detected