mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-04-10 21:03:01 +00:00
oversized milb team logos
This commit is contained in:
@@ -67,7 +67,10 @@ class BaseMiLBManager:
|
||||
try:
|
||||
logo_path = os.path.join(self.logo_dir, f"{team_abbr}.png")
|
||||
if os.path.exists(logo_path):
|
||||
return Image.open(logo_path)
|
||||
logo = Image.open(logo_path)
|
||||
if logo.mode != 'RGBA':
|
||||
logo = logo.convert('RGBA')
|
||||
return logo
|
||||
else:
|
||||
logger.warning(f"Logo not found for team {team_abbr}")
|
||||
return None
|
||||
@@ -135,31 +138,45 @@ class BaseMiLBManager:
|
||||
width = self.display_manager.matrix.width
|
||||
height = self.display_manager.matrix.height
|
||||
image = Image.new('RGB', (width, height), color=(0, 0, 0))
|
||||
draw = ImageDraw.Draw(image)
|
||||
|
||||
# Set logo size to match NHL (150% of display width)
|
||||
max_width = 35
|
||||
max_height = 35
|
||||
logo_size = (max_width, max_height)
|
||||
logo_y_offset = (height - max_height) // 2
|
||||
# Make logos 150% of display dimensions to allow them to extend off screen
|
||||
max_width = int(width * 1.5)
|
||||
max_height = int(height * 1.5)
|
||||
|
||||
# Load team logos
|
||||
away_logo = self._get_team_logo(game_data['away_team'])
|
||||
home_logo = self._get_team_logo(game_data['home_team'])
|
||||
|
||||
if away_logo and home_logo:
|
||||
away_logo = away_logo.resize(logo_size, Image.Resampling.LANCZOS)
|
||||
home_logo = home_logo.resize(logo_size, Image.Resampling.LANCZOS)
|
||||
# Resize maintaining aspect ratio
|
||||
away_logo.thumbnail((max_width, max_height), Image.Resampling.LANCZOS)
|
||||
home_logo.thumbnail((max_width, max_height), Image.Resampling.LANCZOS)
|
||||
|
||||
# Position logos with NHL-style spacing (0px offset)
|
||||
away_x = 0
|
||||
away_y = logo_y_offset
|
||||
# Create a single overlay for both logos
|
||||
overlay = Image.new('RGBA', (width, height), (0, 0, 0, 0))
|
||||
|
||||
# Calculate vertical center line for alignment
|
||||
center_y = height // 2
|
||||
|
||||
# Draw home team logo (far right, extending beyond screen)
|
||||
home_x = width - home_logo.width + 2
|
||||
home_y = center_y - (home_logo.height // 2)
|
||||
|
||||
home_x = width - home_logo.width
|
||||
home_y = logo_y_offset
|
||||
# Paste the home logo onto the overlay
|
||||
overlay.paste(home_logo, (home_x, home_y), home_logo)
|
||||
|
||||
# Draw away team logo (far left, extending beyond screen)
|
||||
away_x = -2
|
||||
away_y = center_y - (away_logo.height // 2)
|
||||
|
||||
overlay.paste(away_logo, (away_x, away_y), away_logo)
|
||||
|
||||
image.paste(away_logo, (away_x, away_y), away_logo)
|
||||
image.paste(home_logo, (home_x, home_y), home_logo)
|
||||
# Composite the overlay with the main image
|
||||
image = image.convert('RGBA')
|
||||
image = Image.alpha_composite(image, overlay)
|
||||
image = image.convert('RGB')
|
||||
|
||||
draw = ImageDraw.Draw(image)
|
||||
|
||||
# For upcoming games, show date and time stacked in the center
|
||||
if game_data['status'] == 'status_scheduled':
|
||||
|
||||
Reference in New Issue
Block a user