Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions pdd/logo_animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,17 +98,22 @@ def _get_centered_logo_positions(
console_height: int
) -> List[Tuple[int, int]]:
"""Calculates target positions for particles to form the centered logo."""
if not logo_art_lines: return [(0,0)] * len(particles) # Should not happen if particles exist
logo_width = max(len(line) for line in logo_art_lines) if logo_art_lines else 0
logo_height = len(logo_art_lines)
if not logo_art_lines:
return [(0, 0)] * len(particles) # Should not happen if particles exist
# Combine computation of logo_height and logo_width in one pass for performance
logo_height = 0
logo_width = 0
for line in logo_art_lines:
logo_height += 1
line_len = len(line)
if line_len > logo_width:
logo_width = line_len

offset_x = (console_width - logo_width) // 2
offset_y = (console_height - logo_height) // 2

target_positions: List[Tuple[int,int]] = []
for p in particles:
target_positions.append((p.orig_logo_x + offset_x, p.orig_logo_y + offset_y))
return target_positions
# List comprehension is faster for simple mapping
return [(p.orig_logo_x + offset_x, p.orig_logo_y + offset_y) for p in particles]

def _get_box_perimeter_positions(
particles: List[AnimatedParticle],
Expand Down