This is a general ease function that is pretty handy for animations.
This is basically a way of saying, given my start and end values, what is the
value when it's at x percent (progress) with easing.
Under the hood, it is simply an alias of [[mathf.lerpEase]] which is
essentially a regular lerp but it passes the progress value (0-1) through
an easing function first.
Using mathf.ease, you can pretty easily calculate eases for numberic values.
Say I wanted to animate a box.x position from 0 - 100.
Without specifying a easing function, you will just get linear interpolation.
You can ease out positions, opacity etc based on "progress".
Progress can be time, scroll position, mouse position etc but it needs to
be normalized to a value between 0 and 1.
See examples of this in [[RafTimer]] where there is a demo of easing an
element for a set duration.
For an exmaple where you may want to tie ease with window.scroll or another
input represented by a normalized value/ progress (a number between 0 and 1)i
see mathf-ease.html in the /examples folder where there is element and
progress level easing to smooth
interaction.
Also related is [[Interpolate]].
Parameters
start: number
The start of the range to lerp.
end: number
The target of the range to lerp.
progress: number
A value between 0-1 representing the progress of the
lerp.
An alias of [[mathf.lerpEase]]
This is a general ease function that is pretty handy for animations.
This is basically a way of saying, given my start and end values, what is the value when it's at x percent (progress) with easing.
Under the hood, it is simply an alias of [[mathf.lerpEase]] which is essentially a regular lerp but it passes the progress value (0-1) through an easing function first.
Using mathf.ease, you can pretty easily calculate eases for numberic values.
Say I wanted to animate a box.x position from 0 - 100. Without specifying a easing function, you will just get linear interpolation.
Now lets try this with easing. You can see the returned values between 0 and 1 are different than a linear ease.
You can also combine with CubicBezier.makeEasingFunction or a catmull-roll.
How can I use this with animations?
You can ease out positions, opacity etc based on "progress". Progress can be time, scroll position, mouse position etc but it needs to be normalized to a value between 0 and 1.
See examples of this in [[RafTimer]] where there is a demo of easing an element for a set duration.
For an exmaple where you may want to tie ease with window.scroll or another input represented by a normalized value/ progress (a number between 0 and 1)i see mathf-ease.html in the /examples folder where there is element and progress level easing to smooth interaction.
Also related is [[Interpolate]].