Exemple #1
0
 def __init__(self, no_of_colors):
     self.output_color = chroma.Color('#000000')
     self.no_of_colors = 12
     self.lookup_table = {}
     for i in range(0, self.no_of_colors):
         self.lookup_table[i] = chroma.Color('#000000')
     self.color_counts = {}
     for j in range(0, self.no_of_colors):
         self.color_counts[j] = [0, 0]
Exemple #2
0
    def test_comparison_methods(self):
        """Test equality and inequality"""

        # Equality
        self.assertFalse(self.c1 == self.c2)
        self.assertTrue(self.c1 == chroma.Color('#335577'))

        # Inequality
        self.assertTrue(self.c1 != self.c2)
        self.assertFalse(self.c1 != chroma.Color('#335577'))
def add_cells_to_image(polys, colors, draw, zone_data=Map()):
    for poly_id, poly in enumerate(polys):

        lines = []
        for line_id, p1 in enumerate(poly):
            lines.append(p1[0])
            lines.append(p1[1])

        color = webcolors.rgb_to_hex(helpers.choose_one(colors))
        color = chroma.Color(color)

        if poly_id == zone_data.center_id:
            color -= chroma.Color(webcolors.name_to_hex('red'))
        elif poly_id in zone_data.city_zones_in_walls:
            color -= chroma.Color(webcolors.name_to_hex('white'))
        # elif poly_id in zone_data.first:
        #     color -= chroma.Color(webcolors.name_to_hex('green'))
        # elif poly_id in zone_data.second:
        #     color -= chroma.Color(webcolors.name_to_hex('yellow'))
        # elif poly_id in zone_data.third:
        #     color -= chroma.Color(webcolors.name_to_hex('brown'))
        # elif poly_id in zone_data.fourth:
        #     color -= chroma.Color(webcolors.name_to_hex('lightblue'))

        draw.polygon(lines, fill=color.hex)

    for poly_id, poly in enumerate(polys):
        for line_id, p1 in enumerate(poly):
            p2 = poly[(line_id + 1) % len(poly)]

            is_outer = False
            is_river = False

            for w_poly, w_id in zone_data.outer_walls:
                if w_poly == poly_id and w_id == line_id:
                    is_outer = True
                    break
            for r_poly, r_id in zone_data.river_edges:
                if r_poly == poly_id and r_id == line_id:
                    is_river = True
                    break

            if is_outer:
                draw.line((p1[0], p1[1], p2[0], p2[1]), fill='black', width=7)

            if is_river:
                draw.line((p1[0], p1[1], p2[0], p2[1]), fill='blue', width=9)
Exemple #4
0
 def _mix_colors(self):
     self.output_color.rgb = (0, 0, 0)
     for i in range(0, self.no_of_colors):
         # if self.color_counts[i][0]:
         # self.output_color = self.output_color + self.lookup_table[i]
         # elif self.color_counts[i][1]:
         hue_value = self.lookup_table[i].hsv[0]
         self.output_color = self.output_color + chroma.Color(
             (hue_value, self.lookup_table[i].hsv[1],
              self.color_counts[i][1]), 'HSV')
def add_polys_to_image(polys, draw, colors, color=None, outline='brown'):
    for poly_id, poly in enumerate(polys):
        lines = []
        if type(poly) == Polygon:
            line = poly.exterior.coords
        else:
            line = poly

        for line_id, p1 in enumerate(line):
            lines.append(p1[0])
            lines.append(p1[1])

        if color is None:
            color_1 = webcolors.rgb_to_hex(helpers.choose_one(colors))
            color_1 = chroma.Color(color_1)
            color_1 -= chroma.Color(webcolors.name_to_hex('orange'))
            color_1 = color_1.hex
            draw.polygon(lines, fill=color_1, outline=outline)
        else:
            draw.polygon(lines, fill=color, outline=outline)
Exemple #6
0
 def add_color(self, color_ref, vel, max_vel):
     if self.lookup_table[color_ref] == chroma.Color('#000000'):
         vel = 0
     else:
         vel /= float(2 * max_vel)
         vel = self._clamp(vel, 0, 0.5)
     self.color_counts[color_ref][0] += 1
     self.color_counts[color_ref] = [self.color_counts[color_ref][0], vel]
     self.color_counts[color_ref][0] = self._clamp(
         self.color_counts[color_ref][0], 0, 1)
     self._mix_colors()
Exemple #7
0
 def recalculate_chase_mix(self):
     self.chasepattern = np.zeros([1 + self._tailsize, 4], np.uint8)
     # TODO: Gamma-correct ??
     rgbbytes = self._chasecolor.rgb256
     self.chasepattern[-1] = [0xff, rgbbytes[2], rgbbytes[1], rgbbytes[0]]
     for x in range(self._tailsize):
         tailcolor = chroma.Color(self._chasecolor)
         tailcolor.alpha = 1.0 / self._tailsize * x
         blended = self._basecolor + tailcolor
         rgbbytes = blended.rgb256
         self.chasepattern[x] = [
             0xff, rgbbytes[2], rgbbytes[1], rgbbytes[0]
         ]
Exemple #8
0
    def test_color_initialization(self):
        """Test construction of color object"""

        white = chroma.Color('#FFFFFF').hex

        self.assertEqual(chroma.Color((1,1,1), 'RGB').hex, white)
        self.assertEqual(chroma.Color((255, 255, 255), 'RGB256').hex, white)
        self.assertEqual(chroma.Color((0, 1, 1), 'HLS').hex, white)
        self.assertEqual(chroma.Color((0, 0, 1), 'HSV').hex, white)
        self.assertEqual(chroma.Color((0, 0, 0, 0), 'CMY').hex, white)
        self.assertEqual(chroma.Color((0, 0, 0, 0), 'CMYK').hex, white)

        # Test ValueError too
        self.assertRaises(ValueError, chroma.Color, (0, 0, 0), 'ERROR')
Exemple #9
0
    def change_mode(self, mode):
        self.output_color = chroma.Color('#000000')
        if mode == 1:  # mode for color scores
            self.no_of_colors = 12
            self.lookup_table[0] = chroma.Color('#ff0000')  # C RED
            self.lookup_table[1] = chroma.Color('#000000')  # C# OFF
            self.lookup_table[2] = chroma.Color('#ff4400')  # D ORANGE
            self.lookup_table[3] = chroma.Color('#000000')  # D# OFF
            self.lookup_table[4] = chroma.Color('#ff8800')  # E YELLOW
            self.lookup_table[5] = chroma.Color('#00ff00')  # F GREEN
            self.lookup_table[6] = chroma.Color('#000000')  # F# OFF
            self.lookup_table[7] = chroma.Color('#00ffcc')  # G TEAL
            self.lookup_table[8] = chroma.Color('#000000')  # G# OFF
            self.lookup_table[9] = chroma.Color('#0000ff')  # A BLUE
            self.lookup_table[10] = chroma.Color('#000000')  # A# OFF
            self.lookup_table[11] = chroma.Color('#ff00cc')  # B PURPLE
        elif mode == 2:  # Rainbow
            self.no_of_colors = 12
            for i in range(0, 12):
                hue = int(i * 340 / 12)
                self.lookup_table[i] = chroma.Color((hue, 1, 1), 'HSV')
        elif mode == 3:  # Reds
            self.no_of_colors = 12
            for i in range(0, 12):
                hue = int(i * 50 / 12)
                self.lookup_table[i] = chroma.Color((hue, 1, 1), 'HSV')
        elif mode == 4:  # Greens
            self.no_of_colors = 12
            for i in range(0, 12):
                hue = int(i * 100 / 12) + 60
                self.lookup_table[i] = chroma.Color((hue, 1, 1), 'HSV')
        elif mode == 5:  # Blues
            self.no_of_colors = 12
            for i in range(0, 12):
                hue = int(i * 100 / 12) + 180
                self.lookup_table[i] = chroma.Color((hue, 1, 1), 'HSV')
        else:  # resonating colors
            self.no_of_colors = 12
            self.lookup_table[0] = chroma.Color('#28ff00')  # C
            self.lookup_table[1] = chroma.Color('#00ffe8')  # C#
            self.lookup_table[2] = chroma.Color('#007cff')  # D
            self.lookup_table[3] = chroma.Color('#0500ff')  # D#
            self.lookup_table[4] = chroma.Color('#4500ea')  # E
            self.lookup_table[5] = chroma.Color('#57009e')  # F
            self.lookup_table[6] = chroma.Color('#740000')  # F#
            self.lookup_table[7] = chroma.Color('#b30000')  # G
            self.lookup_table[8] = chroma.Color('#ee0000')  # G#
            self.lookup_table[9] = chroma.Color('#ff6300')  # A
            self.lookup_table[10] = chroma.Color('#ffec00')  # A#
            self.lookup_table[11] = chroma.Color('#99ff00')  # B

        self.color_counts = {}
        for j in range(0, self.no_of_colors):
            self.color_counts[j] = [0, 0]
Exemple #10
0
        sys.exit(1)

    DEBUG = bool(int(os.environ.get('DEBUG', '0')))

    pattern = Chasepattern(int(sys.argv[2]))
    pattern.forever = True
    pattern.reverse = True
    context = zmq.Context()
    socket = context.socket(zmq.REQ)
    socket.connect(sys.argv[1])

    if len(sys.argv) >= 4:
        pattern.numtails = int(sys.argv[3])

    if len(sys.argv) >= 5:
        pattern.basecolor = chroma.Color(sys.argv[4])

    if len(sys.argv) >= 6:
        pattern.chasecolor = chroma.Color(sys.argv[5])

    delay = 0.005
    if len(sys.argv) >= 7:
        delay = float(sys.argv[6])

    try:
        doread = False
        while True:
            tstart = time.time()
            if pattern.i % 5 == 0:
                hsv = list(pattern.basecolor.hsv)
                hsv[0] = (hsv[0] + 1) % 360
Exemple #11
0
    def change_mode(self, mode):
        self.output_color = chroma.Color('#000000')
        if mode == 1:  # drum palette 1 (reds)
            self.channels = [33, 43, 47, 48, 31, 51, 46, 49, 42,
                             85]  # in order of basines
            for i in range(0, len(self.channels)):
                hue = i * int(45 / (len(self.channels)))
                self.lookup_table[self.channels[i]] = chroma.Color((hue, 1, 1),
                                                                   'HSV')  # C
            # self.lookup_table[self.channels[0]] = chroma.Color('#ff00ff')  # C
            # self.lookup_table[self.channels[1]] = chroma.Color('#ff0000')  # C#
            # self.lookup_table[self.channels[2]] = chroma.Color('#00ffff')  # D
            # self.lookup_table[self.channels[3]] = chroma.Color('#ffff00')  # D#
            # self.lookup_table[self.channels[4]] = chroma.Color('#00ff00')  # E
            # self.lookup_table[self.channels[5]] = chroma.Color('#ff00ff')  # F
            # self.lookup_table[self.channels[6]] = chroma.Color('#00ffff')  # F#
            # self.lookup_table[self.channels[7]] = chroma.Color('#ffff00')  # G
            # self.lookup_table[self.channels[8]] = chroma.Color('#0000ff')  # G#
            # self.lookup_table[self.channels[9]] = chroma.Color('#00ff00')  # A

        elif mode == 2:  # drum color palette (greens)
            self.channels = [33, 43, 47, 48, 31, 51, 46, 49, 42,
                             85]  # in order of basines
            for i in range(0, len(self.channels)):
                hue = i * int(45 / (len(self.channels))) + 90
                self.lookup_table[self.channels[i]] = chroma.Color((hue, 1, 1),
                                                                   'HSV')  # C
            # self.lookup_table[self.channels[0]] = chroma.Color('#ff00ff')  # C
            # self.lookup_table[self.channels[1]] = chroma.Color('#ff0000')  # C#
            # self.lookup_table[self.channels[2]] = chroma.Color('#00ffff')  # D
            # self.lookup_table[self.channels[3]] = chroma.Color('#ffff00')  # D#
            # self.lookup_table[self.channels[4]] = chroma.Color('#00ff00')  # E
            # self.lookup_table[self.channels[5]] = chroma.Color('#ff00ff')  # F
            # self.lookup_table[self.channels[6]] = chroma.Color('#00ffff')  # F#
            # self.lookup_table[self.channels[7]] = chroma.Color('#ffff00')  # G
            # self.lookup_table[self.channels[8]] = chroma.Color('#0000ff')  # G#
            # self.lookup_table[self.channels[9]] = chroma.Color('#00ff00')  # A
        elif mode == 3:  # drums color palette (blues)
            self.channels = [33, 43, 47, 48, 31, 51, 46, 49, 42,
                             85]  # in order of basines
            for i in range(0, len(self.channels)):
                hue = i * int(45 / (len(self.channels))) + 210
                self.lookup_table[self.channels[i]] = chroma.Color((hue, 1, 1),
                                                                   'HSV')  # C
            # self.lookup_table[self.channels[0]] = chroma.Color('#ff00ff')  # C
            # self.lookup_table[self.channels[1]] = chroma.Color('#ff0000')  # C#
            # self.lookup_table[self.channels[2]] = chroma.Color('#00ffff')  # D
            # self.lookup_table[self.channels[3]] = chroma.Color('#ffff00')  # D#
            # self.lookup_table[self.channels[4]] = chroma.Color('#00ff00')  # E
            # self.lookup_table[self.channels[5]] = chroma.Color('#ff00ff')  # F
            # self.lookup_table[self.channels[6]] = chroma.Color('#00ffff')  # F#
            # self.lookup_table[self.channels[7]] = chroma.Color('#ffff00')  # G
            # self.lookup_table[self.channels[8]] = chroma.Color('#0000ff')  # G#
            # self.lookup_table[self.channels[9]] = chroma.Color('#00ff00')  # A
        elif mode == 4:  # mode for keyboard (blues)
            self.channels = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
                             11]  # in order of basines
            for i in range(0, len(self.channels)):
                hue = i * int(45 / (len(self.channels))) + 210
                self.lookup_table[self.channels[i]] = chroma.Color((hue, 1, 1),
                                                                   'HSV')  # C
            # self.lookup_table[self.channels[0]] = chroma.Color('#ff00ff')  # C
            # self.lookup_table[self.channels[1]] = chroma.Color('#ff0000')  # C#
            # self.lookup_table[self.channels[2]] = chroma.Color('#00ffff')  # D
            # self.lookup_table[self.channels[3]] = chroma.Color('#ffff00')  # D#
            # self.lookup_table[self.channels[4]] = chroma.Color('#00ff00')  # E
            # self.lookup_table[self.channels[5]] = chroma.Color('#ff00ff')  # F
            # self.lookup_table[self.channels[6]] = chroma.Color('#00ffff')  # F#
            # self.lookup_table[self.channels[7]] = chroma.Color('#ffff00')  # G
            # self.lookup_table[self.channels[8]] = chroma.Color('#0000ff')  # G#
            # self.lookup_table[self.channels[9]] = chroma.Color('#00ff00')  # A
        elif mode == 5:  # mode for keyboard (Greens)
            self.channels = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
                             11]  # in order of basines
            for i in range(0, len(self.channels)):
                hue = i * int(45 / (len(self.channels))) + 90
                self.lookup_table[self.channels[i]] = chroma.Color((hue, 1, 1),
                                                                   'HSV')  # C
            # self.lookup_table[self.channels[0]] = chroma.Color('#ff00ff')  # C
            # self.lookup_table[self.channels[1]] = chroma.Color('#ff0000')  # C#
            # self.lookup_table[self.channels[2]] = chroma.Color('#00ffff')  # D
            # self.lookup_table[self.channels[3]] = chroma.Color('#ffff00')  # D#
            # self.lookup_table[self.channels[4]] = chroma.Color('#00ff00')  # E
            # self.lookup_table[self.channels[5]] = chroma.Color('#ff00ff')  # F
            # self.lookup_table[self.channels[6]] = chroma.Color('#00ffff')  # F#
            # self.lookup_table[self.channels[7]] = chroma.Color('#ffff00')  # G
            # self.lookup_table[self.channels[8]] = chroma.Color('#0000ff')  # G#
            # self.lookup_table[self.channels[9]] = chroma.Color('#00ff00')  # A

        elif mode == 6:  # mode for keyboard (reds)
            self.channels = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
                             11]  # in order of basines
            for i in range(0, len(self.channels)):
                hue = i * int(45 / (len(self.channels)))
                self.lookup_table[self.channels[i]] = chroma.Color((hue, 1, 1),
                                                                   'HSV')  # C
            # self.lookup_table[self.channels[0]] = chroma.Color('#ff00ff')  # C
            # self.lookup_table[self.channels[1]] = chroma.Color('#ff0000')  # C#
            # self.lookup_table[self.channels[2]] = chroma.Color('#00ffff')  # D
            # self.lookup_table[self.channels[3]] = chroma.Color('#ffff00')  # D#
            # self.lookup_table[self.channels[4]] = chroma.Color('#00ff00')  # E
            # self.lookup_table[self.channels[5]] = chroma.Color('#ff00ff')  # F
            # self.lookup_table[self.channels[6]] = chroma.Color('#00ffff')  # F#
            # self.lookup_table[self.channels[7]] = chroma.Color('#ffff00')  # G
            # self.lookup_table[self.channels[8]] = chroma.Color('#0000ff')  # G#
            # self.lookup_table[self.channels[9]] = chroma.Color('#00ff00')  # A
        elif mode == 7:  # mode for drums
            self.channels = [33, 43, 47, 48, 31, 51, 46, 49, 42,
                             85]  # in order of basines
            for i in range(0, len(self.channels)):
                hue = i * int(6 / (len(self.channels)))
                self.lookup_table[self.channels[i]] = chroma.Color((hue, 1, 1),
                                                                   'HSV')  # C
            # self.lookup_table[self.channels[0]] = chroma.Color('#ff00ff')  # C
            # self.lookup_table[self.channels[1]] = chroma.Color('#ff0000')  # C#
            # self.lookup_table[self.channels[2]] = chroma.Color('#00ffff')  # D
            # self.lookup_table[self.channels[3]] = chroma.Color('#ffff00')  # D#
            # self.lookup_table[self.channels[4]] = chroma.Color('#00ff00')  # E
            # self.lookup_table[self.channels[5]] = chroma.Color('#ff00ff')  # F
            # self.lookup_table[self.channels[6]] = chroma.Color('#00ffff')  # F#
            # self.lookup_table[self.channels[7]] = chroma.Color('#ffff00')  # G
            # self.lookup_table[self.channels[8]] = chroma.Color('#0000ff')  # G#
            # self.lookup_table[self.channels[9]] = chroma.Color('#00ff00')  # A
        elif mode == 8:  # mode for keyboard
            self.channels = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
                             11]  # in order of basines
            for i in range(0, len(self.channels)):
                hue = i * int(6 / (len(self.channels))) + 327
                self.lookup_table[self.channels[i]] = chroma.Color((hue, 1, 1),
                                                                   'HSV')
            # self.lookup_table[self.channels[1]] = chroma.Color('#ff0000')  # C#
            # self.lookup_table[self.channels[2]] = chroma.Color('#00ffff')  # D
            # self.lookup_table[self.channels[3]] = chroma.Color('#ffff00')  # D#
            # self.lookup_table[self.channels[4]] = chroma.Color('#00ff00')  # E
            # self.lookup_table[self.channels[5]] = chroma.Color('#ff00ff')  # F
            # self.lookup_table[self.channels[6]] = chroma.Color('#00ffff')  # F#
            # self.lookup_table[self.channels[7]] = chroma.Color('#ffff00')  # G
            # self.lookup_table[self.channels[8]] = chroma.Color('#0000ff')  # G#
            # self.lookup_table[self.channels[9]] = chroma.Color('#00ff00')  # A
        elif mode == 9:  # mode for keyboard (blues)
            self.channels = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
                             11]  # in order of basines
            for i in range(0, len(self.channels)):
                hue = i * int(6 / (len(self.channels))) + 27
                self.lookup_table[self.channels[i]] = chroma.Color((hue, 1, 1),
                                                                   'HSV')
            # self.lookup_table[self.channels[1]] = chroma.Color('#ff0000')  # C#
            # self.lookup_table[self.channels[2]] = chroma.Color('#00ffff')  # D
            # self.lookup_table[self.channels[3]] = chroma.Color('#ffff00')  # D#
            # self.lookup_table[self.channels[4]] = chroma.Color('#00ff00')  # E
            # self.lookup_table[self.channels[5]] = chroma.Color('#ff00ff')  # F
            # self.lookup_table[self.channels[6]] = chroma.Color('#00ffff')  # F#
            # self.lookup_table[self.channels[7]] = chroma.Color('#ffff00')  # G
            # self.lookup_table[self.channels[8]] = chroma.Color('#0000ff')  # G#
            # self.lookup_table[self.channels[9]] = chroma.Color('#00ff00')  # A
        elif mode == 10:  # mode for drums
            self.channels = [33, 43, 47, 48, 31, 51, 46, 49, 42,
                             85]  # in order of basines
            for i in range(0, len(self.channels)):
                hue = i * int(6 / (len(self.channels))) + 260
                self.lookup_table[self.channels[i]] = chroma.Color((hue, 1, 1),
                                                                   'HSV')
            # self.lookup_table[self.channels[0]] = chroma.Color('#ff00ff')  # C
            # self.lookup_table[self.channels[1]] = chroma.Color('#ff0000')  # C#
            # self.lookup_table[self.channels[2]] = chroma.Color('#00ffff')  # D
            # self.lookup_table[self.channels[3]] = chroma.Color('#ffff00')  # D#
            # self.lookup_table[self.channels[4]] = chroma.Color('#00ff00')  # E
            # self.lookup_table[self.channels[5]] = chroma.Color('#ff00ff')  # F
            # self.lookup_table[self.channels[6]] = chroma.Color('#00ffff')  # F#
            # self.lookup_table[self.channels[7]] = chroma.Color('#ffff00')  # G
            # self.lookup_table[self.channels[8]] = chroma.Color('#0000ff')  # G#
            # self.lookup_table[self.channels[9]] = chroma.Color('#00ff00')  # A
        elif mode == 11:  # mode for keyboard
            self.channels = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
                             11]  # in order of basines
            for i in range(0, len(self.channels)):
                hue = i * int(6 / (len(self.channels))) + 293
                self.lookup_table[self.channels[i]] = chroma.Color((hue, 1, 1),
                                                                   'HSV')
            # self.lookup_table[self.channels[1]] = chroma.Color('#ff0000')  # C#
            # self.lookup_table[self.channels[2]] = chroma.Color('#00ffff')  # D
            # self.lookup_table[self.channels[3]] = chroma.Color('#ffff00')  # D#
            # self.lookup_table[self.channels[4]] = chroma.Color('#00ff00')  # E
            # self.lookup_table[self.channels[5]] = chroma.Color('#ff00ff')  # F
            # self.lookup_table[self.channels[6]] = chroma.Color('#00ffff')  # F#
            # self.lookup_table[self.channels[7]] = chroma.Color('#ffff00')  # G
            # self.lookup_table[self.channels[8]] = chroma.Color('#0000ff')  # G#
            # self.lookup_table[self.channels[9]] = chroma.Color('#00ff00')  # A
        elif mode == 12:  # mode for keyboard
            self.channels = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
                             11]  # in order of basines
            for i in range(0, len(self.channels)):
                hue = i * int(6 / (len(self.channels))) + 220
                self.lookup_table[self.channels[i]] = chroma.Color((hue, 1, 1),
                                                                   'HSV')
            # self.lookup_table[self.channels[1]] = chroma.Color('#ff0000')  # C#
            # self.lookup_table[self.channels[2]] = chroma.Color('#00ffff')  # D
            # self.lookup_table[self.channels[3]] = chroma.Color('#ffff00')  # D#
            # self.lookup_table[self.channels[4]] = chroma.Color('#00ff00')  # E
            # self.lookup_table[self.channels[5]] = chroma.Color('#ff00ff')  # F
            # self.lookup_table[self.channels[6]] = chroma.Color('#00ffff')  # F#
            # self.lookup_table[self.channels[7]] = chroma.Color('#ffff00')  # G
            # self.lookup_table[self.channels[8]] = chroma.Color('#0000ff')  # G#
            # self.lookup_table[self.channels[9]] = chroma.Color('#00ff00')  # A
        elif mode == 13:  # mode for drums
            self.channels = [33, 43, 47, 48, 31, 51, 46, 49, 42,
                             85]  # in order of basines
            for i in range(0, len(self.channels)):
                hue = i * int(6 / (len(self.channels))) + 150
                self.lookup_table[self.channels[i]] = chroma.Color((hue, 1, 1),
                                                                   'HSV')
            # self.lookup_table[self.channels[0]] = chroma.Color('#ff00ff')  # C
            # self.lookup_table[self.channels[1]] = chroma.Color('#ff0000')  # C#
            # self.lookup_table[self.channels[2]] = chroma.Color('#00ffff')  # D
            # self.lookup_table[self.channels[3]] = chroma.Color('#ffff00')  # D#
            # self.lookup_table[self.channels[4]] = chroma.Color('#00ff00')  # E
            # self.lookup_table[self.channels[5]] = chroma.Color('#ff00ff')  # F
            # self.lookup_table[self.channels[6]] = chroma.Color('#00ffff')  # F#
            # self.lookup_table[self.channels[7]] = chroma.Color('#ffff00')  # G
            # self.lookup_table[self.channels[8]] = chroma.Color('#0000ff')  # G#
            # self.lookup_table[self.channels[9]] = chroma.Color('#00ff00')  # A
        elif mode == 14:  # mode for keyboard
            self.channels = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
                             11]  # in order of basines
            for i in range(0, len(self.channels)):
                hue = i * int(6 / (len(self.channels))) + 120
                self.lookup_table[self.channels[i]] = chroma.Color((hue, 1, 1),
                                                                   'HSV')
            # self.lookup_table[self.channels[1]] = chroma.Color('#ff0000')  # C#
            # self.lookup_table[self.channels[2]] = chroma.Color('#00ffff')  # D
            # self.lookup_table[self.channels[3]] = chroma.Color('#ffff00')  # D#
            # self.lookup_table[self.channels[4]] = chroma.Color('#00ff00')  # E
            # self.lookup_table[self.channels[5]] = chroma.Color('#ff00ff')  # F
            # self.lookup_table[self.channels[6]] = chroma.Color('#00ffff')  # F#
            # self.lookup_table[self.channels[7]] = chroma.Color('#ffff00')  # G
            # self.lookup_table[self.channels[8]] = chroma.Color('#0000ff')  # G#
            # self.lookup_table[self.channels[9]] = chroma.Color('#00ff00')  # A
        elif mode == 15:  # mode for keyboard
            self.channels = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
                             11]  # in order of basines
            for i in range(0, len(self.channels)):
                hue = i * int(6 / (len(self.channels))) + 180
                self.lookup_table[self.channels[i]] = chroma.Color((hue, 1, 1),
                                                                   'HSV')
            # self.lookup_table[self.channels[1]] = chroma.Color('#ff0000')  # C#
            # self.lookup_table[self.channels[2]] = chroma.Color('#00ffff')  # D
            # self.lookup_table[self.channels[3]] = chroma.Color('#ffff00')  # D#
            # self.lookup_table[self.channels[4]] = chroma.Color('#00ff00')  # E
            # self.lookup_table[self.channels[5]] = chroma.Color('#ff00ff')  # F
            # self.lookup_table[self.channels[6]] = chroma.Color('#00ffff')  # F#
            # self.lookup_table[self.channels[7]] = chroma.Color('#ffff00')  # G
            # self.lookup_table[self.channels[8]] = chroma.Color('#0000ff')  # G#
            # self.lookup_table[self.channels[9]] = chroma.Color('#00ff00')  # A

        elif mode == 16:  # mode for drums
            self.channels = [33, 43, 47, 48, 31, 51, 46, 49, 42,
                             85]  # in order of basines
            for i in range(0, len(self.channels)):
                hue = i * int(6 / (len(self.channels))) + 30
                self.lookup_table[self.channels[i]] = chroma.Color((hue, 1, 1),
                                                                   'HSV')
            # self.lookup_table[self.channels[0]] = chroma.Color('#ff00ff')  # C
            # self.lookup_table[self.channels[1]] = chroma.Color('#ff0000')  # C#
            # self.lookup_table[self.channels[2]] = chroma.Color('#00ffff')  # D
            # self.lookup_table[self.channels[3]] = chroma.Color('#ffff00')  # D#
            # self.lookup_table[self.channels[4]] = chroma.Color('#00ff00')  # E
            # self.lookup_table[self.channels[5]] = chroma.Color('#ff00ff')  # F
            # self.lookup_table[self.channels[6]] = chroma.Color('#00ffff')  # F#
            # self.lookup_table[self.channels[7]] = chroma.Color('#ffff00')  # G
            # self.lookup_table[self.channels[8]] = chroma.Color('#0000ff')  # G#
            # self.lookup_table[self.channels[9]] = chroma.Color('#00ff00')  # A
        elif mode == 17:  # mode for keyboard
            self.channels = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
                             11]  # in order of basines
            for i in range(0, len(self.channels)):
                hue = i * int(6 / (len(self.channels))) + 240
                self.lookup_table[self.channels[i]] = chroma.Color((hue, 1, 1),
                                                                   'HSV')
            # self.lookup_table[self.channels[1]] = chroma.Color('#ff0000')  # C#
            # self.lookup_table[self.channels[2]] = chroma.Color('#00ffff')  # D
            # self.lookup_table[self.channels[3]] = chroma.Color('#ffff00')  # D#
            # self.lookup_table[self.channels[4]] = chroma.Color('#00ff00')  # E
            # self.lookup_table[self.channels[5]] = chroma.Color('#ff00ff')  # F
            # self.lookup_table[self.channels[6]] = chroma.Color('#00ffff')  # F#
            # self.lookup_table[self.channels[7]] = chroma.Color('#ffff00')  # G
            # self.lookup_table[self.channels[8]] = chroma.Color('#0000ff')  # G#
            # self.lookup_table[self.channels[9]] = chroma.Color('#00ff00')  # A
        elif mode == 18:  # mode for keyboard
            self.channels = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
                             11]  # in order of basines
            for i in range(0, len(self.channels)):
                hue = i * int(6 / (len(self.channels))) + 140
                self.lookup_table[self.channels[i]] = chroma.Color((hue, 1, 1),
                                                                   'HSV')
            # self.lookup_table[self.channels[1]] = chroma.Color('#ff0000')  # C#
            # self.lookup_table[self.channels[2]] = chroma.Color('#00ffff')  # D
            # self.lookup_table[self.channels[3]] = chroma.Color('#ffff00')  # D#
            # self.lookup_table[self.channels[4]] = chroma.Color('#00ff00')  # E
            # self.lookup_table[self.channels[5]] = chroma.Color('#ff00ff')  # F
            # self.lookup_table[self.channels[6]] = chroma.Color('#00ffff')  # F#
            # self.lookup_table[self.channels[7]] = chroma.Color('#ffff00')  # G
            # self.lookup_table[self.channels[8]] = chroma.Color('#0000ff')  # G#
            # self.lookup_table[self.channels[9]] = chroma.Color('#00ff00')  # A

        elif mode == 19:  # mode for drums
            self.channels = [33, 43, 47, 48, 31, 51, 46, 49, 42,
                             85]  # in order of basines
            for i in range(0, len(self.channels)):
                hue = i * int(6 / (len(self.channels))) + 210
                self.lookup_table[self.channels[i]] = chroma.Color((hue, 1, 1),
                                                                   'HSV')
            # self.lookup_table[self.channels[0]] = chroma.Color('#ff00ff')  # C
            # self.lookup_table[self.channels[1]] = chroma.Color('#ff0000')  # C#
            # self.lookup_table[self.channels[2]] = chroma.Color('#00ffff')  # D
            # self.lookup_table[self.channels[3]] = chroma.Color('#ffff00')  # D#
            # self.lookup_table[self.channels[4]] = chroma.Color('#00ff00')  # E
            # self.lookup_table[self.channels[5]] = chroma.Color('#ff00ff')  # F
            # self.lookup_table[self.channels[6]] = chroma.Color('#00ffff')  # F#
            # self.lookup_table[self.channels[7]] = chroma.Color('#ffff00')  # G
            # self.lookup_table[self.channels[8]] = chroma.Color('#0000ff')  # G#
            # self.lookup_table[self.channels[9]] = chroma.Color('#00ff00')  # A
        elif mode == 20:  # mode for keyboard
            self.channels = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
                             11]  # in order of basines
            for i in range(0, len(self.channels)):
                hue = i * int(6 / (len(self.channels)))
                self.lookup_table[self.channels[i]] = chroma.Color((hue, 1, 1),
                                                                   'HSV')
            # self.lookup_table[self.channels[1]] = chroma.Color('#ff0000')  # C#
            # self.lookup_table[self.channels[2]] = chroma.Color('#00ffff')  # D
            # self.lookup_table[self.channels[3]] = chroma.Color('#ffff00')  # D#
            # self.lookup_table[self.channels[4]] = chroma.Color('#00ff00')  # E
            # self.lookup_table[self.channels[5]] = chroma.Color('#ff00ff')  # F
            # self.lookup_table[self.channels[6]] = chroma.Color('#00ffff')  # F#
            # self.lookup_table[self.channels[7]] = chroma.Color('#ffff00')  # G
            # self.lookup_table[self.channels[8]] = chroma.Color('#0000ff')  # G#
            # self.lookup_table[self.channels[9]] = chroma.Color('#00ff00')  # A
        elif mode == 21:  # mode for keyboard
            self.channels = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
                             11]  # in order of basines
            for i in range(0, len(self.channels)):
                hue = i * int(6 / (len(self.channels))) + 60
                self.lookup_table[self.channels[i]] = chroma.Color((hue, 1, 1),
                                                                   'HSV')
            # self.lookup_table[self.channels[1]] = chroma.Color('#ff0000')  # C#
            # self.lookup_table[self.channels[2]] = chroma.Color('#00ffff')  # D
            # self.lookup_table[self.channels[3]] = chroma.Color('#ffff00')  # D#
            # self.lookup_table[self.channels[4]] = chroma.Color('#00ff00')  # E
            # self.lookup_table[self.channels[5]] = chroma.Color('#ff00ff')  # F
            # self.lookup_table[self.channels[6]] = chroma.Color('#00ffff')  # F#
            # self.lookup_table[self.channels[7]] = chroma.Color('#ffff00')  # G
            # self.lookup_table[self.channels[8]] = chroma.Color('#0000ff')  # G#
            # self.lookup_table[self.channels[9]] = chroma.Color('#00ff00')  # A

        elif mode == 22:  # mode for drums
            self.channels = [33, 43, 47, 48, 31, 51, 46, 49, 42,
                             85]  # in order of basines
            for i in range(0, len(self.channels)):
                hue = i * int(360 / (len(self.channels)))
                self.lookup_table[self.channels[i]] = chroma.Color((hue, 1, 1),
                                                                   'HSV')
            # self.lookup_table[self.channels[0]] = chroma.Color('#ff00ff')  # C
            # self.lookup_table[self.channels[1]] = chroma.Color('#ff0000')  # C#
            # self.lookup_table[self.channels[2]] = chroma.Color('#00ffff')  # D
            # self.lookup_table[self.channels[3]] = chroma.Color('#ffff00')  # D#
            # self.lookup_table[self.channels[4]] = chroma.Color('#00ff00')  # E
            # self.lookup_table[self.channels[5]] = chroma.Color('#ff00ff')  # F
            # self.lookup_table[self.channels[6]] = chroma.Color('#00ffff')  # F#
            # self.lookup_table[self.channels[7]] = chroma.Color('#ffff00')  # G
            # self.lookup_table[self.channels[8]] = chroma.Color('#0000ff')  # G#
            # self.lookup_table[self.channels[9]] = chroma.Color('#00ff00')  # A
        elif mode == 23:  # mode for keyboard
            self.channels = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
                             11]  # in order of basines
            for i in range(0, len(self.channels)):
                hue = i * int(360 / (len(self.channels)))
                self.lookup_table[self.channels[i]] = chroma.Color((hue, 1, 1),
                                                                   'HSV')
            # self.lookup_table[self.channels[1]] = chroma.Color('#ff0000')  # C#
            # self.lookup_table[self.channels[2]] = chroma.Color('#00ffff')  # D
            # self.lookup_table[self.channels[3]] = chroma.Color('#ffff00')  # D#
            # self.lookup_table[self.channels[4]] = chroma.Color('#00ff00')  # E
            # self.lookup_table[self.channels[5]] = chroma.Color('#ff00ff')  # F
            # self.lookup_table[self.channels[6]] = chroma.Color('#00ffff')  # F#
            # self.lookup_table[self.channels[7]] = chroma.Color('#ffff00')  # G
            # self.lookup_table[self.channels[8]] = chroma.Color('#0000ff')  # G#
            # self.lookup_table[self.channels[9]] = chroma.Color('#00ff00')  # A
        elif mode == 24:  # mode for keyboard
            self.channels = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
                             11]  # in order of basines
            for i in range(0, len(self.channels)):
                hue = i * int(360 / (len(self.channels)))
                self.lookup_table[self.channels[i]] = chroma.Color((hue, 1, 1),
                                                                   'HSV')
            # self.lookup_table[self.channels[1]] = chroma.Color('#ff0000')  # C#
            # self.lookup_table[self.channels[2]] = chroma.Color('#00ffff')  # D
            # self.lookup_table[self.channels[3]] = chroma.Color('#ffff00')  # D#
            # self.lookup_table[self.channels[4]] = chroma.Color('#00ff00')  # E
            # self.lookup_table[self.channels[5]] = chroma.Color('#ff00ff')  # F
            # self.lookup_table[self.channels[6]] = chroma.Color('#00ffff')  # F#
            # self.lookup_table[self.channels[7]] = chroma.Color('#ffff00')  # G
            # self.lookup_table[self.channels[8]] = chroma.Color('#0000ff')  # G#
            # self.lookup_table[self.channels[9]] = chroma.Color('#00ff00')  # A
        self.color_counts = {}
        # for j in range(0, self.no_of_colors):
        #for j, i in enumerate(self.lookup_table):
        for j in self.channels:
            self.color_counts[j] = [0, 0]
Exemple #12
0
class Chasepattern(Iterator):
    """Generates chase patterns for N LEDs, operates in chroma.Color"""

    i = 0
    _numleds = None
    _basecolor = chroma.Color('#000000')
    _chasecolor = chroma.Color('#000000')
    _tailsize = 5
    _tailinterval = 0
    _numtails = 1
    forever = False
    pattern = None
    chasepattern = None
    frame = None
    reverse = False

    def __init__(self, numleds):
        self.numleds = numleds
        self.basecolor = chroma.Color('#0E1024')
        self.chasecolor = chroma.Color('#FF8FFF')
        self._tailinterval = self._numleds / self._numtails

    @property
    def basecolor(self):
        return self._basecolor

    @basecolor.setter
    def basecolor(self, value):
        self._basecolor = value
        # TODO: Gamma-correct ??
        rgbbytes = self._basecolor.rgb256
        self.pattern[:] = [0xff, rgbbytes[2], rgbbytes[1], rgbbytes[0]]
        self.recalculate_chase_mix()

    @property
    def chasecolor(self):
        return self._chasecolor

    @chasecolor.setter
    def chasecolor(self, value):
        self._chasecolor = value
        self.recalculate_chase_mix()

    @property
    def tailsize(self):
        return self._tailsize

    @tailsize.setter
    def tailsize(self, value):
        self._tailsize = value
        self.recalculate_chase_mix()

    @property
    def numtails(self):
        return self._numtails

    @numtails.setter
    def numtails(self, value):
        self._numtails = value
        # Trigger base refill
        self.basecolor = self.basecolor
        self._tailinterval = self._numleds / self._numtails

    def recalculate_chase_mix(self):
        self.chasepattern = np.zeros([1 + self._tailsize, 4], np.uint8)
        # TODO: Gamma-correct ??
        rgbbytes = self._chasecolor.rgb256
        self.chasepattern[-1] = [0xff, rgbbytes[2], rgbbytes[1], rgbbytes[0]]
        for x in range(self._tailsize):
            tailcolor = chroma.Color(self._chasecolor)
            tailcolor.alpha = 1.0 / self._tailsize * x
            blended = self._basecolor + tailcolor
            rgbbytes = blended.rgb256
            self.chasepattern[x] = [
                0xff, rgbbytes[2], rgbbytes[1], rgbbytes[0]
            ]

    @property
    def numleds(self):
        return self._numleds

    @numleds.setter
    def numleds(self, value):
        self._numleds = value
        self.pattern = np.zeros([value, 4], np.uint8)
        self.initialize_frame()

    def initialize_frame(self):
        eofbits = self._numleds / 2.0
        eofbytes = int(math.ceil(eofbits / 8.0))
        self.frame = np.zeros(
            self.pattern.size + APA102_FRAME_START_SIZE + eofbytes, np.uint8)
        self.frame[-eofbytes:] = 0xff

    def next(self):
        return self.__next__()

    def _position_single_tail(self, chasepos):
        # TODO make this case work too.
        if chasepos < 0:
            return
        tailend = chasepos - len(self.chasepattern)
        # TODO: Gamma-correct ??
        rgbbytes = self._basecolor.rgb256
        self.pattern[tailend -
                     1] = [0xff, rgbbytes[2], rgbbytes[1], rgbbytes[0]]
        if tailend < 0:
            self.pattern[tailend:] = self.chasepattern[0:abs(tailend)]
            self.pattern[0:chasepos] = self.chasepattern[abs(tailend):]
        else:
            self.pattern[tailend:chasepos] = self.chasepattern

    def __next__(self):
        chasepos = self.i % (self._numleds - 1)
        for x in range(self._numtails):
            self._position_single_tail(
                (chasepos + x * self._tailinterval) % (self._numleds - 1))

        if self.reverse:
            self.frame[APA102_FRAME_START_SIZE:self.pattern.size +
                       APA102_FRAME_START_SIZE] = np.flipud(
                           self.pattern).flatten()
        else:
            self.frame[APA102_FRAME_START_SIZE:self.pattern.size +
                       APA102_FRAME_START_SIZE] = self.pattern.flatten()

        self.i += 1
        if self.i > self.numleds and not self.forever:
            raise StopIteration

        return self.frame
Exemple #13
0
 def setUp(self):
     self.c1 = chroma.Color('#335577')
     self.c2 = chroma.Color('#446688')
     self.c3 = chroma.Color('#555555')
Exemple #14
0
    def test_color_blending(self):
        """Test additive and subtractive mixing"""

        # Additive mixing
        self.assertEqual(chroma.Color("#77BBFF"), self.c1 + self.c2)
        self.assertEqual(chroma.Color("#99BBDD"), self.c3 + self.c2)
        self.assertEqual(chroma.Color("#FFFFFF"), chroma.Color("#FFFFFF") + chroma.Color("#000000"))
        self.assertEqual(self.c1, self.c1 + chroma.Color("#000000"))

        # Subtractive mixing
        self.assertEqual(chroma.Color("#FFFF00"), chroma.Color("#FFFFFF") - chroma.Color("#FFFF00"))
        self.assertEqual(chroma.Color("#00FF00"), chroma.Color("#FFFF00") - chroma.Color("#00FFFF"))
Exemple #15
0
 def __init__(self, numleds):
     self.numleds = numleds
     self.basecolor = chroma.Color('#0E1024')
     self.chasecolor = chroma.Color('#FF8FFF')
     self._tailinterval = self._numleds / self._numtails
Exemple #16
0
    def test_system_conversion(self):
        """Test conversion between systems"""

        # Use Wolfram Alpha as external reference
        # Everything -> RGB
        self.assertTupleAlmostEqual(chroma.Color((0.2, 0.3333, 0.4667), 'RGB').rgb, self.c1.rgb)
        self.assertTupleAlmostEqual(chroma.Color((51, 85, 119), 'RGB256').rgb, self.c1.rgb)
        self.assertTupleAlmostEqual(chroma.Color((210, 0.3333, 0.40), 'HLS').rgb, self.c1.rgb)
        self.assertTupleAlmostEqual(chroma.Color((210, 0.57, 0.466), 'HSV').rgb, self.c1.rgb)
        self.assertTupleAlmostEqual(chroma.Color((0.8, 0.67, 0.53), 'CMY').rgb, self.c1.rgb)
        self.assertTupleAlmostEqual(chroma.Color((0.57, 0.29, 0, 0.53), 'CMYK').rgb, self.c1.rgb)

        # RGB -> Everything
        self.assertTupleAlmostEqual(chroma.Color((0.2, 0.3333, 0.4667), 'RGB').rgb, self.c1.rgb)
        self.assertTupleAlmostEqual(chroma.Color((51, 85, 119), 'RGB256').rgb256, self.c1.rgb256)
        self.assertTupleAlmostEqual(chroma.Color((210, 0.3333, 0.40), 'HLS').hls, self.c1.hls)
        self.assertTupleAlmostEqual(chroma.Color((210, 0.57, 0.466), 'HSV').hsv, self.c1.hsv)
        self.assertTupleAlmostEqual(chroma.Color((0.8, 0.67, 0.53), 'CMY').cmy, self.c1.cmy)
        self.assertTupleAlmostEqual(chroma.Color((0.57, 0.29, 0, 0.53), 'CMYK').cmyk, self.c1.cmyk)
Exemple #17
0
    def test_bad_input(self):
        """Test input that goes beyond color system bounds"""
        # Upper bound
        self.assertEqual(chroma.Color((10, -3, 0.5), 'RGB').rgb, chroma.Color((1, 0, 0.5), 'RGB').rgb)
        self.assertEqual(chroma.Color((300, -3, 50), 'RGB256').rgb256, chroma.Color((255, 0, 50), 'RGB256').rgb256)
        self.assertEqual(chroma.Color((400, -3, 10), 'HLS').hls, chroma.Color((360, 0, 1), 'HLS').hls)
        self.assertEqual(chroma.Color((-10, 40, -1), 'HLS').hls, chroma.Color((0, 1, 0), 'HLS').hls)
        self.assertEqual(chroma.Color((400, -3, 10), 'HSV').hsv, chroma.Color((360, 0, 1), 'HSV').hsv)
        self.assertEqual(chroma.Color((-10, 40, -1), 'HSV').hsv, chroma.Color((0, 1, 0), 'HSV').hsv)
        self.assertEqual(chroma.Color((10, -3, 0.5), 'CMY').cmy, chroma.Color((1, 0, 0.5), 'CMY').cmy)
        self.assertEqual(chroma.Color((10, -3, 0.5, 3), 'CMYK').cmyk, chroma.Color((1, 0, 0.5, 1), 'CMYK').cmyk)

        # Test alpha
        self.c1.rgb = (10, -1, 0.5, 10)
        self.assertEqual(self.c1.rgb, (1, 0, 0.5, 1))
        self.c1.rgb = (10, -1, 0.5, -10)
        self.assertEqual(self.c1.rgb, (1, 0, 0.5, 0))
Exemple #18
0
    def __init__(self, no_of_colors):
        self.output_color = chroma.Color('#000000')
        self.no_of_colors = 12
        self.lookup_table = {}
        self.lookup_table[0] = chroma.Color('#28ff00')  # C
        self.lookup_table[1] = chroma.Color('#00ffe8')  # C#
        self.lookup_table[2] = chroma.Color('#007cff')  # D
        self.lookup_table[3] = chroma.Color('#0500ff')  # D#
        self.lookup_table[4] = chroma.Color('#4500ea')  # E
        self.lookup_table[5] = chroma.Color('#57009e')  # F
        self.lookup_table[6] = chroma.Color('#740000')  # F#
        self.lookup_table[7] = chroma.Color('#b30000')  # G
        self.lookup_table[8] = chroma.Color('#ee0000')  # G#
        self.lookup_table[9] = chroma.Color('#ff6300')  # A
        self.lookup_table[10] = chroma.Color('#ffec00')  # A#
        self.lookup_table[11] = chroma.Color('#99ff00')  # B

        self.color_counts = {}
        for j in range(0, self.no_of_colors):
            self.color_counts[j] = [0, 0]
Exemple #19
0
#!/usr/bin/python
# script for testing dmx light colors

import sys
import pysimpledmx
import chroma
import time


def render_color(color):
    mydmx.setChannel(1, 255)  # set DMX channel 1 to full
    mydmx.setChannel(2, int(color[0] * 255))
    mydmx.setChannel(3, int(color[1] * 255))
    mydmx.setChannel(4, int(color[2] * 255))
    mydmx.render()  # render all of the above changes onto the DMX network


mydmx = pysimpledmx.DMXConnection('/dev/ttyUSB0')  # linux com port

color = chroma.Color('#000000')
render_color(color.rgb)
color = chroma.Color('#000000')
render_color(color.rgb)
print color.rgb
# time.sleep(2)

# close dmx connection
mydmx.close()