def __init__(self, **kwargs): kwargs['color'] = RGB() super().__init__(**kwargs) self.pattern_name = "FireWork" self.increment = Modifier('fire power', 10.0, minimum=0.001, maximum=0.25) self.spark = Modifier('sparks', 10.0, minimum=0, maximum=1 / self.strip_length) for idx in range(self.strip_length): self.pixels[idx]['timestep'] = 0 self.centers = [] self.modifiers = dict( increment=self.increment, spark=self.spark, )
def __init__(self, **kwargs): super().__init__(**kwargs) self.pattern_name = "Equation" # max range for function self.max_range = self.strip_length * 1000 self.fns = {} # r,g,b functions in string format self.red_equation = Modifier('red equation', "cos(t)", on_change=self.on_change_red) self.green_equation = Modifier('green equation', "idx", on_change=self.on_change_green) self.blue_equation = Modifier('blue equation', "sin(t)", on_change=self.on_change_blue) # array of colors self.rs = [] self.gs = [] self.bs = [] # time step self.t = 1 self.modifiers = dict( red_equation=self.red_equation, green_equation=self.green_equation, blue_equation=self.blue_equation, )
def __init__(self, **kwargs): super().__init__(**kwargs) self.pattern_name = "ColorMap" self.cmap_name = Modifier('cmap name', random.choice(cmaps), options=cmaps, on_change=self.init_cmap) self.cmap = None self.init_cmap(self.cmap_name()) self.lower_bound = Modifier('lower', 0, minimum=0, maximum=self.strip_length) self.upper_bound = Modifier('upper', 0, minimum=0, maximum=self.strip_length) self.specular = Modifier('specular', False) self.rate.value = 100 self.modifiers = dict( cmap_name=self.cmap_name, lower_bound=self.lower_bound, upper_bound=self.upper_bound, specular=self.specular, )
def __init__(self, **kwargs): super().__init__(**kwargs) self.cooling = Modifier('cooling', 10, minimum=1, maximum=100) self.sparking = Modifier('sparking', 40, minimum=1, maximum=255) self.cooldown_list = [0 for _ in range(self.strip_length)] self.pattern_name = "Fire" self.mid = self.strip_length // 2 self.modifiers = dict(cooling=self.cooling, sparking=self.sparking)
def __init__(self, **kwargs): super().__init__(**kwargs) self.size = Modifier('size', 5, minimum=1, maximum=self.strip_length) self.trail_decay = Modifier('trail decay', 5, minimum=0, maximum=1) self.random_decay = Modifier('random decay', True) self.step = 0 self.pattern_name = "Meteor" self.modifiers = dict(size=self.size, trail_decay=self.trail_decay, random_decay=self.random_decay)
def __init__(self, **kwargs): super().__init__(**kwargs) self.fires = Modifier('fires', self.strip_length // 50, minimum=1, maximum=self.strip_length) self.loss = Modifier('speed', 25, minimum=1, maximum=80) self.step = 0 self.centers = {randint(0, self.strip_length - 1): self.empty_center() for _ in range(self.fires())} self.pattern_name = "FireWork" self.modifiers = dict( fires=self.fires, loss=self.loss )
def __init__(self, **kwargs): super().__init__(**kwargs) self.pattern_name = "Storm" self.rain = Modifier('rain intensity', 10.0, minimum=0, maximum=0.2) self.thunder = Modifier('thunder intensity', 5.0, minimum=0, maximum=0.2) self.thunder_size = Modifier('thunder size', 80, minimum=0, maximum=self.strip_length) self.thunder_color = RGB(white=True) self.rain_color = RGB(r=70, g=100, b=255, a=255) self.thunder_centers = {} for idx in range(self.strip_length): self.pixels[idx]['rain'] = 0
def __init__(self, **kwargs): super().__init__(**kwargs) self.pattern_name = "Perlin" self.x_div = Modifier('horizontal', 2**4, minimum=1, maximum=2**10) self.y_div = Modifier('vertical', 2**4, minimum=1, maximum=2**10) self.op = OpenSimplex() self.counter = 0 self.modifiers = dict( x_div=self.x_div, y_div=self.y_div, )
def __init__(self, handler, rate, pixels, color=RGB()): """ :param handler: The handler for the led strip, either a DotStar_Emulator.emulator.send_test_data.App or a rpi.pi_handler.PiHandler :param rate:(float) the rate for the pixel update :param pixels: (int) the number of pixels :param color: (default RGB), the initial color for the leds """ # init the thread and the handler threading.Thread.__init__(self, name="PatternThread") self.handler = handler self.rate = Modifier("rate", float(rate), minimum=0.0, maximum=1.5) self.stop = False self.strip_length = pixels self.color = color self.alpha = 255 # boolean value to randomize color self.randomize_color = False # string for patter name self.pattern_name = None # dictionary storing the modifiers to be implemented in the web app self.modifiers = dict() # init and set the pixels to the default color self.pixels = {idx: Pixel(index=idx, color=self.color.copy(), set_func=self.color_set) for idx in range(self.strip_length + 1)}
def __init__(self, **kwargs): super().__init__(**kwargs) self.point_number = Modifier('points', 30, minimum=1, maximum=self.strip_length) self.rate_start = Modifier('start rate', 40, minimum=1, maximum=101) self.rate_end = Modifier('end rate', 4, minimum=1, maximum=101) # assert there are no more points than leds self.centers = {randint(0, self.strip_length - 1): self.empty_center() for _ in range(self.point_number())} self.pattern_name = "Fading" self.modifiers = dict( point_number=self.point_number, rate_start=self.rate_start, rate_end=self.rate_end )
def __init__(self, **kwargs): super().__init__(**kwargs) self.increasing = False self.speed = Modifier('speed', 50, minimum=1, maximum=255) self.pattern_name = "Pulse" self.modifiers = dict(loss=self.speed, )
def __init__(self, **kwargs): super().__init__(**kwargs) self.counter = 0 self.color = RGB(white=True) self.r_phi = Modifier('red shift', 0.0, minimum=0, maximum=pi) self.b_phi = Modifier('blue shift', 35.0, minimum=0, maximum=pi) self.g_phi = Modifier('green shift', 70.0, minimum=0, maximum=pi) self.max_range = Modifier('max range', 1, minimum=1, maximum=self.strip_length) self.pattern_name = "Rainbow" self.modifiers = dict( r_phi=self.r_phi, b_phi=self.b_phi, g_phi=self.g_phi, max_range=self.max_range, )
def __init__(self, **kwargs): super().__init__(**kwargs) self.pattern_name = "Ocean" self.x_div = Modifier('horizontal', 2**4, minimum=1, maximum=2**10) self.y_div = Modifier('vertical', 2**4, minimum=1, maximum=2**10) # measure of blueness (the more the more blue) self.deepness = Modifier('deepness', 10, minimum=1, maximum=255) self.op = OpenSimplex() self.counter = 0 self.counter = 0 self.modifiers = dict( x_div=self.x_div, y_div=self.y_div, deepness=self.deepness, )
def __init__(self, **kwargs): super().__init__(**kwargs) # min space between trail end and trail start self.centers = Modifier('centers', 10, minimum=self.strip_length // 2, maximum=self.strip_length) self.trail = Modifier('trail size', 3, minimum=1, maximum=self.strip_length // 2) self.counter = 0 self.pattern_name = "Snow" self.color = RGB(white=True) self.modifiers = dict( trail=self.trail, centers=self.centers, )
def __init__(self, **kwargs): super().__init__(**kwargs) self.pattern_name = "Image" self.image = None self.image_url = Modifier('image url', "https://raw.githubusercontent.com/nicofirst1/ledypi/master/Resources/logo.png", on_change=self.on_change) self.step = 0 self.modifiers = dict( loss=self.image_url, )
def __init__(self, **kwargs): super().__init__(**kwargs) self.pattern_name = "Music" CONFIGS['n_pixels'] = self.strip_length # init visualizer self.vis = Visualizer(CONFIGS) # dict used to set the visualizer effect self.effect_dict = dict( spectrum=self.vis.visualize_spectrum, energy=self.vis.visualize_energy, scroll=self.vis.visualize_scroll, ) # name of the effect to be used self.effect = Modifier('visualizer', "spectrum", options=list(self.effect_dict.keys()), on_change=self.on_change) self._rate = Modifier('Delay', 0, minimum=0, maximum=0) self.modifiers = dict( effect=self.effect, ) # attributes for the mic self.p = None self.stream = None self.frames_per_buffer = int(CONFIGS['mic_rate'] / CONFIGS['fps']) try: # do not initialize if the pattern is temp if kwargs['handler'] is not None: self.setup() except OSError: music_logger.warning(f"Could not initialize the audio stream")
def __init__(self, **kwargs): super().__init__(**kwargs) self.pattern_name = "Sorting" rainbow = rainbow_colormap(n=self.strip_length + 1, end=9 / 10) # define pixels as a list of (index, color) tuples self.pixels = [(idx, rainbow[idx]) for idx in range(self.strip_length + 1)] random.shuffle(self.pixels) # then cast to ToSort type srt = ToSort(self.color_set, self.rate) srt.extend(self.pixels) self.pixels = srt # dict used to set the sorting effect self.sorting_dict = dict( bubble_sort=bubble_sort, insertion_sort=insertion_sort, shell_sort=shell_sort, selection_sort=selection_sort, heap_sort=heap_sort, quick_sort=quick_sort, comb_sort=comb_sort, cycle_sort=cycle_sort, cocktail_sort=cocktail_sort, bitonic_sort=bitonic_sort, pancake_sort=pancake_sort, stooge_sort=stooge_sort, oddEven_sort=odd_even_sort, ) self.sorting_alg = bubble_sort self.sorting_modifier = Modifier("Sorting algorithm", "quick_sort", options=list( self.sorting_dict.keys()), on_change=self.on_sort_change) self.modifiers = dict(sorting_modifier=self.sorting_modifier)