144 lines
5.2 KiB
Plaintext
144 lines
5.2 KiB
Plaintext
# Generated Berry code from Animation DSL
|
|
# Source: palette_showcase.anim
|
|
# Generated automatically
|
|
#
|
|
# This file was automatically generated by compile_all_dsl_examples.sh
|
|
# Do not edit manually - changes will be overwritten
|
|
|
|
# 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(fire_gradient, 3s)
|
|
#
|
|
# animation ocean_waves = rich_palette_animation(ocean_depths, 8s, smooth, 200)
|
|
#
|
|
# animation aurora_lights = rich_palette_animation(aurora_borealis, 12s, smooth, 180)
|
|
#
|
|
# animation sunset_glow = rich_palette_animation(sunset_sky, 6s, smooth, 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
|
|
|
|
import animation
|
|
|
|
# Palette Showcase - Demonstrates all palette features
|
|
# This example shows the full range of palette capabilities
|
|
var strip = global.Leds(60)
|
|
var engine = animation.create_engine(strip)
|
|
# Example 1: Fire palette with hex colors
|
|
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(animation.global('fire_gradient_', 'fire_gradient'), 3000)
|
|
var ocean_waves_ = animation.rich_palette_animation(animation.global('ocean_depths_', 'ocean_depths'), 8000, animation.global('smooth_', 'smooth'), 200)
|
|
var aurora_lights_ = animation.rich_palette_animation(animation.global('aurora_borealis_', 'aurora_borealis'), 12000, animation.global('smooth_', 'smooth'), 180)
|
|
var sunset_glow_ = animation.rich_palette_animation(animation.global('sunset_sky_', 'sunset_sky'), 6000, animation.global('smooth_', 'smooth'), 220)
|
|
# Sequence to showcase all palettes
|
|
def sequence_palette_showcase()
|
|
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
|
|
# Start all animations/sequences
|
|
if global.contains('sequence_palette_showcase')
|
|
var seq_manager = global.sequence_palette_showcase()
|
|
engine.add_sequence_manager(seq_manager)
|
|
else
|
|
engine.add_animation(animation.global('palette_showcase_'))
|
|
end
|
|
engine.start()
|