You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Beyond `solid`, the DSL includes many ready-to-use animation types. Each creates a different visual effect. Let's try `twinkle_animation`, which creates a twinkling stars effect.
119
116
@@ -128,7 +125,7 @@ With no parameters, animations use sensible defaults. The twinkle effect will us
One of the most powerful features is **layering** - running multiple animations simultaneously. Each animation has a `priority` that determines its rendering order. Think of it like layers in an image editor: lower numbers are "on top" and can obscure higher numbers.
162
159
@@ -198,7 +195,7 @@ The key concept is the **color provider** - instead of a fixed color value, you
The `rich_palette_animation` is a complete animation that handles both the color transitions and rendering. It's the easiest way to get smooth rainbow effects.
272
269
@@ -284,7 +281,7 @@ With no parameters, it uses sensible defaults. The `transition_type=SINE` create
Here's where things get interesting: you can make **any parameter dynamic** by using a value provider instead of a fixed number. This example makes the gradient "breathe" by oscillating its spatial period.
380
377
@@ -407,7 +404,7 @@ The `sine_osc` function creates a **value provider** - a number that changes smo
Sometimes the built-in oscillators aren't enough - you need custom logic like random values, sensor readings, or complex calculations. The DSL lets you embed native Berry code and use it in your animations.
466
463
@@ -526,7 +523,7 @@ A beacon has five key properties:
Now for the classic effect: a beacon that moves back and forth across the strip. We use `cosine_osc` on the `pos` parameter to create smooth scanning motion.
599
596
@@ -615,7 +612,7 @@ The cosine oscillator creates smooth acceleration and deceleration at the ends,
Instead of layering animations with priority, you can use one animation as an **opacity mask** for another. This creates a "window" effect where the mask controls what's visible.
670
667
@@ -725,7 +722,7 @@ Sequences are essential when you need things to happen in order: play animation
This example combines both directions: first the shutter expands from center (in-out), then contracts back to center (out-in). The sequence cycles through all palette colors in each direction before switching.
867
864
@@ -943,7 +940,7 @@ Crenels create repeating square wave patterns - alternating blocks of two colors
Instead of showing all pulses (`nb_pulse = -1`), you can animate the number of visible pulses using a value provider. The `triangle` oscillator smoothly varies `nb_pulse` from 0 (no pulses) to the maximum that fits on the strip.
Instead of a fixed `pulse_size`, you can use a value provider to animate the pulse width over time. Here, a `triangle` oscillator smoothly varies the pulse size between 0 and 4 pixels over 2 seconds, creating a breathing effect on the crenel pattern:
The `color` parameter also accepts a color provider instead of a static color. This example uses `rich_palette` to cycle through rainbow colors over 5 seconds, making the crenel pulses continuously change color while the blue background remains fixed:
Instead of using a crenel directly as a visible animation, you can use it as an **opacity mask** for another animation. This creates a "window" effect where the crenel pattern controls what's visible.
1049
1046
@@ -1097,7 +1094,7 @@ Think of templates like functions in programming: define once, use many times wi
The `template animation` keyword creates a new animation type that can be instantiated just like built-in animations (`solid`, `beacon_animation`, etc.). Once defined, you use it by calling `animation my_anim = template_name(param1=value1, ...)` - exactly like native animations.
1103
1100
@@ -1159,7 +1156,7 @@ run eye
1159
1156
1160
1157
### 8.2 Template with Palette Parameter
1161
1158
1162
-

1159
+
<imgsrc="../../_media/berry_animation/chap_8_20.png"alt="Template Color Cycle">
1163
1160
1164
1161
Templates can accept complex types like palettes. Here we create a reusable color cycling animation where the user provides their own palette and cycle period:
Templates support `bool` parameters that can be used with `if` statements inside sequences. This allows users to enable or disable parts of the animation at instantiation time. Here we create a bidirectional shutter that can optionally run in-out, out-in, or both directions.
0 commit comments