Yes, you can do it -- if you are using numbers. However, if you want to save space, at some point you will want to save this as raw
Code: Select all
DATA = (
(255, 255, 255, 255, 255, 255),
(243, 243, 247, 251, 243, 255),
(204, 221, 238, 255, 255, 255),
(221, 128, 221, 128, 221, 255),
(247, 129, 228, 198, 208, 247),
(204, 219, 243, 249, 204, 255),
(246, 205, 99, 220, 102, 255),
(243, 247, 254, 255, 255, 255),
(246, 253, 252, 253, 246, 255),
(231, 223, 207, 223, 231, 255),
(255, 217, 226, 217, 255, 255),
(255, 243, 192, 243, 255, 255),
(255, 255, 255, 243, 247, 254),
(255, 255, 128, 255, 255, 255),
(255, 255, 255, 255, 243, 255),
(207, 219, 243, 249, 252, 255),
(210, 205, 200, 220, 225, 255),
(247, 241, 243, 243, 226, 255),
(225, 206, 227, 253, 192, 255),
(225, 206, 227, 206, 225, 255),
(243, 249, 220, 192, 207, 255),
(192, 252, 228, 207, 225, 255),
(210, 252, 225, 204, 226, 255),
(192, 219, 243, 249, 252, 255),
(226, 204, 226, 204, 226, 255),
(226, 204, 210, 207, 225, 255),
(255, 243, 255, 243, 255, 255),
(255, 243, 255, 243, 247, 254),
(207, 243, 252, 243, 207, 255),
(255, 192, 255, 192, 255, 255),
(252, 243, 207, 243, 252, 255),
(225, 207, 227, 251, 243, 255),
(226, 205, 196, 212, 189, 210),
(226, 221, 204, 196, 204, 255),
(228, 204, 228, 204, 228, 255),
(226, 205, 252, 205, 226, 255),
(228, 220, 204, 220, 228, 255),
(208, 252, 244, 252, 208, 255),
(208, 252, 252, 244, 252, 255),
(210, 253, 252, 141, 210, 255),
(204, 204, 196, 204, 204, 255),
(209, 243, 243, 243, 209, 255),
(203, 207, 207, 220, 226, 255),
(220, 204, 216, 244, 200, 255),
(252, 252, 252, 236, 192, 255),
(221, 196, 192, 200, 204, 255),
(205, 212, 209, 197, 220, 255),
(226, 221, 204, 221, 226, 255),
(228, 204, 204, 228, 252, 255),
(226, 204, 204, 200, 210, 207),
(228, 204, 204, 224, 204, 255),
(210, 236, 226, 206, 225, 255),
(192, 226, 243, 243, 243, 255),
(204, 204, 204, 221, 226, 255),
(204, 204, 221, 230, 243, 255),
(204, 200, 196, 192, 217, 255),
(204, 217, 226, 217, 204, 255),
(204, 221, 230, 243, 243, 255),
(192, 222, 247, 237, 192, 255),
(208, 252, 252, 252, 208, 255),
(252, 249, 243, 219, 207, 255),
(193, 207, 207, 207, 193, 255),
(243, 217, 238, 255, 255, 255),
(255, 255, 255, 255, 128, 255),
(252, 247, 239, 255, 255, 255),
(255, 210, 205, 204, 134, 255),
(252, 228, 220, 204, 228, 255),
(255, 210, 253, 188, 198, 255),
(207, 198, 205, 204, 134, 255),
(255, 214, 205, 177, 210, 255),
(203, 183, 193, 243, 243, 246),
(255, 226, 204, 210, 223, 225),
(252, 228, 220, 204, 204, 255),
(243, 251, 241, 179, 219, 255),
(207, 239, 199, 207, 221, 226),
(253, 236, 216, 244, 204, 255),
(246, 243, 243, 243, 219, 255),
(255, 217, 196, 200, 204, 255),
(255, 228, 221, 204, 204, 255),
(255, 226, 204, 204, 226, 255),
(255, 228, 220, 204, 228, 252),
(255, 198, 205, 204, 198, 207),
(255, 201, 244, 252, 252, 255),
(255, 210, 248, 203, 225, 255),
(243, 209, 243, 179, 219, 255),
(255, 204, 204, 205, 130, 255),
(255, 204, 221, 230, 243, 255),
(255, 204, 200, 209, 217, 255),
(255, 204, 230, 230, 204, 255),
(255, 220, 205, 210, 207, 225),
(255, 192, 219, 249, 192, 255),
(211, 243, 249, 243, 211, 255),
(243, 243, 247, 243, 243, 255),
(241, 243, 219, 243, 241, 255),
(191, 114, 141, 254, 255, 255),
(102, 153, 102, 153, 102, 153),
)
def blit(pixel, x, y, char, palette):
char = ord(char) - 0x20
if not 0 <= char <= 127:
char = 127
for row, byte in enumerate(DATA[char]):
for col in range(4):
pixel(x + col, y + row, palette[(byte >> (col * 2)) & 0x03])
def blit2(pixel, x, y, char):
blit(pixel, x, y, char, (0, 0, 1, 1))
def blit4(pixel, x, y, char):
blit(pixel, x, y, char, (0, 1, 2, 3))
Which, as you can see, is very inoptimal from the point of view of storage, but it was just a quick test of the display, so I didn't care much.
At some point I would probably save this as one large string, something like this:
and saved as compiled bytecode.