the whole game

This commit is contained in:
2026-03-02 22:04:18 +03:00
parent 816e9060b4
commit f0617a5d22
2069 changed files with 581500 additions and 0 deletions

38
project/raspberry/py/image.py Executable file
View File

@@ -0,0 +1,38 @@
import Image
import apiutil
def hexToRgb(hex):
return (hex >> 16) & 255, (hex >> 8) & 255, hex & 255
cgaColors = map(hexToRgb, (
0x000000,
0x0000A8,
0x00A800,
0x00A8A8,
0xFF0000,
0xA800A8,
0xA85400,
0xA8A8A8,
0x545454,
0x5454FE,
0x54FE54,
0x54FEFE,
0xFE5454,
0xFE54FE,
0xFEFE54,
0xFEFEFE))
cgaPalette = apiutil.flatten(cgaColors)
def _padPalette(values, count):
v = tuple(values)
return v + (0, 0, 0) * (count - len(v))
def imageToCga(im):
p = Image.new("P", (1,1))
p.putpalette(_padPalette(cgaPalette, 256))
return im.convert("RGB").quantize(palette=p, kmeans=255)
def imageToWool(im, (w, h)):
cga = imageToCga(im.resize((w, h)))