def blink(self, edge=0.5, reverse=False):
     if isinstance(edge, str):
         edge = {soft: 0.25, medium: 0.5, hard: 0.75, total: 1.0}[edge]
     v1 = 1.0 - edge if reverse else 1.0
     v2 = 1.0 if reverse else 1.0 - edge
     BrightnessAnimation(
         HalfFloatFunc(ConstFloatFunc(v1), ConstFloatFunc(v2))).apply()
 def blink_repeat(self, repeat, edge=0.5):
     if isinstance(edge, str):
         edge = {soft: 0.25, medium: 0.5, hard: 0.75, total: 1.0}[edge]
     BrightnessAnimation(
         RepeatFloatFunc(
             repeat,
             HalfFloatFunc(ConstFloatFunc(1.0),
                           ConstFloatFunc(1.0 - edge)))).apply()
 def saw_tooth(self, edge=0.6, reverse=False):
     if isinstance(edge, str):
         edge = {soft: 0.4, medium: 0.6, hard: 0.8, total: 1.0}[edge]
     min_val = 1.0 - edge if reverse else 1.0
     max_val = 1.0 if reverse else 1.0 - edge
     BrightnessAnimation(LinearFloatFunc(min_val, max_val)).apply()
 def fade_out(self):
     BrightnessAnimation(LinearFloatFunc(1.0, 0.0)).apply()
 def fade_in(self):
     BrightnessAnimation(LinearFloatFunc(0.0, 1.0)).apply()
 def breath(self, edge=0.6, reverse=False):
     if isinstance(edge, str):
         edge = {soft: 0.4, medium: 0.6, hard: 0.8, total: 1.0}[edge]
     phase = 0.25 if reverse else -0.25
     BrightnessAnimation(SinFloatFunc(1.0 - edge, 1.0, phase, 1)).apply()
 def brightness(self, factor):
     BrightnessAnimation(ConstFloatFunc(factor)).apply()
 def brightness(self, val):
     BrightnessAnimation(ConstFloatFunc(val)).apply()
Esempio n. 9
0
from infra.animations_factory import effect, color
from infra.timing import beats, cycle, get_timing, set_timing
from led_objects.groups import group1, group2, group8, group3, group6, group4, group7, group5
from led_objects.objects_selector import elements

front_to_back = [
    group1, [group2, group8], [group3, group6], group4, group7, group5
]
back_to_front = list(reversed(front_to_back))
right_to_left = [[group3, group4], [group2, group7], [group8],
                 [group1, group5], group6]
left_to_right = list(reversed(right_to_left))

spcial_order = [front_to_back, back_to_front, right_to_left, left_to_right]

fade_out_options = [BrightnessAnimation(LinearFloatFunc(1.0, 0.0))]

fill_out_options = [
    FillAnimation(ConstFloatFunc(0.0), LinearFloatFunc(1.0, 0.0)),
    FillAnimation(LinearFloatFunc(0.0, 1.0), ConstFloatFunc(1.0)),
    FillAnimation(LinearFloatFunc(0.0, 0.5), LinearFloatFunc(1.0, 0.5))
]

out_options = [fade_out_options, fill_out_options]


def get_random_fade_func():
    func_class = random.choice(out_options)
    return random.choice(func_class)