The whole "video": one function of time
// drawFrame(ctx, t): same t in, same pixels out.
// A recorder steps t by 1/60 and saves each frame.
const ease = (x) => 1 - Math.pow(1 - Math.min(Math.max(x, 0), 1), 3)
const span = (t, a, b) => ease((t - a) / (b - a))
function drawFrame(ctx, t) {
const W = 1280, H = 720
ctx.fillStyle = '#fff7ed'
ctx.fillRect(0, 0, W, H)
const out = span(t, 5.2, 5.9)
ctx.save()
ctx.translate(0, -out * H)
const r = span(t, 0, 0.8) * 230
ctx.fillStyle = '#f97316'
ctx.beginPath()
ctx.arc(W - 250, H / 2, r, 0, Math.PI * 2)
ctx.fill()
const words = ['CODE', 'IS THE', 'CAMERA']
ctx.font = '900 104px Inter, sans-serif'
words.forEach((word, i) => {
const k = span(t, 0.6 + i * 0.45, 1.1 + i * 0.45)
ctx.globalAlpha = k
ctx.fillStyle = i === 2 ? '#f97316' : '#000'
ctx.fillText(word, 90 - (1 - k) * 120, 230 + i * 120)
})
ctx.globalAlpha = 1
const bars = [0.35, 0.6, 0.45, 0.85, 0.7, 1]
bars.forEach((v, i) => {
const h = v * 300 * span(t, 1.9 + i * 0.12, 2.7 + i * 0.12)
if (h < 1) return
ctx.fillStyle = i === bars.length - 1 ? '#000' : '#fff'
ctx.fillRect(W - 420 + i * 55, H / 2 + 150 - h, 40, h)
ctx.strokeStyle = '#000'
ctx.lineWidth = 4
ctx.strokeRect(W - 420 + i * 55, H / 2 + 150 - h, 40, h)
})
const line = span(t, 3.1, 4.1)
ctx.fillStyle = '#000'
ctx.fillRect(90, 600, 560 * line, 10)
ctx.font = '700 30px Inter, sans-serif'
ctx.globalAlpha = span(t, 3.6, 4.2)
ctx.fillText('360 frames. 0 video models.', 90, 660)
ctx.restore()
}