Berry animation animation as opacity (#23852)
This commit is contained in:
parent
d5114c32c5
commit
356a399569
@ -0,0 +1,76 @@
|
||||
# Generated Berry code from Animation DSL
|
||||
# Source: demo_pattern_fire_opacity.anim
|
||||
#
|
||||
# This file was automatically generated by compile_all_examples.sh
|
||||
# Do not edit manually - changes will be overwritten
|
||||
|
||||
import animation
|
||||
|
||||
# Pattern fire.anim
|
||||
# Define fire palette from black to yellow
|
||||
# Auto-generated strip initialization (using Tasmota configuration)
|
||||
var engine = animation.init_strip()
|
||||
|
||||
var fire_colors_ = bytes("FF800000" "FFFF0000" "FFFF4500" "FFFFFF00")
|
||||
var strip_len_ = animation.strip_length(engine)
|
||||
var fire_color_ = animation.rich_palette(engine)
|
||||
fire_color_.palette = fire_colors_
|
||||
var background_ = animation.solid(engine)
|
||||
background_.color = 0xFF000088
|
||||
background_.priority = 20
|
||||
var eye_mask_ = animation.beacon_animation(engine)
|
||||
eye_mask_.color = 0x00000000
|
||||
eye_mask_.back_color = 0xFFFFFFFF
|
||||
eye_mask_.pos = (def (engine)
|
||||
var provider = animation.cosine_osc(engine)
|
||||
provider.min_value = (-1)
|
||||
provider.max_value = animation.create_closure_value(engine, def (self) return self.resolve(strip_len_) - 2 end)
|
||||
provider.duration = 3000
|
||||
return provider
|
||||
end)(engine)
|
||||
eye_mask_.beacon_size = 4 # small 3 pixels eye
|
||||
eye_mask_.slew_size = 2 # with 2 pixel shading around
|
||||
eye_mask_.priority = 5
|
||||
var fire_pattern_ = animation.palette_gradient_animation(engine)
|
||||
fire_pattern_.color_source = fire_color_
|
||||
fire_pattern_.spatial_period = animation.create_closure_value(engine, def (self) return self.resolve(strip_len_) / 4 end)
|
||||
fire_pattern_.opacity = eye_mask_
|
||||
engine.add_animation(background_)
|
||||
engine.add_animation(fire_pattern_)
|
||||
engine.start()
|
||||
|
||||
|
||||
#- Original DSL source:
|
||||
# Pattern fire.anim
|
||||
|
||||
# Define fire palette from black to yellow
|
||||
palette fire_colors = [
|
||||
0x800000 # Dark red
|
||||
0xFF0000 # Red
|
||||
0xFF4500 # Orange red
|
||||
0xFFFF00 # Yellow
|
||||
]
|
||||
|
||||
set strip_len = strip_length()
|
||||
color fire_color = rich_palette(palette=fire_colors)
|
||||
|
||||
animation background = solid(color=0x000088, priority=20)
|
||||
run background
|
||||
|
||||
animation eye_mask = beacon_animation(
|
||||
color = transparent
|
||||
back_color = white
|
||||
pos = cosine_osc(min_value = -1, max_value = strip_len - 2, duration = 3s)
|
||||
beacon_size = 4 # small 3 pixels eye
|
||||
slew_size = 2 # with 2 pixel shading around
|
||||
priority = 5
|
||||
)
|
||||
|
||||
animation fire_pattern = palette_gradient_animation(
|
||||
color_source = fire_color
|
||||
spatial_period = strip_len / 4
|
||||
opacity = eye_mask
|
||||
)
|
||||
|
||||
run fire_pattern
|
||||
-#
|
||||
@ -1,41 +0,0 @@
|
||||
# Generated Berry code from Animation DSL
|
||||
# Source: pattern_fire.anim
|
||||
#
|
||||
# This file was automatically generated by compile_all_examples.sh
|
||||
# Do not edit manually - changes will be overwritten
|
||||
|
||||
import animation
|
||||
|
||||
# Pattern fire.anim
|
||||
# Define fire palette from black to yellow
|
||||
# Auto-generated strip initialization (using Tasmota configuration)
|
||||
var engine = animation.init_strip()
|
||||
|
||||
var fire_colors_ = bytes("FF800000" "FFFF0000" "FFFF4500" "FFFFFF00")
|
||||
var strip_len_ = animation.strip_length(engine)
|
||||
var fire_color_ = animation.rich_palette(engine)
|
||||
fire_color_.palette = fire_colors_
|
||||
var fire_pattern_ = animation.palette_gradient_animation(engine)
|
||||
fire_pattern_.color_source = fire_color_
|
||||
fire_pattern_.spatial_period = animation.create_closure_value(engine, def (self) return self.resolve(strip_len_) / 2 end)
|
||||
engine.add_animation(fire_pattern_)
|
||||
engine.start()
|
||||
|
||||
|
||||
#- Original DSL source:
|
||||
# Pattern fire.anim
|
||||
|
||||
# Define fire palette from black to yellow
|
||||
palette fire_colors = [
|
||||
0x800000 # Dark red
|
||||
0xFF0000 # Red
|
||||
0xFF4500 # Orange red
|
||||
0xFFFF00 # Yellow
|
||||
]
|
||||
|
||||
set strip_len = strip_length()
|
||||
color fire_color = rich_palette(palette=fire_colors)
|
||||
animation fire_pattern = palette_gradient_animation(color_source=fire_color, spatial_period=strip_len/2)
|
||||
|
||||
run fire_pattern
|
||||
-#
|
||||
@ -0,0 +1,32 @@
|
||||
# Pattern fire.anim
|
||||
|
||||
# Define fire palette from black to yellow
|
||||
palette fire_colors = [
|
||||
0x800000 # Dark red
|
||||
0xFF0000 # Red
|
||||
0xFF4500 # Orange red
|
||||
0xFFFF00 # Yellow
|
||||
]
|
||||
|
||||
set strip_len = strip_length()
|
||||
color fire_color = rich_palette(palette=fire_colors)
|
||||
|
||||
animation background = solid(color=0x000088, priority=20)
|
||||
run background
|
||||
|
||||
animation eye_mask = beacon_animation(
|
||||
color = transparent
|
||||
back_color = white
|
||||
pos = cosine_osc(min_value = -1, max_value = strip_len - 2, duration = 3s)
|
||||
beacon_size = 4 # small 3 pixels eye
|
||||
slew_size = 2 # with 2 pixel shading around
|
||||
priority = 5
|
||||
)
|
||||
|
||||
animation fire_pattern = palette_gradient_animation(
|
||||
color_source = fire_color
|
||||
spatial_period = strip_len / 4
|
||||
opacity = eye_mask
|
||||
)
|
||||
|
||||
run fire_pattern
|
||||
@ -1,15 +0,0 @@
|
||||
# Pattern fire.anim
|
||||
|
||||
# Define fire palette from black to yellow
|
||||
palette fire_colors = [
|
||||
0x800000 # Dark red
|
||||
0xFF0000 # Red
|
||||
0xFF4500 # Orange red
|
||||
0xFFFF00 # Yellow
|
||||
]
|
||||
|
||||
set strip_len = strip_length()
|
||||
color fire_color = rich_palette(palette=fire_colors)
|
||||
animation fire_pattern = palette_gradient_animation(color_source=fire_color, spatial_period=strip_len/2)
|
||||
|
||||
run fire_pattern
|
||||
@ -152,19 +152,25 @@ class Animation : animation.parameterized_object
|
||||
|
||||
# Access parameters via virtual members (auto-resolves ValueProviders)
|
||||
var current_color = self.color
|
||||
var current_opacity = self.opacity
|
||||
|
||||
# Fill the entire frame with the current color if not transparent
|
||||
if (current_color != 0x00000000)
|
||||
frame.fill_pixels(current_color)
|
||||
end
|
||||
|
||||
# Handle opacity - can be number, frame buffer, or animation
|
||||
self._apply_opacity(frame, current_opacity, time_ms)
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
# Post-processing of rendering
|
||||
#
|
||||
# @param frame: FrameBuffer - The frame buffer to render to
|
||||
# @param time_ms: int - Current time in milliseconds
|
||||
def post_render(frame, time_ms)
|
||||
# Handle opacity - can be number, frame buffer, or animation
|
||||
var current_opacity = self.opacity
|
||||
self._apply_opacity(frame, current_opacity, time_ms)
|
||||
end
|
||||
|
||||
# Apply opacity to frame buffer - handles numbers and animations
|
||||
#
|
||||
# @param frame: FrameBuffer - The frame buffer to apply opacity to
|
||||
|
||||
@ -256,6 +256,7 @@ class AnimationEngine
|
||||
var rendered = anim.render(self.temp_buffer, time_ms)
|
||||
|
||||
if rendered
|
||||
anim.post_render(self.temp_buffer, time_ms)
|
||||
# Blend temp buffer into main buffer
|
||||
self.frame_buffer.blend_pixels(self.temp_buffer)
|
||||
end
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user