Files
2025-09-03 22:10:31 +02:00

90 lines
2.6 KiB
Plaintext

# Generated Berry code from Animation DSL
# Source: palette_demo.anim
#
# This file was automatically generated by compile_all_examples.sh
# Do not edit manually - changes will be overwritten
import animation
# Palette Demo - Shows how to use custom palettes in DSL
# This demonstrates the new palette syntax
#strip length 30
# Define a fire palette
# Auto-generated strip initialization (using Tasmota configuration)
var engine = animation.init_strip()
var fire_colors_ = bytes("00000000" "40800000" "80FF0000" "C0FF8000" "FFFFFF00")
# Define an ocean palette
var ocean_colors_ = bytes(
"00000080" # Navy blue
"400000FF" # Blue
"8000FFFF" # Cyan
"C000FF80" # Spring green
"FF008000" # Green
)
# Create animations using the palettes
var fire_anim_ = animation.rich_palette_animation(engine)
fire_anim_.palette = fire_colors_
fire_anim_.cycle_period = 5000
var ocean_anim_ = animation.rich_palette_animation(engine)
ocean_anim_.palette = ocean_colors_
ocean_anim_.cycle_period = 8000
var forest_anim_ = animation.rich_palette_animation(engine)
forest_anim_.palette = animation.PALETTE_FOREST
forest_anim_.cycle_period = 8000
# Sequence to show both palettes
var palette_demo_ = animation.SequenceManager(engine)
.push_play_step(fire_anim_, 10000)
.push_wait_step(1000)
.push_play_step(ocean_anim_, 10000)
.push_wait_step(1000)
.push_repeat_subsequence(animation.SequenceManager(engine, 2)
.push_play_step(fire_anim_, 3000)
.push_play_step(ocean_anim_, 3000)
.push_play_step(forest_anim_, 3000)
)
engine.add(palette_demo_)
engine.run()
#- Original DSL source:
# Palette Demo - Shows how to use custom palettes in DSL
# This demonstrates the new palette syntax
#strip length 30
# Define a fire palette
palette fire_colors = [ (0, 0x000000), (64, 0x800000), (128, 0xFF0000), (192, 0xFF8000), (255, 0xFFFF00) ]
# Define an ocean palette
palette ocean_colors = [
(0, 0x000080) # Navy blue
(64, 0x0000FF), # Blue
(128, 0x00FFFF) # Cyan
(192, 0x00FF80), # Spring green
(255, 0x008000) # Green
]
# Create animations using the palettes
animation fire_anim = rich_palette_animation(palette=fire_colors, cycle_period=5s)
animation ocean_anim = rich_palette_animation(palette=ocean_colors, cycle_period=8s)
animation forest_anim = rich_palette_animation(palette=PALETTE_FOREST, cycle_period=8s)
# Sequence to show both palettes
sequence palette_demo {
play fire_anim for 10s
wait 1s
play ocean_anim for 10s
wait 1s
repeat 2 times {
play fire_anim for 3s
play ocean_anim for 3s
play forest_anim for 3s
}
}
run palette_demo
-#