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 fill_out(self, reverse=False): if reverse: FillAnimation(LinearFloatFunc(0.0, 1.0), ConstFloatFunc(1.0)).apply() else: FillAnimation(ConstFloatFunc(0.0), LinearFloatFunc(1.0, 0.0)).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 hue_blink(self, edge=0.5, reverse=False): if isinstance(edge, str): edge = {soft: 0.05, medium: 0.12, hard: 0.25, total: 0.5}[edge] if reverse: edge = -edge HueShiftAnimation( HalfFloatFunc(ConstFloatFunc(1.0), ConstFloatFunc(1.0 - edge))).apply()
def snake(self, tail=1.0, switch_direction=False): if isinstance(tail, str): tail = {short: 0.25, medium: 1.0, long: 4.0}[tail] if switch_direction: SnakeAnimation(LinearFloatFunc(1.0, 0.0 - tail), ConstFloatFunc(tail), ConstBooleanFunc(not switch_direction)).apply() else: SnakeAnimation(LinearFloatFunc(0.0, 1.0 + tail), ConstFloatFunc(tail), ConstBooleanFunc(not switch_direction)).apply()
def brightness(self, factor): BrightnessAnimation(ConstFloatFunc(factor)).apply()
def gradient(self, hue_start, hue_end): Rainbow(ConstFloatFunc(hue_start), ConstFloatFunc(hue_end)).apply()
def fill_out_in(self, edge=1.0): FillAnimation( ConstFloatFunc(0.0), HalfFloatFunc(LinearFloatFunc(1.0, 1 - edge), LinearFloatFunc(1 - edge, 1.0))).apply()
def fill_in_out(self, edge=1.0): FillAnimation( ConstFloatFunc(0.0), HalfFloatFunc(LinearFloatFunc(0.0, edge), LinearFloatFunc(edge, 0.0))).apply()
def gradient(self, hue_start, hue_end): self.led_object.add_animation( Rainbow(timing.get_timing(), ConstFloatFunc(hue_start), ConstFloatFunc(hue_end)))
def confetti(self): ConfettiAnimation(ConstFloatFunc(0.5)).apply()
def brightness(self, val): BrightnessAnimation(ConstFloatFunc(val)).apply()
def hue_shift(self, edge=0.5): if isinstance(edge, str): edge = {soft: 0.05, medium: 0.12, hard: 0.25, total: 0.5}[edge] HueShiftAnimation(ConstFloatFunc(edge)).apply()
def change_on_cycle_oppsite_hues(timing, number_of_pixels=3): return AlternateAnimation(timing, number_of_pixels, equal_spreads.change_on_cycle(timing), ConstFloatFunc(0.5))
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) def out_gradually(fade_order, func): """ does a fade out effect that swipe the objects over time,
def snake_down_up(self, tail=1.0): if isinstance(tail, str): tail = {short: 0.25, medium: 1.0, long: 4.0}[tail] SnakeAnimation(SinFloatFunc(0.0, 1.0, -0.25, 1), ConstFloatFunc(tail), ConstBooleanFunc(False)).apply()
def fill(self): FillAnimation(ConstFloatFunc(0.0), LinearFloatFunc(0.0, 1.0)).apply()
def fill_in_steps(self, num_steps): FillAnimation(ConstFloatFunc(0.0), StepsFloatFunc(num_steps, 1 / num_steps, 1 / num_steps)).apply()
def static_full_rainbow(timing): return Rainbow(timing, ConstFloatFunc(0.0), ConstFloatFunc(1.0))