Berry animation remove strip from DSL (#23817)

This commit is contained in:
s-hadinger 2025-08-23 19:59:45 +02:00 committed by GitHub
parent 81be80b04a
commit 123cb8ed79
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
23 changed files with 4344 additions and 4304 deletions

View File

@ -1,11 +1,11 @@
# DSL Compilation Report
Generated: Ven 1 aoû 2025 18:49:41 CEST
Generated: Sam 23 aoû 2025 10:30:34 CEST
## Summary
- **Total files**: 25
- **Successfully compiled**: 25
- **Total files**: 24
- **Successfully compiled**: 24
- **Failed to compile**: 0
- **Success rate**: 100%
@ -27,7 +27,6 @@ Generated: Ven 1 aoû 2025 18:49:41 CEST
- ✅ ocean_waves.anim
- ✅ palette_demo.anim
- ✅ palette_showcase.anim
- ✅ pattern_animation_demo.anim
- ✅ plasma_wave.anim
- ✅ police_lights.anim
- ✅ property_assignment_demo.anim

View File

@ -13,7 +13,7 @@
#
# # Dark background
# color matrix_bg = 0x000000
# animation background = solid(color=matrix_bg)
# animation background = solid(color=matrix_bg, priority=50)
#
# # Define matrix green palette
# palette matrix_greens = [
@ -29,33 +29,34 @@
# animation stream1 = comet_animation(
# color=stream1_pattern, # color source
# tail_length=15, # long tail
# speed=1.5s # speed
# speed=1.5s, # speed
# priority = 10
# )
# stream1.priority = 10
#
#
# color stream2_pattern = rich_palette(palette=matrix_greens, cycle_period=1.8s, transition_type=LINEAR, brightness=200)
# animation stream2 = comet_animation(
# color=stream2_pattern, # color source
# tail_length=12, # medium tail
# speed=2.2s # different speed
# speed=2.2s, # different speed
# priority = 8
# )
# stream2.priority = 8
#
# color stream3_pattern = rich_palette(palette=matrix_greens, cycle_period=2.5s, transition_type=LINEAR, brightness=180)
# animation stream3 = comet_animation(
# color=stream3_pattern, # color source
# tail_length=10, # shorter tail
# speed=1.8s # another speed
# speed=1.8s, # another speed
# priority = 6
# )
# stream3.priority = 6
#
# # Add random bright flashes (like code highlights)
# animation code_flash = twinkle_animation(
# color=0x00FFAA, # Bright cyan-green
# density=3, # density (few flashes)
# twinkle_speed=150ms # twinkle speed (quick flash)
# twinkle_speed=150ms, # twinkle speed (quick flash)
# priority = 20
# )
# code_flash.priority = 20
#
# # Start all animations
# run background
@ -76,6 +77,7 @@ var engine = animation.init_strip()
var matrix_bg_ = 0xFF000000
var background_ = animation.solid(engine)
background_.color = animation.global('matrix_bg_', 'matrix_bg')
background_.priority = 50
# Define matrix green palette
var matrix_greens_ = bytes("00000000" "40003300" "80006600" "C000AA00" "FF00FF00")
# Create multiple cascading streams
@ -87,8 +89,8 @@ stream1_pattern_.brightness = 255
var stream1_ = animation.comet_animation(engine)
stream1_.color = animation.global('stream1_pattern_', 'stream1_pattern')
stream1_.tail_length = 15
stream1_.speed = 1500 # speed
animation.global('stream1_').priority = 10
stream1_.speed = 1500
stream1_.priority = 10
var stream2_pattern_ = animation.rich_palette(engine)
stream2_pattern_.palette = animation.global('matrix_greens_', 'matrix_greens')
stream2_pattern_.cycle_period = 1800
@ -97,8 +99,8 @@ stream2_pattern_.brightness = 200
var stream2_ = animation.comet_animation(engine)
stream2_.color = animation.global('stream2_pattern_', 'stream2_pattern')
stream2_.tail_length = 12
stream2_.speed = 2200 # different speed
animation.global('stream2_').priority = 8
stream2_.speed = 2200
stream2_.priority = 8
var stream3_pattern_ = animation.rich_palette(engine)
stream3_pattern_.palette = animation.global('matrix_greens_', 'matrix_greens')
stream3_pattern_.cycle_period = 2500
@ -107,14 +109,14 @@ stream3_pattern_.brightness = 180
var stream3_ = animation.comet_animation(engine)
stream3_.color = animation.global('stream3_pattern_', 'stream3_pattern')
stream3_.tail_length = 10
stream3_.speed = 1800 # another speed
animation.global('stream3_').priority = 6
stream3_.speed = 1800
stream3_.priority = 6
# Add random bright flashes (like code highlights)
var code_flash_ = animation.twinkle_animation(engine)
code_flash_.color = 0xFF00FFAA
code_flash_.density = 3
code_flash_.twinkle_speed = 150 # twinkle speed (quick flash)
animation.global('code_flash_').priority = 20
code_flash_.twinkle_speed = 150
code_flash_.priority = 20
# Start all animations
# Start all animations/sequences
if global.contains('sequence_background')

View File

@ -154,15 +154,6 @@ else
fi
((TOTAL_COUNT++))
echo -n "Testing pattern_animation_demo.be... "
if $BERRY_CMD "$COMPILED_DIR/pattern_animation_demo.be" > /dev/null 2>&1; then
echo "✓"
((SUCCESS_COUNT++))
else
echo "✗"
fi
((TOTAL_COUNT++))
echo -n "Testing plasma_wave.be... "
if $BERRY_CMD "$COMPILED_DIR/plasma_wave.be" > /dev/null 2>&1; then
echo "✓"

View File

@ -4,8 +4,8 @@
set -e
BERRY_CMD="./berry -s -g -m lib/libesp32/berry_animation -e 'import tasmota'"
COMPILED_DIR="anim_examples/compiled"
BERRY_CMD="./berry -s -g -m lib/libesp32/berry_animation/src -e 'import tasmota'"
COMPILED_DIR="lib/libesp32/berry_animation/anim_examples/compiled"
echo "Running compiled DSL examples..."
echo "==============================="

View File

@ -5,7 +5,7 @@
# Dark background
color matrix_bg = 0x000000
animation background = solid(color=matrix_bg)
animation background = solid(color=matrix_bg, priority=50)
# Define matrix green palette
palette matrix_greens = [
@ -21,33 +21,34 @@ color stream1_pattern = rich_palette(palette=matrix_greens, cycle_period=2s, tra
animation stream1 = comet_animation(
color=stream1_pattern, # color source
tail_length=15, # long tail
speed=1.5s # speed
speed=1.5s, # speed
priority = 10
)
stream1.priority = 10
color stream2_pattern = rich_palette(palette=matrix_greens, cycle_period=1.8s, transition_type=LINEAR, brightness=200)
animation stream2 = comet_animation(
color=stream2_pattern, # color source
tail_length=12, # medium tail
speed=2.2s # different speed
speed=2.2s, # different speed
priority = 8
)
stream2.priority = 8
color stream3_pattern = rich_palette(palette=matrix_greens, cycle_period=2.5s, transition_type=LINEAR, brightness=180)
animation stream3 = comet_animation(
color=stream3_pattern, # color source
tail_length=10, # shorter tail
speed=1.8s # another speed
speed=1.8s, # another speed
priority = 6
)
stream3.priority = 6
# Add random bright flashes (like code highlights)
animation code_flash = twinkle_animation(
color=0x00FFAA, # Bright cyan-green
density=3, # density (few flashes)
twinkle_speed=150ms # twinkle speed (quick flash)
twinkle_speed=150ms, # twinkle speed (quick flash)
priority = 20
)
code_flash.priority = 20
# Start all animations
run background

View File

@ -12,7 +12,8 @@ Comments use the `#` character and extend to the end of the line:
```dsl
# This is a full-line comment
strip length 30 # This is an inline comment
# strip length 30 # This is an inline comment (TEMPORARILY DISABLED)
color red = #FF0000 # This is an inline comment
```
Comments are preserved in the generated code and can appear anywhere in the DSL.
@ -22,8 +23,8 @@ Comments are preserved in the generated code and can appear anywhere in the DSL.
A DSL program consists of statements that can appear in any order:
```dsl
# Optional strip configuration (must be first if present)
strip length 60
# Strip configuration is handled automatically
# strip length 60 # TEMPORARILY DISABLED
# Color definitions
color red = #FF0000
@ -52,7 +53,7 @@ run demo
The following keywords are reserved and cannot be used as identifiers:
**Configuration Keywords:**
- `strip` - Strip configuration
- `strip` - Strip configuration (temporarily disabled, reserved keyword)
- `set` - Variable assignment
**Definition Keywords:**
@ -179,13 +180,15 @@ Color123 # Valid identifier
### Strip Configuration
The `strip` statement configures the LED strip and must be the first statement if present:
**Note: The `strip` directive is temporarily disabled.** Strip configuration is handled automatically by the host system.
~~The `strip` statement configures the LED strip and must be the first statement if present:~~
```dsl
strip length 60 # Set strip length to 60 LEDs
# strip length 60 # TEMPORARILY DISABLED
```
If omitted, the system uses the configured strip length from the host system.
~~If omitted,~~ The system uses the configured strip length from the host system.
### Variable Assignment
@ -578,8 +581,8 @@ statement = config_stmt
| execution_stmt ;
(* Configuration *)
config_stmt = strip_config | variable_assignment ;
strip_config = "strip" "length" number ;
config_stmt = variable_assignment ;
(* strip_config = "strip" "length" number ; -- TEMPORARILY DISABLED *)
variable_assignment = "set" identifier "=" expression ;
(* Definitions *)

View File

@ -156,6 +156,9 @@ register_to_animation(rich_palette_animation)
# Function called to initialize the `Leds` and `engine` objects
#
# It keeps track of previously created engines and strips to reuse
# when called with the same arguments
#
# Parameters:
# l - list of arguments (vararg)
#
@ -164,8 +167,24 @@ register_to_animation(rich_palette_animation)
def animation_init_strip(*l)
import global
import animation
var strip = call(global.Leds, l) # call global.Leds() with vararg
var engine = animation.create_engine(strip)
import introspect
# we keep a hash of strip configurations to reuse existing engines
if !introspect.contains(animation, "_engines")
animation._engines = {}
end
var l_as_string = str(l)
var engine = animation._engines.find(l_as_string)
if (engine != nil)
# we reuse it
engine.stop()
engine.clear()
else
var strip = call(global.Leds, l) # call global.Leds() with vararg
engine = animation.create_engine(strip)
animation._engines[l_as_string] = engine
end
return engine
end
animation.init_strip = animation_init_strip

View File

@ -102,12 +102,10 @@ class SimpleDSLTranspiler
# Handle keywords
if tok.type == animation_dsl.Token.KEYWORD
if tok.value == "strip"
if !is_first_real_statement
self.error("'strip' declaration must be the first statement")
self.skip_statement()
return
end
self.process_strip()
# Strip directive is temporarily disabled but remains a reserved keyword
self.error("'strip' directive is temporarily disabled. Strip configuration is handled automatically.")
self.skip_statement()
return
else
# For any other statement, ensure strip is initialized
if !self.strip_initialized
@ -324,16 +322,17 @@ class SimpleDSLTranspiler
end
# Process strip configuration: strip length 60
def process_strip()
self.next() # skip 'strip'
var prop = self.expect_identifier()
if prop == "length"
var length = self.expect_number()
var inline_comment = self.collect_inline_comment()
self.add(f"var engine = animation.init_strip({length}){inline_comment}")
self.strip_initialized = true # Mark that strip was initialized
end
end
# Temporarily disabled
# def process_strip()
# self.next() # skip 'strip'
# var prop = self.expect_identifier()
# if prop == "length"
# var length = self.expect_number()
# var inline_comment = self.collect_inline_comment()
# self.add(f"var engine = animation.init_strip({length}){inline_comment}")
# self.strip_initialized = true # Mark that strip was initialized
# end
# end
# Process variable assignment: set brightness = 80%
def process_set()

View File

@ -1144,7 +1144,7 @@ be_local_closure(scale_oscillate, /* name */
********************************************************************/
be_local_closure(animation_init_strip, /* name */
be_nested_proto(
7, /* nstack */
10, /* nstack */
1, /* argc */
1, /* varg */
0, /* has upvals */
@ -1152,25 +1152,58 @@ be_local_closure(animation_init_strip, /* name */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[ 4]) { /* constants */
( &(const bvalue[10]) { /* constants */
/* K0 */ be_nested_str_weak(global),
/* K1 */ be_nested_str_weak(animation),
/* K2 */ be_nested_str_weak(Leds),
/* K3 */ be_nested_str_weak(create_engine),
/* K2 */ be_nested_str_weak(introspect),
/* K3 */ be_nested_str_weak(contains),
/* K4 */ be_nested_str_weak(_engines),
/* K5 */ be_nested_str_weak(find),
/* K6 */ be_nested_str_weak(stop),
/* K7 */ be_nested_str_weak(clear),
/* K8 */ be_nested_str_weak(Leds),
/* K9 */ be_nested_str_weak(create_engine),
}),
be_str_weak(animation_init_strip),
&be_const_str_solidified,
( &(const binstruction[10]) { /* code */
( &(const binstruction[37]) { /* code */
0xA4060000, // 0000 IMPORT R1 K0
0xA40A0200, // 0001 IMPORT R2 K1
0x600C0016, // 0002 GETGBL R3 G22
0x88100302, // 0003 GETMBR R4 R1 K2
0x5C140000, // 0004 MOVE R5 R0
0x7C0C0400, // 0005 CALL R3 2
0x8C100503, // 0006 GETMET R4 R2 K3
0x5C180600, // 0007 MOVE R6 R3
0x7C100400, // 0008 CALL R4 2
0x80040800, // 0009 RET 1 R4
0xA40E0400, // 0002 IMPORT R3 K2
0x8C100703, // 0003 GETMET R4 R3 K3
0x5C180400, // 0004 MOVE R6 R2
0x581C0004, // 0005 LDCONST R7 K4
0x7C100600, // 0006 CALL R4 3
0x74120002, // 0007 JMPT R4 #000B
0x60100013, // 0008 GETGBL R4 G19
0x7C100000, // 0009 CALL R4 0
0x900A0804, // 000A SETMBR R2 K4 R4
0x60100008, // 000B GETGBL R4 G8
0x5C140000, // 000C MOVE R5 R0
0x7C100200, // 000D CALL R4 1
0x88140504, // 000E GETMBR R5 R2 K4
0x8C140B05, // 000F GETMET R5 R5 K5
0x5C1C0800, // 0010 MOVE R7 R4
0x7C140400, // 0011 CALL R5 2
0x4C180000, // 0012 LDNIL R6
0x20180A06, // 0013 NE R6 R5 R6
0x781A0004, // 0014 JMPF R6 #001A
0x8C180B06, // 0015 GETMET R6 R5 K6
0x7C180200, // 0016 CALL R6 1
0x8C180B07, // 0017 GETMET R6 R5 K7
0x7C180200, // 0018 CALL R6 1
0x70020009, // 0019 JMP #0024
0x60180016, // 001A GETGBL R6 G22
0x881C0308, // 001B GETMBR R7 R1 K8
0x5C200000, // 001C MOVE R8 R0
0x7C180400, // 001D CALL R6 2
0x8C1C0509, // 001E GETMET R7 R2 K9
0x5C240C00, // 001F MOVE R9 R6
0x7C1C0400, // 0020 CALL R7 2
0x5C140E00, // 0021 MOVE R5 R7
0x881C0504, // 0022 GETMBR R7 R2 K4
0x981C0805, // 0023 SETIDX R7 R4 R5
0x80040A00, // 0024 RET 1 R5
})
)
);

View File

@ -0,0 +1,7 @@
/* Solidification of user_functions.h */
/********************************************************************\
* Generated code, don't edit *
\********************************************************************/
#include "be_constobj.h"
/********************************************************************/
/* End of solidification */

View File

@ -141,10 +141,11 @@ end
def test_strip_configuration()
print("Testing strip configuration...")
# Strip directive tests are temporarily disabled
var strip_tests = [
["strip length 30", "var engine = animation.init_strip(30)"],
["strip length 60", "var engine = animation.init_strip(60)"],
["strip length 120", "var engine = animation.init_strip(120)"]
# ["strip length 30", "var engine = animation.init_strip(30)"], # TEMPORARILY DISABLED
# ["strip length 60", "var engine = animation.init_strip(60)"], # TEMPORARILY DISABLED
# ["strip length 120", "var engine = animation.init_strip(120)"] # TEMPORARILY DISABLED
]
for test : strip_tests

View File

@ -28,7 +28,7 @@ class DSLParameterValidationTest
# Test valid parameters - should compile without errors
def test_valid_parameters()
var dsl_code =
"strip length 30\n"
"# strip length 30 # TEMPORARILY DISABLED\n"
"animation breathe_test = breathe_animation(color=0xFF0000FF, period=2000, min_brightness=50)\n"
"run breathe_test"
@ -55,7 +55,7 @@ class DSLParameterValidationTest
# Test invalid parameter - should fail compilation with specific error
def test_invalid_parameter()
var dsl_code =
"strip length 30\n"
"# strip length 30 # TEMPORARILY DISABLED\n"
"animation breathe_test = breathe_animation(color=0xFF0000FF, invalid_param=123)\n"
"run breathe_test"
@ -85,7 +85,7 @@ class DSLParameterValidationTest
# Test mixed valid and invalid parameters
def test_mixed_parameters()
var dsl_code =
"strip length 30\n"
"# strip length 30 # TEMPORARILY DISABLED\n"
"animation breathe_test = breathe_animation(color=0xFF0000FF, period=2000, nonexistent_param=456)\n"
"run breathe_test"
@ -115,7 +115,7 @@ class DSLParameterValidationTest
# Test nested function calls with invalid parameters
def test_nested_function_invalid_parameters()
var dsl_code =
"strip length 30\n"
"# strip length 30 # TEMPORARILY DISABLED\n"
"animation main_anim = pulsating_animation(color=breathe_animation(color=0xFF0000FF, bad_param=789))\n"
"run main_anim"
@ -150,7 +150,7 @@ class DSLParameterValidationTest
end)
var dsl_code =
"strip length 30\n"
"# strip length 30 # TEMPORARILY DISABLED\n"
"animation custom_test = my_custom_anim(123, 456)\n"
"run custom_test"
@ -170,7 +170,7 @@ class DSLParameterValidationTest
# Test multiple animations with different parameter validation results
def test_multiple_animations_validation()
var dsl_code =
"strip length 30\n"
"# strip length 30 # TEMPORARILY DISABLED\n"
"animation valid_anim = breathe_animation(color=0xFF0000FF, period=2000)\n"
"animation invalid_anim = breathe_animation(color=0xFF00FF00, wrong_param=999)\n"
"run valid_anim"

View File

@ -23,7 +23,7 @@ def test_dsl_runtime()
print("\nTest 1: Basic DSL loading")
var simple_dsl =
"strip length 30\n"
"# strip length 30 # TEMPORARILY DISABLED\n"
"color custom_red = 0xFF0000\n"
"animation red_anim = pulsating_animation(color=static_color(color=custom_red), period=2s)\n"
"sequence demo {\n"
@ -107,7 +107,7 @@ def test_dsl_runtime()
print("\nTest 6: Multiple DSL sources")
var dsl1 =
"strip length 30\n" +
"# strip length 30 # TEMPORARILY DISABLED\n" +
"color custom_blue = 0x0000FF\n" +
"animation blue_anim = pulsating_animation(color=static_color(color=custom_blue), period=2s)\n" +
"sequence blue_demo {\n" +
@ -116,7 +116,7 @@ def test_dsl_runtime()
"run blue_demo"
var dsl2 =
"strip length 30\n" +
"# strip length 30 # TEMPORARILY DISABLED\n" +
"color custom_green = 0x00FF00\n" +
"animation green_anim = pulsating_animation(color=static_color(color=custom_green), period=2s)\n" +
"sequence green_demo {\n" +
@ -173,7 +173,7 @@ def test_dsl_file_operations()
# Create a test DSL file
var test_filename = "/tmp/test_animation.dsl"
var test_dsl_content = "strip length 20\n" +
var test_dsl_content = "# strip length 20 # TEMPORARILY DISABLED\n" +
"color custom_purple = 0x800080\n" +
"animation purple_anim = pulsating_animation(color=static_color(color=custom_purple), period=2s)\n" +
"sequence file_test {\n" +

View File

@ -12,7 +12,7 @@ import string
def test_basic_transpilation()
print("Testing basic DSL transpilation...")
var dsl_source = "strip length 60\n" +
var dsl_source = "# strip length 60 # TEMPORARILY DISABLED\n" +
"color custom_red = 0xFF0000\n" +
"animation solid_red = solid(color=custom_red)\n" +
"animation red_anim = solid_red\n" +
@ -26,7 +26,7 @@ def test_basic_transpilation()
var berry_code = animation_dsl.compile(dsl_source)
assert(berry_code != nil, "Should generate Berry code")
assert(string.find(berry_code, "var engine = animation.init_strip(60)") >= 0, "Should generate strip configuration")
assert(string.find(berry_code, "var engine = animation.init_strip()") >= 0, "Should generate strip configuration")
assert(string.find(berry_code, "var custom_red_ = 0xFFFF0000") >= 0, "Should generate color definition")
assert(string.find(berry_code, "def sequence_demo()") >= 0, "Should generate sequence function")
assert(string.find(berry_code, "sequence_demo()") >= 0, "Should generate sequence call")
@ -97,10 +97,11 @@ end
def test_strip_configuration()
print("Testing strip configuration...")
# Strip directive tests are temporarily disabled
var config_tests = [
["strip length 30", "var engine = animation.init_strip(30)"],
["strip length 60", "var engine = animation.init_strip(60)"],
["strip length 120", "var engine = animation.init_strip(120)"]
# ["strip length 30", "var engine = animation.init_strip(30)"], # TEMPORARILY DISABLED
# ["strip length 60", "var engine = animation.init_strip(60)"], # TEMPORARILY DISABLED
# ["strip length 120", "var engine = animation.init_strip(120)"] # TEMPORARILY DISABLED
]
for test : config_tests
@ -170,7 +171,7 @@ def test_multiple_run_statements()
print("Testing multiple run statements...")
# Test with multiple animations
var dsl_source = "strip length 30\n" +
var dsl_source = "# strip length 30 # TEMPORARILY DISABLED\n" +
"color custom_red = 0xFF0000\n" +
"color custom_blue = 0x0000FF\n" +
"color custom_green = 0x00FF00\n" +
@ -224,7 +225,7 @@ def test_multiple_run_statements()
assert(start_line_index > last_add_line_index, "engine.start() should come after all engine.add_* calls")
# Test with mixed animations and sequences
var mixed_dsl = "strip length 30\n" +
var mixed_dsl = "# strip length 30 # TEMPORARILY DISABLED\n" +
"color custom_red = 0xFF0000\n" +
"color custom_blue = 0x0000FF\n" +
"\n" +
@ -264,13 +265,13 @@ end
def test_variable_assignments()
print("Testing variable assignments...")
var dsl_source = "set strip_length = 60\n" +
var dsl_source = "set my_length = 60\n" +
"set brightness = 80%\n" +
"set cycle_time = 5s"
var berry_code = animation_dsl.compile(dsl_source)
assert(berry_code != nil, "Should compile variables")
assert(string.find(berry_code, "var strip_length_ = 60") >= 0, "Should define numeric variable")
assert(string.find(berry_code, "var my_length_ = 60") >= 0, "Should define numeric variable")
assert(string.find(berry_code, "var brightness_ = 204") >= 0, "Should convert percentage to 0-255 range")
assert(string.find(berry_code, "var cycle_time_ = 5000") >= 0, "Should convert time to milliseconds")
@ -351,7 +352,7 @@ def test_complex_dsl()
print("Testing complex DSL example...")
var complex_dsl = "# LED Strip Configuration\n" +
"strip length 60\n" +
"# strip length 60 # TEMPORARILY DISABLED\n" +
"\n" +
"# Color Definitions\n" +
"color custom_red = 0xFF0000\n" +
@ -388,7 +389,7 @@ def test_complex_dsl()
print("Complex DSL compiled successfully!")
# Check for key components
assert(string.find(berry_code, "var engine = animation.init_strip(60)") >= 0, "Should have strip config")
assert(string.find(berry_code, "var engine = animation.init_strip()") >= 0, "Should have default strip initialization")
assert(string.find(berry_code, "var custom_red_ = 0xFFFF0000") >= 0, "Should have color definitions")
assert(string.find(berry_code, "def sequence_demo()") >= 0, "Should have sequence definition")
assert(string.find(berry_code, "sequence_demo()") >= 0, "Should have execution")
@ -485,7 +486,7 @@ end
def test_event_system_dsl()
print("Testing event system DSL compilation...")
var event_dsl = "strip length 30\n" +
var event_dsl = "# strip length 30 # TEMPORARILY DISABLED\n" +
"color custom_red = 0xFF0000\n" +
"color custom_blue = 0x0000FF\n" +
"\n" +
@ -564,7 +565,7 @@ def test_comment_preservation()
print("Testing comment preservation...")
var dsl_with_comments = "# Header comment\n" +
"strip length 30 # Strip config comment\n" +
"# strip length 30 # Strip config comment (TEMPORARILY DISABLED)\n" +
"# Color section\n" +
"color custom_red = 0xFF0000 # Red color\n" +
"animation solid_red = solid(color=custom_red) # Red animation\n" +
@ -609,7 +610,7 @@ end
def test_easing_keywords()
print("Testing easing keywords...")
var dsl_with_easing = "strip length 30\n" +
var dsl_with_easing = "# strip length 30 # TEMPORARILY DISABLED\n" +
"# Test all easing keywords\n" +
"animation linear_anim = solid(color=linear)\n" +
"animation smooth_anim = solid(color=smooth)\n" +
@ -630,7 +631,7 @@ def test_easing_keywords()
end
# Test easing keywords as function calls (regression test for breathing_colors.anim issue)
var dsl_with_function_calls = "strip length 30\n" +
var dsl_with_function_calls = "# strip length 30 # TEMPORARILY DISABLED\n" +
"color custom_red = 0xFF0000\n" +
"animation test_anim = solid(color=custom_red)\n" +
"test_anim.opacity = 128\n" +
@ -651,7 +652,7 @@ def test_animation_type_checking()
print("Testing animation type checking...")
# Test valid animation factory functions
var valid_animation_dsl = "strip length 30\n" +
var valid_animation_dsl = "# strip length 30 # TEMPORARILY DISABLED\n" +
"color custom_red = 0xFF0000\n" +
"animation pulse_red = pulsating_animation(color=custom_red, period=2000)\n" +
"animation solid_blue = solid(color=0x0000FF)\n" +
@ -663,7 +664,7 @@ def test_animation_type_checking()
assert(string.find(berry_code, "animation.solid(engine)") >= 0, "Should generate solid call")
# Test invalid animation factory function (should fail at transpile time)
var invalid_animation_dsl = "strip length 30\n" +
var invalid_animation_dsl = "# strip length 30 # TEMPORARILY DISABLED\n" +
"animation invalid_anim = non_existent_animation(color=custom_red)"
try
@ -674,7 +675,7 @@ def test_animation_type_checking()
end
# Test color provider assigned to animation (should fail at transpile time)
var color_provider_as_animation_dsl = "strip length 30\n" +
var color_provider_as_animation_dsl = "# strip length 30 # TEMPORARILY DISABLED\n" +
"animation invalid_anim = rich_palette(palette=breathe_palette)"
try
@ -693,7 +694,7 @@ def test_color_type_checking()
print("Testing color type checking...")
# Test simple color values
var simple_color_dsl = "strip length 30\n" +
var simple_color_dsl = "# strip length 30 # TEMPORARILY DISABLED\n" +
"color custom_red = 0xFF0000\n" +
"color custom_blue = 0x0000FF\n" +
"color named_green = green\n" +
@ -706,7 +707,7 @@ def test_color_type_checking()
assert(string.find(berry_code, "var custom_blue_ = 0xFF0000FF") >= 0, "Should generate blue color")
# Test color provider functions (if they exist)
var color_provider_dsl = "strip length 30\n" +
var color_provider_dsl = "# strip length 30 # TEMPORARILY DISABLED\n" +
"color cycle_colors = color_cycle(palette=[0xFF0000, 0x00FF00, 0x0000FF])\n" +
"animation cycle_anim = solid(color=cycle_colors)\n" +
"run cycle_anim"
@ -724,7 +725,7 @@ def test_color_type_checking()
end
# Test invalid color provider function (should fail at transpile time)
var invalid_color_dsl = "strip length 30\n" +
var invalid_color_dsl = "# strip length 30 # TEMPORARILY DISABLED\n" +
"color invalid_color = non_existent_color_provider(param=value)"
try

View File

@ -28,7 +28,7 @@ class DSLValueProviderValidationTest
# Test valid value provider parameters
def test_valid_value_provider_parameters()
var dsl_code =
"strip length 30\n"
"# strip length 30 # TEMPORARILY DISABLED\n"
"animation test = pulsating_animation(color=0xFF0000FF, min_brightness=oscillator_value(min_value=0, max_value=100))\n"
"run test"
@ -47,7 +47,7 @@ class DSLValueProviderValidationTest
# Test invalid value provider parameter
def test_invalid_value_provider_parameter()
var dsl_code =
"strip length 30\n"
"# strip length 30 # TEMPORARILY DISABLED\n"
"animation test = pulsating_animation(color=0xFF0000FF, min_brightness=oscillator_value(min_value=0, invalid_param=123))\n"
"run test"
@ -77,7 +77,7 @@ class DSLValueProviderValidationTest
# Test nonexistent value provider
def test_nonexistent_value_provider()
var dsl_code =
"strip length 30\n"
"# strip length 30 # TEMPORARILY DISABLED\n"
"animation test = pulsating_animation(color=0xFF0000FF, min_brightness=nonexistent_provider(param=123))\n"
"run test"
@ -107,7 +107,7 @@ class DSLValueProviderValidationTest
# Test nested value providers
def test_nested_value_providers()
var dsl_code =
"strip length 30\n"
"# strip length 30 # TEMPORARILY DISABLED\n"
"animation test = pulsating_animation(color=color_cycle(palette=[0xFF0000FF, 0xFF00FF00], cycle_period=oscillator_value(min_value=1000, bad_param=456)))\n"
"run test"

View File

@ -127,7 +127,7 @@ end
# Test 7: DSL Event Handler Compilation
def test_dsl_event_compilation()
var dsl_code =
"strip length 30\n"
"# strip length 30 # TEMPORARILY DISABLED\n"
"color custom_red = 0xFF0000\n"
"on button_press: solid(custom_red)\n"
"run solid(custom_red)"
@ -143,7 +143,7 @@ end
# Test 8: DSL Event with Parameters
def test_dsl_event_with_parameters()
var dsl_code =
"strip length 30\n"
"# strip length 30 # TEMPORARILY DISABLED\n"
"color custom_blue = 0x0000FF\n"
"on timer(5s): solid(custom_blue)\n"
"run solid(custom_blue)"

View File

@ -11,7 +11,7 @@ def test_basic_nested_calls()
print("Testing basic nested function calls...")
var dsl_code =
"strip length 30\n"
"# strip length 30 # TEMPORARILY DISABLED\n"
"color custom_red = 0xFF0000\n"
"animation pulse_red = pulsating_animation(color=static_color(color=custom_red), period=3s)\n"
"run pulse_red"
@ -38,7 +38,7 @@ def test_deep_nesting()
print("Testing deep nesting...")
var dsl_code =
"strip length 30\n"
"# strip length 30 # TEMPORARILY DISABLED\n"
"animation complex = pulsating_animation(color=static_color(color=red), period=2s)\n"
"run complex"
@ -62,7 +62,7 @@ def test_mixed_parameter_types()
print("Testing nested calls with mixed parameter types...")
var dsl_code =
"strip length 30\n"
"# strip length 30 # TEMPORARILY DISABLED\n"
"animation mixed = pulsating_animation(color=static_color(color=blue), period=2s, max_brightness=80%)\n"
"run mixed"
@ -88,7 +88,7 @@ def test_nested_calls_in_arrays()
print("Testing nested calls in array literals...")
var dsl_code =
"strip length 30\n"
"# strip length 30 # TEMPORARILY DISABLED\n"
"animation cycle = pulsating_animation(color=static_color(color=red), period=5s)\n"
"run cycle"
@ -115,7 +115,7 @@ def test_error_handling()
# Test unclosed parentheses
var dsl_code1 =
"strip length 30\n"
"# strip length 30 # TEMPORARILY DISABLED\n"
"animation bad = pulsating_animation(color=static_color(color=red)\n" # Missing closing paren
"run bad"
@ -128,7 +128,7 @@ def test_error_handling()
# Test invalid function name
var dsl_code2 =
"strip length 30\n"
"# strip length 30 # TEMPORARILY DISABLED\n"
"animation bad = invalid_function(color=red)\n"
"run bad"
@ -148,7 +148,7 @@ def test_complex_real_world_example()
print("Testing complex real-world example...")
var dsl_code =
"strip length 60\n"
"# strip length 60 # TEMPORARILY DISABLED\n"
"color sunset_red = 0xFF4500\n"
"animation evening = pulsating_animation(\n"
" color=static_color(color=sunset_red),\n"
@ -176,7 +176,7 @@ def test_generated_code_validity()
print("Testing generated code validity...")
var dsl_code =
"strip length 30\n"
"# strip length 30 # TEMPORARILY DISABLED\n"
"color custom_red = 0xFF0000\n"
"animation test = pulsating_animation(color=static_color(color=custom_red), period=3s)\n"
"run test"

View File

@ -9,7 +9,7 @@ def test_basic_transpilation()
# Create a simple DSL program with custom color names (not predefined ones)
var dsl_code =
"strip length 30\n"
"# strip length 30 # TEMPORARILY DISABLED\n"
"color my_red = 0xFF0000\n"
"color my_blue = 0x0000FF\n"
"animation solid_red = solid(color=my_red)\n"
@ -37,7 +37,7 @@ def test_color_resolution()
# Test that named colors work
var dsl_code =
"strip length 10\n"
"# strip length 10 # TEMPORARILY DISABLED\n"
"animation red_pattern = solid(color=red)\n"
"animation blue_pattern = solid(color=blue)\n"
"run red_pattern"
@ -64,7 +64,7 @@ def test_function_calls()
print("Testing function calls...")
var dsl_code =
"strip length 20\n"
"# strip length 20 # TEMPORARILY DISABLED\n"
"animation solid_red = solid(color=red)\n"
"animation test_anim = pulsating_animation(color=red, period=1000)\n"
"run test_anim"

View File

@ -40,79 +40,79 @@ def run_all_tests()
print("")
var test_files = [
"lib/libesp32/berry_animation/tests/sine_int_test.be",
"lib/libesp32/berry_animation/src/tests/sine_int_test.be",
# Core framework tests
"lib/libesp32/berry_animation/tests/frame_buffer_test.be",
"lib/libesp32/berry_animation/tests/nillable_parameter_test.be",
"lib/libesp32/berry_animation/tests/parameterized_object_test.be", # Tests parameter management base class
"lib/libesp32/berry_animation/tests/animation_test.be",
"lib/libesp32/berry_animation/tests/animation_engine_test.be",
"lib/libesp32/berry_animation/tests/fast_loop_integration_test.be",
"lib/libesp32/berry_animation/tests/solid_animation_test.be", # Tests unified solid() function
"lib/libesp32/berry_animation/tests/solid_unification_test.be", # Tests solid unification
"lib/libesp32/berry_animation/src/tests/frame_buffer_test.be",
"lib/libesp32/berry_animation/src/tests/nillable_parameter_test.be",
"lib/libesp32/berry_animation/src/tests/parameterized_object_test.be", # Tests parameter management base class
"lib/libesp32/berry_animation/src/tests/animation_test.be",
"lib/libesp32/berry_animation/src/tests/animation_engine_test.be",
"lib/libesp32/berry_animation/src/tests/fast_loop_integration_test.be",
"lib/libesp32/berry_animation/src/tests/solid_animation_test.be", # Tests unified solid() function
"lib/libesp32/berry_animation/src/tests/solid_unification_test.be", # Tests solid unification
# Animation effect tests
"lib/libesp32/berry_animation/tests/filled_animation_test.be",
"lib/libesp32/berry_animation/tests/pulse_animation_test.be",
"lib/libesp32/berry_animation/tests/breathe_animation_test.be",
"lib/libesp32/berry_animation/tests/color_cycle_animation_test.be",
"lib/libesp32/berry_animation/tests/rich_palette_animation_test.be",
"lib/libesp32/berry_animation/tests/rich_palette_animation_class_test.be",
"lib/libesp32/berry_animation/tests/comet_animation_test.be",
"lib/libesp32/berry_animation/tests/fire_animation_test.be",
"lib/libesp32/berry_animation/tests/twinkle_animation_test.be",
"lib/libesp32/berry_animation/tests/crenel_position_animation_test.be",
"lib/libesp32/berry_animation/tests/beacon_animation_test.be",
"lib/libesp32/berry_animation/tests/gradient_animation_test.be",
"lib/libesp32/berry_animation/tests/noise_animation_test.be",
"lib/libesp32/berry_animation/tests/plasma_animation_test.be",
"lib/libesp32/berry_animation/tests/sparkle_animation_test.be",
"lib/libesp32/berry_animation/tests/wave_animation_test.be",
"lib/libesp32/berry_animation/tests/palette_pattern_animation_test.be",
"lib/libesp32/berry_animation/src/tests/filled_animation_test.be",
"lib/libesp32/berry_animation/src/tests/pulse_animation_test.be",
"lib/libesp32/berry_animation/src/tests/breathe_animation_test.be",
"lib/libesp32/berry_animation/src/tests/color_cycle_animation_test.be",
"lib/libesp32/berry_animation/src/tests/rich_palette_animation_test.be",
"lib/libesp32/berry_animation/src/tests/rich_palette_animation_class_test.be",
"lib/libesp32/berry_animation/src/tests/comet_animation_test.be",
"lib/libesp32/berry_animation/src/tests/fire_animation_test.be",
"lib/libesp32/berry_animation/src/tests/twinkle_animation_test.be",
"lib/libesp32/berry_animation/src/tests/crenel_position_animation_test.be",
"lib/libesp32/berry_animation/src/tests/beacon_animation_test.be",
"lib/libesp32/berry_animation/src/tests/gradient_animation_test.be",
"lib/libesp32/berry_animation/src/tests/noise_animation_test.be",
"lib/libesp32/berry_animation/src/tests/plasma_animation_test.be",
"lib/libesp32/berry_animation/src/tests/sparkle_animation_test.be",
"lib/libesp32/berry_animation/src/tests/wave_animation_test.be",
"lib/libesp32/berry_animation/src/tests/palette_pattern_animation_test.be",
# Motion effects tests
"lib/libesp32/berry_animation/tests/shift_animation_test.be",
"lib/libesp32/berry_animation/tests/bounce_animation_test.be",
"lib/libesp32/berry_animation/tests/scale_animation_test.be",
"lib/libesp32/berry_animation/tests/jitter_animation_test.be",
"lib/libesp32/berry_animation/tests/motion_effects_test.be",
"lib/libesp32/berry_animation/src/tests/shift_animation_test.be",
"lib/libesp32/berry_animation/src/tests/bounce_animation_test.be",
"lib/libesp32/berry_animation/src/tests/scale_animation_test.be",
"lib/libesp32/berry_animation/src/tests/jitter_animation_test.be",
"lib/libesp32/berry_animation/src/tests/motion_effects_test.be",
# Color and parameter tests
"lib/libesp32/berry_animation/tests/crenel_position_color_test.be",
"lib/libesp32/berry_animation/tests/get_param_value_test.be",
"lib/libesp32/berry_animation/tests/parameter_validation_test.be",
"lib/libesp32/berry_animation/src/tests/crenel_position_color_test.be",
"lib/libesp32/berry_animation/src/tests/get_param_value_test.be",
"lib/libesp32/berry_animation/src/tests/parameter_validation_test.be",
# Sequence and timing tests
"lib/libesp32/berry_animation/tests/sequence_manager_test.be",
"lib/libesp32/berry_animation/tests/sequence_manager_layering_test.be",
"lib/libesp32/berry_animation/src/tests/sequence_manager_test.be",
"lib/libesp32/berry_animation/src/tests/sequence_manager_layering_test.be",
# Value provider tests
"lib/libesp32/berry_animation/tests/core_value_provider_test.be",
"lib/libesp32/berry_animation/tests/test_time_ms_requirement.be",
"lib/libesp32/berry_animation/tests/value_provider_test.be",
"lib/libesp32/berry_animation/tests/oscillator_value_provider_test.be",
"lib/libesp32/berry_animation/tests/oscillator_ease_test.be",
"lib/libesp32/berry_animation/tests/oscillator_elastic_bounce_test.be",
"lib/libesp32/berry_animation/tests/breathe_color_provider_test.be",
"lib/libesp32/berry_animation/src/tests/core_value_provider_test.be",
"lib/libesp32/berry_animation/src/tests/test_time_ms_requirement.be",
"lib/libesp32/berry_animation/src/tests/value_provider_test.be",
"lib/libesp32/berry_animation/src/tests/oscillator_value_provider_test.be",
"lib/libesp32/berry_animation/src/tests/oscillator_ease_test.be",
"lib/libesp32/berry_animation/src/tests/oscillator_elastic_bounce_test.be",
"lib/libesp32/berry_animation/src/tests/breathe_color_provider_test.be",
# DSL tests
"lib/libesp32/berry_animation/tests/dsl_lexer_test.be",
"lib/libesp32/berry_animation/tests/token_test.be",
"lib/libesp32/berry_animation/tests/global_variable_test.be",
"lib/libesp32/berry_animation/tests/dsl_transpiler_test.be",
"lib/libesp32/berry_animation/tests/dsl_core_processing_test.be",
"lib/libesp32/berry_animation/tests/simplified_transpiler_test.be",
"lib/libesp32/berry_animation/tests/symbol_registry_test.be",
"lib/libesp32/berry_animation/tests/dsl_runtime_test.be",
"lib/libesp32/berry_animation/tests/nested_function_calls_test.be",
"lib/libesp32/berry_animation/tests/user_functions_test.be",
"lib/libesp32/berry_animation/tests/palette_dsl_test.be",
"lib/libesp32/berry_animation/tests/dsl_parameter_validation_test.be",
"lib/libesp32/berry_animation/tests/dsl_value_provider_validation_test.be",
"lib/libesp32/berry_animation/src/tests/dsl_lexer_test.be",
"lib/libesp32/berry_animation/src/tests/token_test.be",
"lib/libesp32/berry_animation/src/tests/global_variable_test.be",
"lib/libesp32/berry_animation/src/tests/dsl_transpiler_test.be",
"lib/libesp32/berry_animation/src/tests/dsl_core_processing_test.be",
"lib/libesp32/berry_animation/src/tests/simplified_transpiler_test.be",
"lib/libesp32/berry_animation/src/tests/symbol_registry_test.be",
"lib/libesp32/berry_animation/src/tests/dsl_runtime_test.be",
"lib/libesp32/berry_animation/src/tests/nested_function_calls_test.be",
"lib/libesp32/berry_animation/src/tests/user_functions_test.be",
"lib/libesp32/berry_animation/src/tests/palette_dsl_test.be",
"lib/libesp32/berry_animation/src/tests/dsl_parameter_validation_test.be",
"lib/libesp32/berry_animation/src/tests/dsl_value_provider_validation_test.be",
# Event system tests
"lib/libesp32/berry_animation/tests/event_system_test.be"
"lib/libesp32/berry_animation/src/tests/event_system_test.be"
]
var total_tests = size(test_files)

View File

@ -32,7 +32,7 @@ def test_user_function_in_dsl()
print("Testing user function call in DSL...")
var dsl_code =
"strip length 30\n"
"# strip length 30 # TEMPORARILY DISABLED\n"
"color custom_red = 0xFF0000\n"
"animation red_breathing = breathing(custom_red, 4s)\n"
"run red_breathing"
@ -63,7 +63,7 @@ def test_nested_user_function_calls()
animation.register_user_function("complex", complex_effect)
var dsl_code =
"strip length 30\n"
"# strip length 30 # TEMPORARILY DISABLED\n"
"color custom_blue = 0x0000FF\n"
"animation complex_blue = complex(custom_blue, 2s)\n"
"run complex_blue"
@ -88,7 +88,7 @@ def test_user_function_multiple_parameters()
print("Testing user function with multiple parameters...")
var dsl_code =
"strip length 30\n"
"# strip length 30 # TEMPORARILY DISABLED\n"
"animation sparkles = sparkle(red, white, 15%)\n"
"run sparkles"
@ -114,7 +114,7 @@ def test_user_function_in_nested_calls()
print("Testing user function in nested calls...")
var dsl_code =
"strip length 30\n"
"# strip length 30 # TEMPORARILY DISABLED\n"
"color custom_red = 0xFF0000\n"
"animation complex = pulsating_animation(color=breathing(custom_red, 3s), period=2s)\n"
"run complex"
@ -141,7 +141,7 @@ def test_generated_code_validity()
print("Testing generated code validity with user functions...")
var dsl_code =
"strip length 30\n"
"# strip length 30 # TEMPORARILY DISABLED\n"
"color custom_red = 0xFF0000\n"
"animation red_fire = fire(200, 500ms)\n"
"run red_fire"

View File

@ -0,0 +1,100 @@
# User-defined functions for Animation DSL
# This file demonstrates how to create custom functions that can be used in the DSL
import animation
# Example 1: Simple breathing effect
def breathing_effect(engine, base_color, period)
# Create a pulse animation with the specified color and period
var pulse_anim = animation.pulsating_animation(engine)
pulse_anim.color = base_color
pulse_anim.min_brightness = 50
pulse_anim.max_brightness = 255
pulse_anim.period = period
return pulse_anim
end
# Example 2: Police lights effect
def police_lights(engine, flash_speed)
# Create alternating red/blue flash effect
var pulse_anim = animation.pulsating_animation(engine)
pulse_anim.color = 0xFFFF0000 # Red
pulse_anim.min_brightness = 0
pulse_anim.max_brightness = 255
pulse_anim.period = flash_speed
return pulse_anim
end
# Example 3: Fire effect with customizable intensity
def fire_effect(engine, intensity, speed)
# Use the fire palette with custom parameters
var color_provider = animation.rich_palette(engine)
color_provider.palette = animation.PALETTE_FIRE
color_provider.cycle_period = speed
color_provider.easing = 1 # Smooth transitions
var fire_anim = animation.filled(engine)
fire_anim.color_provider = color_provider
fire_anim.brightness = intensity
return fire_anim
end
# Example 4: Sparkle effect
def sparkle_effect(engine, base_color, sparkle_color, density)
# Create a twinkling sparkle effect
var sparkle_anim = animation.twinkle_animation(engine)
sparkle_anim.color = sparkle_color
sparkle_anim.density = density
sparkle_anim.speed = 500
return sparkle_anim
end
# Example 5: Color wheel effect
def color_wheel(engine, speed)
# Create a rainbow that cycles through colors
var color_provider = animation.rich_palette(engine)
color_provider.palette = animation.PALETTE_RAINBOW
color_provider.cycle_period = speed
color_provider.easing = 1 # Smooth transitions
var rainbow_anim = animation.filled(engine)
rainbow_anim.color_provider = color_provider
rainbow_anim.brightness = 255
return rainbow_anim
end
# Example 6: Comet effect with custom tail
def comet_effect(engine, color, tail_length, speed)
# Create a moving comet with customizable tail
var comet_anim = animation.comet_animation(engine)
comet_anim.color = color
comet_anim.tail_length = tail_length
comet_anim.speed = speed
return comet_anim
end
# Example 7: Pulsing position effect
def pulse_spot(engine, color, position, width, period)
# Create a pulsing effect at a specific position
var pulse_pos_anim = animation.beacon_animation(engine)
pulse_pos_anim.color = color
pulse_pos_anim.position = position
pulse_pos_anim.width = width
pulse_pos_anim.period = period
return pulse_pos_anim
end
# Register all user functions with the animation module
animation.register_user_function("breathing", breathing_effect)
animation.register_user_function("police_lights", police_lights)
animation.register_user_function("fire", fire_effect)
animation.register_user_function("sparkle", sparkle_effect)
animation.register_user_function("color_wheel", color_wheel)
animation.register_user_function("comet_effect", comet_effect)
animation.register_user_function("pulse_spot", pulse_spot)
print("User functions registered:")
var functions = animation.list_user_functions()
for func_name : functions
print(f" - {func_name}")
end

View File

@ -1,58 +0,0 @@
# User-defined functions for Animation DSL
# This file demonstrates how to create custom functions that can be used in the DSL
import animation
# Example 1: Simple breathing effect
def breathing_effect(base_color, period)
# Create a gradient from black to base_color to black
var black = 0xFF000000
var gradient_pattern = animation.gradient(black, base_color, black)
# Create a pulse animation with smooth transitions
return animation.pulse(gradient_pattern, period, 0, 255)
end
# Example 2: Police lights effect
def police_lights(flash_speed)
# This would create alternating red/blue pattern
# For now, return a simple red pulse as placeholder
var red = 0xFFFF0000
return animation.pulse(animation.solid(red), flash_speed, 100, 255)
end
# Example 3: Fire effect with customizable intensity
def fire_effect(intensity, speed)
# Use the fire palette with custom parameters
var fire_palette = animation.PALETTE_FIRE
var provider = animation.rich_palette_color_provider(fire_palette, speed, 1, intensity)
return animation.filled(provider, 0, 0, true, "fire")
end
# Example 4: Sparkle effect
def sparkle_effect(base_color, sparkle_color, density)
# Create a sparkle pattern (simplified implementation)
# In a real implementation, this would create random sparkles
return animation.pulse(animation.solid(base_color), 500, 100, 255)
end
# Example 5: Color wheel effect
def color_wheel(speed)
# Create a rainbow that cycles through colors
var rainbow_palette = animation.PALETTE_RAINBOW
var provider = animation.rich_palette_color_provider(rainbow_palette, speed, 1, 255)
return animation.filled(provider, 0, 0, true, "rainbow")
end
# Register all user functions with the animation module
animation.register_user_function("breathing", breathing_effect)
animation.register_user_function("police_lights", police_lights)
animation.register_user_function("fire", fire_effect)
animation.register_user_function("sparkle", sparkle_effect)
animation.register_user_function("color_wheel", color_wheel)
print("User functions registered:")
var functions = animation.list_user_functions()
for func_name : functions
print(f" - {func_name}")
end