57 lines
2.2 KiB
Plaintext
57 lines
2.2 KiB
Plaintext
# Unified Pattern-Animation Demo
|
|
# This DSL example demonstrates the new unified architecture where Animation extends Pattern
|
|
|
|
strip length 30
|
|
|
|
# UNIFIED ARCHITECTURE: solid() returns Animation (which IS a Pattern)
|
|
# No more artificial distinction between patterns and animations
|
|
animation solid_red = solid(red) # Animation: solid red (infinite duration)
|
|
animation solid_blue = solid(blue) # Animation: solid blue (infinite duration)
|
|
animation solid_green = solid(green) # Animation: solid green (infinite duration)
|
|
|
|
# COMPOSITION: Animations can use other animations as base
|
|
animation pulsing_red = pulse(solid_red, 0%, 100%, 2s) # Animation using animation
|
|
animation pulsing_blue = pulse(solid_blue, 50%, 100%, 1s) # Animation using animation
|
|
animation pulsing_green = pulse(solid_green, 20%, 80%, 3s) # Animation using animation
|
|
|
|
# Set priorities (all animations inherit from Pattern)
|
|
solid_red.priority = 0 # Base animation priority
|
|
pulsing_red.priority = 10 # Higher priority
|
|
pulsing_blue.priority = 20 # Even higher priority
|
|
pulsing_green.priority = 5 # Medium priority
|
|
|
|
# Set opacity (all animations inherit from Pattern)
|
|
solid_red.opacity = 255 # Full opacity
|
|
pulsing_red.opacity = 200 # Slightly dimmed
|
|
pulsing_blue.opacity = 150 # More dimmed
|
|
|
|
# RECURSIVE COMPOSITION: Animations can use other animations!
|
|
# This creates infinitely composable effects
|
|
animation complex_pulse = pulse(pulsing_red, 30%, 70%, 4s) # Pulse a pulsing animation!
|
|
|
|
# Create a sequence that demonstrates the unified architecture
|
|
sequence unified_demo {
|
|
# All animations can be used directly in sequences
|
|
play solid_red for 2s # Use solid animation
|
|
wait 500ms
|
|
|
|
# Composed animations work seamlessly
|
|
play pulsing_red for 3s # Use pulse animation
|
|
wait 500ms
|
|
|
|
play pulsing_blue for 2s # Use another pulse animation
|
|
wait 500ms
|
|
|
|
# Show recursive composition - animation using animation
|
|
play complex_pulse for 4s # Nested animation effect
|
|
wait 500ms
|
|
|
|
# Show that all animations support the same properties
|
|
repeat 2 times:
|
|
play solid_green for 1s # Animation with priority/opacity
|
|
play pulsing_green for 2s # Animation with priority/opacity
|
|
wait 500ms
|
|
}
|
|
|
|
# Run the demonstration
|
|
run unified_demo |