# Generates the Parsimony logo files: python3 assets/make-logo.py assets
# The wordmark is drawn with monoline strokes, not typeset: it needs no font and looks the same everywhere.
# The mark is an envelope in a rounded square; the dot of the i echoes it in the accent colour.
import math, sys
INK, TEAL, WHITE = "#0f172a", "#0f766e", "#ffffff"
SW = 4.4 # stroke width of the letters
H = 24 # x-height
B = 40 # baseline y in the wordmark box
T = B - H
GAP = 8.5
def circle(cx, cy, r): return f''
def path(d): return f''
def letter(ch):
"""returns (svg elements, advance width) with x from 0"""
if ch == "o": return circle(12, B-12, 12), 24
if ch == "a": return circle(12, B-12, 12) + path(f"M24 {T}V{B}"), 24
if ch == "p": return path(f"M0 {T}V{B+14}") + circle(12, B-12, 12), 24
if ch == "n": return path(f"M0 {T}V{B}") + path(f"M0 {T+12}A12 12 0 0 1 24 {T+12}V{B}"), 24
if ch == "m": return path(f"M0 {T}V{B}") + path(f"M0 {T+10}A10 10 0 0 1 20 {T+10}V{B}") + path(f"M20 {T+10}A10 10 0 0 1 40 {T+10}V{B}"), 40
if ch == "r": return path(f"M0 {T}V{B}") + path(f"M0 {T+13}A13 13 0 0 1 13 {T}"), 13
if ch == "i": return path(f"M0 {T}V{B}") + f'', 0
if ch == "y": return path(f"M0 {T}L12.6 {B}") + path(f"M24 {T}L6 {B+14}"), 24
if ch == "s":
d = (f"M18 {T+5}C15 {T+1} 11 {T} 9 {T}C4 {T} 2 {T+3.5} 2 {T+6.5}C2 {T+11} 7 {T+12} 10.5 {T+13}"
f"C15 {T+14} 18 {T+16} 18 {T+19}C18 {T+22.5} 14 {B} 9 {B}C5 {B} 2 {B-1.5} 1 {B-5}")
return path(d), 18
raise ValueError(ch)
def wordmark(text="parsimony"):
kern = {("r", "s"): -4.0, ("p", "a"): -0.5}
x = 0; out = []; prev = None
for ch in text:
x += kern.get((prev, ch), 0)
svg, w = letter(ch)
out.append(f'{svg}')
x += w + GAP
prev = ch
return "".join(out), x - GAP
def envelope(cx, cy, w=30, h=22, sw=4):
"""envelope outline with its flap, centred on cx,cy"""
x0, y0, x1, y1 = cx-w/2, cy-h/2, cx+w/2, cy+h/2
f = lambda v: f"{v:g}"
return (f''
f'')
def mark_svg(bg=True, fg=WHITE, bgc=TEAL):
s = f''
return s
def logo_svg(dark=False):
ink = WHITE if dark else INK
teal = "#2dd4bf" if dark else TEAL
wm, ww = wordmark()
gap = 22
scale = 1.0
mark = 56
total_w = mark + gap + ww + 4
# vertical: mark centred on the x-height band of the wordmark
top = T - 14 - 2.2 # i-dot top
bottom = B + 14 + 2.2 # descenders
h = bottom - top
my = (h - mark) / 2
tx = mark + gap + 2.2
ty = -top
s = (f'')
s = s.replace('class="dot"', f'stroke="{teal}"')
return s
if __name__ == "__main__":
out = sys.argv[1]
open(f"{out}/logo.svg","w").write(logo_svg(False))
open(f"{out}/logo-dark.svg","w").write(logo_svg(True))
open(f"{out}/logo-mark.svg","w").write(mark_svg())