36 lines
882 B
Python
36 lines
882 B
Python
"""Shared constants for ComfyUI-GameDev nodes."""
|
|
|
|
|
|
def _build_vga_256_palette():
|
|
"""Build VGA-256 palette using the same method as GlitchNodes Pixel8Bit.
|
|
|
|
Palette recipe:
|
|
- 6x6x6 RGB cube with levels {0, 51, 102, 153, 204, 255}
|
|
- 40-step grayscale ramp across 0..255
|
|
- Remove exact duplicates while preserving first occurrence order
|
|
"""
|
|
levels = [0, 51, 102, 153, 204, 255]
|
|
palette = []
|
|
|
|
for r in levels:
|
|
for g in levels:
|
|
for b in levels:
|
|
palette.append((r, g, b))
|
|
|
|
for i in range(40):
|
|
value = int(round((255.0 * i) / 39.0))
|
|
palette.append((value, value, value))
|
|
|
|
deduped = []
|
|
seen = set()
|
|
for color in palette:
|
|
if color in seen:
|
|
continue
|
|
seen.add(color)
|
|
deduped.append(color)
|
|
|
|
return deduped
|
|
|
|
|
|
VGA_256_COLORS = _build_vga_256_palette()
|