Tasmota/lib/libesp32/berry_animation/anim_examples/compiled/palette_showcase.be

155 lines
5.2 KiB
Plaintext

# Generated Berry code from Animation DSL
# Source: palette_showcase.anim
#
# This file was automatically generated by compile_all_examples.sh
# Do not edit manually - changes will be overwritten
import animation
# Palette Showcase - Demonstrates all palette features
# This example shows the full range of palette capabilities
#strip length 60
# Example 1: Fire palette with hex colors
# Auto-generated strip initialization (using Tasmota configuration)
var engine = animation.init_strip()
var fire_gradient_ = bytes("00000000" "20330000" "40660000" "60CC0000" "80FF3300" "A0FF6600" "C0FF9900" "E0FFCC00" "FFFFFF00")
# Example 2: Ocean palette with named colors
var ocean_depths_ = bytes("00000000" "40000080" "800000FF" "C000FFFF" "FFFFFFFF")
# Example 3: Aurora palette (from the original example)
var aurora_borealis_ = bytes("00000022" "40004400" "8000AA44" "C044AA88" "FF88FFAA")
# Example 4: Sunset palette mixing hex and named colors
var sunset_sky_ = bytes("00191970" "40800080" "80FF69B4" "C0FFA500" "FFFFFF00")
# Create animations using each palette
var fire_effect_ = animation.rich_palette_animation(engine)
fire_effect_.palette = fire_gradient_
fire_effect_.cycle_period = 3000
var ocean_waves_ = animation.rich_palette_animation(engine)
ocean_waves_.palette = ocean_depths_
ocean_waves_.cycle_period = 8000
ocean_waves_.transition_type = animation.SINE
ocean_waves_.brightness = 200
var aurora_lights_ = animation.rich_palette_animation(engine)
aurora_lights_.palette = aurora_borealis_
aurora_lights_.cycle_period = 12000
aurora_lights_.transition_type = animation.SINE
aurora_lights_.brightness = 180
var sunset_glow_ = animation.rich_palette_animation(engine)
sunset_glow_.palette = sunset_sky_
sunset_glow_.cycle_period = 6000
sunset_glow_.transition_type = animation.SINE
sunset_glow_.brightness = 220
# Sequence to showcase all palettes
var palette_showcase_ = (def (engine)
var steps = []
# Fire effect
steps.push(animation.create_play_step(animation.global('fire_effect_'), 8000))
steps.push(animation.create_wait_step(1000))
# Ocean waves
steps.push(animation.create_play_step(animation.global('ocean_waves_'), 8000))
steps.push(animation.create_wait_step(1000))
# Aurora borealis
steps.push(animation.create_play_step(animation.global('aurora_lights_'), 8000))
steps.push(animation.create_wait_step(1000))
# Sunset
steps.push(animation.create_play_step(animation.global('sunset_glow_'), 8000))
steps.push(animation.create_wait_step(1000))
# Quick cycle through all
for repeat_i : 0..3-1
steps.push(animation.create_play_step(animation.global('fire_effect_'), 2000))
steps.push(animation.create_play_step(animation.global('ocean_waves_'), 2000))
steps.push(animation.create_play_step(animation.global('aurora_lights_'), 2000))
steps.push(animation.create_play_step(animation.global('sunset_glow_'), 2000))
end
var seq_manager = animation.SequenceManager(engine)
seq_manager.start_sequence(steps)
return seq_manager
end)(engine)
engine.add_sequence_manager(palette_showcase_)
engine.start()
#- Original DSL source:
# Palette Showcase - Demonstrates all palette features
# This example shows the full range of palette capabilities
#strip length 60
# Example 1: Fire palette with hex colors
palette fire_gradient = [
(0, 0x000000), # Black (no fire)
(32, 0x330000), # Very dark red
(64, 0x660000), # Dark red
(96, 0xCC0000), # Red
(128, 0xFF3300), # Red-orange
(160, 0xFF6600), # Orange
(192, 0xFF9900), # Light orange
(224, 0xFFCC00), # Yellow-orange
(255, 0xFFFF00) # Bright yellow
]
# Example 2: Ocean palette with named colors
palette ocean_depths = [
(0, black), # Deep ocean
(64, navy), # Deep blue
(128, blue), # Ocean blue
(192, cyan), # Shallow water
(255, white) # Foam/waves
]
# Example 3: Aurora palette (from the original example)
palette aurora_borealis = [
(0, 0x000022), # Dark night sky
(64, 0x004400), # Dark green
(128, 0x00AA44), # Aurora green
(192, 0x44AA88), # Light green
(255, 0x88FFAA) # Bright aurora
]
# Example 4: Sunset palette mixing hex and named colors
palette sunset_sky = [
(0, 0x191970), # Midnight blue
(64, purple), # Purple twilight
(128, 0xFF69B4), # Hot pink
(192, orange), # Sunset orange
(255, yellow) # Sun
]
# Create animations using each palette
animation fire_effect = rich_palette_animation(palette=fire_gradient, cycle_period=3s)
animation ocean_waves = rich_palette_animation(palette=ocean_depths, cycle_period=8s, transition_type=SINE, brightness=200)
animation aurora_lights = rich_palette_animation(palette=aurora_borealis, cycle_period=12s, transition_type=SINE, brightness=180)
animation sunset_glow = rich_palette_animation(palette=sunset_sky, cycle_period=6s, transition_type=SINE, brightness=220)
# Sequence to showcase all palettes
sequence palette_showcase {
# Fire effect
play fire_effect for 8s
wait 1s
# Ocean waves
play ocean_waves for 8s
wait 1s
# Aurora borealis
play aurora_lights for 8s
wait 1s
# Sunset
play sunset_glow for 8s
wait 1s
# Quick cycle through all
repeat 3 times:
play fire_effect for 2s
play ocean_waves for 2s
play aurora_lights for 2s
play sunset_glow for 2s
}
run palette_showcase
-#