Skip to content

🎥 Make videos programmatically with React

timings

Jonny Burger702aac743d73
diff --git a/packages/skills/skills/spring-physics/SKILL.md b/packages/skills/skills/spring-physics/SKILL.md
deleted file mode 100644
index 9b3be6c145..0000000000
--- a/packages/skills/skills/spring-physics/SKILL.md
+++ /dev/null
@@ -1,133 +0,0 @@
----
-name: spring-physics
-description: Spring physics animation patterns for Remotion. Use when creating bouncy animations, organic motion, elastic effects, or overshoot animations.
-metadata:
- impact: HIGH
- tags: spring, physics, bounce, easing, organic
----
-
-## Prefer spring() Over interpolate()
-
-Use spring() for natural motion, interpolate() only for linear progress.
-
-**Incorrect (mechanical motion):**
-
-```tsx
-const scale = interpolate(frame, [0, 30], [0, 1], {extrapolateRight: 'clamp'});
-```
-
-**Correct (organic spring motion):**
-
-```tsx
-const scale = spring({
- frame,
- fps,
- config: {damping: 12, stiffness: 100},
- durationInFrames: 30,
-});
-```
-
-## Spring Config Parameters
-
-```tsx
-spring({
- frame,
- fps,
- config: {
- damping: 10, // Higher = less bounce (10-200)
- stiffness: 100, // Higher = faster snap (50-200)
- mass: 1, // Higher = more inertia (0.5-3)
- },
-});
-```
-
-## Common Spring Presets
-
-```tsx
-// Snappy, minimal bounce (UI elements)
-const snappy = {damping: 20, stiffness: 200};
-
-// Bouncy entrance (playful animations)
-const bouncy = {damping: 8, stiffness: 100};
-
-// Smooth, no bounce (subtle reveals)
-const smooth = {damping: 200, stiffness: 100};
-
-// Heavy, slow (large objects)
-const heavy = {damping: 15, stiffness: 80, mass: 2};
-```
-
-## Delayed Spring Start
-
-Offset the frame for delayed spring animations:
-
-**Incorrect (spring starts immediately):**
-
-```tsx
-const entrance = spring({frame, fps, config: {damping: 12}});
-```
-
-**Correct (spring starts after delay):**
-
-```tsx
-const ENTRANCE_DELAY = 20;
-const entrance = spring({
- frame: frame - ENTRANCE_DELAY,
- fps,
- config: {damping: 12, stiffness: 100},
-});
-// Returns 0 until frame 20, then animates to 1
-```
-
-## Spring for Scale with Overshoot
-
-For bouncy scale animations that overshoot:
-
-```tsx
-const bounce = spring({
- frame,
- fps,
- config: {damping: 8, stiffness: 150},
-});
-// Will overshoot past 1.0 before settling
-
-<div style={{transform: `scale(${bounce})`}}>{content}</div>;
-```
-
-## Combining Spring with Interpolate
-
-Map spring output (0-1) to custom ranges:
-
-```tsx
-const springProgress = spring({ frame, fps, config: { damping: 15 } });
-
-// Map to rotation
-const rotation = interpolate(springProgress, [0, 1], [0, 360]);
-
-// Map to position
-const translateY = interpolate(springProgress, [0, 1], [50, 0]);
-
-<div style={{ transform: `translateY(${translateY}px) rotate(${rotation}deg)` }}>
-```
-
-## Chained Springs for Sequential Motion
-
-```tsx
-const PHASE_1_END = 30;
-const PHASE_2_START = 25; // Slight overlap
-
-const phase1 = spring({frame, fps, config: {damping: 15}});
-const phase2 = spring({
- frame: frame - PHASE_2_START,
- fps,
- config: {damping: 12},
-});
-
-// phase1 controls entrance, phase2 controls secondary motion
-```
-
-## Complete Examples
-
-For full working code examples, see:
-
-- [Animated Shapes Example](../example-animated-shapes/SKILL.md) - Bouncing and rotating shapes with spring
diff --git a/packages/skills/skills/timing/SKILL.md b/packages/skills/skills/timing/SKILL.md
new file mode 100644
index 0000000000..e4b68312e3
--- /dev/null
+++ b/packages/skills/skills/timing/SKILL.md
@@ -0,0 +1,195 @@
+---
+name: timing
+description: Interpolation curves in Remotion - linear, easing, spring animations
+metadata:
+ impact: HIGH
+ tags: spring, bounce, easing, interpolation
+---
+
+A simple linear interpolation is done using the `interpolate` function.
+
+```ts title="Going from 0 to 1 over 100 frames"
+import { interpolate } from 'remotion';
+
+const opacity = interpolate(frame, [0, 100], [0, 1]);
+```
+
+By default, the values are not clamped, so the value can go outside the range [0, 1].
+Here is how they can be clamped:
+
+```ts title="Going from 0 to 1 over 100 frames with extrapolation"
+const opacity = interpolate(frame, [0, 100], [0, 1], {
+ extrapolateRight: 'clamp',
+ extrapolateLeft: 'clamp'
+});
+```
+
+## Spring animations
+
+Spring animations have a more natural motion.
+They go from 0 to 1 over time.
+
+```ts title="Spring animation from 0 to 1 over 100 frames"
+import { spring, useCurrentFrame, useVideoConfig } from 'remotion';
+
+const frame = useCurrentFrame();
+const { fps } = useVideoConfig();
+
+const scale = spring({
+ frame,
+ fps,
+});
+```
+
+### Physical properties
+
+The default configuration is: `mass: 1, damping: 10, stiffness: 100`.
+This leads to the animation having a bit of bounce before it settles.
+
+The config can be overwritten like this:
+
+```ts
+const scale = spring({
+ frame,
+ fps,
+ config: {damping: 200},
+});
+```
+
+The recommended configuration for a natural motion without a bounce is: `{ damping: 200 }`.
+
+Here are some common configurations:
+
+```tsx
+const smooth = {damping: 200}; // Smooth, no bounce (subtle reveals)
+const snappy = {damping: 20, stiffness: 200}; // Snappy, minimal bounce (UI elements)
+const bouncy = {damping: 8}; // Bouncy entrance (playful animations)
+const heavy = {damping: 15, stiffness: 80, mass: 2}; // Heavy, slow, small bounce
+```
+
+### Delay
+
+The animation starts immediately by default.
+Use the `delay` parameter to delay the animation by a number of frames.
+
+```tsx
+const entrance = spring({
+ frame: frame - ENTRANCE_DELAY,
+ fps,
+ delay: 20
+});
+```
+
+### Duration
+
+A `spring()` has a natural duration based on the physical properties.
+To stretch the animation to a specific duration, use the `durationInFrames` parameter.
+
+```tsx
+const spring = spring({
+ frame,
+ fps,
+ durationInFrames: 40
+});
+```
+
+### Combining spring() with interpolate()
+
+Map spring output (0-1) to custom ranges:
+
+```tsx
+const springProgress = spring({
+ frame,
+ fps,
+});
+
+// Map to rotation
+const rotation = interpolate(springProgress, [0, 1], [0, 360]);
+
+<div style={{ rotation: rotation + 'deg }} />
+```
+
+### Adding springs
+
+Springs return just numbers, so math can be performed:
+
+```tsx
+const frame = useCurrentFrame();
+const {fps, durationInFrames} = useVideoConfig();
+
+const inAnimation = spring({
+ frame,
+ fps
+});
+const outAnimation = spring({
+ frame,
+ fps,
+ durationInFrames: 30,
+ delay: durationInFrames - 30
+});
+
+const scale = inAnimation - outAnimation;
+```
+
+## Easing
+
+Easing can be added to the `interpolate` function:
+
+```ts
+import {interpolate, Easing} from 'remotion';
+
+const value1 = interpolate(
+ frame,
+ [0, 100],
+ [0, 1],
+ {
+ easing: Easing.inOut(Easing.quad),
+ extrapolateLeft: 'clamp',
+ extrapolateRight: 'clamp',
+ }
+);
+```
+
+The default easing is `Easing.linear`.
+There are various other convexities:
+
+- `Easing.in` for starting slow and accelerating
+- `Easing.out` for starting fast and slowing down
+- `Easing.inOut`
+
+and curves (sorted from most linear to most curved):
+
+- `Easing.quad`
+- `Easing.sin`
+- `Easing.exp`
+- `Easing.circle`
+
+Convexities and curves need be combined for an easing function:
+
+```ts
+const value1 = interpolate(
+ frame,
+ [0, 100],
+ [0, 1],
+ {
+ easing: Easing.inOut(Easing.quad),
+ extrapolateLeft: 'clamp',
+ extrapolateRight: 'clamp',
+ }
+);
+```
+
+Cubic bezier curves are also supported:
+
+```ts
+const value1 = interpolate(
+ frame,
+ [0, 100],
+ [0, 1],
+ {
+ easing: Easing.bezier(0.8, 0.22, 0.96, 0.65),
+ extrapolateLeft: 'clamp',
+ extrapolateRight: 'clamp',
+ }
+);
+```
\ No newline at end of file