238 lines · 15.8 KB · PythonRaw
#!/usr/bin/env python3"""Cotton Notes' icon set, drawn for this app (assets/design/notes/DECISIONS.md "Look": one set, thin rounded line,consistent weight; research.md Part B lists what is needed). Nothing is traced or copied from another product.Every icon is drawn here on a 24-unit grid with a 1.6-unit stroke, round ends and round joins, and written as anAndroid vector drawable `mark_<name>.xml` into the writing kit's resources, and as the iPhone's same drawings in`WritingMarkSet.swift` (CottonWriting, drawn by `WritingMark`), tinted by whoever draws it. Run it again afterchanging a drawing: python3 scripts/draw-notes-icons.py"""import mathimport osimport sysOUT = os.path.join(os.path.dirname(__file__), "..", "apps", "android", "writing", "src", "main", "res", "drawable")SWIFT = os.path.join(os.path.dirname(__file__), "..", "apps", "cotton", "Sources", "CottonWriting", "WritingMarkSet.swift")STROKE = 1.6def f(v): return ("%.2f" % v).rstrip("0").rstrip(".")def line(x1, y1, x2, y2): return f"M{f(x1)} {f(y1)} L{f(x2)} {f(y2)}"def poly(*pts, close=False): it = iter(pts) pairs = list(zip(it, it)) d = f"M{f(pairs[0][0])} {f(pairs[0][1])}" + "".join(f" L{f(x)} {f(y)}" for x, y in pairs[1:]) return d + (" Z" if close else "")def circle(cx, cy, r): return f"M{f(cx - r)} {f(cy)} A{f(r)} {f(r)} 0 1 0 {f(cx + r)} {f(cy)} A{f(r)} {f(r)} 0 1 0 {f(cx - r)} {f(cy)} Z"def rect(x, y, w, h, r): return (f"M{f(x + r)} {f(y)} H{f(x + w - r)} A{f(r)} {f(r)} 0 0 1 {f(x + w)} {f(y + r)} V{f(y + h - r)} " f"A{f(r)} {f(r)} 0 0 1 {f(x + w - r)} {f(y + h)} H{f(x + r)} A{f(r)} {f(r)} 0 0 1 {f(x)} {f(y + h - r)} " f"V{f(y + r)} A{f(r)} {f(r)} 0 0 1 {f(x + r)} {f(y)} Z")class Dot: """A filled round dot (a bullet, an info point).""" def __init__(self, cx, cy, r=1.25): self.d = circle(cx, cy, r)class Fill: def __init__(self, d): self.d = ddef star(cx, cy, big, small): pts = [] for i in range(10): r = big if i % 2 == 0 else small a = -math.pi / 2 + i * math.pi / 5 pts += [cx + r * math.cos(a), cy + r * math.sin(a)] return poly(*pts, close=True)TAG = "M3.75 11.6 V5.25 A1.5 1.5 0 0 1 5.25 3.75 H11.6 L20.25 12.4 A1.2 1.2 0 0 1 20.25 14.1 L14.1 20.25 A1.2 1.2 0 0 1 12.4 20.25 Z"HASH = [line(9.75, 4, 7.75, 20), line(16.25, 4, 14.25, 20), line(4.5, 9, 19.75, 9), line(4.25, 15, 19.5, 15)]BIN = [line(4, 6.5, 20, 6.5), "M9.5 6.5 V4.75 A1.25 1.25 0 0 1 10.75 3.5 H13.25 A1.25 1.25 0 0 1 14.5 4.75 V6.5", "M6 6.5 L6.9 18.9 A1.75 1.75 0 0 0 8.65 20.5 H15.35 A1.75 1.75 0 0 0 17.1 18.9 L18 6.5"]PIN = "M9 3.75 H15 M10.25 3.75 V9.75 L7 13.5 H17 L13.75 9.75 V3.75 M12 13.5 V20.5"PAGE = ["M13.5 3.5 H7.25 A2 2 0 0 0 5.25 5.5 V18.5 A2 2 0 0 0 7.25 20.5 H16.75 A2 2 0 0 0 18.75 18.5 V8.75 Z", "M13.5 3.5 V8.75 H18.75"]CHECK = poly(8, 12.25, 10.75, 15, 16, 9.25)KEYS = [Dot(7, 10, 0.95), Dot(10.35, 10, 0.95), Dot(13.65, 10, 0.95), Dot(17, 10, 0.95)]ICONS = { # ── Places on the side page ── "notes": [rect(5, 3.5, 14, 17, 2.5), line(8.5, 8.5, 15.5, 8.5), line(8.5, 12, 15.5, 12), line(8.5, 15.5, 12.5, 15.5)], "untagged": [TAG, circle(8, 8, 1.2), line(4, 20, 20, 4)], "todo": [rect(4.25, 4.25, 15.5, 15.5, 4), CHECK], "today": [rect(4, 5, 16, 15.5, 3), line(4, 9.5, 20, 9.5), line(8.5, 3, 8.5, 6.5), line(15.5, 3, 15.5, 6.5), Dot(12, 14.75, 1.7)], "pinned": [PIN], "locked": [rect(5, 10.5, 14, 10, 2.5), "M8.25 10.5 V8 A3.75 3.75 0 0 1 15.75 8 V10.5", line(12, 14.25, 12, 16.5)], "archive": [rect(3.5, 4, 17, 4.5, 1.5), "M5 8.5 V18 A2 2 0 0 0 7 20 H17 A2 2 0 0 0 19 18 V8.5", line(10, 12.5, 14, 12.5)], "bin": BIN + [line(10, 10.5, 10, 16.5), line(14, 10.5, 14, 16.5)], "delete_forever": BIN + [line(9.75, 11, 14.25, 16), line(14.25, 11, 9.75, 16)], "tag": [TAG, circle(8, 8, 1.2)], "hash": HASH, "lists": ["M3.5 7.25 A2 2 0 0 1 5.5 5.25 H9.25 L11.25 7.25 H18.5 A2 2 0 0 1 20.5 9.25 V16.75 A2 2 0 0 1 18.5 18.75 H5.5 A2 2 0 0 1 3.5 16.75 Z"], # Memory: a closed book with its ribbon, what the assistant keeps of what the person said. "memory": ["M6 4 H17.5 A1.5 1.5 0 0 1 19 5.5 V20 H7.5 A2.5 2.5 0 0 1 5 17.5 V5 A1 1 0 0 1 6 4 Z", "M5 17.5 A2.5 2.5 0 0 1 7.5 15 H19", poly(10.5, 4, 10.5, 10.5, 12.25, 9, 14, 10.5, 14, 4)], "assistant": ["M5 5 H19 A2 2 0 0 1 21 7 V15 A2 2 0 0 1 19 17 H10.5 L6.5 20.25 V17 H5 A2 2 0 0 1 3 15 V7 A2 2 0 0 1 5 5 Z", Dot(8.5, 11, 1), Dot(12, 11, 1), Dot(15.5, 11, 1)], "settings": [line(4, 7, 6.6, 7), circle(9, 7, 2.4), line(11.4, 7, 20, 7), line(4, 17, 12.6, 17), circle(15, 17, 2.4), line(17.4, 17, 20, 17)], "account": [circle(12, 8.5, 3.75), "M4.75 20 A7.25 7.25 0 0 1 19.25 20"], "chevron_right": [poly(10, 6, 16, 12, 10, 18)], "chevron_down": [poly(6, 10, 12, 16, 18, 10)], "caret": [poly(8.5, 10, 12, 13.5, 15.5, 10)], # The list's way to the side page (the drawer, 22 Nov 2026): the page's left edge standing, and its places as three # lines beside it, the last a short one. Words' own drawing, not a menu's three bars. "side": [line(4.75, 4.5, 4.75, 19.5), line(9, 7, 19.5, 7), line(9, 12, 19.5, 12), line(9, 17, 15, 17)], # ── The list ── "back": [poly(15, 5, 8, 12, 15, 19)], "close": [line(6.5, 6.5, 17.5, 17.5), line(17.5, 6.5, 6.5, 17.5)], "more": [Dot(6, 12, 1.6), Dot(12, 12, 1.6), Dot(18, 12, 1.6)], "search": [circle(10.5, 10.5, 6.25), line(15.25, 15.25, 20, 20)], "compose": ["M12 4.25 H7.25 A3 3 0 0 0 4.25 7.25 V16.75 A3 3 0 0 0 7.25 19.75 H16.75 A3 3 0 0 0 19.75 16.75 V12", poly(17.75, 3.75, 20.25, 6.25, 12.25, 14.25, 9.25, 14.75, 9.75, 11.75, close=True)], "plus": [line(12, 5, 12, 19), line(5, 12, 19, 12)], "select": [circle(12, 12, 8.5), CHECK], "sort": [line(4, 7, 20, 7), line(4, 12, 15, 12), line(4, 17, 10, 17)], # ── A row's acts ── "pin": [PIN], "unpin": [PIN, line(4, 4, 20, 20)], "restore": ["M4.5 12 A7.5 7.5 0 1 0 6.7 6.7", poly(6.7, 3.2, 6.7, 6.7, 10.2, 6.7)], "share": ["M12 3.5 V14.5", poly(8, 7.5, 12, 3.5, 16, 7.5), "M8.5 10.5 H7 A2 2 0 0 0 5 12.5 V18.5 A2 2 0 0 0 7 20.5 H17 A2 2 0 0 0 19 18.5 V12.5 A2 2 0 0 0 17 10.5 H15.5"], "export": PAGE + [line(9, 14.5, 15, 14.5), poly(12.75, 12.25, 15, 14.5, 12.75, 16.75)], "import": ["M12 3.5 V14", poly(8, 10, 12, 14, 16, 10), "M4.5 14.5 V18 A2.5 2.5 0 0 0 7 20.5 H17 A2.5 2.5 0 0 0 19.5 18 V14.5"], "file": PAGE, # ── The note's top ── "info": [circle(12, 12, 8.5), line(12, 11, 12, 16.5), Dot(12, 7.75, 1.1)], "format": [poly(3.5, 18, 8, 6, 12.5, 18), line(5.25, 14, 10.75, 14), circle(17, 15, 3), line(20, 12, 20, 18)], "find": [circle(10.5, 10.5, 6.25), line(15.25, 15.25, 20, 20), line(8, 10.5, 13, 10.5)], "replace": ["M5 9 H18 L15 6", "M19 15 H6 L9 18"], # ── Info's three parts ── "stats": [line(6, 19.5, 6, 12), line(12, 19.5, 12, 4.5), line(18, 19.5, 18, 9)], "contents": [line(4, 6, 20, 6), line(8, 11, 20, 11), line(8, 16, 20, 16), Dot(4.75, 11, 1), Dot(4.75, 16, 1)], "backlinks": ["M14 5.5 H17.5 A2.5 2.5 0 0 1 20 8 V16 A2.5 2.5 0 0 1 17.5 18.5 H14", line(4, 12, 14, 12), poly(10, 8, 14, 12, 10, 16)], # ── The bar and the formatting keys ── "undo": [poly(9, 5.75, 4.5, 10.25, 9, 14.75), "M4.5 10.25 H14.25 A5 5 0 0 1 14.25 20.25 H11"], "redo": [poly(15, 5.75, 19.5, 10.25, 15, 14.75), "M19.5 10.25 H9.75 A5 5 0 0 0 9.75 20.25 H13"], "keyboard": [rect(3, 6, 18, 12, 2.5)] + KEYS + [line(8, 14.5, 16, 14.5)], "hide": [rect(3, 3.5, 18, 11, 2.5)] + [Dot(7, 7.25, 0.95), Dot(10.35, 7.25, 0.95), Dot(13.65, 7.25, 0.95), Dot(17, 7.25, 0.95)] + [line(8, 11, 16, 11), poly(9, 17.75, 12, 20.75, 15, 17.75)], "picture": [rect(3.5, 5, 17, 14, 2.5), circle(9, 10, 1.6), poly(3.75, 17, 9, 12.5, 13, 16, 16, 13.5, 20.25, 17)], "camera": ["M3.5 9 A2 2 0 0 1 5.5 7 H8 L9.5 5 H14.5 L16 7 H18.5 A2 2 0 0 1 20.5 9 V17 A2 2 0 0 1 18.5 19 H5.5 A2 2 0 0 1 3.5 17 Z", circle(12, 13, 3.3)], "heading": [line(4.5, 5.5, 4.5, 18.5), line(12, 5.5, 12, 18.5), line(4.5, 12, 12, 12), poly(16, 9, 18.75, 6.75, 18.75, 18.5)], "bold": ["M7 5 H12.5 A3.5 3.5 0 0 1 12.5 12 H7 Z", "M7 12 H13.5 A3.5 3.5 0 0 1 13.5 19 H7 Z"], "italic": [line(10, 5, 17, 5), line(7, 19, 14, 19), line(13.75, 5, 10.25, 19)], "underline": ["M7 4.5 V11 A5 5 0 0 0 17 11 V4.5", line(6, 20, 18, 20)], "strike": ["M16 7.25 C15.25 5.5 13.75 4.75 12 4.75 C9.75 4.75 8 6 8 8 C8 9.75 9.25 10.75 11 11.25", "M8 16.75 C8.75 18.5 10.25 19.25 12 19.25 C14.25 19.25 16 18 16 16 C16 14.75 15.5 13.75 14.25 13", line(4, 12, 20, 12)], "highlight": [poly(14.5, 4, 20, 9.5, 11, 18.5, 6.5, 18.5, 6.5, 14, close=True), line(12.25, 6.25, 17.75, 11.75), line(3.5, 21, 20.5, 21)], "code": [poly(8.5, 7, 3.5, 12, 8.5, 17), poly(15.5, 7, 20.5, 12, 15.5, 17)], "code_block": [rect(3.5, 4.5, 17, 15, 2.5), poly(9.25, 9.5, 6.75, 12, 9.25, 14.5), line(11.75, 14.5, 16, 14.5)], "link": ["M10.25 13.75 A3.5 3.5 0 0 1 10.25 8.75 L12.75 6.25 A3.54 3.54 0 0 1 17.75 11.25 L16.25 12.75", "M13.75 10.25 A3.5 3.5 0 0 1 13.75 15.25 L11.25 17.75 A3.54 3.54 0 0 1 6.25 12.75 L7.75 11.25"], "note_link": [poly(6.25, 5, 4, 5, 4, 19, 6.25, 19), poly(9.5, 5, 7.25, 5, 7.25, 19, 9.5, 19), poly(14.5, 5, 16.75, 5, 16.75, 19, 14.5, 19), poly(17.75, 5, 20, 5, 20, 19, 17.75, 19)], "bullets": [Dot(5.5, 7), Dot(5.5, 12), Dot(5.5, 17), line(9.5, 7, 20, 7), line(9.5, 12, 20, 12), line(9.5, 17, 20, 17)], "numbers": [line(5.25, 5, 5.25, 10), poly(4, 5.75, 5.25, 5), poly(3.75, 14.5, 4.5, 13.75, 6, 13.75, 6.75, 14.5, 6.75, 15.25, 3.75, 19, 6.75, 19), line(10, 7, 20, 7), line(10, 12, 20, 12), line(10, 17, 20, 17)], "check": [rect(4.25, 4.25, 15.5, 15.5, 4)], "checked": [rect(4.25, 4.25, 15.5, 15.5, 4), CHECK], "quote": [line(5.5, 5, 5.5, 19), line(9.5, 8, 19, 8), line(9.5, 12, 19, 12), line(9.5, 16, 15.5, 16)], "divider": [line(3.5, 12, 20.5, 12), Dot(8, 6.5, 0.9), Dot(12, 6.5, 0.9), Dot(16, 6.5, 0.9)], "table": [rect(3.5, 5, 17, 14, 2.5), line(3.5, 10, 20.5, 10), line(3.5, 14.5, 20.5, 14.5), line(10, 5, 10, 19)], "indent": [line(4, 5, 20, 5), line(11, 10, 20, 10), line(11, 14, 20, 14), line(4, 19, 20, 19), poly(4, 9, 7, 12, 4, 15)], "outdent": [line(4, 5, 20, 5), line(11, 10, 20, 10), line(11, 14, 20, 14), line(4, 19, 20, 19), poly(7, 9, 4, 12, 7, 15)], "up": [line(12, 19.5, 12, 4.75), poly(6.5, 10.25, 12, 4.75, 17.5, 10.25)], "down": [line(12, 4.5, 12, 19.25), poly(6.5, 13.75, 12, 19.25, 17.5, 13.75)], "fold": [poly(7, 4.5, 12, 9, 17, 4.5), poly(7, 19.5, 12, 15, 17, 19.5)], "unfold": [poly(7, 9, 12, 4.5, 17, 9), poly(7, 15, 12, 19.5, 17, 15)], "corner": [Fill("M20.5 15.5 V20.5 H15.5 Z")], "return": [poly(19.5, 5, 19.5, 13, 5, 13), poly(9, 9, 5, 13, 9, 17)], "space": [poly(4, 10, 4, 15, 20, 15, 20, 10)], "delete": [poly(8, 5, 20.5, 5, 20.5, 19, 8, 19, 2.5, 12, close=True), line(11.75, 9, 16.75, 15), line(16.75, 9, 11.75, 15)], "row_add": [rect(3.5, 3.5, 17, 10, 2), line(3.5, 8.5, 20.5, 8.5), line(12, 3.5, 12, 13.5), line(8.5, 19, 15.5, 19), line(12, 15.5, 12, 22.5)], "row_remove": [rect(3.5, 3.5, 17, 10, 2), line(3.5, 8.5, 20.5, 8.5), line(12, 3.5, 12, 13.5), line(8.5, 19, 15.5, 19)], "column_add": [rect(3.5, 3.5, 10, 17, 2), line(8.5, 3.5, 8.5, 20.5), line(3.5, 12, 13.5, 12), line(16, 12, 22.5, 12), line(19.25, 8.75, 19.25, 15.25)], "column_remove": [rect(3.5, 3.5, 10, 17, 2), line(8.5, 3.5, 8.5, 20.5), line(3.5, 12, 13.5, 12), line(16, 12, 22.5, 12)], "resize": [line(20, 12.5, 12.5, 20), line(20, 17, 17, 20)], # ── Tag icons: a starter set, each a word's own drawing; a tag with none wears the hash ── "tag_work": [rect(3.5, 7.5, 17, 12, 2.5), "M9 7.5 V5.5 A1.5 1.5 0 0 1 10.5 4 H13.5 A1.5 1.5 0 0 1 15 5.5 V7.5", line(3.5, 12.5, 20.5, 12.5)], "tag_home": [poly(4, 11, 12, 4, 20, 11), "M6 9.5 V19 A1 1 0 0 0 7 20 H17 A1 1 0 0 0 18 19 V9.5", poly(10, 20, 10, 14.5, 14, 14.5, 14, 20)], "tag_book": ["M12 6.5 C10 5 7 4.5 4 5 V18.5 C7 18 10 18.5 12 20 C14 18.5 17 18 20 18.5 V5 C17 4.5 14 5 12 6.5 Z", line(12, 6.5, 12, 20)], "tag_idea": ["M9 16.75 V15 C7.25 13.75 6 12 6 10 A6 6 0 0 1 18 10 C18 12 16.75 13.75 15 15 V16.75 Z", line(9.5, 20, 14.5, 20)], "tag_travel": [circle(12, 12, 8.5), "M12 3.5 C9 6 9 18 12 20.5 C15 18 15 6 12 3.5", line(3.5, 12, 20.5, 12)], "tag_food": ["M5 8 H16 V13 A5 5 0 0 1 11 18 H10 A5 5 0 0 1 5 13 Z", "M16 9.5 H17.5 A2.5 2.5 0 0 1 17.5 14.5 H16", line(5, 20.75, 16, 20.75)], "tag_music": ["M9 18 V6 L19 4 V16", circle(6.5, 18, 2.5), circle(16.5, 16, 2.5)], "tag_health": ["M12 20 C5 15 3.5 11.5 3.5 8.75 A4.25 4.25 0 0 1 12 7 A4.25 4.25 0 0 1 20.5 8.75 C20.5 11.5 19 15 12 20 Z"], "tag_money": [circle(12, 12, 8.5), "M14.5 9 C14 8 13 7.5 12 7.5 C10.5 7.5 9.5 8.25 9.5 9.5 C9.5 12 14.5 11 14.5 14 C14.5 15.25 13.5 16.5 12 16.5 C11 16.5 9.75 16 9.25 15", line(12, 6, 12, 7.5), line(12, 16.5, 12, 18)], "tag_people": [circle(9, 8.5, 3), "M3.5 19 A5.5 5.5 0 0 1 14.5 19", circle(16.75, 9.5, 2.25), "M16 14 A4.5 4.5 0 0 1 20.5 18.5"], "tag_star": [star(12, 12.5, 8.5, 3.75)], "tag_garden": ["M5 19 C5 10 10 5 19.5 4.5 C19 14 14 19 5 19 Z", line(5, 19, 13, 11)], "tag_code": [poly(8.5, 7, 3.5, 12, 8.5, 17), poly(15.5, 7, 20.5, 12, 15.5, 17), line(13.5, 5, 10.5, 19)], "tag_calendar": [rect(4, 5, 16, 15.5, 3), line(4, 9.5, 20, 9.5), line(8.5, 3, 8.5, 6.5), line(15.5, 3, 15.5, 6.5)], "tag_school": [poly(2.5, 9.5, 12, 5, 21.5, 9.5, 12, 14, close=True), "M6.5 11.5 V16 C8 17.75 10 18.5 12 18.5 C14 18.5 16 17.75 17.5 16 V11.5"],}def drawable(parts): paths = [] for p in parts: if isinstance(p, Dot) or isinstance(p, Fill): paths.append(f' <path android:fillColor="#FF000000" android:pathData="{p.d}" />') else: paths.append( f' <path android:fillColor="#00000000" android:strokeColor="#FF000000" android:strokeWidth="{STROKE}"\n' f' android:strokeLineCap="round" android:strokeLineJoin="round" android:pathData="{p}" />') return ('<?xml version="1.0" encoding="utf-8"?>\n' '<!-- Cotton Notes\' own icon, drawn by scripts/draw-notes-icons.py: edit the drawing there, not here. -->\n' '<vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp"\n' ' android:viewportWidth="24" android:viewportHeight="24">\n' + "\n".join(paths) + "\n</vector>\n")def swift(icons): rows = [] for name, parts in icons.items(): drawn = [] for p in parts: if isinstance(p, Dot) or isinstance(p, Fill): drawn.append(f'.init(fill: "{p.d}")') else: drawn.append(f'.init(stroke: "{p}")') rows.append(f' "{name}": [' + ", ".join(drawn) + "],") return ("// Cotton Notes' own icons, written by scripts/draw-notes-icons.py (pnpm notes:icons): edit the drawing there,\n" "// not here. The same drawings as Android's `mark_<name>.xml`, on a 24-unit grid; `WritingMark` draws them.\n\n" "extension WritingMarks {\n" f" /// The stroke every line is drawn with, in grid units.\n static let stroke: Double = {STROKE}\n\n" " /// Each icon's parts, by name.\n" " static let set: [String: [Part]] = [\n" + "\n".join(rows) + "\n ]\n}\n")def main(): os.makedirs(OUT, exist_ok=True) for old in os.listdir(OUT): if old.startswith("mark_") and old.endswith(".xml"): os.remove(os.path.join(OUT, old)) for name, parts in ICONS.items(): with open(os.path.join(OUT, f"mark_{name}.xml"), "w") as out: out.write(drawable(parts)) with open(SWIFT, "w") as out: out.write(swift(ICONS)) print(f"{len(ICONS)} icons → {os.path.relpath(OUT)} and {os.path.relpath(SWIFT)}", file=sys.stderr)if __name__ == "__main__": main()