Пример #1
0
 def draw(self):
   self.iteration += 1
   if self.iteration <= self.maxIteration:
     return
   self.iteration = 0
   if self.x <= self.rows / 3:
     self.maxIteration = 4
   elif self.x >= 2 * (self.rows / 3):
     self.maxIteration = 4
   elif self.x <= self.rows / 5:
     self.maxIteration = 8
   elif self.x >= 4 * (self.rows / 5):
     self.maxIteration = 8
   else:
     self.maxIteration = 1
   if self.direction:
     self.x += 1
     if self.x >= self.rows:
       self.x = self.rows - 1
       self.direction = False
       self.maxIteration = 8
   else:
     self.x -= 1
     if self.x < 0:
       self.x = 0
       self.direction = True
       self.maxIteration = 8
   self.drawEye(self.x, self.y)
   for i in range(self.rows):
     for j in range(self.columns):
       if self.grid[i][j] > 0:
         dcfurs.set_pix_rgb(i, j, self.grid[i][j])
       else:
         dcfurs.set_pix_rgb(i, j, 0)
Пример #2
0
def render(str, color=0xffffff):
    ## Check for special cases
    if str == 'boop':
        boop(color)
        return
    if str == 'owo':
        owo(color)
        return
    if str == 'awoo':
        awoo(color)
        return

    ## Otherwise, generate from our character set.
    lbits = font7bit[str[0]]
    rbits = font7bit[str[-1]]
    dcfurs.clear()

    ## Draw the left character.
    column = int((8 - len(lbits))/2)
    for colbits in lbits:
        for y in range(0, dcfurs.nrows):
            if (colbits & (1 << y)) != 0:
                dcfurs.set_pix_rgb(column, y, color)
        column = column + 1

    ## Draw the right character.
    column = int((28 - len(rbits) + 1)/2)
    for colbits in rbits:
        for y in range(0, dcfurs.nrows):
            if (colbits & (1 << y)) != 0:
                dcfurs.set_pix_rgb(column, y, color)
        column = column + 1
Пример #3
0
    def drawframe(self, frame):
        self.interval = int(frame['interval'])
        x = 0
        y = 0

        # Handle monochrome and legacy animations
        if 'frame' in frame:
            # Generate the animation color mapping.
            colormap = [0] * 16
            color = badge.color()
            c_red = (color & 0xff0000) >> 16
            c_green = (color & 0x00ff00) >> 8
            c_blue = (color & 0x0000ff) >> 0
            for i in range(0, 16):
                p_red = c_red * self.intensity[i] >> 8
                p_green = c_green * self.intensity[i] >> 8
                p_blue = c_blue * self.intensity[i] >> 8
                colormap[i] = (p_red << 16) + (p_green << 8) + p_blue

            # Set the pixel values.
            data = frame['frame']
            for ch in data:
                if ch == ':':
                    x = 0
                    y = y + 1
                else:
                    dcfurs.set_pix_rgb(x, y, colormap[int(ch, 16)])
                    x = x + 1
        # Handle 8-bit RGB data
        elif 'rgb' in frame:
            pix = 0
            even = True
            data = frame['rgb']
            for ch in data:
                if ch == ':':
                    x = 0
                    y = y + 1
                elif even:
                    even = False
                    pix = int(ch, 16) << 4
                else:
                    even = True
                    pix += int(ch, 16)
                    dcfurs.set_pixel(x, y, pix)
                    x = x + 1
        # Handle 4-bit palette data
        elif 'palette' in frame:
            data = frame['palette']
            for ch in data:
                if ch == ':':
                    x = 0
                    y = y + 1
                else:
                    dcfurs.set_pixel(x, y, self.xterm[int(ch, 16)])
                    x = x + 1
        # Otherwise, we couldn't make sense of it.
        else:
            dcfurs.clear()
Пример #4
0
    def draw(self):
        #    start = utime.ticks_ms()
        #    print("start")
        self.checkButtons()
        self.update()
        #    dcfurs.clear()
        for i in range(self.rows):
            for j in range(self.columns):
                dcfurs.set_pix_rgb(i, j, self.getGrid(i, j))
#    self.bogusDisplay()
        if randrange(0, 100) < self.newDropPct:
            self.createLight()
Пример #5
0
  def draw(self):
    self.checkButtons()
#    dcfurs.clear()
    for i in range(self.rows):
      for j in range(self.columns):
        if self.grid[i][j] == 1:
          self.heatmap[i][j] += 1
          if self.heatmap[i][j] > 19:
            self.heatmap[i][j] = 19
          dcfurs.set_pix_rgb(i, j, self.nblue)
        else:
          if self.heatmap[i][j] > 0:
            dcfurs.set_pix_rgb(i, j, self.heatcolors[self.heatmap[i][j]])
    self.update()
Пример #6
0
    def draw(self):
        self.update_fire()
        self.update_boop()

        if self.boop_remaining:
            # Render at 1/4 brightness unless it's the Boop text.
            for y, row_mask in enumerate(boop_mask):
                for x in range(dcfurs.ncols):
                    color = colors[self.buffer[y][x]]
                    if (1 << x) & row_mask == 0:
                        # Non-boop pixel.
                        color = (color >> 2) & 0x3f3f3f
                    dcfurs.set_pix_rgb(x, y, color)
        else:
            for y in range(dcfurs.nrows):
                for x in range(dcfurs.ncols):
                    dcfurs.set_pix_rgb(x, y, colors[self.buffer[y][x]])
Пример #7
0
    def draw(self):
        global frameRate
        global decoder
        global videoFile
        global colorDepth

        if colorDepth == 8: frameSize = 112
        elif colorDepth == 24: frameSize = 336

        # Represents the positions of the missing pixels on the badge
        # These are used in the display algorithm to skip the missing pixels. Used to save ~14% on file size of the video.
        deadPixels0 = (0, 17)  # The missing pixels on the first row
        deadPixels5 = (7, 8, 9, 10)  # The missing pixels on row 5
        deadPixels6 = (0, 6, 7, 8, 9, 10, 11, 17
                       )  # The missing pixels on row 6

        framePos = 0

        frame = decoder.read(frameSize)  # The amount of bytes per frame

        # Reloads the video file if it reaches the end.
        if frame == b'':
            del decoder
            videoFile.close()
            videoFile = open("animations\\" + video_file_name, 'rb')
            decoder = uzlib.DecompIO(videoFile, 31)
            frame = decoder.read(frameSize)

        for y in range(0, 7,
                       1):  # A step for every vertical pixel on the badge
            for x in range(0, 18,
                           1):  # Step for every horizontal pixel on the badge
                if not (y == 0 and x in deadPixels0):  # Skips missing pixels
                    if not (y == 5 and x in deadPixels5):
                        if not (y == 6 and x in deadPixels6):
                            #testnum = ord(frame[framePos])
                            if colorDepth == 24:
                                dcfurs.set_pix_rgb(
                                    x, y,
                                    int.from_bytes(
                                        frame[framePos * 3:framePos * 3 + 3],
                                        "big"))
                            elif colorDepth == 8:
                                dcfurs.set_pixel(x, y, frame[framePos])
                            framePos += 1
Пример #8
0
    def draw(self):
        self.shift += 1

        xshift = self.xshift_scale * math.sin(self.shift / self.xshift_speed)
        yshift = self.yshift_scale * math.sin(self.shift / self.yshift_speed)
        hshift = self.hshift_scale * math.sin(self.shift / self.hshift_speed)

        for x in range(dcfurs.ncols):
            for y in range(dcfurs.nrows):
                colbright = math.sin(math.sin(x/self.xscale + self.xoffset) + xshift) * \
                            math.sin(math.sin(y/self.yscale + self.yoffset) + yshift)
                hue = math.sin(math.sin(x/self.hscale + self.hoffset) + hshift) * \
        math.sin(math.sin(y/self.hscale + self.hoffset) + hshift)
                #dcfurs.set_pix_rgb(x, y, gamma_table[int(colbright*255)])
                dcfurs.set_pix_rgb(
                    x, y,
                    badge.hue2rgb(int(hue * 360),
                                  val=gamma_table[int(colbright * 255)]))