make fantasy cell smaller

This commit is contained in:
2026-06-25 23:56:42 -04:00
parent 91cf160685
commit b132736a9f
2 changed files with 10 additions and 9 deletions
+9 -9
View File
@@ -2,7 +2,7 @@ import requests
from PIL import Image from PIL import Image
from rgbmatrix import graphics from rgbmatrix import graphics
import utils.logos as logos import utils.logos as logos
from utils.vars import Colors, font, font_small, PANEL_WIDTH, PANEL_HEIGHT, GAME_WIDTH, DIVIDER_COLOR from utils.vars import Colors, font, font_small, PANEL_WIDTH, PANEL_HEIGHT, FANTASY_WIDTH, DIVIDER_COLOR
from time import time from time import time
FETCH_INTERVAL = 60 # seconds between API calls FETCH_INTERVAL = 60 # seconds between API calls
@@ -122,13 +122,13 @@ def _build_virtual_canvas(cells):
if not cells: if not cells:
return None return None
n = len(cells) n = len(cells)
total_w = GAME_WIDTH * (n + 4) # +4 tail so wrap never shows black total_w = FANTASY_WIDTH * (n + 4) # +4 tail so wrap never shows black
img = Image.new("RGB", (total_w, PANEL_HEIGHT), (0, 0, 0)) img = Image.new("RGB", (total_w, PANEL_HEIGHT), (0, 0, 0))
for i, cell in enumerate(cells * 2): for i, cell in enumerate(cells * 2):
if i >= n + 4: if i >= n + 4:
break break
_render_pil(img, cell, i * GAME_WIDTH) _render_pil(img, cell, i * FANTASY_WIDTH)
return img, n return img, n
@@ -136,7 +136,7 @@ def _build_virtual_canvas(cells):
def _render_pil(img, cell, x): def _render_pil(img, cell, x):
# right-edge divider # right-edge divider
for y in range(PANEL_HEIGHT): for y in range(PANEL_HEIGHT):
img.putpixel((x + GAME_WIDTH - 1, y), DIVIDER_COLOR) img.putpixel((x + FANTASY_WIDTH - 1, y), DIVIDER_COLOR)
# NFL team logo for player cells # NFL team logo for player cells
if cell["type"] == "player" and cell["nfl_team"]: if cell["type"] == "player" and cell["nfl_team"]:
@@ -161,13 +161,13 @@ def _blit_slice(canvas, img, offset):
# Text overlay (drawn on top of the blitted PIL layer) # Text overlay (drawn on top of the blitted PIL layer)
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
def _draw_overlay(canvas, cells, scroll_x): def _draw_overlay(canvas, cells, scroll_x):
total_w = GAME_WIDTH * len(cells) total_w = FANTASY_WIDTH * len(cells)
for i, cell in enumerate(cells): for i, cell in enumerate(cells):
bx = i * GAME_WIDTH - scroll_x bx = i * FANTASY_WIDTH - scroll_x
for wrap in [0, total_w]: for wrap in [0, total_w]:
x = bx + wrap x = bx + wrap
if x + GAME_WIDTH < 0 or x >= PANEL_WIDTH: if x + FANTASY_WIDTH < 0 or x >= PANEL_WIDTH:
continue continue
if cell["type"] == "team_info": if cell["type"] == "team_info":
_draw_team_info(canvas, cell, x) _draw_team_info(canvas, cell, x)
@@ -224,7 +224,7 @@ def _draw_player(canvas, cell, x):
ind_map = {"Questionable": "Q", "Doubtful": "D", "Out": "X", "IR": "IR"} ind_map = {"Questionable": "Q", "Doubtful": "D", "Out": "X", "IR": "IR"}
indicator = ind_map.get(injury, "?") indicator = ind_map.get(injury, "?")
ind_color = Colors.YELLOW.value if injury in ("Questionable", "Doubtful") else Colors.RED.value ind_color = Colors.YELLOW.value if injury in ("Questionable", "Doubtful") else Colors.RED.value
graphics.DrawText(canvas, font_small, x + GAME_WIDTH - 10, 7, graphics.DrawText(canvas, font_small, x + FANTASY_WIDTH - 10, 7,
_rbg(ind_color), indicator) _rbg(ind_color), indicator)
# Position + fantasy points # Position + fantasy points
@@ -265,7 +265,7 @@ def draw_frame(canvas):
_virtual_dirty = False _virtual_dirty = False
_scroll_x = 0 _scroll_x = 0
total_scroll_w = GAME_WIDTH * len(_cells) total_scroll_w = FANTASY_WIDTH * len(_cells)
canvas.Clear() canvas.Clear()
+1
View File
@@ -18,6 +18,7 @@ LOGO_DIR = os.path.join(ASSET_DIR, "logos")
PANEL_WIDTH = 256 PANEL_WIDTH = 256
PANEL_HEIGHT = 32 PANEL_HEIGHT = 32
GAME_WIDTH = 128 GAME_WIDTH = 128
FANTASY_WIDTH = 64
DIVIDER_COLOR = (40, 40, 40) DIVIDER_COLOR = (40, 40, 40)
font = graphics.Font() font = graphics.Font()