Coverage for src/retrospeedlab/games/zenith_rush/pixels.py: 54%

13 statements  

« prev     ^ index     » next       coverage.py v7.16.2, created at 2026-12-04 02:12 +0000

1Rows = tuple[str, ...] 

2 

3 

4def mirrored(half: Rows) -> Rows: 

5 return tuple(row + row[::-1] for row in half) 

6 

7 

8def swapped(rows: Rows, mapping: dict[str, str]) -> Rows: 

9 return tuple("".join(mapping[pixel] if pixel in mapping else pixel for pixel in row) for row in rows) 

10 

11 

12def padded(rows: Rows, width: int, height: int) -> Rows: 

13 left = (width - len(rows[0])) // 2 

14 top = (height - len(rows)) // 2 

15 blank = "." * width 

16 body = tuple(("." * left + row).ljust(width, ".") for row in rows) 

17 return (blank,) * top + body + (blank,) * (height - top - len(rows)) 

18 

19 

20def flipped(rows: Rows) -> Rows: 

21 return tuple(reversed(rows))