Berry animation continue renaming classes (#24296)

This commit is contained in:
s-hadinger 2026-01-03 11:55:40 +01:00 committed by GitHub
parent 219cdfd57a
commit cbbc9461aa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
19 changed files with 5010 additions and 5532 deletions

View File

@ -35,16 +35,15 @@ ParameterizedObject (base class with parameter management and playable interface
├── SequenceManager (orchestrates animation sequences)
└── ValueProvider (dynamic value generation)
├── StaticValueProvider (wraps static values)
├── StripLengthProvider (provides LED strip length)
├── strip_length (provides LED strip length)
├── IterationNumberProvider (provides sequence iteration number)
├── OscillatorValueProvider (oscillating values with waveforms)
├── ClosureValueProvider (computed values, internal use only)
└── ColorProvider (dynamic color generation)
├── closure_value (computed values, internal use only)
└── color_provider (dynamic color generation)
├── StaticColorProvider (solid color)
├── ColorCycleColorProvider (cycles through palette)
├── rich_palette_color (smooth palette transitions)
├── BreatheColorProvider (breathing color effect)
└── CompositeColorProvider (blends multiple colors)
└── breathe_color (breathing color effect)
```
## Base Classes
@ -228,7 +227,7 @@ Wraps static values to provide ValueProvider interface. Inherits from `ValueProv
**Factory**: `animation.static_value(engine)`
### StripLengthProvider
### strip_length
Provides access to the LED strip length as a dynamic value. Inherits from `ValueProvider`.
@ -270,7 +269,7 @@ Generates oscillating values using various waveforms. Inherits from `ValueProvid
**See Also**: [Oscillation Patterns](Oscillation_Patterns.md) - Visual examples and usage patterns for oscillation waveforms
### ClosureValueProvider
### closure_value
**⚠️ INTERNAL USE ONLY - NOT FOR DIRECT USE**
@ -284,7 +283,7 @@ Wraps a closure/function as a value provider for internal transpiler use. This c
#### Mathematical Helper Methods
The ClosureValueProvider includes built-in mathematical helper methods that can be used within closures for computed values:
The closure_value includes built-in mathematical helper methods that can be used within closures for computed values:
| Method | Description | Parameters | Return Type | Example |
|--------|-------------|------------|-------------|---------|
@ -307,7 +306,7 @@ The ClosureValueProvider includes built-in mathematical helper methods that can
#### Closure Signature
Closures used with ClosureValueProvider must follow this signature:
Closures used with closure_value must follow this signature:
```berry
def closure_func(engine, param_name, time_ms)
# engine: AnimationEngine reference
@ -335,13 +334,13 @@ animation pulse = pulsating_animation(
**Factory**: `animation.closure_value(engine)` (internal use only)
**Note**: Users should not create ClosureValueProvider instances directly. Instead, use the DSL's computed value syntax which automatically creates these providers as needed.
**Note**: Users should not create closure_value instances directly. Instead, use the DSL's computed value syntax which automatically creates these providers as needed.
## Color Providers
Color providers generate dynamic colors over time, extending ValueProvider for color-specific functionality.
### ColorProvider
### color_provider
Base interface for all color providers. Inherits from `ValueProvider`.
@ -356,12 +355,12 @@ Base interface for all color providers. Inherits from `ValueProvider`.
### StaticColorProvider
Returns a single, static color. Inherits from `ColorProvider`.
Returns a single, static color. Inherits from `color_provider`.
| Parameter | Type | Default | Constraints | Description |
|-----------|------|---------|-------------|-------------|
| `color` | int | 0xFFFFFFFF | - | The solid color to return |
| *(inherits brightness from ColorProvider)* | | | | |
| *(inherits brightness from color_provider)* | | | | |
#### Usage Examples
@ -382,7 +381,7 @@ color static_accent = solid(color=accent)
### ColorCycleColorProvider
Cycles through a palette of colors with brutal switching. Inherits from `ColorProvider`.
Cycles through a palette of colors with brutal switching. Inherits from `color_provider`.
| Parameter | Type | Default | Constraints | Description |
|-----------|------|---------|-------------|-------------|
@ -390,7 +389,7 @@ Cycles through a palette of colors with brutal switching. Inherits from `ColorPr
| `period` | int | 5000 | min: 0 | Cycle time in ms (0 = manual only) |
| `next` | int | 0 | - | Write 1 to move to next color manually, or any number to go forward or backwards by `n` colors |
| `palette_size` | int | 3 | read-only | Number of colors in the palette (automatically updated when palette changes) |
| *(inherits brightness from ColorProvider)* | | | | |
| *(inherits brightness from color_provider)* | | | | |
**Note**: The `get_color_for_value()` method accepts values in the 0-255 range for value-based color mapping.
@ -420,14 +419,14 @@ color mixed_cycle = color_cycle(
### rich_palette_color
Generates colors from predefined palettes with smooth transitions and professional color schemes. Inherits from `ColorProvider`.
Generates colors from predefined palettes with smooth transitions and professional color schemes. Inherits from `color_provider`.
| Parameter | Type | Default | Constraints | Description |
|-----------|------|---------|-------------|-------------|
| `colors` | bytes | rainbow palette | - | Palette bytes or predefined palette constant |
| `period` | int | 5000 | min: 0 | Cycle time in ms (0 = value-based only) |
| `transition_type` | int | animation.LINEAR | enum: [animation.LINEAR, animation.SINE] | LINEAR=constant speed, SINE=smooth ease-in/ease-out |
| *(inherits brightness from ColorProvider)* | | | | |
| *(inherits brightness from color_provider)* | | | | |
#### Available Predefined Palettes
@ -457,9 +456,9 @@ color fire_colors = rich_palette_color(
)
```
### BreatheColorProvider
### breathe_color
Creates breathing/pulsing color effects by modulating the brightness of a base color over time. Inherits from `ColorProvider`.
Creates breathing/pulsing color effects by modulating the brightness of a base color over time. Inherits from `color_provider`.
| Parameter | Type | Default | Constraints | Description |
|-----------|------|---------|-------------|-------------|
@ -468,12 +467,12 @@ Creates breathing/pulsing color effects by modulating the brightness of a base c
| `max_brightness` | int | 255 | 0-255 | Maximum brightness level (breathing effect) |
| `duration` | int | 3000 | min: 1 | Time for one complete breathing cycle in ms |
| `curve_factor` | int | 2 | 1-5 | Breathing curve shape (1=cosine wave, 2-5=curved breathing with pauses) |
| *(inherits brightness from ColorProvider)* | | | | Overall brightness scaling applied after breathing effect |
| *(inherits brightness from color_provider)* | | | | Overall brightness scaling applied after breathing effect |
| *(inherits all OscillatorValueProvider parameters)* | | | | |
**Curve Factor Effects:**
- `1`: Pure cosine wave (smooth pulsing, equivalent to pulsating_color)
- `2`: Natural breathing with slight pauses at peaks
- `1`: Pure cosine wave (smooth pulsing)
- `2`: Natural breathing with slight pauses at peaks (default)
- `3`: More pronounced breathing with longer pauses
- `4`: Deep breathing with extended pauses
- `5`: Most pronounced pauses at peaks (dramatic breathing effect)
@ -490,7 +489,7 @@ color breathing_red = breathe_color(
curve_factor=3
)
# Fast pulsing effect (equivalent to pulsating_color)
# Fast pulsing effect
color pulse_blue = breathe_color(
base_color=blue,
min_brightness=50,
@ -519,20 +518,7 @@ color breathing_rainbow = breathe_color(
)
```
**Factories**: `animation.breathe_color(engine)`, `animation.pulsating_color(engine)`
**Note**: The `pulsating_color()` factory creates a BreatheColorProvider with `curve_factor=1` and `duration=1000ms` for fast pulsing effects.
### CompositeColorProvider
Combines multiple color providers with blending. Inherits from `ColorProvider`.
| Parameter | Type | Default | Constraints | Description |
|-----------|------|---------|-------------|-------------|
| `blend_mode` | int | 0 | enum: [0,1,2] | 0=overlay, 1=add, 2=multiply |
| *(inherits brightness from ColorProvider)* | | | | Overall brightness scaling applied to final composite color |
**Factory**: `animation.composite_color(engine)`
**Factories**: `animation.breathe_color(engine)`
## Animation Classes

View File

@ -217,7 +217,7 @@ end
### Color Provider LUT Optimization
For color providers that perform expensive color calculations (like palette interpolation), the base `ColorProvider` class provides a Lookup Table (LUT) mechanism for caching pre-computed colors:
For color providers that perform expensive color calculations (like palette interpolation), the base `color_provider` class provides a Lookup Table (LUT) mechanism for caching pre-computed colors:
```berry
#@ solidify:MyColorProvider,weak
@ -234,7 +234,7 @@ class MyColorProvider : animation.color_provider
def on_param_changed(name, value)
super(self).on_param_changed(name, value)
if name == "colors" || name == "transition_type"
self._lut_dirty = true # Inherited from ColorProvider
self._lut_dirty = true # Inherited from color_provider
end
end
@ -296,7 +296,7 @@ class MyColorProvider : animation.color_provider
end
# Access LUT from outside (returns bytes() or nil)
# Inherited from ColorProvider: get_lut()
# Inherited from color_provider: get_lut()
end
```
@ -320,7 +320,7 @@ end
**Brightness Handling:**
The `ColorProvider` base class includes a `brightness` parameter (0-255, default 255) and a static method for applying brightness scaling:
The `color_provider` base class includes a `brightness` parameter (0-255, default 255) and a static method for applying brightness scaling:
```berry
# Static method for brightness scaling (only scales if brightness != 255)

View File

@ -383,7 +383,8 @@ color breathing_red = breathe_color(
duration=3s
curve_factor=2
)
color pulsing_blue = pulsating_color(
color pulsing_blue = breathe_color(
curve_factor=1
base_color=blue
min_brightness=20%
max_brightness=80%
@ -685,7 +686,7 @@ test.opacity = min(255, max(50, scale(sqrt(strip_len), 0, 16, 100, 255)))
- **Closure Context**: In computed parameters, mathematical functions are called as `animation._math.<function>()` in the generated closure context
**How It Works:**
When the DSL detects arithmetic expressions containing value providers, variable references, or mathematical functions, it automatically creates closure functions that capture the computation. These closures are called with `(self, param_name, time_ms)` parameters, allowing the computation to be re-evaluated dynamically as needed. Mathematical functions are automatically prefixed with `animation._math.` in the closure context to access the ClosureValueProvider's mathematical methods.
When the DSL detects arithmetic expressions containing value providers, variable references, or mathematical functions, it automatically creates closure functions that capture the computation. These closures are called with `(self, param_name, time_ms)` parameters, allowing the computation to be re-evaluated dynamically as needed. Mathematical functions are automatically prefixed with `animation._math.` in the closure context to access the closure_value's mathematical methods.
**User Functions in Computed Parameters:**
User-defined functions can also be used in computed parameter expressions, providing powerful custom effects:
@ -1422,9 +1423,7 @@ Color providers create dynamic colors that change over time:
| `static_color` | Solid color with optional dynamic opacity |
| `color_cycle` | Cycles through a palette of colors |
| `rich_palette_color` | Advanced palette-based color cycling with smooth transitions |
| `composite_color` | Combines multiple color providers |
| `breathe_color` | Breathing/pulsing color effect with brightness modulation |
| `pulsating_color` | Fast pulsing color effect (alias for breathe_color with curve_factor=1) |
### Animation Classes

View File

@ -742,7 +742,7 @@ get_error_report()
- **Factory function discovery** via introspection with existence checking
- **Parameter validation** using instance methods and has_param()
- **Symbol resolution** using module contents with fallback handling
- **Mathematical function detection** using dynamic introspection of ClosureValueProvider
- **Mathematical function detection** using dynamic introspection of closure_value
- **Automatic strip initialization** when no explicit strip configuration
### User Function Integration

View File

@ -115,8 +115,8 @@ import "providers/color_provider.be" as color_provider
register_to_animation(color_provider)
import "providers/color_cycle_color_provider.be" as color_cycle_color_provider
register_to_animation(color_cycle_color_provider)
import "providers/composite_color_provider.be" as composite_color_provider
register_to_animation(composite_color_provider)
# import "providers/composite_color_provider.be" as composite_color_provider
# register_to_animation(composite_color_provider)
import "providers/static_color_provider.be" as static_color_provider
register_to_animation(static_color_provider)
import "providers/rich_palette_color_provider.be" as rich_palette_color_provider

View File

@ -11,8 +11,8 @@
import "./core/param_encoder" as encode_constraints
#@ solidify:BreatheColorProvider,weak
class BreatheColorProvider : animation.oscillator_value
#@ solidify:breathe_color,weak
class breathe_color : animation.oscillator_value
# Additional parameter definitions for color-specific functionality
# The oscillator parameters (min_value, max_value, duration, form, etc.) are inherited
static var PARAMS = animation.enc_params({
@ -102,12 +102,4 @@ class BreatheColorProvider : animation.oscillator_value
end
end
# Factory function to create a pulsating color provider (sine wave)
def pulsating_color_provider(engine)
var provider = animation.breathe_color(engine)
provider.curve_factor = 1 # Pure cosine wave for pulsing effect
provider.duration = 1000 # Faster default duration for pulsing
return provider
end
return {'breathe_color': BreatheColorProvider, 'pulsating_color': pulsating_color_provider}
return {'breathe_color': breathe_color}

View File

@ -1,4 +1,4 @@
# ClosureValueProvider - ValueProvider that wraps a closure/function
# closure_value - ValueProvider that wraps a closure/function
#
# This provider allows using closures (functions) as value providers.
# The closure is called with (self, param_name, time_ms) parameters when
@ -17,8 +17,8 @@
import "./core/param_encoder" as encode_constraints
#@ solidify:ClosureValueProvider,weak
class ClosureValueProvider : animation.value_provider
#@ solidify:closure_value,weak
class closure_value : animation.value_provider
var _closure # We keep the closure as instance variable for faster dereferencing, in addition to PARAMS
# Static parameter definitions
@ -54,13 +54,13 @@ class ClosureValueProvider : animation.value_provider
end
end
# Create a ClosureValueProvider in a single call, by passing the closure argument
# Create a closure_value in a single call, by passing the closure argument
#
# This is used only by the transpiler, and is not usable in the DSL by itself
#
# @param engine: AnimationEngine - Animation engine reference
# @param closure: function - the closure to evaluate at run-time
# @return ClosureValueProvider - New ClosureValueProvider instance
# @return closure_value - New closure_value instance
def create_closure_value(engine, closure)
var provider = animation.closure_value(engine)
provider.closure = closure
@ -89,6 +89,6 @@ def animation_resolve(value, param_name, time_ms)
end
end
return {'closure_value': ClosureValueProvider,
return {'closure_value': closure_value,
'create_closure_value': create_closure_value,
'resolve': animation_resolve}

View File

@ -1,10 +1,10 @@
# ColorProvider interface for Berry Animation Framework
# color_provider interface for Berry Animation Framework
#
# This defines the core interface for color providers in the animation framework.
# Color providers generate colors based on time or values, which can be used by
# renderers or other components that need color information.
#
# ColorProvider now inherits from ValueProvider, making it a specialized value provider
# color_provider now inherits from ValueProvider, making it a specialized value provider
# for color values. This provides consistency with the ValueProvider system while
# maintaining the specific color-related methods.
#
@ -12,8 +12,8 @@
# - Constructor takes only 'engine' parameter
# - All other parameters set via virtual member assignment after creation
#@ solidify:ColorProvider,weak
class ColorProvider : animation.value_provider
#@ solidify:color_provider,weak
class color_provider : animation.value_provider
# LUT (Lookup Table) management for color providers
# Subclasses can use this to cache pre-computed colors for performance
# If a subclass doesn't use a LUT, this remains nil
@ -92,11 +92,11 @@ class ColorProvider : animation.value_provider
end
# Add a method to check if an object is a color provider
# Note: Since ColorProvider now inherits from ValueProvider, all ColorProviders
# Note: Since color_provider now inherits from ValueProvider, all ColorProviders
# are also ValueProviders and will be detected by animation.is_value_provider()
def is_color_provider(obj)
return isinstance(obj, animation.color_provider)
end
return {'color_provider': ColorProvider,
return {'color_provider': color_provider,
'is_color_provider': is_color_provider}

View File

@ -45,7 +45,7 @@ class rich_palette_color : animation.color_provider
"colors": {"type": "bytes", "default": nil}, # Palette bytes or predefined palette constant
"period": {"min": 0, "default": 5000}, # 5 seconds default, 0 = value-based only
"transition_type": {"enum": [1 #-animation.LINEAR-#, 5 #-animation.SINE-#], "default": 1 #-animation.LINEAR-#}
# brightness parameter inherited from ColorProvider base class
# brightness parameter inherited from color_provider base class
})
# Initialize a new rich_palette_color

View File

@ -1,7 +1,7 @@
# StaticColorProvider for Berry Animation Framework
#
# This color provider returns a single, static color.
# It's the simplest implementation of the ColorProvider interface.
# It's the simplest implementation of the color_provider interface.
#
# Follows the parameterized class specification:
# - Constructor takes only 'engine' parameter

View File

@ -1,4 +1,4 @@
# StripLengthProvider for Berry Animation Framework
# strip_length for Berry Animation Framework
#
# This value provider returns the length of the LED strip from the animation engine.
# It provides access to the strip length as a dynamic value that can be used by
@ -11,8 +11,8 @@
# - Constructor takes only 'engine' parameter
# - No additional parameters needed since strip length is obtained from engine
#@ solidify:StripLengthProvider,weak
class StripLengthProvider : animation.value_provider
#@ solidify:strip_length,weak
class strip_length : animation.value_provider
# Produce the strip length value
#
# @param name: string - Parameter name being requested (ignored)
@ -23,4 +23,4 @@ class StripLengthProvider : animation.value_provider
end
end
return {'strip_length': StripLengthProvider}
return {'strip_length': strip_length}

View File

@ -31,7 +31,7 @@ class CompositeColorProvider : animation.color_provider
# Add a provider to the list
#
# @param provider: ColorProvider - Provider to add
# @param provider: color_provider - Provider to add
# @return self for method chaining
def add_provider(provider)
self.providers.push(provider)

File diff suppressed because it is too large Load Diff

View File

@ -1,11 +1,11 @@
# Test file for Breathe Color Provider
#
# This file contains tests for the BreatheColorProvider class following parameterized class specification
# This file contains tests for the breathe_color class following parameterized class specification
#
# Command to run test is:
# ./berry -s -g -m lib/libesp32/berry_animation -e "import tasmota" lib/libesp32/berry_animation/tests/breathe_color_provider_test.be
print("Testing BreatheColorProvider...")
print("Testing breathe_color...")
# Import the core animation module
import animation
@ -130,11 +130,6 @@ var curve_5_color = curve_5_provider.produce_value("color", engine.time_ms)
print(f"Curve factor 1 at 3/8 cycle: 0x{curve_1_color :08x}")
print(f"Curve factor 5 at 3/8 cycle: 0x{curve_5_color :08x}")
# Test pulsating color provider factory
var pulsating = animation.pulsating_color(engine)
print(f"Pulsating provider curve_factor: {pulsating.curve_factor}")
print(f"Pulsating provider duration: {pulsating.duration}")
# Test parameter validation
try
blue_breathe.min_brightness = 300 # Should fail validation (max is 255)
@ -201,7 +196,6 @@ print(f"Provider string representation: {str(blue_breathe)}")
assert(provider != nil, "Default breathe color provider should be created")
assert(blue_breathe != nil, "Custom breathe color provider should be created")
assert(red_breathe != nil, "Red breathe color provider should be created")
assert(pulsating != nil, "Pulsating color provider should be created")
assert(blue_breathe.base_color == 0xFF0000FF, "Blue breathe should have correct base color")
assert(blue_breathe.min_brightness == 30, "Min brightness should be updated to 30")
assert(blue_breathe.max_brightness == 220, "Max brightness should be updated to 220")
@ -211,8 +205,6 @@ assert(blue_breathe.form == 4 #-COSINE-#, "Form should be COSINE")
assert(blue_breathe.min_value == 0, "Inherited min_value should be 0")
assert(blue_breathe.max_value == 255, "Inherited max_value should be 255")
assert(blue_breathe.engine == engine, "Provider should have correct engine reference")
assert(pulsating.curve_factor == 1, "Pulsating provider should have curve_factor 1")
assert(pulsating.duration == 1000, "Pulsating provider should have duration 1000")
assert(alpha_actual == 128, "Alpha channel should be preserved")
# Test that colors are different at different cycle points (breathing effect working)

View File

@ -1,12 +1,12 @@
# Test for ClosureValueProvider
# Test for closure_value
#
# This test verifies that the ClosureValueProvider correctly wraps
# This test verifies that the closure_value correctly wraps
# closures and evaluates them when producing values.
import animation
def test_closure_value_provider()
print("Testing ClosureValueProvider...")
print("Testing closure_value...")
# Create a mock engine
class MockEngine
@ -244,7 +244,7 @@ def test_closure_value_provider()
assert(boundary3 == 0, f"Expected 0, got {boundary3}")
print("✓ Edge cases with zero, negative, and boundary values work")
print("All ClosureValueProvider tests passed!")
print("All closure_value tests passed!")
# Fake add() method for value provider auto-registration
def add(obj)
@ -254,7 +254,7 @@ end
# Test mathematical helper methods
def test_closure_math_methods()
print("Testing ClosureValueProvider mathematical methods...")
print("Testing closure_value mathematical methods...")
# Create a mock engine
class MockEngine

View File

@ -1,7 +1,7 @@
# Test suite for CrenelPositionAnimation color handling
#
# This test verifies that CrenelPositionAnimation correctly handles both
# integer colors and ColorProvider instances.
# integer colors and color_provider instances.
import string
import animation
@ -44,9 +44,9 @@ def test_crenel_with_integer_color()
print("✓ CrenelPositionAnimation with integer color test passed")
end
# Test CrenelPositionAnimation with ColorProvider
# Test CrenelPositionAnimation with color_provider
def test_crenel_with_color_provider()
print("Testing CrenelPositionAnimation with ColorProvider...")
print("Testing CrenelPositionAnimation with color_provider...")
# Create engine and strip for testing
var strip = global.Leds(10)
@ -63,7 +63,7 @@ def test_crenel_with_color_provider()
var crenel = animation.crenel_animation(engine)
# Set parameters via virtual member assignment
crenel.color = color_provider # ColorProvider
crenel.color = color_provider # color_provider
crenel.back_color = 0x00000000 # transparent (default)
crenel.pos = 1
crenel.pulse_size = 2
@ -80,15 +80,15 @@ def test_crenel_with_color_provider()
frame.clear()
var result = crenel.render(frame, engine.time_ms, engine.strip_length)
assert(result == true, "Render should succeed with ColorProvider")
assert(result == true, "Render should succeed with color_provider")
assert(crenel.is_running == true, "Animation should be running")
print("✓ CrenelPositionAnimation with ColorProvider test passed")
print("✓ CrenelPositionAnimation with color_provider test passed")
end
# Test CrenelPositionAnimation with dynamic ColorProvider
# Test CrenelPositionAnimation with dynamic color_provider
def test_crenel_with_dynamic_color_provider()
print("Testing CrenelPositionAnimation with dynamic ColorProvider...")
print("Testing CrenelPositionAnimation with dynamic color_provider...")
# Create engine and strip for testing
var strip = global.Leds(10)
@ -105,7 +105,7 @@ def test_crenel_with_dynamic_color_provider()
var crenel = animation.crenel_animation(engine)
# Set parameters via virtual member assignment
crenel.color = palette_provider # dynamic ColorProvider
crenel.color = palette_provider # dynamic color_provider
crenel.back_color = 0x00000000 # transparent (default)
crenel.pos = 0
crenel.pulse_size = 4
@ -132,7 +132,7 @@ def test_crenel_with_dynamic_color_provider()
var result2 = crenel.render(frame, engine.time_ms, engine.strip_length)
assert(result2 == true, "Second render should succeed")
print("✓ CrenelPositionAnimation with dynamic ColorProvider test passed")
print("✓ CrenelPositionAnimation with dynamic color_provider test passed")
end
# Test CrenelPositionAnimation with generic ValueProvider
@ -217,7 +217,7 @@ def test_crenel_set_color_methods()
crenel.update(1000)
frame.clear()
var result2 = crenel.render(frame, engine.time_ms, engine.strip_length)
assert(result2 == true, "Render with ColorProvider should succeed")
assert(result2 == true, "Render with color_provider should succeed")
print("✓ CrenelPositionAnimation direct color assignment test passed")
end
@ -267,7 +267,7 @@ def test_crenel_tostring()
var str_provider = str(crenel_provider)
# Just verify the string is not empty
assert(size(str_provider) > 0, "String representation should not be empty")
print(f"ColorProvider string: {str_provider}")
print(f"color_provider string: {str_provider}")
print("✓ CrenelPositionAnimation tostring method test passed")
end

View File

@ -105,35 +105,35 @@ frame.clear()
result = palette_anim.render(frame, mock_engine.time_ms, mock_engine.strip_length)
assert(result, "Render should return true")
# Test 4: animation.solid with a composite provider
print("Test 4: animation.solid with a composite provider")
var rich_provider2 = animation.rich_palette_color(mock_engine)
rich_provider2.colors = animation.PALETTE_RAINBOW
rich_provider2.period = 1000
# Note: transition_type removed
rich_provider2.brightness = 255
# # Test 4: animation.solid with a composite provider
# print("Test 4: animation.solid with a composite provider")
# var rich_provider2 = animation.rich_palette_color(mock_engine)
# rich_provider2.colors = animation.PALETTE_RAINBOW
# rich_provider2.period = 1000
# # Note: transition_type removed
# rich_provider2.brightness = 255
var composite_provider = animation.composite_color(mock_engine)
composite_provider.providers = [cycle_provider, rich_provider2]
composite_provider.blend_mode = 0 # Overlay blend mode
# var composite_provider = animation.composite_color(mock_engine)
# composite_provider.providers = [cycle_provider, rich_provider2]
# composite_provider.blend_mode = 0 # Overlay blend mode
var composite_anim = animation.solid(mock_engine)
composite_anim.color = composite_provider
composite_anim.priority = 10
composite_anim.duration = 0
composite_anim.loop = false # Use boolean instead of integer
composite_anim.opacity = 255
assert(composite_anim != nil, "Failed to create composite animation")
# var composite_anim = animation.solid(mock_engine)
# composite_anim.color = composite_provider
# composite_anim.priority = 10
# composite_anim.duration = 0
# composite_anim.loop = false # Use boolean instead of integer
# composite_anim.opacity = 255
# assert(composite_anim != nil, "Failed to create composite animation")
# Start the animation
composite_anim.start()
assert(composite_anim.is_running, "Animation should be running")
# # Start the animation
# composite_anim.start()
# assert(composite_anim.is_running, "Animation should be running")
# Update and render
composite_anim.update(mock_engine.time_ms)
frame.clear()
result = composite_anim.render(frame, mock_engine.time_ms, mock_engine.strip_length)
assert(result, "Render should return true")
# # Update and render
# composite_anim.update(mock_engine.time_ms)
# frame.clear()
# result = composite_anim.render(frame, mock_engine.time_ms, mock_engine.strip_length)
# assert(result, "Render should return true")
# Test 5: Changing color provider dynamically
print("Test 5: Changing color provider dynamically")

View File

@ -23,7 +23,7 @@ var mock_engine = MockEngine()
# Test that get_param_value() calls produce_value() for ColorProviders
def test_get_param_value_with_color_provider()
print("Testing get_param_value() with ColorProvider...")
print("Testing get_param_value() with color_provider...")
# Create a test animation using new constructor pattern
var test_anim = animation.animation(mock_engine)
@ -32,7 +32,7 @@ def test_get_param_value_with_color_provider()
test_anim.loop = false
test_anim.opacity = 255
# Create a ColorProvider that we can track calls on
# Create a color_provider that we can track calls on
class TrackingColorProvider : animation.color_provider
var color
var produce_value_called
@ -55,7 +55,7 @@ def test_get_param_value_with_color_provider()
var tracking_provider = TrackingColorProvider(mock_engine, 0xFF00FF00) # Green
# Set the ColorProvider (using the 'color' parameter that exists in base Animation)
# Set the color_provider (using the 'color' parameter that exists in base Animation)
test_anim.color = tracking_provider
# Call get_param_value() - should call produce_value()
@ -64,7 +64,7 @@ def test_get_param_value_with_color_provider()
assert(result == 0xFF00FF00, "Should return the color value")
assert(tracking_provider.produce_value_called == 1, "Should call produce_value() once")
print("✓ get_param_value() with ColorProvider test passed")
print("✓ get_param_value() with color_provider test passed")
end
# Test that get_param_value() calls produce_value() for generic ValueProviders

View File

@ -1,6 +1,6 @@
# Test file for StripLengthProvider class
# Test file for strip_length class
#
# This file contains tests for the StripLengthProvider class which provides
# This file contains tests for the strip_length class which provides
# access to the LED strip length as a dynamic value provider.
#
# Command to run test is:
@ -8,7 +8,7 @@
import animation
print("Testing StripLengthProvider...")
print("Testing strip_length...")
# Create a mock LED strip for testing
class MockStrip
@ -51,7 +51,7 @@ def test_basic_functionality()
var strip = MockStrip(length)
var engine = animation.create_engine(strip)
# Create StripLengthProvider
# Create strip_length
var provider = animation.strip_length(engine)
# Test the provider
@ -150,7 +150,7 @@ def run_all_tests()
test_integration()
test_engine_consistency()
print("All StripLengthProvider tests passed!")
print("All strip_length tests passed!")
return true
end