Replace the small logo and plain title with a banner that pairs the app
icon with a monoline "reims-go" wordmark (light and dark versions picked
by GitHub's theme), a two-line tagline, and status badges.
scripts/brand/wordmark.py draws the wordmark from circles and lines and
writes the banners plus standalone assets/wordmark-{light,dark}.svg.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
174 lines
6.9 KiB
Python
174 lines
6.9 KiB
Python
"""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'<path d="M{f(s)} {f(g.BOT)}V{f(g.MID)}{arc(rx, g.MID - g.TOP, 0, 1, s + rx, g.TOP)}"')]
|
|
|
|
|
|
def g_e(g, x):
|
|
c, a = x + g.H + g.R, math.radians(42)
|
|
ex, ey = c + g.R * math.cos(a), g.MID + g.R * math.sin(a)
|
|
return 2 * g.R + g.W, [("ink", f'<path d="M{f(c - g.R)} {f(g.MID)}H{f(c + g.R)}{arc(g.R, g.R, 1, 0, ex, ey)}"')]
|
|
|
|
|
|
def g_i(g, x):
|
|
s = x + g.H
|
|
return g.W, [("ink", f'<path d="M{f(s)} {f(g.TOP)}V{f(g.BOT)}"'),
|
|
("dot", f'<circle cx="{f(s)}" cy="{f(-X - 22)}" r="{f(g.H + 1.5)}"')]
|
|
|
|
|
|
def g_m(g, x):
|
|
s, rx, ry = x + g.H, 22, g.MID - g.TOP
|
|
return 4 * rx + g.W, [("ink", f'<path d="M{f(s)} {f(g.BOT)}V{f(g.MID)}{arc(rx, ry, 0, 1, s + 2 * rx, g.MID)}V{f(g.BOT)}'
|
|
f'M{f(s + 2 * rx)} {f(g.MID)}{arc(rx, ry, 0, 1, s + 4 * rx, g.MID)}V{f(g.BOT)}"')]
|
|
|
|
|
|
def g_s(g, x):
|
|
rx, ry = 21, (g.BOT - g.TOP) / 4
|
|
c, up, lo, a = x + g.H + rx, g.TOP + ry, g.BOT - ry, math.radians(38)
|
|
sx, sy = c + rx * math.cos(a), up - ry * math.sin(a)
|
|
tx, ty = c - rx * math.cos(a), lo + ry * math.sin(a)
|
|
return 2 * rx + g.W, [("ink", f'<path d="M{f(sx)} {f(sy)}{arc(rx, ry, 0, 0, c - rx, up)}{arc(rx, ry, 0, 0, c, g.MID)}'
|
|
f'{arc(rx, ry, 0, 1, c + rx, lo)}{arc(rx, ry, 0, 1, tx, ty)}"')]
|
|
|
|
|
|
def g_dash(g, x):
|
|
return 18 + g.W, [("muted", f'<path d="M{f(x + g.H)} {f(g.MID)}H{f(x + g.H + 18)}"')]
|
|
|
|
|
|
def g_bolt(g, x):
|
|
# The icon's bolt, scaled to the x-height and centred on it.
|
|
pts = [(800, 628), (708, 744), (768, 744), (748, 822), (846, 700), (784, 700)]
|
|
s = (X + 14) / 194
|
|
d = "M" + "L".join(f"{f(x + (px - 708) * s)} {f(g.MID + (py - 725) * s)}" for px, py in pts) + "Z"
|
|
return 138 * s, [("bolt", f'<path d="{d}"')]
|
|
|
|
|
|
def g_g(g, x):
|
|
c, hook, a = x + g.H + g.R, 22.5, math.radians(150)
|
|
hx, hy = c + g.R * math.cos(a), hook * math.sin(a)
|
|
return 2 * g.R + g.W, [("go", f'<path d="M{f(c + g.R)} {f(g.MID)}{arc(g.R, g.R, 1, 1, c + g.R, g.MID - 0.01)}"'),
|
|
("go", f'<path d="M{f(c + g.R)} {f(g.TOP)}V0{arc(g.R, hook, 0, 1, hx, hy)}"')]
|
|
|
|
|
|
def g_o(g, x):
|
|
c = x + g.H + g.R
|
|
return 2 * g.R + g.W, [("go", f'<path d="M{f(c + g.R)} {f(g.MID)}{arc(g.R, g.R, 1, 1, c + g.R, g.MID - 0.01)}"')]
|
|
|
|
|
|
def wordmark(theme, style=STYLE, gid="wm"):
|
|
"""Returns (svg body, width, ascent, descent); the baseline is y=0."""
|
|
g = Geo(style["stroke"])
|
|
joiner = {"dash": [(g_dash, 10)], "bolt": [(g_bolt, 8)], "none": []}[style["joiner"]]
|
|
pill = style["go"] == "pill"
|
|
seq = [(g_r, 4), (g_e, 11), (g_i, 11), (g_m, 11), (g_s, 10 if joiner else 14)] + joiner + [(g_g, 11), (g_o, 0)]
|
|
paint = {
|
|
"ink": f'stroke="{INK[theme]}"',
|
|
"muted": f'stroke="{MUTED[theme]}"',
|
|
"dot": f'fill="{GRADIENT[2]}"' if style["dot"] == "accent" else f'fill="{INK[theme]}"',
|
|
"bolt": f'fill="url(#{gid}b)" stroke="none"',
|
|
"go": 'stroke="#ffffff"' if pill else f'stroke="url(#{gid})"',
|
|
}
|
|
out, x, go0 = [], 0.0, None
|
|
for draw, gap in seq:
|
|
if draw is g_g:
|
|
go0 = x + (14 if pill else 0)
|
|
x = go0
|
|
width, parts = draw(g, x)
|
|
out += [f"{el} {paint[role]}/>" 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'<rect x="{f(go0 - 14)}" y="{f(top)}" width="{f(x - go0 + 14)}" '
|
|
f'height="{f(bot - top)}" rx="{f((bot - top) * 0.36)}" fill="url(#{gid})"/>')
|
|
asc, desc = max(asc, -top), bot
|
|
stops = "".join(f'<stop offset="{i / 2:g}" stop-color="{c}"/>' for i, c in enumerate(GRADIENT))
|
|
bolt = "".join(f'<stop offset="{i}" stop-color="{c}"/>' for i, c in enumerate(BOLT))
|
|
defs = (f'<defs><linearGradient id="{gid}" gradientUnits="userSpaceOnUse" x1="{f(go0 - (14 if pill else 0))}" '
|
|
f'y1="0" x2="{f(x)}" y2="0">{stops}</linearGradient>'
|
|
f'<linearGradient id="{gid}b" x1="0" y1="0" x2="0" y2="1">{bolt}</linearGradient></defs>')
|
|
body = (f'{defs}{pill_el}<g fill="none" stroke-width="{f(g.W)}" stroke-linecap="round" '
|
|
f'stroke-linejoin="round">{"".join(out)}</g>')
|
|
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'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 {f(w)} {f(h)}" width="{f(w)}" '
|
|
f'height="{f(h)}" role="img" aria-label="Reims-Go"><g transform="translate({pad} {f(pad + asc)})">'
|
|
f'{body}</g></svg>\n')
|
|
|
|
|
|
def banner(theme, style=STYLE):
|
|
logo = (ROOT / "assets/logo.svg").read_text(encoding="utf-8")
|
|
icon_body = re.sub(r"^.*?<svg[^>]*>", "", logo, flags=re.S).rsplit("</svg>", 1)[0]
|
|
body, width, _, _ = wordmark(theme, style)
|
|
icon, gap = 180, 26
|
|
w = icon + gap + width + 6
|
|
return (f'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 {f(w)} {icon}" width="{f(w)}" '
|
|
f'height="{icon}" role="img" aria-label="Reims-Go">'
|
|
f'<svg x="0" y="0" width="{icon}" height="{icon}" viewBox="0 0 1024 1024">{icon_body}</svg>'
|
|
f'<g transform="translate({icon + gap} {f(icon / 2 + X / 2)})">{body}</g></svg>\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()
|