Esempio n. 1
0
    def refresh(self, matrix):
        # this relies on the fact that the pixels we seed get multiplied and
        # overfow the uint8 in intresting ways
        matrix.blur(3)
        matrix.buf.buf = (self.mult*matrix.buf.buf).astype(np.uint8)

        self.amp += DELTA_AMP
        if self.amp >= 1 and False:
            self.amp = 0

        self.hue += DELTA_HUE

        self.ang += DELTA_ANG

        xcenter = matrix.width / 2.0
        ycenter = matrix.height / 2.0
        amp = sin(self.amp)

        tx = amp * sin(self.ang)
        ty = amp * cos(self.ang)

        x = xcenter + xcenter * tx
        y = ycenter + ycenter * ty
        color = hsvToRgb(fmod(self.hue, 1), 1, 1)
        matrix.drawPixel(x, y, color)
        self.train.add(matrix, x, y)
Esempio n. 2
0
    def _setCell(self, matrix, addr, neighbors):
        x, y = self._decode(addr)
        matrix.drawPixel(x, y, hsvToRgb(self.hue, 1, 1), self.value)
        self.filling[addr] = neighbors
        self.value -= self.deltaValue

        return self.value <= 0
Esempio n. 3
0
File: flow.py Progetto: ak15199/rop
    def _color(self):
        self.offset += 1

        if self.contiguous:
            hue = 0.0 + (self.offset+2*self.base) % 256
            return hsvToRgb(hue/255)

        index = ((self.base+self.offset)/self.blocksize) % self.huecount
        hue = self.hues[int(index)]

        phase = (self.base+self.offset) % self.blocksize
        value = self.sinlut[phase]

        self.usecount[int(index)] += 1

        return hsvToRgb(hue, 1, value)
Esempio n. 4
0
    def refresh(self, matrix):
        # this relies on the fact that the pixels we seed get multiplied and
        # overfow the uint8 in intresting ways
        matrix.blur(3)
        matrix.buf.buf = (self.mult * matrix.buf.buf).astype(np.uint8)

        self.amp += DELTA_AMP
        if self.amp >= 1 and False:
            self.amp = 0

        self.hue += DELTA_HUE

        self.ang += DELTA_ANG

        xcenter = matrix.width / 2.0
        ycenter = matrix.height / 2.0
        amp = sin(self.amp)

        tx = amp * sin(self.ang)
        ty = amp * cos(self.ang)

        x = xcenter + xcenter * tx
        y = ycenter + ycenter * ty
        color = hsvToRgb(fmod(self.hue, 1), 1, 1)
        matrix.drawPixel(x, y, color)
        self.train.add(matrix, x, y)
Esempio n. 5
0
    def _color(self):
        self.offset += 1

        if self.contiguous:
            hue = 0.0 + (self.offset + 2 * self.base) % 256
            return hsvToRgb(hue / 255)

        index = ((self.base + self.offset) / self.blocksize) % self.huecount
        hue = self.hues[index]

        phase = (self.base + self.offset) % self.blocksize
        value = self.sinlut[phase]

        self.usecount[index] += 1

        return hsvToRgb(hue, 1, value)
Esempio n. 6
0
    def refresh(self, matrix):
        matrix.shift(ds=0.75, dv=0.9)

        self.x = self.x + self.dx*self.dt
        self.y = self.y + self.dy*self.dt

        absdx, absdy = fabs(self.dx), fabs(self.dy)

        if self.x < self.radius:
            self.dx = absdx
        elif self.x >= (matrix.width-self.radius-1):
            self.dx = -absdx

        if self.y < self.radius:
            self.dy = absdy
        elif self.dy < 0.2 and self.dy > 0:
            self.dy = -absdy

        self.dy = self.dy - self.accel*self.dt

        if self.dy < 0 and self.y < self.radius:
            self._reset(matrix)
        else:
            matrix.fillCircle(self.x, self.y, self.radius,
                              hsvToRgb(self.color))
Esempio n. 7
0
    def refresh(self, matrix):
        matrix.fade(0.995)

        y0 = matrix.height/2
        x0 = matrix.width/2

        if self.angle >= pi:
            x0 -= 1

        if self.angle > (0.5*pi) and self.angle < (1.5*pi):
            y0 -= 1

        x1 = int(self.x0 + self.radius * sin(self.angle-self.astep))
        y1 = int(self.y0 + self.radius * cos(self.angle+self.astep))

        x2 = int(self.x0 + self.radius * sin(self.angle))
        y2 = int(self.y0 + self.radius * cos(self.angle))

        matrix.drawPoly(
            [(self.x0, self.y0), (x1, y1), (x2, y2)],
            hsvToRgb(self.hue)
        )

        self.hue = fmod(self.hue+self.hstep, 1.0)
        self.angle += self.astep
Esempio n. 8
0
    def refresh(self, matrix):
        matrix.fade(0.995)

        y0 = matrix.height/2
        x0 = matrix.width/2

        if self.angle >= pi:
            x0 -= 1

        if self.angle > (0.5*pi) and self.angle < (1.5*pi):
            y0 -= 1

        x1 = int(self.x0 + self.radius * sin(self.angle-self.astep))
        y1 = int(self.y0 + self.radius * cos(self.angle+self.astep))

        x2 = int(self.x0 + self.radius * sin(self.angle))
        y2 = int(self.y0 + self.radius * cos(self.angle))

        matrix.drawPoly(
            [(self.x0, self.y0), (x1, y1), (x2, y2)],
            hsvToRgb(self.hue)
        )

        self.hue = fmod(self.hue+self.hstep, 1.0)
        self.angle += self.astep
Esempio n. 9
0
File: spill.py Progetto: ak15199/rop
    def _setCell(self, matrix, addr, neighbors):
        x, y = self._decode(addr)
        matrix.drawPixel(x, y, hsvToRgb(self.hue, 1, 1), self.value)
        self.filling[addr] = neighbors
        self.value -= self.deltaValue

        return self.value <= 0
Esempio n. 10
0
    def refresh(self, matrix):
        matrix.shift(ds=0.75, dv=0.9)

        self.x = self.x + self.dx * self.dt
        self.y = self.y + self.dy * self.dt

        absdx, absdy = fabs(self.dx), fabs(self.dy)

        if self.x < self.radius:
            self.dx = absdx
        elif self.x >= (matrix.width - self.radius - 1):
            self.dx = -absdx

        if self.y < self.radius:
            self.dy = absdy
        elif self.dy < 0.2 and self.dy > 0:
            self.dy = -absdy

        self.dy = self.dy - self.accel * self.dt

        if self.dy < 0 and self.y < self.radius:
            self._reset(matrix)
        else:
            matrix.fillCircle(self.x, self.y, self.radius,
                              hsvToRgb(self.color))
Esempio n. 11
0
 def refresh(self, matrix):
     self.base += 1
     for x in range(matrix.width):
         hue = ((self.base+32*x) % 1024)/1024.0
         for y in range(matrix.height):
             pcent50 = 0.50*float(y)/(matrix.height-1)
             sat = .5 + pcent50
             val = 1 - pcent50
             matrix.drawPixel(x, y, hsvToRgb(hue, sat, val))
Esempio n. 12
0
    def refresh(self, matrix):
        self.base += 4
        h = matrix.height - 1

        for x in range(matrix.width):
            hue = (self.base + 32 * x) / (sqrt(matrix.numpix) * 64.0)
            for y in range(matrix.height):
                sat = min(1, 0.25 + (1.5 * y) / h)
                val = min(1, 0.25 + (1.5 * (h - y) / h))
                matrix.drawPixel(x, y, hsvToRgb(hue, sat, val))
Esempio n. 13
0
File: block.py Progetto: ak15199/rop
    def update(self, matrix):
        self.value += 0.2

        matrix.fillRect(
            self.x, self.y,
            self.w, self.h,
            hsvToRgb(h=self.hue, v=self.value),
            )

        return self.value < 1
Esempio n. 14
0
    def refresh(self, matrix):
        self.base += 4
        h = matrix.height - 1

        for x in range(matrix.width):
            hue = ((self.base+32*x) % 1024)/1024.0
            for y in range(matrix.height):
                sat = min(1, 0.25 + (1.5*y)/h)
                val = min(1, 0.25 + (1.5*(h-y)/h))
                matrix.drawPixel(x, y, hsvToRgb(hue, sat, val))
Esempio n. 15
0
    def refresh(self, matrix):
        try:
            pos = next(self.random)
        except:
            self.random = compoundLfsr(matrix.numpix)
            pos = next(self.random)

        # gently transition through all hues over HUEINCYCLES fills
        self.hue += 1.0/(matrix.numpix*HUEINCYCLES)
        color = hsvToRgb(self.hue, 1, 0.2+0.8*random())
        matrix.setStripPixel(pos, color)
Esempio n. 16
0
    def _render(self, matrix, target):
        grid = self.mandel.draw(target)

        matrix.clear()

        for x in range(matrix.width):
            for y in range(matrix.height):
                point = grid[x][y]
                if point is not None:
                    hue = (0.0+point)/self.mandel.maxsteps
                    matrix.drawPixel(x, y, hsvToRgb(hue))
Esempio n. 17
0
    def _render(self, matrix, target):
        grid = self.mandel.draw(target)

        matrix.clear()

        for x in range(matrix.width):
            for y in range(matrix.height):
                point = grid[x][y]
                if point is not None:
                    hue = (0.0+point)/self.mandel.maxsteps
                    matrix.drawPixel(x, y, hsvToRgb(hue))
Esempio n. 18
0
    def refresh(self, matrix):
        try:
            pos = self.random.next()
        except:
            self.random = compoundLfsr(matrix.numpix)
            pos = self.random.next()

        # gently transition through all hues over HUEINCYCLES fills
        self.hue += 1.0/(matrix.numpix*HUEINCYCLES)
        color = hsvToRgb(self.hue, 1, 0.2+0.8*random())
        matrix.setStripPixel(pos, color)
Esempio n. 19
0
    def refresh(self, matrix):
        self.huebase = self.huebase + 0.001

        # canvas for us to write to
        field = np.empty((matrix.width, matrix.height))

        # linearize x and y coordinates for regions
        xs = np.array([region["x"] for region in self.regions])
        ys = np.array([region["y"] for region in self.regions])

        # find closest region to eack pixel
        for y in range(matrix.height):
            for x in range(matrix.width):
                c = self._closest(xs, ys, x, y)
                field[x, y] = self.huebase + c / self.count

        # update region coordinates
        self.regions = [{
            "dx":
            self._bounce(region["x"], region["dx"], matrix.width - 1),
            "dy":
            self._bounce(region["y"], region["dy"], matrix.height - 1),
            "x":
            region["x"] + region["dx"],
            "y":
            region["y"] + region["dy"],
        } for region in self.regions]

        # blend old and new
        if self.field is not None:
            self.field = (self.field * 0.3) + (field * 0.7)
        else:
            self.field = field

        # draaw
        for y in range(matrix.height):
            for x in range(matrix.width):
                matrix.drawPixel(x, y, hsvToRgb(self.field[x, y], 1, 1))

        for region in self.regions:
            matrix.drawPixel(region["x"], region["y"], hsvToRgb(1, 0, 0))
Esempio n. 20
0
    def update(self, matrix, expires):
        decay = 1-(float(self.age)/expires)
        color = hsvToRgb(self.hue, 1, decay)
        matrix.drawPixel(self.x, self.y, color)

        self.x += self.dx
        if self.x == 0 or self.x >= (matrix.width-1):
            self.dx = -self.dx

        self.y += self.dy
        if self.y == 0 or self.y >= (matrix.height-1):
            self.dy = -self.dy
Esempio n. 21
0
    def update(self, matrix, expires):
        decay = 1 - (float(self.age) / expires)
        color = hsvToRgb(self.hue, 1, decay)
        matrix.drawPixel(self.x, self.y, color)

        self.x += self.dx
        if self.x == 0 or self.x >= (matrix.width - 1):
            self.dx = -self.dx

        self.y += self.dy
        if self.y == 0 or self.y >= (matrix.height - 1):
            self.dy = -self.dy
Esempio n. 22
0
File: chess.py Progetto: ak15199/rop
    def refresh(self, matrix):
        hue = next(self.hue)

        # pixels per squre 
        pps = int((sqrt(matrix.numpix)-1)/GRIDSIZE)

        xcorner = matrix.midWidth - pps*(GRIDSIZE/2)
        ycorner = matrix.midHeight - pps*(GRIDSIZE/2)

        matrix.drawRect(xcorner-1, ycorner-1,
                        pps*GRIDSIZE+1, pps*GRIDSIZE+1, C_BORDER)

        for x in range(GRIDSIZE):
            for y in range(GRIDSIZE):
                black = (x & 1) ^ (y & 1)
                if black:
                    color = hsvToRgb(hue, s=0.7, v=0.5)
                else:
                    color = hsvToRgb(hue + 0.2, v=0.8)

                matrix.fillRect(xcorner+pps*x, ycorner+pps*y, pps, pps, color)
Esempio n. 23
0
    def update(self, matrix):
        self.value += 0.2

        matrix.fillRect(
            self.x,
            self.y,
            self.w,
            self.h,
            hsvToRgb(h=self.hue, v=self.value),
        )

        return self.value < 1
Esempio n. 24
0
    def refresh(self, matrix):
        hue = next(self.hue)

        # pixels per squre
        pps = int((sqrt(matrix.numpix) - 1) / GRIDSIZE)

        xcorner = matrix.midWidth - pps * (GRIDSIZE / 2)
        ycorner = matrix.midHeight - pps * (GRIDSIZE / 2)

        matrix.drawRect(xcorner - 1, ycorner - 1, pps * GRIDSIZE + 1,
                        pps * GRIDSIZE + 1, C_BORDER)

        for x in range(GRIDSIZE):
            for y in range(GRIDSIZE):
                black = (x & 1) ^ (y & 1)
                if black:
                    color = hsvToRgb(hue, s=0.7, v=0.5)
                else:
                    color = hsvToRgb(hue + 0.2, v=0.8)

                matrix.fillRect(xcorner + pps * x, ycorner + pps * y, pps, pps,
                                color)
Esempio n. 25
0
File: pen.py Progetto: mbbx6spp/rop
    def clock(self, matrix):
        if not self.persist:
            matrix.drawPixel(self.x, self.y, BLACK)

        self.x += self.dx
        if (self.x < 1 and self.dx < 0) or \
                (self.x >= self.w-1 and self.dx > 0):
            self.ax(x=True)

        self.y += self.dy
        if (self.y < 1 and self.dy < 0) or \
                (self.y >= self.h-1 and self.dy > 0):
            self.ay(y=True)

        if self.radius == 0:
            matrix.drawPixel(self.x, self.y,
                             hsvToRgb(self.hue, v=self.value))
        else:
            matrix.fillCircle(self.x, self.y, self.radius,
                              hsvToRgb(self.hue, v=self.value))

        self.hue = fmod(self.hue + self.huedelta, 1)
Esempio n. 26
0
    def _draw(self, matrix):
        x = matrix.width*random()
        y = self.center.y + (self.pieslice[0][1]-self.center.y)*random()
        z = 2 + random()*10/self.freq

        if random() < 0.1:
            color = WHITE
        else:
            offset = int(random()*4)/4.0 if random() < 0.5 else 0
            color = hsvToRgb(offset+self.hue.next(), 1, 1)

        if random() < 0.5:
            matrix.drawRect(x, y, z, z, color)
        else:
            matrix.fillRect(x, y, z, z, color)
Esempio n. 27
0
    def refresh(self, matrix):
        minval, maxval = (10, -10)

        for y in range(matrix.height):
            for x in range(matrix.width):
                hue = (
                    sin(self._dist(x + self.base, y, 128.0, 128.0) / 8.0)
                  + sin(self._dist(y, y, 64.0, 64.0) / 8.0)
                  + sin(self._dist(x, y + self.base / 7, 192.0, 64) / 7.0)
                  + sin(self._dist(y, x, 192.0, 100.0) / 8.0))
           
                hue = fmod(fabs(1+hue/2), 1.0)
                matrix.drawPixel(x, y, hsvToRgb(hue))
        
        self.base+=0.1
Esempio n. 28
0
    def _draw(self, matrix):
        x = matrix.width * random()
        y = self.center.y + (self.pieslice[0][1] - self.center.y) * random()
        z = 2 + random() * 10 / self.freq

        if random() < 0.1:
            color = WHITE
        else:
            offset = int(random() * 4) / 4.0 if random() < 0.5 else 0
            color = hsvToRgb(offset + self.hue.next(), 1, 1)

        if random() < 0.5:
            matrix.drawRect(x, y, z, z, color)
        else:
            matrix.fillRect(x, y, z, z, color)
Esempio n. 29
0
    def translate(self, matrix, hue=None, colormap=None):
        if hue is None and colormap is None:
            raise AttributeError("Need either a hue or colormap")

        vmin = np.min(self.values)
        vmax = np.max(self.values)
        values = (self.values-vmin)/(vmax-vmin)

        if colormap is None:
            for x in range(self.width):
                for y in range(self.height):
                    color = hsvToRgb(hue+values[x, y]/5, 1, values[x, y])
                    matrix.drawPixel(x, y, color)
        else:
            buffer = colormap.apply(values)
            matrix.copyBuffer(buffer)
Esempio n. 30
0
    def translate(self, matrix, hue=None, colormap=None):
        if hue is None and colormap is None:
            raise AttributeError("Need either a hue or colormap")

        vmin = np.min(self.values)
        vmax = np.max(self.values)
        values = (self.values - vmin) / (vmax - vmin)

        if colormap is None:
            for x in range(self.width):
                for y in range(self.height):
                    color = hsvToRgb(hue + values[x, y] / 5, 1, values[x, y])
                    matrix.drawPixel(x, y, color)
        else:
            buffer = colormap.apply(values)
            matrix.copyBuffer(buffer)
Esempio n. 31
0
    def refresh(self, matrix):
        self.matrix.clear()

        self.hue += 1.0 / (6 * 4 * matrix.width)

        for y, z in enumerate(self.ys):
            val = (1 + sin(radians(360 * z))) / 2
            self.matrix.drawPixel(self.x, y, hsvToRgb(self.hue, 1, val))

        self.ys = [y + 0.08 * random() for y in self.ys]

        self.x = (self.x + 1) % matrix.width

        self.matrix.maskbelow(55, BLACK)
        matrix.fade(0.99)
        matrix.add(self.matrix)
Esempio n. 32
0
    def clock(self, matrix):
        if not self.persist:
            self._plot(matrix, BLACK)

        self.x += self.dx
        if (self.x < 1 and self.dx < 0) or \
                (self.x >= self.w-1 and self.dx > 0):
            self.ax(x=True)

        self.y += self.dy
        if (self.y < 1 and self.dy < 0) or \
                (self.y >= self.h-1 and self.dy > 0):
            self.ay(y=True)

        self._plot(matrix, hsvToRgb(self.hue, s=self.saturation, v=self.value))

        self.hue = fmod(self.hue + self.huedelta, 1)
Esempio n. 33
0
File: sweep.py Progetto: ak15199/rop
    def refresh(self, matrix):
        self.matrix.clear()

        self.hue += 1.0/(6*4*matrix.width)

        
        for y, z in enumerate(self.ys):
            val = (1+sin(radians(360*z)))/2
            self.matrix.drawPixel(self.x, y, hsvToRgb(self.hue, 1, val))

        self.ys = [y+0.08*random() for y in self.ys]

        self.x = (self.x+1)%matrix.width

        self.matrix.maskbelow(55, BLACK)
        matrix.fade(0.99)
        matrix.add(self.matrix)
Esempio n. 34
0
    def refresh(self, matrix):
        matrix.fade(0.97)

        self.amp += DELTA_AMP
        self.hue += DELTA_HUE
        self.ang += DELTA_ANG

        amp = sin(self.amp)

        tx = amp * sin(self.ang)
        ty = amp * cos(self.ang)

        x = matrix.midWidth + matrix.midWidth * tx
        y = matrix.midHeight + matrix.midHeight * ty

        color = hsvToRgb(fmod(self.hue, 1), 1, 1)

        matrix.fillRect(x-self.radius, y-self.radius, 2*self.radius, 2*self.radius, color)
Esempio n. 35
0
    def refresh(self, matrix):
        matrix.fade(0.97)

        self.amp += DELTA_AMP
        self.hue += DELTA_HUE
        self.ang += DELTA_ANG

        amp = sin(self.amp)

        tx = amp * sin(self.ang)
        ty = amp * cos(self.ang)

        x = matrix.midWidth + matrix.midWidth * tx
        y = matrix.midHeight + matrix.midHeight * ty

        color = hsvToRgb(fmod(self.hue, 1), 1, 1)

        matrix.fillRect(x-self.radius, y-self.radius, 2*self.radius, 2*self.radius, color)
Esempio n. 36
0
    def _translate(self, matrix, hue, colormap):
        vmin =  100.0
        vmax = -100.0

        for x in range(self.width):
            for y in range(self.height):
                value = self.values[x][y]
                vmin = min(value, vmin)
                vmax = max(value, vmax)

        vscale = 1.0/(vmax-vmin)

        for x in range(self.width):
            for y in range(self.height):
                value = vscale * (self.values[x][y] - vmin)
                if hue is not None:
                    color = hsvToRgb(hue+value/5, 1, value)
                else:
                    color = colormap.convert(value, 1)

                matrix.drawPixel(x, y, color)
Esempio n. 37
0
    def clock(self, matrix):
        if self.theta:
            self.angle += self.theta
            mx, my = sin(self.angle), cos(self.angle)
        else:
            mx, my = 1, 1

        if not self.persist:
            matrix.drawPixel(self.x, self.y, BLACK)

        self.x += self.dx
        if (self.x < 1 and self.dx < 0) or (self.x >= self.w-1 and self.dx > 0):
            self.ax(x=True)
        
        self.y += self.dy
        if (self.y < 1 and self.dy < 0) or (self.y >= self.h-1 and self.dy > 0):
            self.ay(y=True)
        
        matrix.drawPixel(self.x, self.y, hsvToRgb(self.hue, v=self.value))

        self.hue = fmod(self.hue + self.huedelta, 1)
Esempio n. 38
0
    def refresh(self, matrix):
        """
        For any pair of colors represented as a hue, we need to calculate
        the distance between those two hues for each of the rgb components
        of the color. For the set of four corners, we have to interpolate
        each gun independently.
        """
        rgbs = self._rotate([hsvToRgb(self.cornerValues[i]) for i in range(4)])

        for x in range(matrix.width):
            px = self._percent(x, matrix.width)
            for y in range(matrix.height):
                py = self._percent(y, matrix.height)
                rgb = self._interpolate(rgbs, px, py)
                matrix.drawPixel(x, y, rgb)

        for i in range(4):
            new = self.cornerValues[i] + self.cornerValueDeltas[i]
            self.cornerValues[i] = fmod(new, 1.0)

        if self.bits is not None:
            matrix.buf.downSample(self.bits)
Esempio n. 39
0
    def refresh(self, matrix):
        self.amp += DELTA_AMP
        if self.amp >= 1 and False:
            self.amp = 0 

        self.hue += DELTA_HUE

        self.ang += DELTA_ANG
 
        xcenter = matrix.width / 2.0
        ycenter = matrix.height / 2.0
        amp = sin(self.amp)

        tx = amp * sin (self.ang)
        ty = amp * cos (self.ang)

        x = xcenter + xcenter * tx 
        y = ycenter + ycenter * ty 
        color = hsvToRgb(fmod(self.hue, 1), 1, 1)
        
        matrix.drawPixel(x, y, color)
        self.train.add(matrix, x, y)
Esempio n. 40
0
    def refresh(self, matrix):

        """
        For any pair of colors represented as a hue, we need to calculate
        the distance between those two hues for each of the rgb components
        of the color. For the set of four corners, we have to interpolate
        each gun independently.
        """
        rgbs = self._rotate([ hsvToRgb(self.cornerValues[i]) for i in range(4) ])

        for x in range(matrix.width):
            px = self._percent(x, matrix.width)
            for y in range(matrix.height):
                py = self._percent(y, matrix.height)
                rgb = self._interpolate(rgbs, px, py)
                matrix.drawPixel(x, y, rgb)

        for i in range(4):
            new = self.cornerValues[i] + self.cornerValueDeltas[i]
            self.cornerValues[i] = fmod(new, 1.0)

        if self.bits is not None:
            matrix.buf.downSample(self.bits)
Esempio n. 41
0
    def translate(self, matrix, hue=None, colormap=None):
        vmin = 100.0
        vmax = -100.0

        if hue is None and colormap is None:
            raise AttributeError("Need either a hue or colormap")

        for x in range(self.width):
            for y in range(self.height):
                value = self.values[x][y]
                vmin = min(value, vmin)
                vmax = max(value, vmax)

        vscale = 1.0/(vmax-vmin)

        for x in range(self.width):
            for y in range(self.height):
                value = vscale * (self.values[x][y] - vmin)
                if hue is not None:
                    color = hsvToRgb(hue+value/5, 1, value)
                else:
                    color = colormap.convert(value, 1)

                matrix.drawPixel(x, y, color)
Esempio n. 42
0
    def __init__(self, matrix, horizontal):
        # increments are split into primary and secondary. primary items(p)
        # increase on subsequent calls, secondary increments happen within
        # a call to draw a row.
        if horizontal:
            self.pdx, self.pdy = 0, 1
            self.sdx, self.sdy = 1, 0
        else:
            self.pdx, self.pdy = 1, 0
            self.sdx, self.sdy = 0, 1

        if self._cointoss(0.1):
            self.color = WHITE
        else:
            self.color = hsvToRgb(random(), self._stepped(), self._stepped())

        cycleSize = int(sqrt(matrix.width * matrix.height) / REPEATS)

        self.bits = [True]
        # bits can't be all True or all false
        while not any(self.bits) or all(self.bits):
            self.bits = [self._cointoss(0.3) for bit in range(cycleSize)]

        self.px, self.py = 0, 0
Esempio n. 43
0
    def __init__(self, matrix, horizontal):
        # increments are split into primary and secondary. primary items(p)
        # increase on subsequent calls, secondary increments happen within
        # a call to draw a row.
        if horizontal:
            self.pdx, self.pdy = 0, 1
            self.sdx, self.sdy = 1, 0
        else:
            self.pdx, self.pdy = 1, 0
            self.sdx, self.sdy = 0, 1

        if self._cointoss(0.1):
            self.color = WHITE
        else:
            self.color = hsvToRgb(random(), self._stepped(), self._stepped())

        cycleSize = int(sqrt(matrix.width*matrix.height)/REPEATS)

        self.bits = [True]
        # bits can't be all True or all false
        while not any(self.bits) or all(self.bits):
            self.bits = [self._cointoss(0.3) for bit in range(cycleSize)]

        self.px, self.py = 0, 0
Esempio n. 44
0
 def _hue(self, offset):
     return hsvToRgb(self.hue + HSCALE * offset)
Esempio n. 45
0
 def _line(self, matrix, x1, x2, hue):
     color = hsvToRgb(hue, 1, 1)
     matrix.drawLine( x1, 0, x2, 0, color)
Esempio n. 46
0
 def _line(self, matrix, x1, x2, hue):
     color = hsvToRgb(hue, 1, 1)
     matrix.drawLine(x1, 0, x2, 0, color)
Esempio n. 47
0
 def _line(self, matrix, x1, x2, hue):
     for x in range(x1, x2):
         val = 0.8 + 0.2 * random()
         matrix.drawPixel(x, 0, hsvToRgb(hue, 1, val))