mirror of
https://github.com/Makuna/NeoPixelBus.git
synced 2025-08-07 04:44:26 +02:00
Updated NeoPixelAnimator object (markdown)
@@ -1,5 +1,3 @@
|
||||
(under construction)
|
||||
|
||||
[NeoPixelAnimator object API](https://github.com/Makuna/NeoPixelBus/wiki/NeoPixelAnimator-object-API)
|
||||
|
||||
The NeoPixelAnimator manages the timing and lifetime for animations. It does not provide specific animations effects, as these are varied and specific to the application and left for you to create.
|
||||
@@ -12,7 +10,7 @@ For each animation you start, you will need to provide a function that will "app
|
||||
|
||||
To "apply" an animation takes several small pieces of code:
|
||||
|
||||
First, apply a curve to the AnimationParam.progress. The progress is a linear time value from 0.0f at the start of the animation to 1.0f at the end of the animation. The term "linear time" means that progress will map 1:1 to real time. But sometimes what you want is to simulate "mass" so that the animation feels like it starts slow but ends up faster. To do this, we just modify the given progress by using a curve equation that will "ease-in" or "ease-out". More on this latter.
|
||||
First, apply an optional curve to the AnimationParam.progress. This progress is a linear time value from 0.0f at the start of the animation to 1.0f at the end of the animation. The term "linear time" means that progress will map 1:1 to real time. But sometimes what you want is to simulate "mass" so that the animation feels like it starts slow but ends up faster. To do this, we just modify the given progress by using a curve equation that will "ease-in", "ease-out", or "ease in and out". More on this subject below.
|
||||
|
||||
Second, use the progress to effect the animation. The animation maybe just moving one lit pixel along a strip of pixels, or it maybe blending from one color to another.
|
||||
|
||||
@@ -25,13 +23,34 @@ To keep the NeoPixelAnimator running, you will need to call UpdateAnimations() i
|
||||
```
|
||||
|
||||
## Easing equations
|
||||
Most easing equations are grouped by three basic types.
|
||||
Ease In - Calculates a progress that is accelerating from a complete stop with no velocity.
|
||||
Ease Out - Calculates a progress that is decelerating toward a complete stop.
|
||||
Ease In/Out - Calculates a progress that is accelerating from a complete stop until the halfway point at which time it then decelerates toward a complete stop at the end.
|
||||
|
||||
One very simple equation to use for "ease-in" is the POW (or POWER) function. This raises a value to the power given.
|
||||
```
|
||||
uint8_t progress = POW(param.progress, 2.0f);
|
||||
```
|
||||
The effects due to this equations are that calculated progress will change very little at the beginning and then quickly catch up.
|
||||
Increasing the exponent parameter to the equation will make the effect more dramatic, and decreasing it will make it more linear.
|
||||
In the NeoEase class you will find a whole series of these functions; each with a different curve. A great place to see them visualized is at [Gizam.com Easing](http://www.gizma.com/easing).
|
||||
|
||||
For more advanced equations with visualizations, see [Gizam.com Easing](http://www.gizma.com/easing/#expo2).
|
||||
This first set are basically similar curve shapes but with more pronounced acceleration as you progress down the list.
|
||||
QuadraticIn
|
||||
QuadraticOut
|
||||
QuadraticInOut
|
||||
CubicIn
|
||||
CubicOut
|
||||
CubicInOut
|
||||
QuarticIn
|
||||
QuarticOut
|
||||
QuarticInOut
|
||||
QuinticIn
|
||||
QuinticOut
|
||||
QuinticInOut
|
||||
SinusoidalIn
|
||||
SinusoidalOut
|
||||
SinusoidalInOut
|
||||
ExponentialIn
|
||||
ExponentialOut
|
||||
ExponentialInOut
|
||||
|
||||
The following equations have a more circular shape to the curve. They have a much more dramatic ease at the end.
|
||||
CircularIn
|
||||
CircularOut
|
||||
CircularInOut
|
||||
|
Reference in New Issue
Block a user