195 lines
6.8 KiB
Python
195 lines
6.8 KiB
Python
"""Render the early 200 x 130 mm panel concept.
|
|
|
|
This records the earlier numeric display and 64-cell lamp ring. The current
|
|
200 x 100 mm layout is drawn by panel_mockup_vintage.py.
|
|
|
|
python tools/panel_mockup.py img/panel-mockup.png
|
|
"""
|
|
import math
|
|
import sys
|
|
|
|
from PIL import Image, ImageDraw, ImageFont
|
|
|
|
S = 7 # design mm -> pixels
|
|
W, H = 200 * S, 100 * S
|
|
|
|
BG = (24, 24, 25)
|
|
CASE = (188, 191, 195)
|
|
CASE_EDGE = (104, 107, 112)
|
|
FACE = (44, 48, 53)
|
|
FACE_EDGE = (18, 20, 23)
|
|
SILK = (139, 135, 122)
|
|
TEXT = (203, 198, 182)
|
|
RED = (255, 59, 48)
|
|
AMBER = (255, 176, 32)
|
|
DIM = (56, 61, 67)
|
|
DIM_EDGE = (88, 92, 97)
|
|
GREEN = (43, 111, 59)
|
|
GREEN_DIM = (30, 72, 40)
|
|
BLUE = (47, 95, 143)
|
|
BLUE_DIM = (33, 56, 79)
|
|
DARK = (13, 15, 17)
|
|
|
|
SEGS = {"a": (0.10, 0.00, 0.80, 0.10), "b": (0.88, 0.08, 0.12, 0.42),
|
|
"c": (0.88, 0.52, 0.12, 0.44), "d": (0.10, 0.92, 0.80, 0.10),
|
|
"e": (0.00, 0.52, 0.12, 0.44), "f": (0.00, 0.08, 0.12, 0.42),
|
|
"g": (0.10, 0.45, 0.80, 0.10)}
|
|
DIGITS = {"0": "abcdef", "1": "bc", "2": "abged", "3": "abgcd", "4": "fgbc",
|
|
"5": "afgcd", "6": "afgedc", "7": "abc", "8": "abcdefg", "9": "abcdfg",
|
|
"-": "g", " ": ""}
|
|
|
|
|
|
def font(pt):
|
|
for path in (r"C:\Windows\Fonts\consola.ttf", r"C:\Windows\Fonts\lucon.ttf"):
|
|
try:
|
|
return ImageFont.truetype(path, int(pt * S))
|
|
except OSError:
|
|
continue
|
|
return ImageFont.load_default()
|
|
|
|
|
|
def p(v):
|
|
return int(round(v * S))
|
|
|
|
|
|
def box(d, x, y, w, h, fill, edge=None, rad=0.6, width=0.3):
|
|
d.rounded_rectangle([p(x), p(y), p(x + w), p(y + h)], radius=p(rad),
|
|
fill=fill, outline=edge, width=max(1, p(width)))
|
|
|
|
|
|
def digits(d):
|
|
box(d, 12, 21, 46, 16, DARK, DIM_EDGE, rad=0.6)
|
|
for i, ch in enumerate("0046"):
|
|
lit = DIGITS[ch]
|
|
for name, (sx, sy, sw, sh) in SEGS.items():
|
|
x, y = 13.6 + i * 11, 23.0
|
|
d.rounded_rectangle(
|
|
[p(x + sx * 8), p(y + sy * 12), p(x + sx * 8 + sw * 8),
|
|
p(y + sy * 12 + sh * 12)], radius=p(0.3),
|
|
fill=RED if name in lit else (52, 18, 16))
|
|
|
|
|
|
def lamps(d):
|
|
d.text((p(64), p(11.0)), "INSTRUCTION", font=font(1.8), fill=SILK)
|
|
for i, op in enumerate("><+-[].,"):
|
|
x = 64 + i * 7.6
|
|
lit = i == 1
|
|
box(d, x, 14.0, 5.6, 5.6, AMBER if lit else DIM,
|
|
(140, 96, 14) if lit else DIM_EDGE, rad=0.5)
|
|
d.text((p(x + 1.7), p(20.4)), op, font=font(2.1), fill=TEXT)
|
|
|
|
d.text((p(64), p(24.4)), "IP", font=font(1.7), fill=SILK)
|
|
for i in range(16):
|
|
box(d, 64 + i * 4.4, 27.4, 3.4, 2.6, GREEN if i % 3 == 0 else GREEN_DIM,
|
|
(26, 70, 37), rad=0.3)
|
|
d.text((p(64), p(31.6)), "DP", font=font(1.7), fill=SILK)
|
|
for i in range(6):
|
|
box(d, 64 + i * 5.8, 34.6, 4.4, 2.8, BLUE if i < 4 else BLUE_DIM,
|
|
(28, 54, 80), rad=0.3)
|
|
|
|
|
|
def buttons(d):
|
|
for cx, color, label in ((70, (140, 42, 42), "RUN"),
|
|
(86, (46, 106, 56), "STEP"),
|
|
(102, (56, 61, 67), "RESET")):
|
|
r = 4.5
|
|
d.ellipse([p(cx - r), p(42 - r), p(cx + r), p(42 + r)], fill=color,
|
|
outline=(36, 36, 36), width=p(0.35))
|
|
tw = d.textlength(label, font=font(1.7))
|
|
d.text((p(cx) - tw / 2, p(47.2)), label, font=font(1.7), fill=TEXT)
|
|
|
|
|
|
def input_byte(d):
|
|
d.text((p(12), p(41.0)), "INPUT BYTE", font=font(1.7), fill=SILK)
|
|
box(d, 12, 44.0, 42, 7.2, (32, 36, 41), DIM_EDGE, rad=0.5)
|
|
for i in range(8):
|
|
box(d, 13.6 + i * 5.0, 45.4, 3.0, 4.4, (214, 209, 192), None, rad=0.3)
|
|
d.text((p(12), p(53.0)), "8 switches + SEND", font=font(1.5), fill=(92, 96, 108))
|
|
|
|
|
|
def ring(d):
|
|
cx, cy, r = 160, 33, 19
|
|
d.ellipse([p(cx - r), p(cy - r), p(cx + r), p(cy + r)], outline=(54, 59, 64),
|
|
width=p(0.3))
|
|
dp = 33
|
|
for i in range(64):
|
|
a = -math.pi / 2 + 2 * math.pi * i / 64
|
|
px, py = cx + r * math.cos(a), cy + r * math.sin(a)
|
|
lit = i == dp
|
|
rr = 0.9 if lit else 0.5
|
|
d.ellipse([p(px - rr), p(py - rr), p(px + rr), p(py + rr)],
|
|
fill=AMBER if lit else GREEN,
|
|
outline=(140, 96, 14) if lit else None)
|
|
a = -math.pi / 2 + 2 * math.pi * dp / 64
|
|
d.line([p(cx), p(cy), p(cx + r * math.cos(a)), p(cy + r * math.sin(a))],
|
|
fill=AMBER, width=p(0.45))
|
|
d.text((p(cx - 2.4), p(cy - 1.5)), "DP", font=font(1.4), fill=TEXT)
|
|
d.text((p(cx - 19), p(cy + 21)), "DATA RING 64 (dp lit)", font=font(1.6),
|
|
fill=SILK)
|
|
|
|
|
|
def cartridge(d):
|
|
box(d, 12, 61, 52, 15, DARK, DIM_EDGE, rad=0.6)
|
|
d.text((p(13.6), p(62.8)), "ZIF-28 27C512", font=font(1.6), fill=SILK)
|
|
d.text((p(13.6), p(66.0)), "UV window", font=font(1.5), fill=(92, 96, 108))
|
|
d.text((p(13.6), p(69.6)), "64K x 8, one byte", font=font(1.5), fill=(92, 96, 108))
|
|
d.text((p(13.6), p(72.8)), "per instruction", font=font(1.5), fill=(92, 96, 108))
|
|
|
|
|
|
def uart(d):
|
|
d.text((p(72), p(59.0)), "UART 9600 8N1", font=font(1.6), fill=SILK)
|
|
box(d, 72, 62.0, 46, 6.2, DARK, DIM_EDGE, rad=0.4)
|
|
d.text((p(73.4), p(63.3)), "> 12 34 + .", font=font(1.5), fill=(92, 96, 108))
|
|
box(d, 72, 70.0, 46, 6.2, DARK, DIM_EDGE, rad=0.4)
|
|
d.text((p(73.4), p(71.3)), "0046", font=font(1.5), fill=AMBER)
|
|
|
|
|
|
def mech_dp(d):
|
|
cx, cy, r = 160, 70, 10
|
|
d.ellipse([p(cx - r), p(cy - r), p(cx + r), p(cy + r)], fill=(136, 141, 147),
|
|
outline=(88, 92, 97), width=p(0.35))
|
|
d.ellipse([p(cx - 2.2), p(cy - 2.2), p(cx + 2.2), p(cy + 2.2)], fill=FACE,
|
|
outline=FACE_EDGE)
|
|
d.line([p(cx), p(cy), p(cx + r * 0.7), p(cy - r * 0.7)], fill=(58, 62, 68),
|
|
width=p(0.45))
|
|
d.text((p(cx - 14), p(cy + 11)), "mechanical dp", font=font(1.5),
|
|
fill=(92, 96, 108))
|
|
d.text((p(cx - 14), p(cy + 13.8)), "(optional dial)", font=font(1.4),
|
|
fill=(74, 78, 90))
|
|
|
|
|
|
def main():
|
|
out = sys.argv[1] if len(sys.argv) > 1 else "panel-mockup.png"
|
|
img = Image.new("RGB", (W, H), BG)
|
|
d = ImageDraw.Draw(img)
|
|
d.fontmode = "L"
|
|
|
|
box(d, 4, 4, 192, 92, CASE, CASE_EDGE, rad=2.0, width=0.6)
|
|
box(d, 7.5, 7.5, 185, 85, FACE, FACE_EDGE, rad=1.2, width=0.3)
|
|
|
|
d.text((p(12), p(9.0)), "ROT-8", font=font(5.0), fill=TEXT)
|
|
d.text((p(12), p(16.4)), "8 BIT · 64 CELLS · ONE INSTRUCTION PER BYTE",
|
|
font=font(1.7), fill=SILK)
|
|
digits(d)
|
|
d.text((p(12), p(38.4)), "CELL · IP · DP (toggle)", font=font(1.6), fill=SILK)
|
|
lamps(d)
|
|
buttons(d)
|
|
input_byte(d)
|
|
ring(d)
|
|
cartridge(d)
|
|
uart(d)
|
|
mech_dp(d)
|
|
d.text((p(12), p(79.0)),
|
|
"inside: Eurocard 160 x 100 mm · ~34 DIP sockets · 5 V 2 A",
|
|
font=font(1.6), fill=SILK)
|
|
d.text((p(12), p(82.6)),
|
|
"1 MHz can · 27C512 + 6116 + 74LS · 6850 UART", font=font(1.5),
|
|
fill=(92, 96, 108))
|
|
|
|
img.save(out)
|
|
print("wrote", out)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|