MCPcopy Create free account
hub / github.com/ICE27182/Python-3D-renderer / display

Function display

pyrender.py:3603–3620  ·  view source on GitHub ↗

Store the last color(except 12, 12, 12) to fasten the print process

(frame, num=False)

Source from the content-addressed store, hash-verified

3601
3602
3603def 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
3623def display_gs(frame) -> None:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected