Linear tweening
Linear tweening is a basic animation technique used in computer graphics and animation to create smooth transitions between two values over a specified duration. The term "tweening" comes from the word "inbetweening," which refers to the process of generating intermediate frames between two keyframes to create the illusion of motion.
### How Linear Tweening Works:
1. **Keyframes**: You start with two keyframes (initial and final states) representing the start and end points of the animation. Each keyframe has a specific value (such as position, color, scale, etc.).
2. **Interpolation**: Linear tweening calculates intermediate values between the keyframes based on a linear interpolation formula. For a value that transitions from `startValue` to `endValue` over a period of time from `t=0` to `t=1`, the formula for linear interpolation is:
\[
value(t) = startValue + (endValue - startValue) \times t
\]
where `t` is a normalized value representing the progress of the animation (0 corresponds to the start of the transition, and 1 corresponds to the end).
3. **Frame Rate**: In practice, the interpolation is computed over time, and the value of `t` is incremented based on the elapsed time in relation to the duration of the animation.
### Example:
Suppose you want to animate an object moving from an initial position of 0 to a final position of 100 over 2 seconds:
- **Start keyframe**: Position = 0
- **End keyframe**: Position = 100
- **Duration**: 2 seconds
During the animation, you would calculate the position at various time intervals:
- At `0s` (t = 0): Position = \(0 + (100 - 0) \times 0 = 0\)
- At `1s` (t = 0.5): Position = \(0 + (100 - 0) \times 0.5 = 50\)
- At `2s` (t = 1): Position = \(0 + (100 - 0) \times 1 = 100\)
### Applications:
Linear tweening is commonly used in:
- 2D and 3D animations
- Game development
- UI/UX animations
- Motion graphics
While linear tweening is straightforward and effective for many cases, it can feel mechanical and less dynamic compared to more advanced easing functions, which offer different rates of acceleration and deceleration throughout the animation.


