Cotton code
503 lines · 19.6 KB · PythonRaw
#!/usr/bin/env python3"""Cotton Days' marks, drawn: every mark of the catalogue as a loose ballpointdoodle of 5 to 8 single strokes (assets/design/days/DECISIONS.md, Marks).Each mark is sketched here as a few strokes through rough points on a 24 by 24square; the pen then wobbles them the way a hand does (a little off the line,ends that overshoot or fall short, loops that do not quite close) and writeseach stroke as one SVG path of absolute M and C commands into the catalogue(crates/cotton-rules/src/days/marks.json, `strokes`). Both phones draw thosepaths: round caps, width 1.6, the pen blue, never filled.The wobble is seeded by the mark's id, so a run draws the same set every time.Run: pnpm days:marks"""import jsonimport mathimport randomimport sysfrom pathlib import PathCATALOGUE = Path(__file__).resolve().parent.parent / "crates/cotton-rules/src/days/marks.json"# ── strokes, sketched ────────────────────────────────────────────────────────def line(*points):    """An open stroke through the points."""    return ("open", [tuple(p) for p in points])def loop(*points):    """A closed stroke through the points; the pen overshoots its start a little."""    return ("loop", [tuple(p) for p in points])def ring(cx, cy, rx, ry=None, start=200, sweep=380, n=10):    """An ellipse drawn as one stroke, starting at `start` degrees and going a    little past round (`sweep` > 360) so the ends cross, as a hand does."""    ry = rx if ry is None else ry    pts = []    for i in range(n + 1):        a = math.radians(start + sweep * i / n)        pts.append((cx + rx * math.cos(a), cy + ry * math.sin(a)))    return ("open", pts)def arc(cx, cy, rx, ry, a0, a1, n=6):    """Part of an ellipse, from `a0` to `a1` degrees (y grows downwards)."""    pts = []    for i in range(n + 1):        a = math.radians(a0 + (a1 - a0) * i / n)        pts.append((cx + rx * math.cos(a), cy + ry * math.sin(a)))    return ("open", pts)def box(x0, y0, x1, y1):    """A rectangle in one stroke, corners a touch soft."""    return ("loop", [(x0, y0), (x1, y0), (x1, y1), (x0, y1)])def dot(x, y):    """A pen dot: a tiny closed scribble."""    return ("open", [(x - 0.3, y), (x + 0.3, y - 0.3), (x + 0.2, y + 0.3), (x - 0.2, y + 0.1)])SKETCHES = {    "cake": [        line((4, 20.5), (20, 20.3)),        line((5.5, 20.3), (5.6, 13.6), (18.4, 13.4), (18.6, 20.2)),        line((5.6, 16.6), (8.2, 17.8), (10.6, 16.3), (13.2, 17.7), (15.8, 16.2), (18.4, 17.4)),        line((9, 13.4), (9.1, 10)),        line((15, 13.4), (14.9, 10)),        loop((9, 9.4), (8.2, 7.8), (9.1, 6), (9.8, 7.9)),        loop((15, 9.4), (14.2, 7.8), (15.1, 6), (15.8, 7.9)),    ],    "plane": [        loop((3.5, 13), (8, 11.6), (17, 11.2), (20.6, 12.2), (17, 13.6), (8, 14)),        line((10.5, 12.6), (8.8, 18.6), (11.4, 18.5), (14.2, 12.8)),        line((11, 11.6), (9.6, 7.4), (11.6, 7.4), (14, 11.3)),        line((4.6, 12.4), (3.4, 9.2), (5.2, 9.2), (7, 11.9)),        line((17.2, 12.1), (18.3, 12.1)),        line((14, 18.2), (19.6, 18.8)),    ],    "tooth": [        line((7.4, 5.4), (5.2, 7.6), (5.8, 12), (7.6, 16.6), (8.4, 20.4), (10, 19.8), (11, 14.6), (12, 13.6),             (13, 14.6), (14, 19.8), (15.6, 20.4), (16.4, 16.6), (18.2, 12), (18.8, 7.6), (16.6, 5.4), (14, 5.4), (12, 6.6)),        line((12, 6.6), (10, 5.3), (7.6, 5.3)),        arc(9.6, 9.8, 2.2, 2.4, 190, 260, n=4),        line((19.6, 4.2), (20.6, 3.2)),        line((20.4, 6.4), (21.6, 6.2)),    ],    "fork-knife": [        line((7.4, 11.6), (7.2, 20.6)),        line((4.6, 4), (4.8, 9.2), (7.3, 11.6), (9.8, 9.2), (10, 4)),        line((6.4, 4.2), (6.5, 8.6)),        line((8.3, 4.2), (8.3, 8.6)),        line((16.6, 20.6), (16.6, 13.4)),        line((16.6, 13.6), (19, 12.4), (19.2, 6.6), (17.4, 3.4), (16.4, 4.4), (16.5, 13.4)),    ],    "cup": [        line((5, 9.6), (5.6, 16.2), (8, 18.4), (13.4, 18.4), (15.6, 16.2), (16.2, 9.6), (5, 9.6)),        line((16.2, 11), (18.8, 11), (19.4, 13.2), (17.6, 15.2), (15.6, 15.4)),        line((3.6, 20.4), (6.4, 21.1), (14.8, 21.1), (17.6, 20.4)),        line((8.6, 7.6), (7.8, 6), (9, 4.6), (8.4, 3)),        line((12.4, 7.6), (11.6, 6), (12.8, 4.6), (12.2, 3)),    ],    "basket": [        line((3.6, 11.2), (20.4, 11)),        line((4.6, 11.2), (6.2, 19.6), (17.8, 19.6), (19.4, 11)),        arc(12, 11, 6.6, 7, 185, 355, n=6),        line((5.4, 14.6), (18.6, 14.4)),        line((9.4, 11.6), (9.8, 19.2)),        line((14.6, 11.6), (14.2, 19.2)),    ],    "dumbbell": [        line((7, 12.1), (17, 11.9)),        box(3.8, 8.2, 5.8, 15.8),        box(5.8, 6.6, 7.6, 17.4),        box(16.4, 6.6, 18.2, 17.4),        box(18.2, 8.2, 20.2, 15.8),    ],    "phone": [        loop((7.2, 3.2), (16.8, 3.1), (17.4, 4.2), (17.3, 20), (16.6, 21), (7.4, 21), (6.6, 20), (6.6, 4.2)),        box(8.2, 5.6, 15.8, 17),        line((10.6, 4.3), (13.4, 4.3)),        ring(12, 19, 0.8, n=6),        line((19.4, 6.6), (20.4, 8.2), (19.6, 10)),    ],    "envelope": [        box(3.4, 6.8, 20.6, 18.2),        line((3.6, 7.2), (12, 13.4), (20.4, 7.2)),        line((3.8, 17.8), (9.8, 12)),        line((20.2, 17.8), (14.2, 12)),        box(16.2, 8.6, 18.8, 11),    ],    "house": [        line((3, 11.6), (12, 4.2), (21, 11.6)),        line((5.4, 10.2), (5.6, 20.4), (18.4, 20.2), (18.6, 10.2)),        line((10, 20.2), (10.1, 14.6), (13.8, 14.5), (14, 20.2)),        box(14.8, 11.2, 17.2, 13.4),        line((15.6, 7.6), (15.7, 4.6), (17.6, 4.6), (17.6, 9.2)),        line((3.6, 20.6), (20.4, 20.5)),    ],    "car": [        line((3.4, 16.6), (3.2, 12.8), (6.6, 12.2), (8.8, 8.4), (15.2, 8.2), (17.8, 12), (20.4, 12.8), (20.8, 16.4), (18.6, 16.6)),        line((9.6, 16.6), (14.4, 16.6)),        ring(7.6, 16.8, 1.9, n=8),        ring(16.4, 16.8, 1.9, n=8),        line((7.8, 12), (9.8, 9.4), (11.8, 9.3), (11.8, 12), (7.8, 12)),        line((13.2, 9.3), (14.8, 9.3), (16.4, 12), (13.2, 12)),    ],    "train": [        loop((6, 4.4), (18, 4.2), (18.6, 6), (18.4, 16.4), (5.6, 16.6), (5.4, 6)),        box(7.6, 6.6, 16.4, 10.6),        dot(8.6, 13.8),        dot(15.4, 13.6),        line((8.6, 16.8), (5.6, 20.6)),        line((15.4, 16.6), (18.4, 20.6)),        line((7.2, 19), (16.8, 18.9)),    ],    "bed": [        line((3.6, 7.2), (3.6, 19.4)),        line((3.6, 13.6), (20.4, 13.4), (20.4, 19.4)),        line((3.6, 16.6), (20.4, 16.4)),        loop((5.2, 13.2), (5.4, 10.6), (9.6, 10.8), (9.4, 13.2)),        line((10.6, 13.2), (11.8, 10.6), (19.6, 10.8), (20.4, 13.4)),    ],    "book": [        line((12, 6.6), (8.6, 5.2), (3.6, 5.6), (3.8, 18.4), (8.6, 17.8), (12, 19.2)),        line((12, 6.6), (15.4, 5.2), (20.4, 5.6), (20.2, 18.4), (15.4, 17.8), (12, 19.2)),        line((12, 6.8), (12, 19)),        line((6, 9.2), (9.8, 9.4)),        line((6, 12.2), (9.8, 12.4)),        line((14.2, 9.4), (18, 9.2)),    ],    "clapperboard": [        box(4, 10, 20, 20),        line((3.8, 9.6), (19.2, 5.4), (18.8, 3.6), (3.4, 7.8), (3.8, 9.6)),        line((7.6, 7), (9.2, 8.6)),        line((11.6, 5.8), (13.2, 7.4)),        line((15.4, 4.8), (17, 6.4)),        line((4.2, 13.4), (19.8, 13.2)),    ],    "watering-can": [        line((6.2, 10.4), (6.6, 19.4), (15.2, 19.4), (15.6, 10.4), (6.2, 10.4)),        line((15.4, 15.6), (20, 9.6)),        line((19, 8.8), (21, 10.6)),        arc(10.9, 10.4, 4, 4.4, 185, 355, n=6),        line((6.2, 12.6), (3.6, 13.6), (3.4, 16.4), (6.4, 17.4)),        dot(21.4, 13),        dot(20.2, 15.2),    ],    "dog": [        line((8, 7), (12, 5.6), (16, 7), (17.4, 12), (15.8, 17), (12, 18.6), (8.2, 17), (6.6, 12), (8, 7)),        line((8.2, 7.4), (5, 6.6), (3.6, 10.4), (5.2, 13.6), (6.8, 12)),        line((15.8, 7.4), (19, 6.6), (20.4, 10.4), (18.8, 13.6), (17.2, 12)),        dot(10, 11),        dot(14, 11),        loop((11, 14), (13, 14), (12, 15.2)),        line((12, 15.4), (11.6, 16.6), (10.4, 16.6)),    ],    "pill": [        loop((4.6, 13.4), (10.6, 7.4), (13.4, 7.6), (13.6, 10.4), (7.6, 16.4), (4.8, 16.2)),        line((8, 10.2), (10.8, 13.2)),        ring(17, 16.4, 3.2, n=10),        line((15, 18.4), (19, 14.4)),        line((6.4, 13), (8.2, 11.2)),    ],    "stethoscope": [        line((6, 4), (5, 4.6), (5, 10), (8, 13.6), (11, 10), (11, 4.6), (10, 4)),        line((8, 13.6), (8.2, 17.6), (11, 20.4), (14.6, 19.6), (16.4, 15.6)),        ring(16.6, 13, 2.6, n=10),        dot(16.6, 13),        dot(6, 3.8),        dot(10, 3.8),    ],    "purse": [        line((4.4, 10.2), (19.6, 10), (19, 19.6), (5, 19.8), (4.4, 10.2)),        arc(12, 10, 4.6, 5, 185, 355, n=6),        line((4.6, 13.2), (12, 15), (19.4, 13)),        ring(12, 15.6, 1, n=6),        line((6.4, 18), (8, 18)),    ],    "gift": [        box(5, 11, 19, 20),        box(4, 8, 20, 11),        line((12, 8.2), (12.1, 19.8)),        line((12, 8), (8.4, 4.6), (7.4, 6.8), (12, 8)),        line((12, 8), (15.6, 4.6), (16.6, 6.8), (12, 8)),        line((5.2, 14.6), (18.8, 14.4)),    ],    "glass": [        line((6.6, 3.6), (6.4, 8.4), (8.6, 12.4), (12, 13.4), (15.4, 12.4), (17.6, 8.4), (17.4, 3.6)),        line((12, 13.4), (12, 19.4)),        line((8, 20.2), (12, 19.6), (16, 20.2)),        line((6.8, 7.6), (9.6, 8.2), (12.4, 7.4), (17.2, 7.8)),        ring(11, 10.4, 0.6, n=6),    ],    "suitcase": [        box(3.6, 8.2, 20.4, 18.6),        line((9, 8), (9.2, 5.4), (14.8, 5.4), (15, 8)),        line((7.6, 8.4), (7.8, 18.4)),        line((16.4, 8.4), (16.2, 18.4)),        ring(6.4, 19.8, 0.9, n=6),        ring(17.6, 19.8, 0.9, n=6),    ],    "shoe": [        line((3.2, 18.8), (20.8, 18.6)),        line((3.4, 18.6), (3.6, 9.2), (7.6, 9.4), (10, 12.2), (15.6, 13.4), (19.8, 14.8), (20.8, 18.4)),        line((7.6, 9.4), (8.2, 6.8), (3.8, 6.4), (3.6, 9.2)),        line((9.4, 11.2), (11.2, 10)),        line((11.6, 12.6), (13.2, 11.2)),        line((3.4, 16.2), (20.6, 16.2)),    ],    "scissors": [        ring(6.4, 17.4, 2.6, n=10),        ring(17.6, 17.4, 2.6, n=10),        line((8.4, 15.6), (17.8, 3.8)),        line((15.6, 15.6), (6.2, 3.8)),        dot(12, 10.6),    ],    "laptop": [        box(5.4, 5, 18.6, 14.6),        line((2.8, 17.6), (5.2, 14.8), (18.8, 14.8), (21.2, 17.6), (2.8, 17.6)),        line((10, 16.4), (14, 16.4)),        line((7.4, 8.2), (11, 8.2)),        line((7.4, 10.8), (14.6, 10.8)),    ],    "guitar": [        line((10.4, 12.4), (7.2, 11.6), (4.4, 14.4), (5.4, 17.4), (4.6, 20), (8, 20.4), (10.4, 19.4), (12.6, 16.6), (11.6, 13.6)),        ring(8.6, 16.2, 1.4, n=8),        line((9.6, 15.2), (18.4, 6.4)),        line((10.6, 16.2), (19.4, 7.4)),        loop((18, 6), (19.6, 3.6), (21, 4.4), (19.8, 7.8)),        line((6.6, 18.4), (10, 15)),    ],    "bicycle": [        ring(6, 15.4, 3.8, n=10),        ring(18, 15.4, 3.8, n=10),        line((6, 15.4), (9.6, 9.6), (15.6, 9.6), (11.6, 15.4), (6, 15.4)),        line((11.6, 15.4), (8.6, 7.4)),        line((7.2, 7.2), (10.4, 7.2)),        line((18, 15.4), (15.4, 6.6), (17.6, 6)),    ],    "sun": [        ring(12, 12, 4.2, n=10),        line((12, 2.6), (12.2, 5.4)),        line((12, 18.6), (11.8, 21.4)),        line((2.6, 12.2), (5.4, 12)),        line((18.6, 12), (21.4, 11.8)),        line((5.2, 5.2), (7.2, 7.2)),        line((16.8, 16.8), (18.8, 18.8)),        line((18.8, 5.2), (16.8, 7.2)),    ],    "moon": [        line((14.4, 3.6), (8.6, 5.4), (5.6, 11), (7.4, 17.4), (13, 20.6), (19.4, 18.4), (14.8, 16.4), (11.8, 11.4), (12.6, 6.6), (14.4, 3.6)),        line((18.4, 6.6), (18.6, 9.8)),        line((17, 8.2), (20, 8.2)),        dot(20.4, 13),        dot(16.4, 12.6),    ],    "heart": [        line((12, 20), (5.4, 13.6), (3.6, 9.6), (5.2, 5.8), (8.6, 5), (12, 8), (15.4, 5), (18.8, 5.8), (20.4, 9.6), (18.6, 13.6), (12.4, 20.2)),        arc(8.2, 9.4, 2.4, 2.4, 190, 260, n=4),        line((19.8, 3), (21, 2)),        line((21.2, 5), (22.4, 4.8)),        line((3, 3.2), (3.8, 4.2)),    ],    "star": [        line((12, 3.2), (14.4, 9.2), (20.6, 9.4), (15.6, 13.4), (17.6, 20), (12, 16.2), (6.4, 20), (8.4, 13.4), (3.4, 9.4), (9.6, 9.2), (12.2, 3.4)),        line((19.6, 2.6), (19.8, 5.2)),        line((18.4, 3.8), (21, 4)),        line((3.6, 15.4), (4.4, 17)),        dot(4.6, 4.6),    ],    "question": [        line((4, 5.6), (20, 5.4), (20.2, 15.8), (11, 16), (7, 19.8), (7.4, 16), (3.8, 15.8), (4, 5.6)),        line((9.6, 9), (10.6, 7.4), (13, 7.2), (14.4, 8.6), (13.4, 10.4), (12, 11.2), (12, 12.4)),        dot(12, 14.2),        line((20.6, 2.8), (21.6, 1.8)),        line((2.4, 2.6), (3.4, 3.6)),    ],    "bus": [        loop((4.6, 4.6), (19.4, 4.4), (19.6, 18.4), (4.4, 18.6)),        box(6.2, 6.6, 17.8, 11.6),        line((12, 6.8), (12, 11.4)),        ring(7.6, 15.4, 0.8, n=6),        ring(16.4, 15.4, 0.8, n=6),        line((6.4, 18.6), (6.6, 20.8)),        line((17.6, 18.6), (17.4, 20.8)),    ],    "coin": [        ring(12, 12, 8, n=12),        ring(12, 12, 5.6, n=10, start=40),        line((10, 9.4), (14, 9.4)),        line((10, 11.4), (14, 11.4)),        line((11.2, 9.4), (13, 10.6), (10.6, 14.8)),        arc(12, 12, 6.8, 6.8, 200, 240, n=3),    ],    "flower": [        ring(12, 8.6, 1.8, n=8),        loop((12, 6.8), (9.6, 3.6), (12, 1.8), (14.4, 3.6)),        loop((13.8, 8), (17.4, 5.8), (19, 8.6), (15.6, 10.6)),        loop((13.2, 10.2), (15.2, 14), (12.2, 15.2), (11.2, 10.6)),        loop((10.2, 9.8), (6.4, 11.4), (5, 8.4), (9.8, 7.4)),        line((12, 10.6), (12.2, 16), (11.6, 21.6)),        line((12, 18.4), (15.4, 15.6), (17.4, 16.4), (12.2, 19.4)),    ],    "ball": [        ring(12, 12, 8.2, n=12),        arc(3.2, 12, 4.6, 6.4, -70, 70, n=6),        arc(20.8, 12, 4.6, 6.4, 110, 250, n=6),        line((15.6, 4.6), (16.4, 3.2)),        line((18.6, 6), (19.8, 5)),    ],    "cat": [        line((6, 10), (5.4, 4), (9.6, 7.6), (14.4, 7.6), (18.6, 4), (18, 10), (18.8, 14.4), (15.6, 19), (12, 19.8),             (8.4, 19), (5.2, 14.4), (6, 10)),        dot(9.6, 12),        dot(14.4, 12),        loop((11.2, 14.6), (12.8, 14.6), (12, 15.6)),        line((2.8, 14.6), (7.6, 15.2)),        line((21.2, 14.6), (16.4, 15.2)),        line((3.4, 17.4), (7.8, 16.4)),    ],    "camera": [        line((3.4, 8.2), (8, 8.2), (9.4, 5.8), (14.6, 5.8), (16, 8.2), (20.6, 8.2), (20.6, 19), (3.4, 19), (3.4, 8.2)),        ring(12, 13.4, 3.8, n=10),        ring(12, 13.4, 1.6, n=8, start=60),        box(17, 10, 19, 11.4),        line((5.2, 6.8), (7, 6.8)),    ],    "key": [        ring(7.6, 12, 3.8, n=10),        dot(6.6, 12),        line((11.4, 11.8), (20.8, 11.6)),        line((17.6, 11.8), (17.8, 15)),        line((20.2, 11.6), (20.4, 14.4)),        line((15, 11.8), (15, 13.6)),    ],    "baby": [        ring(12, 13, 7.4, 7, n=12),        line((11.6, 6.2), (11, 3.8), (12.8, 3), (13.6, 4.6), (12.4, 5.4)),        dot(9.4, 12),        dot(14.6, 12),        arc(12, 14.6, 2.4, 1.8, 20, 160, n=5),        line((6.6, 14.6), (7.6, 15)),        line((17.4, 14.6), (16.4, 15)),    ],    "pen": [        line((5.6, 18.4), (16.8, 7.2), (19, 7.6), (19.2, 9.4), (7.8, 20.6), (5.6, 18.4)),        line((5.6, 18.4), (4, 21.6), (7.8, 20.6)),        line((15.2, 8.8), (17.6, 11.2)),        line((17.4, 6.6), (19.2, 4.8), (21.2, 6.4), (19.6, 8.2)),        line((10.4, 22), (13.4, 20.6), (15.6, 21.6), (19.4, 20)),    ],}# ── the hand ────────────────────────────────────────────────────────────────def wobble(points, rng, amount):    out = []    for i, (x, y) in enumerate(points):        out.append((x + rng.uniform(-amount, amount), y + rng.uniform(-amount, amount)))    return outdef bow(points, rng):    """A long straight piece of a stroke bows a little, as a drawn line does."""    if len(points) < 2:        return points    out = [points[0]]    for (x0, y0), (x1, y1) in zip(points, points[1:]):        length = math.hypot(x1 - x0, y1 - y0)        if length > 4:            nx, ny = -(y1 - y0) / length, (x1 - x0) / length            k = rng.uniform(-0.35, 0.35) * min(length / 8, 1.2)            out.append(((x0 + x1) / 2 + nx * k, (y0 + y1) / 2 + ny * k))        out.append((x1, y1))    return outdef ends(points, rng):    """The pen starts a touch early or late and lifts a touch early or late."""    if len(points) < 2:        return points    (x0, y0), (x1, y1) = points[0], points[1]    (xa, ya), (xb, yb) = points[-2], points[-1]    s = rng.uniform(-0.12, 0.18)    e = rng.uniform(-0.12, 0.22)    first = (x0 - (x1 - x0) * s, y0 - (y1 - y0) * s)    last = (xb + (xb - xa) * e, yb + (yb - ya) * e)    return [first] + points[1:-1] + [last]def closed(points, rng):    """A loop: back to the start and a little past it, slightly off."""    (x0, y0), (x1, y1) = points[0], points[1]    over = rng.uniform(0.15, 0.35)    return points + [(x0 + rng.uniform(-0.4, 0.4), y0 + rng.uniform(-0.4, 0.4)), (x0 + (x1 - x0) * over, y0 + (y1 - y0) * over)]def catmull(points, tension=0.9):    """Catmull-Rom through the points, written as one SVG path of cubics."""    if len(points) == 1:        x, y = points[0]        return f"M{x:.1f} {y:.1f}"    pts = [points[0]] + points + [points[-1]]    d = [f"M{pts[1][0]:.1f} {pts[1][1]:.1f}"]    for i in range(1, len(pts) - 2):        p0, p1, p2, p3 = pts[i - 1], pts[i], pts[i + 1], pts[i + 2]        c1 = (p1[0] + (p2[0] - p0[0]) / 6 * tension, p1[1] + (p2[1] - p0[1]) / 6 * tension)        c2 = (p2[0] - (p3[0] - p1[0]) / 6 * tension, p2[1] - (p3[1] - p1[1]) / 6 * tension)        d.append(f"C{c1[0]:.1f} {c1[1]:.1f} {c2[0]:.1f} {c2[1]:.1f} {p2[0]:.1f} {p2[1]:.1f}")    return " ".join(d)def draw(mark_id, strokes):    rng = random.Random(f"cotton-days-{mark_id}")    # One small slant and squash for the whole doodle: a hand's own angle.    tilt = math.radians(rng.uniform(-4, 4))    squash = rng.uniform(0.96, 1.03)    def hand(p):        x, y = p[0] - 12, (p[1] - 12) * squash        return (12 + x * math.cos(tilt) - y * math.sin(tilt), 12 + x * math.sin(tilt) + y * math.cos(tilt))    out = []    for kind, points in strokes:        points = [hand(p) for p in points]        points = bow(points, rng)        if kind == "loop":            points = closed(points, rng)        points = wobble(points, rng, 0.28)        points = ends(points, rng)        points = [(min(max(x, 0.8), 23.2), min(max(y, 0.8), 23.2)) for x, y in points]        out.append(catmull(points))    return outdef main():    catalogue = json.loads(CATALOGUE.read_text())    missing = [mark["id"] for mark in catalogue["marks"] if mark["id"] not in SKETCHES]    if missing:        sys.exit(f"no sketch for: {', '.join(missing)}")    for mark in catalogue["marks"]:        strokes = SKETCHES[mark["id"]]        if not 5 <= len(strokes) <= 8:            sys.exit(f"{mark['id']} has {len(strokes)} strokes; a mark is 5 to 8")        mark["strokes"] = draw(mark["id"], strokes)    catalogue["about"] = (        "The marks catalogue: each mark's words per language, and its drawing as `strokes`, one SVG path "        "(absolute M and C) per ballpoint stroke on a 24 by 24 square, drawn with round caps at width 1.6 in "        "the pen blue, never filled. The strokes are written by scripts/days-marks-draw.py (pnpm days:marks); "        "change a sketch there, never a path here. `words` per language are what typed words are looked up against, offline. A new mark or language is a new entry, never new code."    )    CATALOGUE.write_text(json.dumps(catalogue, ensure_ascii=False, indent=1) + "\n")    print(f"drew {len(catalogue['marks'])} marks into {CATALOGUE}")if __name__ == "__main__":    main()