Berry animation fix foc (#23833)
This commit is contained in:
parent
580d4f4da1
commit
bff1e53c42
@ -13,7 +13,7 @@ Comments use the `#` character and extend to the end of the line:
|
||||
```berry
|
||||
# This is a full-line comment
|
||||
# strip length 30 # This is an inline comment (TEMPORARILY DISABLED)
|
||||
color red = #FF0000 # This is an inline comment
|
||||
color bordeaux = 0x6F2C4F # This is an inline comment
|
||||
```
|
||||
|
||||
Comments are preserved in the generated code and can appear anywhere in the DSL.
|
||||
@ -27,18 +27,18 @@ A DSL program consists of statements that can appear in any order:
|
||||
# strip length 60 # TEMPORARILY DISABLED
|
||||
|
||||
# Color definitions
|
||||
color red = #FF0000
|
||||
color blue = #0000FF
|
||||
color bordeaux = 0x6F2C4F
|
||||
color majorelle = 0x6050DC
|
||||
|
||||
# Animation definitions
|
||||
animation pulse_red = pulsating_animation(color=red, period=2s)
|
||||
animation pulse_bordeaux = pulsating_animation(color=bordeaux, period=2s)
|
||||
|
||||
# Property assignments
|
||||
pulse_red.priority = 10
|
||||
|
||||
# Sequences
|
||||
sequence demo {
|
||||
play pulse_red for 5s
|
||||
play pulse_bordeaux for 5s
|
||||
wait 1s
|
||||
}
|
||||
|
||||
@ -213,27 +213,27 @@ The `color` keyword defines static colors or color providers:
|
||||
|
||||
```berry
|
||||
# Static colors
|
||||
color red = 0xFF0000 # Static hex color
|
||||
color blue = 0x0000FF # Static hex color
|
||||
color bordeaux = 0x6F2C4F # Static hex color
|
||||
color majorelle = 0x6050DC # Static hex color
|
||||
color semi_red = 0x80FF0000 # Static color with alpha channel
|
||||
color my_white = white # Reference to predefined color
|
||||
|
||||
# Color providers for dynamic colors
|
||||
color rainbow_cycle = color_cycle(
|
||||
palette=[red, green, blue],
|
||||
palette=[red, green, blue]
|
||||
cycle_period=5s
|
||||
)
|
||||
color breathing_red = breathe_color(
|
||||
base_color=red,
|
||||
min_brightness=20,
|
||||
max_brightness=255,
|
||||
duration=3s,
|
||||
base_color=red
|
||||
min_brightness=5%
|
||||
max_brightness=100%
|
||||
duration=3s
|
||||
curve_factor=2
|
||||
)
|
||||
color pulsing_blue = pulsating_color(
|
||||
base_color=blue,
|
||||
min_brightness=50,
|
||||
max_brightness=200,
|
||||
base_color=blue
|
||||
min_brightness=20%
|
||||
max_brightness=80%
|
||||
duration=1s
|
||||
)
|
||||
```
|
||||
@ -249,8 +249,8 @@ Standard palettes use value positions from 0-255:
|
||||
```berry
|
||||
# Traditional syntax with commas
|
||||
palette fire_colors = [
|
||||
(0, 0x000000), # Position 0: Black
|
||||
(128, 0xFF0000), # Position 128: Red
|
||||
(0, 0x000000) # Position 0: Black
|
||||
(128, 0xFF0000) # Position 128: Red
|
||||
(255, 0xFFFF00) # Position 255: Yellow
|
||||
]
|
||||
|
||||
@ -276,8 +276,8 @@ Palettes can also use tick counts for timing-based transitions:
|
||||
|
||||
```berry
|
||||
palette timed_colors = [
|
||||
(10, 0xFF0000), # Red for 10 ticks
|
||||
(20, 0x00FF00), # Green for 20 ticks
|
||||
(10, 0xFF0000) # Red for 10 ticks
|
||||
(20, 0x00FF00) # Green for 20 ticks
|
||||
(15, 0x0000FF) # Blue for 15 ticks
|
||||
]
|
||||
```
|
||||
@ -298,14 +298,14 @@ The `animation` keyword defines instances of animation classes (subclasses of An
|
||||
animation red_solid = solid(color=red)
|
||||
|
||||
animation pulse_effect = pulsating_animation(
|
||||
color=blue,
|
||||
color=blue
|
||||
period=2s
|
||||
)
|
||||
|
||||
animation comet_trail = comet_animation(
|
||||
color=white,
|
||||
tail_length=10,
|
||||
speed=1500,
|
||||
color=white
|
||||
tail_length=10
|
||||
speed=1500
|
||||
direction=1
|
||||
)
|
||||
```
|
||||
|
||||
@ -13,13 +13,13 @@ Create a simple pulsing red light:
|
||||
|
||||
```berry
|
||||
# Define colors
|
||||
color red = #FF0000
|
||||
color bordeaux = 0x6F2C4F
|
||||
|
||||
# Create pulsing animation
|
||||
animation pulse_red = pulsating_animation(color=red, period=3s)
|
||||
animation pulse_bordeaux = pulsating_animation(color=bordeaux, period=3s)
|
||||
|
||||
# Run it
|
||||
run pulse_red
|
||||
run pulse_bordeaux
|
||||
```
|
||||
|
||||
## Step 2: Color Cycling
|
||||
@ -29,8 +29,8 @@ Create smooth color transitions:
|
||||
```berry
|
||||
# Use predefined rainbow palette
|
||||
animation rainbow_cycle = rich_palette(
|
||||
palette=PALETTE_RAINBOW,
|
||||
cycle_period=5s,
|
||||
palette=PALETTE_RAINBOW
|
||||
cycle_period=5s
|
||||
transition_type=1
|
||||
)
|
||||
|
||||
@ -44,17 +44,17 @@ Create your own color palettes:
|
||||
```berry
|
||||
# Define a sunset palette
|
||||
palette sunset = [
|
||||
(0, #191970), # Midnight blue
|
||||
(64, purple), # Purple
|
||||
(128, #FF69B4), # Hot pink
|
||||
(192, orange), # Orange
|
||||
(0, 0x191970) # Midnight blue
|
||||
(64, purple) # Purple
|
||||
(128, 0xFF69B4) # Hot pink
|
||||
(192, orange) # Orange
|
||||
(255, yellow) # Yellow
|
||||
]
|
||||
|
||||
# Create palette animation
|
||||
animation sunset_glow = rich_palette(
|
||||
palette=sunset,
|
||||
cycle_period=8s,
|
||||
palette=sunset
|
||||
cycle_period=8s
|
||||
transition_type=1
|
||||
)
|
||||
|
||||
@ -93,23 +93,23 @@ Add movement and variation to your animations:
|
||||
```berry
|
||||
# Breathing effect with smooth oscillation
|
||||
animation breathing = pulsating_animation(
|
||||
color=blue,
|
||||
min_brightness=50,
|
||||
max_brightness=255,
|
||||
color=blue
|
||||
min_brightness=20%
|
||||
max_brightness=100%
|
||||
period=4s
|
||||
)
|
||||
|
||||
# Moving comet effect
|
||||
animation comet = comet_animation(
|
||||
color=white,
|
||||
tail_length=8,
|
||||
color=white
|
||||
tail_length=8
|
||||
speed=2000
|
||||
)
|
||||
|
||||
# Sparkle effect
|
||||
animation sparkles = sparkle_animation(
|
||||
color=white,
|
||||
density=80,
|
||||
color=white
|
||||
density=80
|
||||
fade_speed=60
|
||||
)
|
||||
|
||||
@ -121,8 +121,8 @@ run breathing
|
||||
### Fire Effect
|
||||
```berry
|
||||
animation fire = rich_palette(
|
||||
palette=PALETTE_FIRE,
|
||||
cycle_period=2s,
|
||||
palette=PALETTE_FIRE
|
||||
cycle_period=2s
|
||||
transition_type=1
|
||||
)
|
||||
|
||||
@ -132,8 +132,8 @@ run fire
|
||||
### Ocean Waves
|
||||
```berry
|
||||
animation ocean = rich_palette(
|
||||
palette=PALETTE_OCEAN,
|
||||
cycle_period=6s,
|
||||
palette=PALETTE_OCEAN
|
||||
cycle_period=6s
|
||||
transition_type=1
|
||||
)
|
||||
|
||||
@ -179,7 +179,7 @@ animation.register_user_function("sparkle", my_sparkle)
|
||||
|
||||
```berry
|
||||
# Use in DSL - engine is automatically passed
|
||||
animation gold_sparkles = sparkle(#FFD700, 8, 500ms)
|
||||
animation gold_sparkles = sparkle(0xFFD700, 8, 500ms)
|
||||
run gold_sparkles
|
||||
```
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user