split out

This commit is contained in:
2026-06-21 00:56:13 -04:00
parent 8c932a8d86
commit 8cf50c9413
6 changed files with 285 additions and 270 deletions
+9
View File
@@ -0,0 +1,9 @@
from enum import Enum
# --- Pre-built colors ---
class Colors(Enum):
WHITE = (255, 255, 255)
YELLOW = (255, 200, 0)
RED = (255, 50, 50)
SABRES_BLUE = (0, 135, 48)
SABRES_GOLD = (252, 20, 210)
+6
View File
@@ -0,0 +1,6 @@
import os
from pathlib import Path
SCRIPT_DIR = Path(__file__).parent.resolve()
ASSET_DIR = os.path.join(SCRIPT_DIR, "assets")
LOGO_DIR = os.path.join(ASSET_DIR, "logos")
+10
View File
@@ -0,0 +1,10 @@
from rgbmatrix import graphics
from utils.data import ASSET_DIR
import os
font = graphics.Font()
font_small = graphics.Font()
font_big = graphics.Font()
font.LoadFont(os.path.join(ASSET_DIR, "fonts/7x13.bdf"))
font_small.LoadFont(os.path.join(ASSET_DIR, "fonts/5x7.bdf"))
font_big.LoadFont(os.path.join(ASSET_DIR, "fonts/9x18.bdf"))
+35
View File
@@ -0,0 +1,35 @@
import os
from utils.data import LOGO_DIR
from PIL import Image
logo_cache = {}
def load_logo(league, abbr):
key = f"{league}_{abbr}"
if key in logo_cache:
return logo_cache[key]
path = os.path.join(LOGO_DIR, f"{key}.png")
if not os.path.exists(path):
print(f"Logo not found: {path}")
logo_cache[key] = None
return None
try:
# FIX: convert to RGB here so draw_logo always gets 3-channel pixels
img = Image.open(path).convert("RGB")
logo_cache[key] = img
return img
except Exception as e:
print(f"Error loading logo {key}: {e}")
logo_cache[key] = None
return None
def draw_logo(canvas, img, x, y):
if img is None:
return
for px in range(img.width):
for py in range(img.height):
# FIX: unpack as RGB (load_logo guarantees RGB now)
r, g, b = img.getpixel((px, py))
canvas.SetPixel(x + px, y + py, r, b, g) # bgr panels