Example #1
0
 def test_color_blend(self):
     self.assertEqual(colors.color_blend(colors.Red, colors.Green),
                      (255, 255, 1))
     self.assertEqual(colors.color_blend(colors.Red, colors.White),
                      (255, 255, 255))
     self.assertEqual(colors.color_blend(colors.Red, colors.Black),
                      (255, 1, 1))
Example #2
0
    def step(self, amt=1):
        led = self._led
        led.all_off()

        now = util.getNow()

        led.fillScreen(util.getSunColor(now))

        text = str(now.hour)
        (width, height) = font.str_dim(text, '6x4', final_sep=False)
        led.drawText(str(now.hour),
                     x=math.floor((led.width - width) / 2),
                     y=math.floor((led.height - height) / 2),
                     color=self.digitColor,
                     bg=None,
                     font='6x4')

        self.minutex = self.minutex * .25 + led.width * (
            now.minute * 60 + now.second) / 3600 * 0.75
        self.secondx = self.secondx * .25 + led.width * now.second / 60 * 0.75

        for x in range(0, led.width):
            minuteLevel = 128 - (x - self.minutex) * (x - self.minutex) * 60
            if minuteLevel < 0:
                minuteLevel = 0

            secondLevel = 128 - (x - self.secondx) * (x - self.secondx) * 60
            if (secondLevel < 0):
                secondLevel = 0

            pointerColor = colors.color_blend(
                colors.color_scale(colors.DarkGreen, secondLevel),
                colors.color_scale(colors.DarkRed, minuteLevel))
            if minuteLevel > secondLevel:
                pointerLevel = minuteLevel
            else:
                pointerLevel = secondLevel

            for y in range(0, led.height):
                color = colors.color_blend(
                    colors.color_scale(led.get(x, y), 256 - pointerLevel),
                    colors.color_scale(pointerColor, pointerLevel))

                led.set(x, y, color)

        self._step += amt
Example #3
0
 def render(self):
    arr = [(0,0,0) for i in range(0, self.numLED)]
    arr1 = self.pattern1.render()
    arr2 = self.pattern2.render()
    
    for x in range(0, len(arr)):
       arr[x] = colors.color_blend(arr1[x], arr2[x])
    
    return arr
Example #4
0
    def step(self, amt = 1):
	for i in range(self._led.numLEDs):
		color = colors.color_scale(self._led.get(i), 245)
		
		if i == (self._step % self._led.numLEDs):
			color = colors.color_blend(color, colors.hue2rgb_spectrum(self._step % 127))

		self._led.set(i, color);
        #Increment the internal step by the given amount
        self._step += amt
Example #5
0
    def __init__(self, led, start=0, end=-1, backgroundColor=colors.White, clockColor=colors.Red):
        # The base class MUST be initialized by calling super like this
        super(StripeClock, self).__init__(led, start, end)
        self._backgroundColor = backgroundColor
        self._color = colors.color_blend(colors.color_scale(backgroundColor, 128), clockColor)
        self._color1 = (255, 212, 125)
        self._color2 = (245, 135, 76)
        self._myadd = lambda xs, ys: tuple(x + y for x, y in izip(xs, ys))

        print "Clock color:" + str(self._color)
        print "Background color:" + str(self._backgroundColor)
Example #6
0
    def step(self, amt = 1):
        now = util.getNow()
        startOfDay = util.getStartOfDay(now)

        led = self._led
        showMarker = True
        for x in range(0, led.width):
            for y in range(0, led.height):
                current = startOfDay + datetime.timedelta(days=1) * (x * led.height + y) / led.numLEDs
                color = util.getSunColor(current)

                if showMarker and current >= now:
                    color = colors.color_blend(colors.Red, colors.color_scale(color, 128))
                    showMarker = False

                led.set(x, y, color)

        return