Lerp per frame versus damp
No canvas: pure numbers, so you can read them.
Move a value from A to B over a set time along a curve that starts slow, ends slow or overshoots. You write the tween by hand, then compare it with damp and a spring when the target keeps changing.
Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.
Ready for more? This phase has 6 hands-on exercises with automatic checks.
Practice questions
Write the code in the editor, run it, then open the model answer to compare.
Write createTween(from, to, duration, ease) with a tick(delta) that returns the value, and show that tick(0.5) for from = 0, to = 1, duration = 1 with easeOutCubic is 0.875.
A sphere should follow a mouse x position with damp. Write the frame code with lambda 8.
Explain it without notes
Why must a tween clamp elapsed to the duration?
A slider moves the camera's target every frame. Would you use a tween or damp, and why?
Console
Nothing logged yet.Expected console output
fps lerp 0.1 per frame damp(lambda 6.3, delta)
30 0.958 0.998
60 0.998 0.998
144 1.000 0.998
damp is lerp(x, y, 1 - exp(-lambda * dt)): 0.0997 = 0.0997