def step(self, amt=1):

        center = float(self._maxLed) / 2
        center_floor = math.floor(center)
        center_ceil = math.ceil(center)

        if self._centerOut:
            self.layout.fill(bp_colors.hue2rgb(self._step),
                             int(center_floor - self._current),
                             int(center_floor - self._current))
            self.layout.fill(bp_colors.hue2rgb(self._step),
                             int(center_ceil + self._current),
                             int(center_ceil + self._current))
        else:
            self.layout.fill(bp_colors.hue2rgb(self._step), int(self._current),
                             int(self._current))
            self.layout.fill(bp_colors.hue2rgb(self._step),
                             int(self._maxLed - self._current),
                             int(self._maxLed - self._current))

        if self._step == len(bp_colors.conversions.HUE_RAINBOW) - 1:
            self._step = 0
        else:
            self._step += amt + self._rainbowInc
            if self._step > len(bp_colors.conversions.HUE_RAINBOW) - 1:
                self._step = 0

        if self._current == center_floor:
            self._current = self._minLed
        else:
            self._current += amt

        delay_time = MidiTransform.remap_cc_value(self.delay_control, 0, 1)
        time.sleep(delay_time)
Ejemplo n.º 2
0
    def step(self, amt=1):

        center = float(self._maxLed) / 2
        center_floor = math.floor(center)
        center_ceil = math.ceil(center)

        if self._centerOut:
            self.layout.fill(
                colors.hue2rgb(self._step), int(center_floor - self._current), int(center_floor - self._current))
            self.layout.fill(
                colors.hue2rgb(self._step), int(center_ceil + self._current), int(center_ceil + self._current))
        else:
            self.layout.fill(
                colors.hue2rgb(self._step), int(self._current), int(self._current))
            self.layout.fill(
                colors.hue2rgb(self._step), int(self._maxLed - self._current), int(self._maxLed - self._current))

        if self._step == len(colors.conversions.HUE_RAINBOW) - 1:
            self._step = 0
        else:
            self._step += amt + self._rainbowInc
            if self._step > len(colors.conversions.HUE_RAINBOW) - 1:
                self._step = 0

        if self._current == center_floor:
            self._current = self._minLed
        else:
            self._current += amt
Ejemplo n.º 3
0
    def step(self, amt=1):
        self._led.all_off()

        for i in range(self._growthRate):
            newTail = random.randrange(0, 360, self._angleDiff)
            self._tails[newTail].append(0)

        for a in range(360):
            angle = self._tails[a]
            if len(angle) > 0:
                removals = []
                for r in range(len(angle)):
                    tail = angle[r]
                    if tail <= self.lastRing:
                        c = colors.hue2rgb(tail * (255 // self.lastRing))
                        self._drawTail(a, tail, c)
                        colors.hue2rgb(tail * (255 // self.lastRing))
                    if tail - (self._tail - 1) <= self.lastRing:
                        tail = tail + amt
                        self._tails[a][r] = tail
                    else:
                        removals.append(tail)
                for r in removals:
                    self._tails[a].remove(r)

        self._step = 0
Ejemplo n.º 4
0
    def step(self, amt=1):
        t = time.localtime()

        r, g, b = colors.hue2rgb(t.tm_hour * (256 // 24))
        self.layout.fillRGB(r, g, b, self._hStart, self._hEnd)

        r, g, b = colors.hue2rgb(t.tm_min * (256 // 60))
        self.layout.fillRGB(r, g, b, self._mStart, self._mEnd)

        r, g, b = colors.hue2rgb(t.tm_sec * (256 // 60))
        self.layout.fillRGB(r, g, b, self._sStart, self._sEnd)

        self._step = 0
Ejemplo n.º 5
0
    def step(self, amt=1):
        t = time.localtime()
        self.layout.all_off()
        c = colors.hue2rgb((t.tm_hour - 12) * (256 // 12))
        self.layout.set_text(str(t.tm_hour - 12).zfill(2), c, index=0)

        c = colors.hue2rgb(t.tm_min * (256 // 60))
        self.layout.set_text(str(t.tm_min).zfill(2), c, index=2)

        c = colors.hue2rgb(t.tm_sec * (256 // 60))
        self.layout.set_text(str(t.tm_sec).zfill(2), c, index=4)

        self._step = 0
    def step(self, amt=1):
        num_colors = int(MidiTransform.remap_cc_value(self.color_control, 1, 10))
        hue = int(MidiTransform.remap_cc_value(self.color_control, 1, 255))

        levels_count = int(MidiTransform.remap_cc_value(self.width_control, 5, 25))
        self._levels = self.wave_range(30, 255, levels_count)

        if num_colors > 1:
            hues = bp_colors.hue_gradient(0, hue, num_colors)
        else:
            hues = [hue]

        self._colors = list(map(lambda x: bp_colors.hue2rgb(x), hues))

        self._level_count = len(self._levels)
        self._color_count = len(self._colors)

        if self._step > self._level_count * self._color_count:
            self._step = 0

        c_index = (self._step // self._level_count) % self._color_count
        l_index = (self._step % self._level_count)

        color = self._colors[c_index]

        self.layout.fill(bp_colors.color_scale(color, self._levels[l_index]), self._start, self._end)

        self._step += amt

        delay_time = MidiTransform.remap_cc_value(self.delay_control, 0, 1)
        time.sleep(delay_time)
Ejemplo n.º 7
0
    def step(self, amt=1):
        self.layout.all_off()

        for i in range(self._growthRate):
            x = random.randint(0, self.x - 1)
            z = random.randint(0, self.z - 1)
            self._drops[x][z].append(0)

        for x in range(self.x):
            for z in range(self.z):
                col = self._drops[x][z]
                if len(col) > 0:
                    removals = []
                    for y in range(len(col)):
                        drop = col[y]
                        if drop < self.y:
                            self._drawDrop(
                                x, drop, z,
                                colors.hue2rgb(drop * (255 // self.y)))
                        if drop - (self._tail - 1) < self.y:
                            drop = drop + 1
                            self._drops[x][z][y] = drop
                        else:
                            removals.append(drop)
                    for r in removals:
                        self._drops[x][z].remove(r)

        self._step = 0
Ejemplo n.º 8
0
    def step(self, amt=1):
        num_colors = int(
            MidiTransform.remap_cc_value(self.count_control, 1, 10))
        hue = int(MidiTransform.remap_cc_value(self.color_control, 1, 255))
        self._width = int(
            MidiTransform.remap_cc_value(self.width_control, 1, 100))

        if num_colors > 1:
            hues = bp_colors.hue_gradient(0, hue, num_colors)
        else:
            hues = [hue]

        self._colors = list(map(lambda x: bp_colors.hue2rgb(x), hues))
        self._color_count = len(self._colors)
        self._total_width = self._width * self._color_count

        for i in range(self._size):
            cIndex = ((i + self._step) % self._total_width) // self._width
            self.layout.set(i, self._colors[cIndex])

        self._step += amt * (1 if self._dir else -1)

        if self._dir and self._step >= self.layout.numLEDs:
            self._step = 0
        elif not self._dir and self._step < 0:
            self._step = self.layout.numLEDs - 1

        delay_time = MidiTransform.remap_cc_value(self.delay_control, 0, 1)
        time.sleep(delay_time)
    def step(self, amt=1):
        self._led.all_off()
        t = time.localtime()
        hrs = t.tm_hour % 12
        mins = t.tm_min
        sec = t.tm_sec

        h_hrs = hrs * (256 // 12)
        h_min = mins * (256 // 60)
        h_sec = sec * (256 // 60)

        grad = []

        grad += colors.hue_gradient(h_hrs, h_min, self.half)
        if self.odd:
            grad += [h_min]
        grad += colors.hue_gradient(h_min, h_sec, self.half)

        log.debug('{}:{}:{}'.format(hrs, mins, sec))

        for x in range(self.cdim):
            self._led.drawLine(x, 0, x, self._led.height - 1,
                               colors.hue2rgb(grad[x]))

        self._step = 0
Ejemplo n.º 10
0
    def step(self, amt=1):
        self._led.all_off()

        for i in range(self._growthRate):
            newDrop = random.randint(0, self._led.width - 1)
            self._drops[newDrop].append(0)

        for x in range(self._led.width):
            col = self._drops[x]
            if len(col) > 0:
                removals = []
                for y in range(len(col)):
                    drop = col[y]
                    if drop < self._led.height:
                        self._drawDrop(
                            x, drop,
                            colors.hue2rgb(drop * (255 / self._led.height)))
                    if drop - (self._tail - 1) < self._led.height:
                        drop = drop + 1
                        self._drops[x][y] = drop
                    else:
                        removals.append(drop)
                for r in removals:
                    self._drops[x].remove(r)

        self._step = 0
    def step(self, amt=1):
        self._tail = int(MidiTransform.remap_cc_value(self.count_control, 2, self._size))
        hue = int(MidiTransform.remap_cc_value(self.color_control, 1, 255))
        hues = bp_colors.hue_gradient(0, hue, 3)

        self._colors = list(map(lambda x: bp_colors.hue2rgb(x), hues))

        self._ledcolors = [(0, 0, 0) for i in range(self._size)]
        self.layout.all_off()

        for i in range(0, 3):
            self._currentpos[i] = self._start + self._steps[i]

            # average the colors together so they blend
            self._ledcolors[self._currentpos[i]] = list(map(lambda x, y: (x + y) // 2, self._colors[i], self._ledcolors[self._currentpos[i]]))
            for j in range(1, self._tail):
                if self._currentpos[i] - j >= 0:
                    self._ledcolors[self._currentpos[i] - j] = list(map(lambda x, y: (x + y) // 2, self._ledcolors[self._currentpos[i] - j], bp_colors.color_scale(self._colors[i], 255 - (self._fadeAmt * j))))
                if self._currentpos[i] + j < self._size:
                    self._ledcolors[self._currentpos[i] + j] = list(map(lambda x, y: (x + y) // 2, self._ledcolors[self._currentpos[i] + j], bp_colors.color_scale(self._colors[i], 255 - (self._fadeAmt * j))))
            if self._start + self._steps[i] >= self._end:
                self._direction[i] = -1
            elif self._start + self._steps[i] <= 0:
                self._direction[i] = 1

            # advance each searchlight at a slightly different speed
            self._steps[i] += self._direction[i] * amt * int(random.random() > (i * 0.05))

        for i, thiscolor in enumerate(self._ledcolors):
            self.layout.set(i, thiscolor)

        delay_time = MidiTransform.remap_cc_value(self.delay_control, 0, 1)
        time.sleep(delay_time)
Ejemplo n.º 12
0
    def step(self, amt=1):
        for i in range(self._size):
            h = (i + self._step) % 255
            self.layout.set(self._start + i, colors.hue2rgb(h))

        self._step += amt
        overflow = self._step - 256
        if overflow >= 0:
            self._step = overflow
    def step(self, amt):
        for y in range(self.height):
            for x in range(self.width):
                v = int(
                    self.func(x / self._freq,
                              y / self._freq,
                              self._step / self._freq,
                              octaves=self._octaves) * 127.0 + 128.0)
                c = colors.hue2rgb(v)
                self.layout.set(x, y, c)

        self._step += amt
Ejemplo n.º 14
0
    def step(self, amt=1):
        self.layout.all_off()
        t = time.localtime()
        hrs = t.tm_hour % 12
        mins = t.tm_min
        sec = t.tm_sec

        p_hrs = pointOnCircle(self._centerX, self._centerY,
                              int(self.hand_length * 0.7), hrs * 30)
        p_min = pointOnCircle(self._centerX, self._centerY, self.hand_length,
                              mins * 6)
        p_sec = pointOnCircle(self._centerX, self._centerY, self.hand_length,
                              sec * 6)

        c_hrs = colors.hue2rgb(hrs * (256 // 12))

        c_min = colors.hue2rgb(mins * (256 // 60))

        c_sec = colors.hue2rgb(sec * (256 // 60))

        self.layout.drawLine(self._centerX,
                             self._centerY,
                             p_hrs[0],
                             p_hrs[1],
                             c_hrs,
                             aa=self.aa)
        self.layout.drawLine(self._centerX,
                             self._centerY,
                             p_min[0],
                             p_min[1],
                             c_min,
                             aa=self.aa)
        self.layout.drawLine(self._centerX,
                             self._centerY,
                             p_sec[0],
                             p_sec[1],
                             c_sec,
                             aa=self.aa)

        self._step = 0
Ejemplo n.º 15
0
    def step(self, amt):
        for y in range(self.x):
            for x in range(self.y):
                for z in range(self.z):
                    v = int(
                        snoise4(x / self._freq,
                                y / self._freq,
                                z / self._freq,
                                self._step / self._freq,
                                octaves=self._octaves) * 127.0 + 128.0)
                    c = colors.hue2rgb(v)
                    self._led.set(x, y, z, c)

        self._step += amt
Ejemplo n.º 16
0
    def draw(self, anim, left, right):
        chan = (len(left) + len(right))
        bar_w = int(self.width / chan)

        pos = (self.width - (bar_w * chan)) / 2
        count = 0
        for level in left + right:
            if self.use_hue:
                c = colors.hue2rgb(level)
            else:
                c = self.colors[count % len(self.colors)]
            self.rect(pos, self.height - self.height_map[level],
                      bar_w, self.height, c)
            pos += bar_w
            count += 1
    def step(self, amt=1):
        if self._individualPixel:
            # This setting will change the colour of each pixel on each cycle
            self.layout.fill(colors.hue2rgb(self._step), self._current,
                             self._current)

        else:
            # This setting will change the colour of all pixels on each cycle
            self.layout.fill(colors.wheel_color(self._step), 0, self._current)

        if self._step == len(colors.conversions.HUE_RAINBOW) - 1:
            self._step = 0
        else:
            self._step += amt

        if self._current == self._maxLed:
            self._current = self._minLed
        else:
            self._current += amt
    def step(self, amt = 1):
        self._led.all_off()

        for i in range(self._growthRate):
            newDrop = random.randint(0, self._led.width - 1)
            self._drops[newDrop].append(0);

        for x in range(self._led.width):
            col = self._drops[x]
            if len(col) > 0:
                removals = []
                for y in range(len(col)):
                    drop = col[y]
                    if drop < self._led.height:
                        self._drawDrop(x, drop, colors.hue2rgb(drop * (255/self._led.height)))
                    if drop - (self._tail - 1) < self._led.height:
                        drop = drop + 1
                        self._drops[x][y] = drop
                    else:
                        removals.append(drop)
                for r in removals:
                    self._drops[x].remove(r)
                      
        self._step = 0
Ejemplo n.º 19
0
 def color_map(self, width, offset=0):
     return [
         colors.hue2rgb((((i * (255)) // (width - 1)) + offset) % 256)
         for i in range(width)
     ]
Ejemplo n.º 20
0
 def step(self, amt=1):
     for i in range(self.layout.numLEDs):
         self.layout.set(i, colors.hue2rgb((i * 4) % 256))
Ejemplo n.º 21
0
 def color_map(self, width, offset=0):
     return [colors.hue2rgb((((i * (255)) / (width - 1)) + offset) % 256) for i in range(width)]
Ejemplo n.º 22
0
import bibliopixel.colors as colors
import bibliopixel.image as image

from bibliopixel.led import *
from bibliopixel.drivers.driver_base import *
from lightshow_serial_driver import *
from bibliopixel import log
from PIL import Image, ImageSequence, ImageChops, ImageEnhance

from driver_sacn import DriverSACN

log.setLogLevel(log.WARNING)
# log.setLogLevel(log.DEBUG)

color_map = [list(colors.hue2rgb(c)) for c in range(256)]
green_map = [list(colors.Green) for g in range(256)]
graded_green_map = [colors.Green for g in range(0)] + \
     [colors.Green for g in range(15)] + \
     [colors.Green for g in range(31)] + \
     [colors.Green for g in range(47)] + \
     [colors.Green for g in range(63)] + \
     [colors.Green for g in range(79)] + \
     [colors.Green for g in range(95)] + \
     [colors.Green for g in range(111)] + \
     [colors.Green for g in range(127)] + \
     [colors.Green for g in range(143)] + \
     [colors.Green for g in range(159)] + \
     [colors.Green for g in range(175)] + \
     [colors.Green for g in range(191)] + \
     [colors.Green for g in range(207)] + \
Ejemplo n.º 23
0
def mptest(i, step):
    return hue2rgb((i + step) % 255)