Example #1
0
File: ryb.py Project: zrlram/leds
    def update_at_progress(self, progress, new_loop, loop_instance):

        if self.mode == 0:
            # Color striped from top to bottom by slices
            v_range = tween.easeInQuad(0.1, 0.98, (self.cm.brightness + 1.0)/2.0)
            per_slice = v_range / len(self.range)

            for idx, sl in enumerate(self.range):
                hue = progress - (idx * per_slice) + self.offsets[0]
                while hue > 1.0:
                    hue -= 1.0
                while hue < 0.0:
                    hue += 1.0

                hsv = (hue, 1.0, 1.0)

                rgbTuple = color2.hsvRYB_to_rgb(hsv)
                rgbTuple = (int(rgbTuple[0]), int(rgbTuple[1]), int(rgbTuple[2]))

                for i in sl:
                    self.geometry.set_pixel(i, rgbTuple)

            self.geometry.draw()


        elif self.mode == 1:
            # Each bird gets a unique color based on it's offset
            for idx,bird in enumerate(self.range):
                hue = progress + self.offsets[idx]
                if hue > 1.0:
                    hue -= 1.0
                hsv = (hue, 1.0, 1.0)

                rgbTuple = color2.hsvRYB_to_rgb(hsv)
                rgbTuple = (int(rgbTuple[0]), int(rgbTuple[1]), int(rgbTuple[2]))

                for i in bird:
                    self.geometry.set_pixel(i, rgbTuple)

            self.geometry.draw()

        else:
            # Everything the same color
            hsv = (progress + self.offsets[0], 1.0, 1.0)

            rgbTuple = color2.hsvRYB_to_rgb(hsv)
            rgbTuple = (int(rgbTuple[0]), int(rgbTuple[1]), int(rgbTuple[2]))

            for i in range(self.geometry.get_nof_pixels()):
                self.geometry.set_pixel(i, rgbTuple)

            self.geometry.draw()
Example #2
0
File: color.py Project: zrlram/leds
def rainbow_(progress, step, brightness, numSlices=18):
    # step chooses which color of the rainbow
    # progress is the blender parameter from 0 to 1

    v_range = tween.easeInQuad(0.1, 0.98, (brightness + 1.0)/2.0)
    per_slice = v_range / numSlices
            
    hue = progress - (step % numSlices * per_slice) 
    while hue > 1.0:
        hue -= 1.0
    while hue < 0.0:
        hue += 1.0

    hsv = (hue, 1.0, 1.0)

    rgbTuple = color2.hsvRYB_to_rgb(hsv)
    return (int(rgbTuple[0]), int(rgbTuple[1]), int(rgbTuple[2]))