Beispiel #1
0
    def render(self):
        font = get_font()
        text_color = graphics.Color(*ledcolors.scoreboard.text)

        self.canvas.Fill(*ledcolors.scoreboard.fill)
        no_text = 'No'
        no_x = center_text_position(no_text, self.canvas.width)
        graphics.DrawText(self.canvas, font, no_x, 8, text_color, no_text)

        games_text = 'games'
        games_x = center_text_position(games_text, self.canvas.width)
        graphics.DrawText(self.canvas, font, games_x, 15, text_color,
                          games_text)

        today_text = 'today'
        today_x = center_text_position(today_text, self.canvas.width)
        graphics.DrawText(self.canvas, font, today_x, 22, text_color,
                          today_text)

        frown_text = ':('
        frown_x = center_text_position(frown_text, self.canvas.width)
        graphics.DrawText(self.canvas, font, frown_x, 29, text_color,
                          frown_text)

        self.matrix.SwapOnVSync(self.canvas)

        while True:
            pass  # I hate the offseason and off days.
Beispiel #2
0
    def render(self):
        font = get_font()
        text_color = graphics.Color(255, 235, 59)
        if self.canvas.width > 32:
            long_word = 'scheduled'
        else:
            long_word = 'today'

        while True:
            time_now = time.strftime("%-I:%M%p")
            self.canvas.Fill(7, 14, 25)

            no_games_text = 'No games scheduled today'
            no_games_x = center_text_position(no_games_text,
                                              self.canvas.width / 2, 4)
            graphics.DrawText(self.canvas, font, no_games_x, 8, text_color,
                              no_games_text)

            today_text = long_word
            today_x = center_text_position(today_text, self.canvas.width / 2,
                                           4)
            graphics.DrawText(self.canvas, font, today_x, 15, text_color,
                              today_text)

            time_text = time_now
            time_x = center_text_position(time_text, self.canvas.width / 2, 4)
            graphics.DrawText(self.canvas, font, time_x, 26, text_color,
                              time_text)

            self.matrix.SwapOnVSync(self.canvas)
            time.sleep(15)
            pass
Beispiel #3
0
 def __render_inning_break(self):
     color = graphics.Color(*ledcolors.scoreboard.text)
     text = self.inning.state
     num = self.inning.ordinal()
     text_x = center_text_position(text, self.canvas.width)
     num_x = center_text_position(num, self.canvas.width)
     graphics.DrawText(self.canvas, self.font, text_x, 22, color, text)
     graphics.DrawText(self.canvas, self.font, num_x, 29, color, num)
 def __render_matchup(self):
   away_text = '{:>3s}'.format(self.game.away_team)
   home_text = '{:3s}'.format(self.game.home_team)
   teams_text = "{}  {}".format(away_text, home_text)
   teams_text_x = center_text_position(teams_text, self.canvas.width)
   at_x = center_text_position("@", self.canvas.width)
   graphics.DrawText(self.canvas, self.font, teams_text_x, self.coords["matchup"]["y"], self.text_color, teams_text)
   graphics.DrawText(self.canvas, self.font, at_x, self.coords["matchup"]["y"], self.text_color, "@")
Beispiel #5
0
 def __render_inning_break(self):
   text_font = self.layout.font("inning.break.text")
   num_font = self.layout.font("inning.break.number")
   text_coords = self.layout.coords("inning.break.text")
   num_coords = self.layout.coords("inning.break.number")
   color = self.colors.graphics_color("inning.break.text")
   text = self.inning.state
   num  = self.inning.ordinal()
   text_x = center_text_position(text, text_coords["x"], text_font["size"]["width"])
   num_x = center_text_position(num, num_coords["x"], num_font["size"]["width"])
   graphics.DrawText(self.canvas, text_font["font"], text_x, text_coords["y"], color, text)
   graphics.DrawText(self.canvas, num_font["font"], num_x, num_coords["y"], color, num)
Beispiel #6
0
 def __render_warmup(self):
   warmup_text = self.game.status
   coords = self.layout.coords("pregame.warmup_text")
   font = self.layout.font("pregame.warmup_text")
   color = self.colors.graphics_color("pregame.warmup_text")
   warmup_x = center_text_position(warmup_text, coords["x"], font["size"]["width"])
   graphics.DrawText(self.canvas, font["font"], warmup_x, coords["y"], color, warmup_text)
Beispiel #7
0
 def __render_start_time(self):
   time_text = self.game.start_time
   coords = self.layout.coords("pregame.start_time")
   font = self.layout.font("pregame.start_time")
   color = self.colors.graphics_color("pregame.start_time")
   time_x = center_text_position(time_text, coords["x"], font["size"]["width"])
   graphics.DrawText(self.canvas, font["font"], time_x, coords["y"], color, time_text)
Beispiel #8
0
 def __render_inning_break(self):
     text_font = self.layout.font("inning.break.text")
     num_font = self.layout.font("inning.break.number")
     text_coords = self.layout.coords("inning.break.text")
     num_coords = self.layout.coords("inning.break.number")
     color = self.colors.graphics_color("inning.break.text")
     text = self.inning.state
     num = self.inning.ordinal()
     text_x = center_text_position(text, text_coords["x"],
                                   text_font["size"]["width"])
     num_x = center_text_position(num, num_coords["x"],
                                  num_font["size"]["width"])
     graphics.DrawText(self.canvas, text_font["font"], text_x,
                       text_coords["y"], color, text)
     graphics.DrawText(self.canvas, num_font["font"], num_x,
                       num_coords["y"], color, num)
Beispiel #9
0
  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.matrix.SwapOnVSync(self.canvas)
      time.sleep(10.0)
      self.__fill_bg()
      self.data.advance_to_next_standings()
 def __render_start_time(self):
   time_text = self.game.start_time
   coords = self.layout.coords("pregame.start_time")
   font = self.layout.font("pregame.start_time")
   color = self.colors.graphics_color("pregame.start_time")
   time_x = center_text_position(time_text, coords["x"], font["size"]["width"])
   graphics.DrawText(self.canvas, font["font"], time_x, coords["y"], color, time_text)
def __render_game_status(canvas, layout, colors, scoreboard, short_text):
    color = colors.graphics_color("status.text")
    text = __get_text_for_status(scoreboard, short_text)
    coords = layout.coords("status.text")
    font = layout.font("status.text")
    text_x = center_text_position(text, coords["x"], font["size"]["width"])
    graphics.DrawText(canvas, font["font"], text_x, coords["y"], color, text)
 def __render_warmup(self):
   warmup_text = self.game.status
   coords = self.layout.coords("pregame.warmup_text")
   font = self.layout.font("pregame.warmup_text")
   color = self.colors.graphics_color("pregame.warmup_text")
   warmup_x = center_text_position(warmup_text, coords["x"], font["size"]["width"])
   graphics.DrawText(self.canvas, font["font"], warmup_x, coords["y"], color, warmup_text)
Beispiel #13
0
 def __render_game_status(self):
     color = graphics.Color(*ledcolors.scoreboard.text)
     text = self.scoreboard.game_status
     if self.canvas.width == 32 and text == POSTPONED:
         text = POSTPONED_SHORTHAND
     text_x = center_text_position(text, self.canvas.width)
     graphics.DrawText(self.canvas, self.font, text_x, 20, color, text)
Beispiel #14
0
 def __render_clock(self):
   time_text = time.strftime("%-I:%M%p")
   coords = self.layout.coords("offday.time")
   font = self.layout.font("offday.time")
   color = self.colors.graphics_color("offday.time")
   text_x = center_text_position(time_text, coords["x"], font["size"]["width"])
   graphics.DrawText(self.canvas, font["font"], text_x, coords["y"], color, time_text)
Beispiel #15
0
 def __render_final_inning(self):
     color = graphics.Color(*ledcolors.scoreboard.text)
     text = "FINAL"
     if self.scoreboard.inning.number > NORMAL_GAME_LENGTH:
         text += " " + str(self.scoreboard.inning.number)
     text_x = center_text_position(text, self.canvas.width)
     graphics.DrawText(self.canvas, self.font, text_x, 20, color, text)
Beispiel #16
0
 def __render_weather_text(self, text, keyname):
     coords = self.layout.coords("offday.{}".format(keyname))
     font = self.layout.font("offday.{}".format(keyname))
     color = self.colors.graphics_color("offday.{}".format(keyname))
     text_x = center_text_position(text, coords["x"], font["size"]["width"])
     graphics.DrawText(self.canvas, font["font"], text_x, coords["y"],
                       color, text)
  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.matrix.SwapOnVSync(self.canvas)
      time.sleep(10.0)
      self.__fill_bg()
      self.data.advance_to_next_standings()
Beispiel #18
0
 def __render_game_status(self):
     color = self.colors.graphics_color("status.text")
     text = self.__get_text_for_status()
     coords = self.data.config.layout.coords("status.text")
     font = self.data.config.layout.font("status.text")
     text_x = center_text_position(text, coords["x"], font["size"]["width"])
     graphics.DrawText(self.canvas, font["font"], text_x, coords["y"],
                       color, text)
Beispiel #19
0
def render(matrix, canvas, error_strings):
    font = get_font()
    text_color = graphics.Color(*ledcolors.scoreboard.text)
    current_y = 9
    offset = 7

    canvas.Fill(*ledcolors.scoreboard.fill)
    error_text = 'ERROR'
    error_x = center_text_position(error_text, canvas.width)
    graphics.DrawText(canvas, font, error_x, 7, text_color, error_text)

    for error_string in error_strings:
        current_y += offset
        text = error_string
        text_x = center_text_position(text, canvas.width)
        graphics.DrawText(canvas, font, text_x, current_y, text_color, text)

    matrix.SwapOnVSync(canvas)
def render(matrix, canvas, error_strings):
  font = get_font()
  text_color = graphics.Color(255, 235, 59)
  current_y = 9
  offset = 7

  canvas.Fill(7, 14, 25)
  error_text = 'ERROR'
  error_x = center_text_position(error_text, canvas.width/2, 4)
  graphics.DrawText(canvas, font, error_x, 7, text_color, error_text)

  for error_string in error_strings:
    current_y += offset
    text = error_string
    text_x = center_text_position(text, canvas.width/2, 4)
    graphics.DrawText(canvas, font, text_x, current_y, text_color, text)

  matrix.SwapOnVSync(canvas)
Beispiel #21
0
def __render_clock(canvas, layout, colors, time_format):
    time_format_str = "{}:%M".format(time_format)
    if time_format == "%-I":
        time_format_str += "%p"
    time_text = time.strftime(time_format_str)
    coords = layout.coords("offday.time")
    font = layout.font("offday.time")
    color = colors.graphics_color("offday.time")
    text_x = center_text_position(time_text, coords["x"], font["size"]["width"])
    graphics.DrawText(canvas, font["font"], text_x, coords["y"], color, time_text)
Beispiel #22
0
def render_network_error(canvas, layout, colors):
    font = layout.font("network")
    coords = layout.coords("network")
    bg_coords = coords["background"]
    text_color = colors.graphics_color("network.text")
    bg_color = colors.color("network.background")

    # Fill in the background so it's clearly visible
    for x in range(bg_coords["width"]):
        for y in range(bg_coords["height"]):
            canvas.SetPixel(x + bg_coords["x"], y + bg_coords["y"], bg_color["r"], bg_color["g"], bg_color["b"])
    text = NETWORK_ERROR_TEXT
    x = center_text_position(text, coords["text"]["x"], font["size"]["width"])
    graphics.DrawText(canvas, font["font"], x, coords["text"]["y"], text_color, text)
Beispiel #23
0
  def __render_final_inning(self):
    text = "FINAL"
    color = self.colors.graphics_color("final.inning")
    coords = self.data.config.layout.coords("final.inning")
    font = self.data.config.layout.font("final.inning")
    if self.scoreboard.inning.number != NORMAL_GAME_LENGTH:
      text += " " + str(self.scoreboard.inning.number)
    text_x = center_text_position(text, coords["x"], font["size"]["width"])
    graphics.DrawText(self.canvas, font["font"], text_x, coords["y"], color, text)

    if self.data.config.layout.state_is_nohitter():
      nohit_text = NoHitterRenderer(self.canvas, self.data).nohitter_text()
      nohit_coords = self.data.config.layout.coords("final.nohit_text")
      nohit_color = self.colors.graphics_color("final.nohit_text")
      nohit_font = self.data.config.layout.font("final.nohit_text")
      graphics.DrawText(self.canvas, nohit_font["font"], nohit_coords["x"], nohit_coords["y"], nohit_color, nohit_text)
def _render_final_inning(canvas, layout, colors, scoreboard):
    text = "FINAL"
    color = colors.graphics_color("final.inning")
    coords = layout.coords("final.inning")
    font = layout.font("final.inning")
    if scoreboard.inning.number != NORMAL_GAME_LENGTH:
        text += " " + str(scoreboard.inning.number)
    text_x = center_text_position(text, coords["x"], font["size"]["width"])
    graphics.DrawText(canvas, font["font"], text_x, coords["y"], color, text)

    if layout.state_is_nohitter():
        nohit_text = nohitter._get_nohitter_text(layout)
        nohit_coords = layout.coords("final.nohit_text")
        nohit_color = colors.graphics_color("final.nohit_text")
        nohit_font = layout.font("final.nohit_text")
        graphics.DrawText(canvas, nohit_font["font"], nohit_coords["x"],
                          nohit_coords["y"], nohit_color, nohit_text)
Beispiel #25
0
    def render(self):
        if self.data.network_issues == True:
            font = self.layout.font("network")
            coords = self.layout.coords("network")
            bg_coords = coords["background"]
            text_color = self.colors.graphics_color("network.text")
            bg_color = self.colors.color("network.background")

            # Fill in the background so it's clearly visible
            for x in range(bg_coords["width"]):
                for y in range(bg_coords["height"]):
                    self.canvas.SetPixel(x + bg_coords["x"],
                                         y + bg_coords["y"], bg_color['r'],
                                         bg_color['g'], bg_color['b'])
            text = NETWORK_ERROR_TEXT
            x = center_text_position(text, coords["text"]["x"],
                                     font["size"]["width"])
            graphics.DrawText(self.canvas, font["font"], x,
                              coords["text"]["y"], text_color, text)
    def __render_final_inning(self):
        text = "FINAL"
        color = self.colors.graphics_color("final.inning")
        coords = self.data.config.layout.coords("final.inning")
        font = self.data.config.layout.font("final.inning")
        if self.scoreboard.inning.number != NORMAL_GAME_LENGTH:
            text += " " + str(self.scoreboard.inning.number)
        text_x = center_text_position(text, coords["x"], font["size"]["width"])
        graphics.DrawText(self.canvas, font["font"], text_x, coords["y"],
                          color, text)

        if self.data.config.layout.state_is_nohitter():
            nohit_text = NoHitterRenderer(self.canvas,
                                          self.data).nohitter_text()
            nohit_coords = self.data.config.layout.coords("final.nohit_text")
            nohit_color = self.colors.graphics_color("final.nohit_text")
            nohit_font = self.data.config.layout.font("final.nohit_text")
            graphics.DrawText(self.canvas, nohit_font["font"],
                              nohit_coords["x"], nohit_coords["y"],
                              nohit_color, nohit_text)
def __render_static_wide_standings(canvas, layout, colors, division, league):
    coords = layout.coords("standings")
    font = layout.font("standings")
    divider_color = get_standings_color_node(colors, "divider", league)
    team_stat_color = get_standings_color_node(colors, "team.stat", league)
    team_name_color = get_standings_color_node(colors, "team.name", league)
    team_elim_color = get_standings_color_node(colors, "team.elim", league)
    team_clinched_color = get_standings_color_node(colors, "team.clinched", league)
    start = coords.get("start", 0)
    offset = coords["offset"]

    graphics.DrawLine(canvas, 0, start, coords["width"], start, divider_color)

    graphics.DrawLine(
        canvas, coords["divider"]["x"], start, coords["divider"]["x"], start + coords["height"], divider_color
    )

    offset += start

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

        color = team_elim_color if team.elim else (team_clinched_color if team.clinched else team_name_color)
        team_text = team.team_abbrev
        graphics.DrawText(canvas, font["font"], coords["team"]["name"]["x"], offset, 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"])

        color = team_elim_color if team.elim else (team_clinched_color if team.clinched else team_stat_color)
        graphics.DrawText(canvas, font["font"], record_text_x, offset, color, record_text)
        graphics.DrawText(canvas, font["font"], gb_text_x, offset, color, gb_text)

        offset += coords["offset"]
Beispiel #28
0
 def __render_weather_text(self, text, keyname):
   coords = self.layout.coords("offday.{}".format(keyname))
   font = self.layout.font("offday.{}".format(keyname))
   color = self.colors.graphics_color("offday.{}".format(keyname))
   text_x = center_text_position(text, coords["x"], font["size"]["width"])
   graphics.DrawText(self.canvas, font["font"], text_x, coords["y"], color, text)
Beispiel #29
0
	def __center_position(self):
		return center_text_position(self.text, abs(self.width/2) + self.x, self.font["size"]["width"])
Beispiel #30
0
 def __render_warmup(self):
     warmup_text = self.game.status
     warmup_x = center_text_position(warmup_text, self.canvas.width)
     graphics.DrawText(self.canvas, self.font, warmup_x, 20,
                       self.text_color, warmup_text)
Beispiel #31
0
 def __render_game_status(self):
     color = graphics.Color(*ledcolors.scoreboard.text)
     text = self.__get_text_for_status()
     text_x = center_text_position(text, self.canvas.width)
     graphics.DrawText(self.canvas, self.font, text_x,
                       self.config.coords["status"]["y"], color, text)
def __center_position(text, font, width, x):
    return center_text_position(text,
                                abs(width // 2) + x, font["size"]["width"])
Beispiel #33
0
 def __render_start_time(self):
     time_text = self.game.start_time
     time_x = center_text_position(time_text, self.canvas.width)
     graphics.DrawText(self.canvas, self.font, time_x, 13, self.text_color,
                       time_text)