def huecycle(): tree.color = Color('red') timeout = time.time() + ShowFor while True: tree.color += Hue(deg=5) if time.time() > timeout: break;
def RGBXhue(RGBXmashue): timeout = 150 timeout_start = time.time() tree.brightness = 0.1 tree.color = Color(RGBXmashue) while time.time() < timeout_start + timeout: tree.color += Hue(deg=1) """except KeyboardInterrupt:
def RGBXhue(): timeout_start = time.time() tree.brightness = 0.1 tree.color = Color('red') try: while time.time() < timeout_start + timeout: tree.color += Hue(deg=1) except KeyboardInterrupt: tree.brightness = 0.0 tree.close()
def test_color_mul(): verify_color(Color('magenta') * Color('blue'), Color('blue')) verify_color(Color('magenta') * Color('white'), Color('magenta')) verify_color(Color('magenta') * Red(0.5), Color(0.5, 0, 1)) verify_color(Color('magenta') * Green(0.5), Color('magenta')) verify_color(Color('magenta') * Blue(0.5), Color(1, 0, 0.5)) verify_color(Color('magenta') * Hue(0), Color('red')) verify_color(Color('magenta') * Lightness(0.5), Color(0.5, 0.0, 0.5)) verify_color(Color('magenta') * Saturation(0), Color(0.5, 0.5, 0.5)) verify_color(Color('magenta') * Luma(1), Color('magenta')) verify_color(Red(0.5) * Color('magenta'), Color(0.5, 0, 1)) # pylint: disable=expression-not-assigned with pytest.raises(TypeError): Color('magenta') * 1 with pytest.raises(TypeError): 1 * Color('magenta')
def test_color_add(): verify_color(Color('red') + Color('blue'), Color('magenta')) verify_color(Color('red') + Color('white'), Color('white')) verify_color(Color('red') + Red(1), Color('red')) verify_color(Color('red') + Green(1), Color('yellow')) verify_color(Color('red') + Blue(1), Color('magenta')) verify_color(Color('red') + Hue(0), Color('red')) verify_color(Color('red') + Lightness(0.5), Color('white')) verify_color(Color('red') + Saturation(1), Color('red')) verify_color(Color('red') + Luma(1), Color('white')) verify_color(Green(1) + Color('red'), Color('yellow')) # pylint: disable=expression-not-assigned with pytest.raises(TypeError): Color('red') + 1 with pytest.raises(TypeError): 1 + Color('red')
def test_color_sub(): verify_color(Color('magenta') - Color('blue'), Color('red')) verify_color(Color('magenta') - Color('white'), Color('black')) verify_color(Color('magenta') - Red(1), Color('blue')) verify_color(Color('magenta') - Green(1), Color('magenta')) verify_color(Color('magenta') - Blue(1), Color('red')) verify_color(Color('magenta') - Hue(0), Color('magenta')) verify_color(Color('magenta') - Lightness(0.5), Color('black')) verify_color(Color('magenta') - Saturation(1), Color(0.5, 0.5, 0.5)) verify_color(Color('magenta') - Luma(1), Color('black')) verify_color(Red(1) - Color('magenta'), Color(0, 0, 0)) verify_color(Green(1) - Color('magenta'), Color(0, 1, 0)) verify_color(Blue(1) - Color('magenta'), Color(0, 0, 0)) # pylint: disable=expression-not-assigned with pytest.raises(TypeError): Color('magenta') - 1 with pytest.raises(TypeError): 1 - Color('magenta')
def test_color_attr(): assert Color('red').hue == Hue(0) assert Color('red').lightness == Lightness(0.5) assert Color('red').saturation == Saturation(1) assert Color('red').luma == Luma(0.299)
from tree import RGBXmasTree from colorzero import Hue, Color tree = RGBXmasTree() tree.color = Color('red') tree.brightness = 0.1 while True: tree.color += Hue(deg=5)
parser = argparse.ArgumentParser() parser.add_argument("brightness", help="brightness for all LEDs", type=float, default=0.1, nargs="?") parser.add_argument( "degrees", help="degrees of hue separation between steps", type=int, default=25, nargs="?", ) args = parser.parse_args() tree.brightness = args.brightness try: while True: for count in range(32): for n, pixel in enumerate(tree): hue = Hue(deg=args.degrees * n) pixel.color += hue print(f"pixel:{n} \t count:{count} \t Hue:{hue:.2f}") tree.brightness = args.brightness except KeyboardInterrupt: tree.close() tree = RGBXmasTree() tree.close()
def hueCycle(self): self.color = Color('red') for x in range(36): self.color += Hue(deg=10) sleep(timingDelay)