Skip to content

Animations

May Ben-Arie edited this page Feb 17, 2017 · 1 revision

Animations

All animations have 2 important methods:

  1. __init__(self, indexes):
    indexes - an array of indexes in the parent_array that the animation will run on. the order does matter to some animations.

  2. apply(self, parent_array):
    parent_array - the array of LEDs the animation should run on. the animation will effect only indexes that it got in the init method.
    The array size is actually 3 * num_of_leds, because each led has its own [r ,g ,b]. so if it has 2 leds, then the parent array will be [r1, b1 ,g1, r2, b2, g2].
    This method should be called every cycle.

Types

Animations are divided into two types:

1. Core Animations

These animations are the base animations of each led.
They are used to set the base color.
All core animations should get the max_brightness in their init method:
__init__(self, indexes, max_brightness)
max_brightness - a number between 0 to 1.

2. Add On Animations

These animations change the color of each LED based on the its core color. They must be applied after a core animation is applied.
You can apply as many add on animations as you want.

Categories

Peak Animations

Peak animations get one time notice for each peak.
They can be used to change color, speed or direction on each peak.

apply(self, parent_array, is_change)
is_change - a boolean, yes - if it's the first apply after the peak, and false otherwise.

After Peak Animations

After peak animations get the time past from the last peak in seconds, and an initial slow down speed.
They can be used to slow things down after a peak.
They will try to animate to a different state or speed after each peak. The total time for slow down is the initial slow down speed.
If in the process a new peak is coming, then they will start the slow down process again from the beginning.

__init__(self, indexes, speed):
speed - the time in seconds (float) of the slow down process

apply(self, time_since_last_peak, parent_array)
time_since_last_peak - in seconds (float)

Clone this wiki locally