Compare commits
1
Commits
aa8fa3ddf9
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d5789ad8b3 |
Binary file not shown.
|
After Width: | Height: | Size: 1.8 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.3 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 650 B |
@@ -67,6 +67,49 @@ def swatches(path, cols, sw=32, h=64):
|
||||
write_png(path, [[c for c in cols for _ in range(sw)]] * h)
|
||||
|
||||
|
||||
# 3x5 glyphs, enough for indices and hex codes. No font library here.
|
||||
GLYPHS = {
|
||||
"0": "111101101101111", "1": "010110010010111", "2": "111001111100111",
|
||||
"3": "111001111001111", "4": "101101111001001", "5": "111100111001111",
|
||||
"6": "111100111101111", "7": "111001001001001", "8": "111101111101111",
|
||||
"9": "111101111001111", "A": "111101111101101", "B": "110101110101110",
|
||||
"C": "111100100100111", "D": "110101101101110", "E": "111100111100111",
|
||||
"F": "111100111100100", "#": "101111101111101", " ": "000000000000000",
|
||||
"-": "000000111000000",
|
||||
}
|
||||
|
||||
|
||||
def _text(px, x, y, s, col, scale=2):
|
||||
for ch in s.upper():
|
||||
g = GLYPHS.get(ch, GLYPHS[" "])
|
||||
for gy in range(5):
|
||||
for gx in range(3):
|
||||
if g[gy*3 + gx] == "1":
|
||||
for sy in range(scale):
|
||||
for sx in range(scale):
|
||||
yy, xx = y + gy*scale + sy, x + gx*scale + sx
|
||||
if 0 <= yy < len(px) and 0 <= xx < len(px[0]):
|
||||
px[yy][xx] = col
|
||||
x += 4 * scale
|
||||
|
||||
|
||||
def card(path, cols, names, idx, scale=2):
|
||||
"""Labelled reference: swatch, palette index, hex code, role name."""
|
||||
rowh, sww, pad = 7*scale + 8, 22*scale, 6
|
||||
W = sww + pad*2 + 4*scale*22
|
||||
H = rowh*len(cols) + pad*2
|
||||
bg, fg = (26, 26, 26), (255, 255, 219)
|
||||
px = [[bg]*W for _ in range(H)]
|
||||
for i, (c, n, ix) in enumerate(zip(cols, names, idx)):
|
||||
y = pad + i*rowh
|
||||
for yy in range(y, y + 7*scale):
|
||||
for xx in range(pad, pad + sww):
|
||||
px[yy][xx] = c
|
||||
label = f"{ix:02d} #{c[0]:02X}{c[1]:02X}{c[2]:02X}"
|
||||
_text(px, pad + sww + pad, y + scale, label, fg, scale)
|
||||
write_png(path, px)
|
||||
|
||||
|
||||
def emit(stem, idx, title):
|
||||
cols = [PALETTE[i] for i in idx]
|
||||
names = [NAMES[i] for i in idx]
|
||||
@@ -76,7 +119,8 @@ def emit(stem, idx, title):
|
||||
aco(p("aco"), cols, names)
|
||||
act(p("act"), cols)
|
||||
swatches(p("png"), cols)
|
||||
print(f"{stem}: {len(cols)} colours -> .gpl .ase .aco .act .png")
|
||||
card(os.path.normpath(os.path.join(OUT, f"{stem}-card.png")), cols, names, idx)
|
||||
print(f"{stem}: {len(cols)} colours -> .gpl .ase .aco .act .png + -card.png")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user