"""Draws the Reims-Go wordmark and README banners.
The wordmark is monoline lettering: one stroke width, round caps, built
from circles, ellipses and straight lines so it matches the rounded app
icon. Run from the repository root:
python scripts/brand/wordmark.py
It writes assets/wordmark-{light,dark}.svg and
.github/readme/banner-{light,dark}.svg. It needs only the standard library.
"""
import math
import re
from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
X = 72.0 # x-height, outer edge to outer edge
INK = {"light": "#16182e", "dark": "#f4f5fa"}
MUTED = {"light": "#a3a8bf", "dark": "#5d6382"}
GRADIENT = ("#3b8cff", "#6d5dfc", "#ff7a9a")
BOLT = ("#ffd43b", "#ff9f0a")
# The style the script writes. Variants used while choosing it:
# joiner: "dash" | "bolt" | "none"; go: "gradient" | "pill"
# dot: "accent" | "ink"; stroke: stroke width.
STYLE = dict(stroke=15.0, joiner="dash", go="gradient", dot="accent")
def f(v):
return ("%.2f" % v).rstrip("0").rstrip(".")
def arc(rx, ry, large, sweep, x, y):
return f"A{f(rx)} {f(ry)} 0 {large} {sweep} {f(x)} {f(y)}"
class Geo:
def __init__(self, w):
self.W, self.H = w, w / 2
self.TOP, self.BOT, self.MID = -X + w / 2, -w / 2, -X / 2
self.R = (X - w) / 2
# Glyphs take the geometry and the left outer edge x, and return
# (outer width, [(role, svg element without paint)]). Roles pick the paint.
def g_r(g, x):
s, rx = x + g.H, 24
return g.W + rx, [("ink", f'" for role, el in parts]
x += width + gap
asc, desc = X + 22 + g.H + 1.5, 22.5 + g.H
pill_el = ""
if pill:
top, bot = -X - 12, desc + 8
x += 14
pill_el = (f'')
asc, desc = max(asc, -top), bot
stops = "".join(f'' for i, c in enumerate(GRADIENT))
bolt = "".join(f'' for i, c in enumerate(BOLT))
defs = (f'{stops}'
f'{bolt}')
body = (f'{defs}{pill_el}{"".join(out)}')
return body, x, asc, desc
def standalone(theme, style=STYLE):
body, width, asc, desc = wordmark(theme, style)
pad = 4
w, h = width + 2 * pad, asc + desc + 2 * pad
return (f'\n')
def banner(theme, style=STYLE):
logo = (ROOT / "assets/logo.svg").read_text(encoding="utf-8")
icon_body = re.sub(r"^.*?", 1)[0]
body, width, _, _ = wordmark(theme, style)
icon, gap = 180, 26
w = icon + gap + width + 6
return (f'\n')
def main():
for theme in ("light", "dark"):
(ROOT / f"assets/wordmark-{theme}.svg").write_text(standalone(theme), encoding="utf-8", newline="\n")
(ROOT / f".github/readme/banner-{theme}.svg").write_text(banner(theme), encoding="utf-8", newline="\n")
if __name__ == "__main__":
main()