Exemplo n.º 1
0
 def __init__(self, bor):
     self.set_defaults()
     self.bor = bor
     self.palette = [Color.white(), Color.red(), Color.green(), Color.blue(),
                    Color(255,255,0), Color(0,255,255), Color(255,0,255),
                    Color(255,121,0), Color.black()]
     self.current = Color.blue()
Exemplo n.º 2
0
    def render(self, display):
        for x in xrange(display.width):
            for y in xrange(display.height):
                display.set(
                    x, y,
                    Color(*colorsys.hsv_to_rgb(self.get_val(x, y), 1, 255)))

        display.set(int(self.x), int(self.y), Color(255, 255, 255))
Exemplo n.º 3
0
 def render(self, display):
     display.fill(Color())
     shift = 0
     for x in range(display.width):
         y = self.get_y(x)
         hue = (self.hue + shift) % 1
         if self.bor.get(x, y):
             hue += 0.5
         c = Color(*colorsys.hsv_to_rgb(hue, self.sat, self.val))
         for dy in range(self.sinewidth):
             display.set(x, y + dy, c)
             display.set(x, y - dy, c)
         shift += self.dshift
Exemplo n.º 4
0
 def __init__(self, bor):
     k = constants.font.keys()
     k.sort()
     self.set_text(0, 0, ''.join(k))
     self.color = Color(0, 0, 255)
     self.speed = 15
     self.repeat = True
     self.bor = bor
Exemplo n.º 5
0
 def render(self, display):
     fade_shiet = 1.0 - (self.fade_rate * self.dt) % 1
     # print(fade_shiet)
     display.fade(fade_shiet)
     for y in range(display.height):
         for x in range(display.width):
             if self.bor.get(x, y) or random() < (self.random_rate * self.dt):
                 display.set(x, y, Color(
                     *colorsys.hsv_to_rgb(random(), self.sat, self.val)))
Exemplo n.º 6
0
    def render(self, display):
        if self._matrix is None:
            display.fill(Color(self.ERROR_COOLOR))
            return

        for y, row in enumerate(self._matrix):
            for x, color_idx in enumerate(row):
                display.safe_set(
                    x, y, self.COLOR_PALETTE.get(color_idx, self.ERROR_COOLOR))
Exemplo n.º 7
0
 def render(self, display):
     shift = 0
     for y in range(display.height):
         for x in range(display.width):
             hue = self.hue % 1
             if self.bor.get(x, y):
                 hue += 0.5
             display.set(
                 x, y, Color(*colorsys.hsv_to_rgb(hue, self.sat, self.val)))
Exemplo n.º 8
0
    def render(self, display):
        display.fill(Color())
        shift = 0
        for x in range(display.width):
            for y in range(display.height):
                hue = (self.hue + shift) % 1
                if self.bor.get(x, y):
                    hue += 0.5
                dist = dist_to_sine(x, y, self.const, self.amp, self.freq,
                                    self.phase)
                dist = 1.0 / (1.0 + dist)

                #cp = copy.copy(c)
                #cp.fade(dist)
                c = Color(*colorsys.hsv_to_rgb(hue, self.sat, self.val * dist))

                display.set(x, y, c)

            shift += self.dshift
Exemplo n.º 9
0
    def render(self, display):
        display.fill(Color(0, 0, 0))
        for x in xrange(display.width):
            for y in xrange(display.height):
                r, g, b = 0, 0, 0
                for ball in self.balls:
                    val = ball.get_val(x, y)
                    r += ball.c.r * val
                    g += ball.c.g * val
                    b += ball.c.b * val

                if r > 255:
                    r = 255
                if g > 255:
                    g = 255
                if b > 255:
                    b = 255
                if self.bor.get(x, y):
                    display.set(x, y, Color(255, 255, 255))
                else:
                    display.set(x, y, Color(r, g, b))
Exemplo n.º 10
0
    def render(self, display):
        if self.win_animation:
            if self.winner == 1:
                c = self.paddle1.c.clone()
                display.fill(c.fade(self.factor))

            if self.winner == 2:
                c = self.paddle2.c.clone()
                display.fill(c.fade(self.factor))
            return

        display.fill(Color(0, 0, 0))
        self.ball.render(display)
        self.paddle1.render(display)
        self.paddle2.render(display)
        self.ball.handle_collisions_paddles(display)
Exemplo n.º 11
0
 def __init__(self):
     self.phase = 0
     self.dphase = 5.0
     self.colors = [
         Color(255, 182, 193),
         Color(127, 255, 212),
         Color(240, 230, 140),
         Color(165, 214, 167),
         Color(211, 211, 211),
         Color(129, 199, 132)
     ]
Exemplo n.º 12
0
 def render(self, display):
     display.fill(Color(0, 0, 0))
     for x in xrange(display.width):
         n = x - self.x - int(self.shift) - 1
         if n < len(self.buf) and n >= 0:
             self.render_col(x, self.y, n, display)
Exemplo n.º 13
0
 def render(self, display):
     current_frame = self._frames[self._current_frame_idx]
     for y in range(display.height):
         for x in range(display.width):
             display.set(x, y, Color(*current_frame.getpixel((x, y))))
Exemplo n.º 14
0
class Heatmap(object):
    COLOR_PALETTE = {
        0: Color(247, 251, 255),
        1: Color(227, 238, 249),
        2: Color(208, 225, 242),
        3: Color(182, 212, 233),
        4: Color(148, 196, 223),
        5: Color(107, 174, 214),
        6: Color(74, 152, 201),
        7: Color(46, 126, 188),
        8: Color(23, 100, 171),
        9: Color(8, 74, 145),
        None: Color(0, 0, 0)
    }

    FETCH_INTERVAL = 5 * 60  # seconds
    ERROR_COOLOR = Color(128, 0, 0)

    def __init__(self):
        self._last_fetch = 0
        self._matrix = None
        # im = Image.open(gif_path)
        # if im.size != (10, 10):
        #     raise Exception('Wrong giff size! Expected 10x10 got %sx%s' % im.size)

        # rgb_im = im.convert('RGB')

        # self._current_frame_idx = 0
        # self._frames = []

        # for frame in ImageSequence.Iterator(im):
        #     self._frames.append(frame.convert('RGB'))

        # self._dz = 8
        # self._z = 0

    def step(self, dt):
        if time.time() - self._last_fetch > self.FETCH_INTERVAL:
            self._last_fetch = time.time()
            self._matrix = get_matrix()
        # self._z += self._dz * dt
        # self._current_frame_idx = int(self._z % len(self._frames))

    def render(self, display):
        if self._matrix is None:
            display.fill(Color(self.ERROR_COOLOR))
            return

        for y, row in enumerate(self._matrix):
            for x, color_idx in enumerate(row):
                display.safe_set(
                    x, y, self.COLOR_PALETTE.get(color_idx, self.ERROR_COOLOR))