def __render_rotating_standings(self):
    coords = self.data.config.layout.coords("standings")
    font = self.data.config.layout.font("standings")
    stat = 'w'
    starttime = time.time()
    while True:
      offset = coords["offset"]
      graphics.DrawText(self.canvas, font["font"], coords["stat_title"]["x"], offset, self.stat_color, stat.upper())
      graphics.DrawLine(self.canvas, coords["divider"]["x"], 0, coords["divider"]["x"], coords["height"], self.divider_color)

      for team in self.data.current_standings().teams:
        graphics.DrawLine(self.canvas, 0, offset, coords["width"], offset, self.divider_color)

        team_text = "{:3s}".format(team.team_abbrev)
        stat_text = str(getattr(team, stat))
        graphics.DrawText(self.canvas, font["font"], coords["team"]["name"]["x"], offset, self.team_name_color, team_text)
        graphics.DrawText(self.canvas, font["font"], coords["team"]["record"]["x"], offset, self.team_stat_color, stat_text)
      
        offset += coords["offset"]
      
      self.matrix.SwapOnVSync(self.canvas)
      time.sleep(5.0)

      self.__fill_bg()

      if stat == 'l':
        self.data.advance_to_next_standings()
        stat = 'w'
      else:
        stat = 'l'
  def __render_static_wide_standings(self):
    coords = self.data.config.layout.coords("standings")
    font = self.data.config.layout.font("standings")
    while True:
      offset = coords["offset"]
      graphics.DrawLine(self.canvas, coords["divider"]["x"], 0, coords["divider"]["x"], coords["height"], self.divider_color)

      for team in self.data.current_standings().teams:
        graphics.DrawLine(self.canvas, 0, offset, coords["width"], offset, self.divider_color)

        team_text = team.team_abbrev
        graphics.DrawText(self.canvas, font["font"], coords["team"]["name"]["x"], offset, self.team_name_color, team_text)

        record_text = "{}-{}".format(team.w, team.l)
        record_text_x = center_text_position(record_text, coords["team"]["record"]["x"], font["size"]["width"])

        if "-" in str(team.gb):
          gb_text = " -  "
        else:
          gb_text = "{:>4s}".format(str(team.gb))
        gb_text_x = coords["team"]["games_back"]["x"] - (len(gb_text) * font["size"]["width"])

        graphics.DrawText(self.canvas, font["font"], record_text_x, offset, self.team_stat_color, record_text)
        graphics.DrawText(self.canvas, font["font"], gb_text_x, offset, self.team_stat_color, gb_text)

        offset += coords["offset"]
      
      self.__fill_standings_footer()

      self.matrix.SwapOnVSync(self.canvas)
      time.sleep(10.0)
      self.__fill_bg()
      self.data.advance_to_next_standings()
Exemple #3
0
def animate():
    global canvas, matrix

    for times in range(3):
        for color_code in range(256):
            if times == 0:
                color = graphics.Color(color_code, 0, 0)
            if times == 1:
                color = graphics.Color(0, color_code, 0)
            if times == 2:
                color = graphics.Color(0, 0, color_code)

            for i in range(led_rows):
                graphics.DrawLine(canvas, 0, i, led_cols * led_chain, i, color)

            time.sleep(0.001)
            canvas = matrix.SwapOnVSync(canvas)

        for color_code in range(255, -1, -1):
            if times == 0:
                color = graphics.Color(color_code, 0, 0)
            if times == 1:
                color = graphics.Color(0, color_code, 0)
            if times == 2:
                color = graphics.Color(0, 0, color_code)

            for i in range(led_rows):
                graphics.DrawLine(canvas, 0, i, led_cols * led_chain, i, color)

            time.sleep(0.001)
            canvas = matrix.SwapOnVSync(canvas)
Exemple #4
0
def display_idle():
    matrix.Clear()
    matrix.brightness = 3
    white = graphics.Color(255, 255, 255)
    graphics.DrawLine(matrix, 0, 0, 0, 63, white)
    graphics.DrawLine(matrix, 0, 63, 63, 63, white)
    graphics.DrawLine(matrix, 63, 63, 63, 0, white)
    graphics.DrawLine(matrix, 63, 0, 0, 0, white)
Exemple #5
0
def bars(matrix):
    for i in range(24):
        colorChanger(matrix[0])
        for a in range(4):
            graphics.DrawLine(matrixL, (0 + a) + 4 * i, 32, (0 + a) + 4 * i, 0,
                              black)
            graphics.DrawLine(matrixL, (0 + a) + 4 * i, 32, (0 + a) + 4 * i,
                              32 - matrix[i], green)
Exemple #6
0
 def drawPercentH(self, centerX, centerY, percent, scale, dispColour):
     percent = int(percent / 10)
     scale = int(scale/2)
     
     graphics.DrawLine(self.offscreen_canvas, centerX - (scale + 1), centerY, centerX - (scale + 1),  centerY + 1, Colours.White)
     graphics.DrawLine(self.offscreen_canvas, centerX + scale, centerY, centerX + scale,  centerY + 1, Colours.White)
     graphics.DrawLine(self.offscreen_canvas, centerX - (scale + 1), centerY + 1, centerX + scale,  centerY + 1, dispColour)
     
     graphics.DrawLine(self.offscreen_canvas, centerX + (-(scale + 1) + percent), centerY, centerX + (-(scale + 1) + percent),  centerY + 1, dispColour)
 def __render_base_outline(self, base, color):
     x, y = (base["x"], base["y"])
     size = base["size"]
     half = abs(size / 2)
     graphics.DrawLine(self.canvas, x + half, y, x, y + half, color)
     graphics.DrawLine(self.canvas, x + half, y, x + size, y + half, color)
     graphics.DrawLine(self.canvas, x + half, y + size, x, y + half, color)
     graphics.DrawLine(self.canvas, x + half, y + size, x + size, y + half,
                       color)
 def __render_baserunner(self, base, color):
     x, y = (base["x"], base["y"])
     size = base["size"]
     half = abs(size / 2)
     for offset in range(1, half + 1):
         graphics.DrawLine(self.canvas, x + half - offset,
                           y + size - offset, x + half + offset,
                           y + size - offset, color)
         graphics.DrawLine(self.canvas, x + half - offset, y + offset,
                           x + half + offset, y + offset, color)
Exemple #9
0
def bars(matrix):
    if nOfK !=0:
        for i in range(16):
            colorChanger(matrix[0])
            for a in range(6):
                graphics.DrawLine(matrixL,(0+a)+6*i,32,(0+a)+6*i,0,black)
                graphics.DrawLine(matrixL,(0+a)+6*i,32,(0+a)+6*i,32-matrix[i],green)
    else:
        for i in range(96):
                graphics.DrawLine(matrixL,0+i,32,0+i,0,black)
Exemple #10
0
    def draw_4(self, location, canvas):
        if location == 'top':
            text_offset = 0
            circle_offset = 2
        else:
            text_offset = 15
            circle_offset = 17
        green = graphics.Color(0, 120, 60)
        white = graphics.Color(255, 255, 255)

        self.drawCircle(canvas, circle_offset, green)

        graphics.DrawLine(canvas, 10, 5 + text_offset, 10, 5 + text_offset,
                          white)
        graphics.DrawLine(canvas, 9, 6 + text_offset, 10, 6 + text_offset,
                          white)
        graphics.DrawLine(canvas, 8, 7 + text_offset, 8, 7 + text_offset,
                          white)
        graphics.DrawLine(canvas, 10, 7 + text_offset, 10, 7 + text_offset,
                          white)
        graphics.DrawLine(canvas, 7, 8 + text_offset, 7, 8 + text_offset,
                          white)
        graphics.DrawLine(canvas, 10, 8 + text_offset, 10, 8 + text_offset,
                          white)
        graphics.DrawLine(canvas, 7, 9 + text_offset, 11, 9 + text_offset,
                          white)
        graphics.DrawLine(canvas, 10, 10 + text_offset, 10, 10 + text_offset,
                          white)
        graphics.DrawLine(canvas, 10, 11 + text_offset, 10, 11 + text_offset,
                          white)
Exemple #11
0
def draw_incident(canvas, font_file, message):
    logging.info("Got to draw incident")
    height_delta = 8
    width_delta = 6

    total_width = 128

    font = graphics.Font()
    font.LoadFont(font_file)
    red_color = graphics.Color(255, 0, 0)
    yellow_color = graphics.Color(200, 125, 0)
    green_color = graphics.Color(50, 150, 0)

    canvas.Clear()

    for y in range(0, 8):
        for x in range(0, 32):
            x0 = x * 4
            x1 = x0 + 3
            if x % 2 == 0 and y <= 3:
                graphics.DrawLine(canvas, x0, y, x1, y, yellow_color)
            elif x % 2 != 0 and y > 3:
                graphics.DrawLine(canvas, x0, y, x1, y, yellow_color)

    logging.info("Got past drawing squares")

    if "scheduled maintenance" in message or "scheduled track work" in message:
        graphics.DrawText(canvas, font, 1, 15, red_color, "SCHEDULED")
        graphics.DrawText(canvas, font, 1, 23, red_color, "TRACK WORK")
        logging.info("Drawing scheduled track workd")
    else:
        logging.info("Drawing service advisory")
        service = "SERVICE"
        advisory = "ADVISORY"
        graphics.DrawText(canvas, font, compute_offset(service), 15, red_color,
                          service)
        graphics.DrawText(canvas, font, compute_offset(advisory), 23,
                          red_color, advisory)

    for y in range(24, 32):
        for x in range(0, 32):
            x0 = x * 4
            x1 = x0 + 3
            if x % 2 == 0 and y <= 27:
                graphics.DrawLine(canvas, x0, y, x1, y, yellow_color)
            elif x % 2 != 0 and y > 27:
                graphics.DrawLine(canvas, x0, y, x1, y, yellow_color)

    logging.info("Got past drawing other squares")

    time.sleep(5)

    canvas.Clear()
    draw_message(canvas, message, font_file)
 def __fill_standings_footer(self):
     coords = self.data.config.layout.coords("standings")
     graphics.DrawLine(self.canvas, 0, coords["height"], coords["width"],
                       coords["height"], self.bg_color)
     graphics.DrawLine(self.canvas, coords["divider"]["x"], 0,
                       coords["divider"]["x"], coords["height"],
                       self.divider_color)
     graphics.DrawLine(self.canvas, 0, coords["height"] + 1,
                       coords["width"], coords["height"] + 1, self.bg_color)
     graphics.DrawLine(self.canvas, coords["divider"]["x"], 0,
                       coords["divider"]["x"], coords["height"] + 1,
                       self.divider_color)
Exemple #13
0
    def DrawRect(self, canvas, color, centroid: tuple, size: tuple):
        c_x, c_y = centroid
        width, height = size

        x1 = c_x - width / 2
        y1 = c_y - height / 2
        x2 = c_x + width / 2
        y2 = c_y + height / 2

        graphics.DrawLine(canvas, x1, y1, x1, y2, color)
        graphics.DrawLine(canvas, x1, y1, x2, y1, color)
        graphics.DrawLine(canvas, x1, y2, x2, y2, color)
        graphics.DrawLine(canvas, x2, y2, x2, y1, color)
Exemple #14
0
 def draw(self, canvas):
     graphics.DrawLine(canvas,
                       self.x + self.radius * math.cos(self.orientation),
                       self.y + self.radius * math.sin(self.orientation), 
                       self.x + self.radius * math.cos(self.orientation + 90),
                       self.y + self.radius * math.sin(self.orientation + 90),
                       blue)
     graphics.DrawLine(canvas,
                       self.x + self.radius * math.cos(self.orientation),
                       self.y + self.radius * math.sin(self.orientation), 
                       self.x + self.radius * math.cos(self.orientation - 90),
                       self.y + self.radius * math.sin(self.orientation - 90),
                       blue)
Exemple #15
0
	def render(self, scroll_pos):
		if self.__text_should_scroll():
			x = scroll_pos
			pos = graphics.DrawText(self.canvas, self.font["font"], x, self.y, self.text_color, self.text)
			h = self.font["size"]["height"]
			for x in range(self.x):
				graphics.DrawLine(self.canvas, x, self.y, x, self.y - h, self.bg_color)
			for x in range(self.x + self.width, self.canvas.width):
				graphics.DrawLine(self.canvas, x, self.y, x, self.y - h, self.bg_color)
			return pos

		else:
			graphics.DrawText(self.canvas, self.font["font"], self.__center_position(), self.y, self.text_color, self.text)
			return 0
Exemple #16
0
 def drawCircle(self, canvas,  x, y, color):
     # Draw circle with lines
     graphics.DrawLine(canvas, x+2, y+0, x+6, y+0, color)
     graphics.DrawLine(canvas, x+1, y+1, x+7, y+1, color)
     graphics.DrawLine(canvas, x+0, y+2, x+8, y+2, color)
     graphics.DrawLine(canvas, x+0, y+3, x+8, y+3, color)
     graphics.DrawLine(canvas, x+0, y+4, x+8, y+4, color)
     graphics.DrawLine(canvas, x+0, y+5, x+8, y+5, color)
     graphics.DrawLine(canvas, x+0, y+6, x+8, y+6, color)
     graphics.DrawLine(canvas, x+1, y+7, x+7, y+7, color)
     graphics.DrawLine(canvas, x+2, y+8, x+6, y+8, color)
Exemple #17
0
 def drawPercentV(self, centerX, centerY, percent, scale,  low,  high, dispColour):
     
     high -= low
     percent -= low
     low = 0
     
     percent = int((scale / high) * percent)
     
     scale = int(scale / 2)
     
     graphics.DrawLine(self.offscreen_canvas, centerX - 1, centerY - scale, centerX + 1,  centerY - scale, Colours.White)
     graphics.DrawLine(self.offscreen_canvas, centerX - 1, centerY + scale, centerX + 1,  centerY + scale, Colours.White)
     graphics.DrawLine(self.offscreen_canvas, centerX, centerY - scale, centerX,  centerY + scale, dispColour)
     
     graphics.DrawLine(self.offscreen_canvas, centerX - 1, (centerY + scale) - percent, centerX + 1,  (centerY + scale) - percent, dispColour)
Exemple #18
0
    def draw_line(self, x1, y1, x2, y2, c):
        """Allows for shapes to be drawn on the matrix
        @:param canvas (rgb matrix) can be left none, if this is done, Pen will create a new matrix object"""
        if not isinstance(c, graphics.Color):
            c = graphics.Color(c[0], c[1], c[2])

        graphics.DrawLine(self.matrix, x1, y1, x2, y2, c)
Exemple #19
0
def RGBesitoMatch(puntiA, puntiB):
    offline_matrix.Clear()  # pulisce la matrice offline da comporre
    ESITOfont = font2
    fontL = 5  # font 5x7
    ESITOcolor = graphics.Color(96, 96, 96)
    stringa1 = 'VINCE'
    stringa1X = 32 - int(fontL * len(stringa1) / 2)
    stringa1Y = 7
    stringa2 = 'LA PARTITA'
    stringa2X = 32 - int(fontL * len(stringa2) / 2)
    stringa2Y = 14
    graphics.DrawText(offline_matrix, ESITOfont, stringa1X, stringa1Y,
                      ESITOcolor, stringa1)
    graphics.DrawText(offline_matrix, ESITOfont, stringa2X, stringa2Y,
                      ESITOcolor, stringa2)
    stringa3 = ''
    stringa3Y = 28
    WINNERfont = font4
    fontL = 9  # font 9x18
    WINNERcolor = RGBColWhite
    if puntiA == pntMax:
        stringa3 = 'A'
        stringa3X = 0
    elif puntiB == pntMax:
        stringa3 = 'B'
        stringa3X = 64 - fontL
    graphics.DrawText(offline_matrix, WINNERfont, stringa3X, stringa3Y,
                      WINNERcolor, stringa3)
    graphics.DrawLine(offline_matrix, 0, 29, 63, 29, WINNERcolor)
    sound3.play(0)
    return
Exemple #20
0
 def __render_arrow(self, x, y, size, direction):
     keypath = "inning.arrow.up" if direction == 1 else "inning.arrow.down"
     color = self.colors.graphics_color(keypath)
     for offset in range(size):
         graphics.DrawLine(self.canvas, x - offset,
                           y + (offset * direction), x + offset,
                           y + (offset * direction), color)
    def draw_f(self, location, canvas):
        if location == 'top':
            text_offset = 0
            circle_offset = 2
        else:
            text_offset = 15
            circle_offset = 17

        self.drawCircle(canvas, circle_offset, orange)

        graphics.DrawLine(canvas, 7, 5 + text_offset, 11, 5 + text_offset,
                          white)
        graphics.DrawLine(canvas, 7, 6 + text_offset, 7, 11 + text_offset,
                          white)
        graphics.DrawLine(canvas, 8, 8 + text_offset, 9, 8 + text_offset,
                          white)
Exemple #22
0
    def draw_f(self, location, canvas):
        if location == 'top':
            text_offset = 0
            circle_offset = 2
        else:
            text_offset = 15
            circle_offset = 17
        orange = graphics.Color(255, 99, 25)
        black = graphics.Color(0, 0, 0)

        self.drawCircle(canvas, circle_offset, orange)
        graphics.DrawLine(canvas, 7, 5 + text_offset, 11, 5 + text_offset,
                          black)
        graphics.DrawLine(canvas, 7, 6 + text_offset, 7, 11 + text_offset,
                          black)
        graphics.DrawLine(canvas, 8, 8 + text_offset, 9, 8 + text_offset,
                          black)
Exemple #23
0
def drawLineAnimation(canvas=None, counterIncr=1):
    global _state

    if canvas is None:
        canvas = _state.matrix
    data = _state.timer_tick_data

    drawLineAnimationCounter = data.get('drawLineAnimationCounter', 1)
    data['drawLineAnimationCounter'] = drawLineAnimationCounter + counterIncr
    red = data.get('red')

    if drawLineAnimationCounter >= canvas.height:
        data['drawLineAnimationCounter'] = 0
        graphics.DrawLine(canvas, 0, 0, 0, canvas.height, data.get('black'))
    else:
        graphics.DrawLine(canvas, 0, 0, 0,
                          drawLineAnimationCounter % canvas.height, red)
Exemple #24
0
def showOrders(canvas, font, color):
    #Print how many orders we still have to pack
    incomming, done = getOrders()
    graphics.DrawText(canvas, font, 6, 13, color, "Kvar")
    graphics.DrawText(canvas, font, 39, 13, color, "Klar")
    graphics.DrawLine(canvas, 32, 32, 32, 0, color)
    graphics.DrawText(canvas, font, 12, 27, color, incomming)
    graphics.DrawText(canvas, font, 43, 27, color, done)
    def draw_m(self, location, canvas):
        if location == 'top':
            text_offset = 0
            circle_offset = 2
        else:
            text_offset = 15
            circle_offset = 17
        orange = graphics.Color(255, 99, 25)
        black = graphics.Color(0, 0, 0)
        white = graphics.Color(255, 255, 255)
        yellow = graphics.Color(252, 204, 10)

        self.drawCircle(canvas, circle_offset, orange)

        graphics.DrawLine(canvas, 6, 5 + text_offset, 6, 11 + text_offset,
                          black)
        graphics.DrawLine(canvas, 12, 5 + text_offset, 12, 11 + text_offset,
                          black)
        graphics.DrawLine(canvas, 7, 6 + text_offset, 7, 6 + text_offset,
                          black)
        graphics.DrawLine(canvas, 8, 7 + text_offset, 8, 7 + text_offset,
                          black)
        graphics.DrawLine(canvas, 9, 8 + text_offset, 9, 8 + text_offset,
                          black)
        graphics.DrawLine(canvas, 10, 7 + text_offset, 10, 7 + text_offset,
                          black)
        graphics.DrawLine(canvas, 11, 6 + text_offset, 11, 6 + text_offset,
                          black)
Exemple #26
0
 def animCorner(self):
     animColour = Colours.Red
     x = (self.__panelWidth - self.__animTotal) + self.__animStep
     
     graphics.DrawLine(self.offscreen_canvas, x, 0, x,  10, animColour)
     
     self.__animStep += 1
     if self.__animStep > self.__animTotal:
         self.__animStep = 0
Exemple #27
0
	def draw_offday(self, font):
		for x in range(self.matrix.height):
			graphics.DrawLine(self.matrix, 0, x, self.matrix.width, x, graphics.Color(0, 0, 0))
		nhl_logo_img = Image.open("nhl_logo.png")
		nhl_logo_img.thumbnail((self.matrix.height, self.matrix.height), Image.ANTIALIAS)
		self.matrix.SetImage(nhl_logo_img.convert('RGB'))
		graphics.DrawText(self.matrix, font, 40, 10, graphics.Color(255, 255, 255), "No")
		graphics.DrawText(self.matrix, font, 31, 17, graphics.Color(255, 255, 255), "games")
		graphics.DrawText(self.matrix, font, 40, 26, graphics.Color(255, 255, 255), ":(")
Exemple #28
0
    def draw_e(self, location, canvas):
        if location == 'top':
            text_offset = 0
            circle_offset = 2
        else:
            text_offset = 15
            circle_offset = 17
        blue = graphics.Color(0, 57, 166)
        white = graphics.Color(255, 255, 255)

        self.drawCircle(canvas, circle_offset, blue)
        graphics.DrawLine(canvas, 7, 5 + text_offset, 7, 11 + text_offset,
                          white)
        graphics.DrawLine(canvas, 8, 5 + text_offset, 11, 5 + text_offset,
                          white)
        graphics.DrawLine(canvas, 8, 8 + text_offset, 10, 8 + text_offset,
                          white)
        graphics.DrawLine(canvas, 8, 11 + text_offset, 11, 11 + text_offset,
                          white)
 def run(self):
     base_point = (self.x2, self.y1)
     x = base_point[0]
     for item in self.history:
         graphics.DrawLine(self.canvas, 
             x, base_point[1], 
             x, base_point[1] + self.map(item['value']), item['color'])
         x -= 1
     length = self.x2 - self.x1
     if len(self.history) > length:
         self.history.pop(0)
Exemple #30
0
 def windDirection(self, centerX, centerY, windPointer,  windSpeed,  handLength,  handColour):
     circleRadius = 5
     arrowHeadSize = 10
     
     windPointer = float(windPointer)
     windPointerR = math.radians(windPointer)
     
     sinMult = math.sin(windPointerR)
     cosMult = math.cos(windPointerR)
     
     graphics.DrawCircle(self.offscreen_canvas, centerX, centerY, circleRadius,  handColour)
     graphics.DrawLine(self.offscreen_canvas, centerX + ((sinMult * circleRadius) * 1.1), centerY - ((cosMult * circleRadius) * 1.1), centerX + (sinMult * handLength),  centerY - (cosMult * handLength), handColour)
     
     # Left
     headAngle = windPointer - arrowHeadSize
     if headAngle > 360:
         headAngle += 360
     
     sinMultL = math.sin(math.radians(headAngle))
     cosMultL = math.cos(math.radians(headAngle))
     
     graphics.DrawLine(self.offscreen_canvas, centerX + (sinMultL * (handLength - 1)),  centerY - (cosMultL * (handLength - 1)), centerX + (sinMult * handLength),  centerY - (cosMult * handLength), handColour)
     
     # Right
     headAngle = windPointer + arrowHeadSize
     if headAngle > 360:
         headAngle -= 360
     
     sinMultR = math.sin(math.radians(headAngle))
     cosMultR = math.cos(math.radians(headAngle))
     
     graphics.DrawLine(self.offscreen_canvas, centerX + (sinMultR * (handLength - 1)),  centerY - (cosMultR * (handLength - 1)), centerX + (sinMult * handLength),  centerY - (cosMult * handLength), handColour)
     
     dispString = "%2.0f" % (float(windSpeed))
     
     if float(windSpeed) < 10:
         charWidth = 2
     else:
         charWidth  = 0
     
     graphics.DrawText(self.offscreen_canvas, self.__font, (centerX - 3) - charWidth, centerY + 3, handColour, dispString)