Tweening is the process of transitioning something from an initial
state to a final state over a pre-determined period of time. In other
words, tweening is a way to create animation. The tween
procedure can be used within any script like so:
(define x 0) (script ;; 0 to 100 in 60 ticks of the agenda. (tween 60 0 100 (lambda (y) (set! x y))))
1
] [#:ease smoothstep
] #:interpolate lerp
]Transition a value from start to end over duration, sending each succesive value to proc. step controls the amount of time between each update of the animation.
To control how the animation goes from the initial to final state, an
“easing” procedure may be specified. By default, the
smoothstep
easing is used, which is a more pleasing default
than a simplistic linear function. See Easings for a complete list
of available easing procedures.
The interpolate procedure computes the values in between start and end. By default, linear interpolation (“lerp” for short) is used.