Commit 6462ee48 authored by Malte Schmitz's avatar Malte Schmitz

Add color

parent c80e79df
20px-color.bmp

4.9 KB | W: | H:

20px-color.bmp

4.9 KB | W: | H:

20px-color.bmp
20px-color.bmp
20px-color.bmp
20px-color.bmp
  • 2-up
  • Swipe
  • Onion skin
██ ██ ██ ██ ██
██ ██ ██ ██ ██
██ ██ ██ ██ ██
████████████████████
████████████████████████
██████████ ██████ ████
██████████████████ ██ ████████████
██████████████ ████████
██████████████████████ ████████████████
████████████████████████████
██████████ ██████ ████████████
████ ████ ████
██████████ ████ ██████████ ██████████
████ ████ ██████████ ████
██████████ ████ ██████ ██████████
████ ██████ ██████ ██████
████████████████████████
████████████████████
██ ██ ██ ██ ██
██ ██ ██ ██ ██
██ ██ ██ ██ ██
██████████████
██
██
██████████
██████ ██
██ ██ ██
██ ██ ██
██████████
██████████
██ ██
██ ██
██████████
████████████
██ ██
██████████ ██
██████████████
██
██ ██
██ ██
██████████
██
██
██████████
██████████
██
██
██████████
██
██
██████████
uint32_t[62] = {0x2aa0,0x2aa0,0x2aa0,0x7fe0,0xfff0,0x1f398,0xff93f,0x1fc78,0xffeff,0x1fff8,0xfb83f,0x1b018,0xfb7df,0x1b7d8,0xfb39f,0x1bbb8,0xfff0,0x7fe0,0x5540,0x5540,0x5540,0x0,0xfe0,0x80,0x80,0xf80,0x0,0xe80,0xa80,0xa80,0xf80,0x0,0xf80,0x880,0x880,0xf80,0x0,0xfc0,0x880,0x0,0xfa0,0x0,0xfe0,0x200,0x500,0x880,0x0,0xf80,0x800,0x800,0xf80,0x0,0xf80,0x80,0x80,0xf80,0x80,0x80,0xf80,0x0,0x0,0x0};
uint64_t[62] pixels = {0x18618618000,0x18618618000,0x18618618000,0x1fffffff8000,0xfffffffff000,0x7fffdbffb7e00,0x6dfffffb7dbfedb,0x7fffff6dffe00,0x6dffffffefffedb,0x7fffffffffe00,0x6dffbff6db7fedb,0x7fbfb6db6fe00,0x6dffbfbfffefedb,0x7fbfbfffefe00,0x6dffbfb7ff6fedb,0x7fbff7ff7fe00,0xfffffffff000,0x1fffffff8000,0xc30c30c0000,0xc30c30c0000,0xc30c30c0000,0x0,0xfffff8000,0xe00000,0xe00000,0xfffe00000,0x0,0xff8e00000,0xe38e00000,0xe38e00000,0xfffe00000,0x0,0xfffe00000,0xe00e00000,0xe00e00000,0xfffe00000,0x0,0xffffc0000,0xe00e00000,0x0,0xfffe38000,0x0,0xfffff8000,0x38000000,0x1c7000000,0xe00e00000,0x0,0xfffe00000,0xe00000000,0xe00000000,0xfffe00000,0x0,0xfffe00000,0xe00000,0xe00000,0xfffe00000,0xe00000,0xe00000,0xfffe00000,0x0,0x0,0x0};
for (int x = 0; x < 62; x++) {
uint32_t line = pixels[x];
uint64_t line = pixels[x];
for (int y = 0; y < 20; y++) {
uint32_t color = 0;
if (line & (1 << y)) {
color = 0xFFFFFF;
uint64_t color = 0;
if (line & (1ll << y * 3)) {
color |= 0xFF0000;
}
if (line & (1ll << y * 3 + 1)) {
color |= 0x00FF00;
}
if (line & (1ll << y * 3 + 2)) {
color |= 0x0000FF;
}
strip.setPixelColor(y, color);
}
......
......@@ -3,29 +3,32 @@ from PIL import Image
def p(a):
result = 0
for i, rgb in enumerate(a):
r,g,b = rgb
black = r == 0 and g == 0 and b == 0
if not black:
result |= 1 << i
r,g,b = [round(v / 255.0) for v in rgb]
result |= r << i * 3
result |= g << i * 3 + 1
result |= b << i * 3 + 2
return result
img = Image.open("20px-mono.bmp").convert('RGB')
img = Image.open("20px-color.bmp").convert('RGB')
width, height = img.size
pixels = [p([img.getpixel((x,y)) for y in range(height)]) for x in range(width)]
print("\n".join([format(p, '020b').replace('0', ' ').replace('1', '██') for p in pixels]))
print("\n\n\n\n\n")
array = "{" + ",".join([hex(p) for p in pixels]) + "}"
code = """uint32_t[{width}] pixels = {array};
code = """uint64_t[{width}] pixels = {array};
for (int x = 0; x < {width}; x++) {{
uint32_t line = pixels[x];
uint64_t line = pixels[x];
for (int y = 0; y < {height}; y++) {{
uint32_t color = 0;
if (line & (1l << y)) {{
color = 0xFFFFFF;
uint64_t color = 0;
if (line & (1ll << y * 3)) {{
color |= 0xFF0000;
}}
if (line & (1ll << y * 3 + 1)) {{
color |= 0x00FF00;
}}
if (line & (1ll << y * 3 + 2)) {{
color |= 0x0000FF;
}}
strip.setPixelColor(y, color);
}}
......
No preview for this file type
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment