Skip to content
Merged
Show file tree
Hide file tree
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
42 changes: 24 additions & 18 deletions src/vic/color/color.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
COLORS = [
(0, 0, 0), # Black
(255, 255, 255), # White
(136, 0, 0), # Red
(170, 255, 238), # Cyan
(204, 68, 204), # Purple
(0, 204, 85), # Green
(0, 0, 170), # Blue
(238, 238, 119), # Yellow
(221, 136, 85), # Orange
(102, 68, 0), # Brown
(255, 119, 119), # Light Red
(51, 51, 51), # Dark Grey
(119, 119, 119), # Grey
(170, 255, 102), # Light Green
(0, 136, 255), # Light Blue
(187, 187, 187), # Light Grey
]
import numpy as np

# Precomputed RGB values for the 16 C64 colors.
COLORS: np.ndarray = np.array(
[
(0, 0, 0), # Black
(255, 255, 255), # White
(136, 0, 0), # Red
(170, 255, 238), # Cyan
(204, 68, 204), # Purple
(0, 204, 85), # Green
(0, 0, 170), # Blue
(238, 238, 119), # Yellow
(221, 136, 85), # Orange
(102, 68, 0), # Brown
(255, 119, 119), # Light Red
(51, 51, 51), # Dark Grey
(119, 119, 119), # Grey
(170, 255, 102), # Light Green
(0, 136, 255), # Light Blue
(187, 187, 187), # Light Grey
],
dtype=np.uint8,
)
5 changes: 2 additions & 3 deletions src/vic/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,8 @@ def draw_sprites(self) -> None:

def update_pygame_display(self) -> None:
"""Updates the Pygame window with the rendered frame."""
for y in range(self.native_height):
for x in range(self.native_width):
self.rgb_framebuffer[x, y] = COLORS[self.framebuffer[x, y]]
# Vectorized color lookup to convert the indexed framebuffer into RGB.
self.rgb_framebuffer[:] = COLORS[self.framebuffer]

surface: pygame.Surface = pygame.surfarray.make_surface(self.rgb_framebuffer)
scaled_surface: pygame.Surface = pygame.transform.scale(
Expand Down