Store the last color(except 12, 12, 12) to fasten the print process
(frame, num=False)
| 3601 | |
| 3602 | |
| 3603 | def display(frame, num=False) -> None: |
| 3604 | """Store the last color(except 12, 12, 12) to fasten the print process""" |
| 3605 | last_color = None |
| 3606 | frame_in_str = [] |
| 3607 | for y, row in enumerate(frame): |
| 3608 | for pixel in row: |
| 3609 | # if pixel == (0, 0, 0): |
| 3610 | # frame_in_str.append(" ") |
| 3611 | # else: |
| 3612 | if pixel == last_color: |
| 3613 | frame_in_str.append("██") |
| 3614 | else: |
| 3615 | last_color = pixel |
| 3616 | frame_in_str.append( |
| 3617 | f"\033[38;2;{pixel[0]};{pixel[1]};{pixel[2]}m██" |
| 3618 | ) |
| 3619 | frame_in_str.append(f"{y:2d}\n" if num else "\n") |
| 3620 | print("".join(frame_in_str), end="\033[0m\033[F") |
| 3621 | |
| 3622 | |
| 3623 | def display_gs(frame) -> None: |
nothing calls this directly
no outgoing calls
no test coverage detected