Files
Remus/branding/generate.py
T
Ansho Rei 578a4f5607 fix: enlarge the app icon's mark so it reads at small sizes
The tile now starts 2 units from the edge instead of 8 and the mark is
100 tall instead of 74, nudged up 1 unit because its base reads heavier
than the R.
2026-11-04 13:06:36 +01:00

218 lines
13 KiB
Python

#!/usr/bin/env python3
"""Writes every Remus logo variant as SVG into branding/svg.
All variants are built from the same mark geometry below, so a change to the
mark only has to be made here. Run `make branding` to regenerate the SVGs and
render the PNGs.
"""
from pathlib import Path
MAROON = "#5a0712"
CREAM = "#faebda"
# Slightly lifted maroon for decorative bars on the hero image.
MAROON_LIGHT = "#6b0d1b"
# The mark is drawn in the coordinates of the 1254 px source artwork.
# It is mirror-symmetric around x = 627.5.
CX = 627.5
MARK_BOX = (340.0, 313.0, 915.0, 941.5) # x0, y0, x1, y1
# Traced from the source artwork.
R_PATH = "M456.32,605.50C452.96,605.35 452.88,605.29 452.88,603.08C452.88,601.03 453.05,600.88 456.88,599.52C460.01,598.41 460.90,598.05 463.45,596.85C464.45,596.38 465.33,596.00 465.40,596.00C465.81,596.00 472.53,592.55 474.76,591.20C490.25,581.80 496.47,573.90 499.54,559.75L500.11,557.12L500.24,497.38C500.43,412.59 500.22,363.56 499.67,360.75C498.12,352.93 496.40,348.79 492.61,343.77C485.58,334.43 474.65,326.59 459.62,320.12C457.15,319.06 454.76,318.08 454.31,317.95C453.12,317.62 452.67,316.78 452.80,315.14C452.86,314.39 453.06,313.60 453.24,313.39C453.53,313.04 462.72,313.00 547.89,313.00C653.06,313.00 647.36,312.92 660.75,314.64C672.81,316.19 690.05,321.27 698.25,325.70C709.70,331.88 714.98,335.69 721.89,342.78C731.72,352.87 738.85,366.60 740.96,379.50C742.04,386.15 742.34,389.75 742.17,394.18C741.67,407.42 738.27,418.76 731.68,429.15C724.99,439.71 714.77,449.22 702.54,456.28C701.26,457.02 699.91,457.80 699.54,458.02C693.02,461.86 679.82,467.01 670.12,469.50C665.05,470.81 664.39,471.06 664.30,471.71C664.21,472.26 665.78,474.37 671.26,481.12C672.72,482.91 677.78,489.21 682.52,495.13C687.27,501.04 692.08,507.00 693.22,508.38C694.36,509.75 696.22,512.11 697.37,513.62C698.51,515.14 700.73,517.97 702.29,519.91C710.78,530.50 718.71,540.31 721.45,543.62C723.15,545.69 726.41,549.68 728.71,552.50C735.86,561.29 738.22,564.01 742.11,567.89C750.99,576.78 762.35,584.44 773.88,589.31C774.70,589.66 776.22,590.31 777.25,590.75C778.28,591.20 779.69,591.76 780.38,592.00C783.56,593.10 786.30,593.97 788.25,594.49C789.42,594.79 791.11,595.26 792.00,595.52C793.57,595.97 795.02,596.30 799.48,597.23C802.20,597.80 802.25,597.88 802.25,601.41C802.25,604.02 802.21,604.27 801.65,604.92L801.04,605.62L753.96,605.62C715.51,605.62 706.46,605.56 704.62,605.28C692.89,603.51 683.14,597.15 674.69,585.75C673.21,583.76 671.10,580.94 670.00,579.50C667.28,575.93 664.03,571.58 660.00,566.13C658.14,563.62 655.56,560.13 654.25,558.38C652.94,556.62 650.03,552.70 647.77,549.66C641.97,541.85 633.78,530.97 619.02,511.50C617.41,509.37 613.97,504.81 611.37,501.38C608.78,497.94 605.19,493.21 603.39,490.88C601.59,488.54 599.31,485.56 598.33,484.25C596.30,481.54 595.64,480.88 594.74,480.66C594.38,480.58 589.15,480.50 583.11,480.49L572.13,480.47L571.68,481.02C571.25,481.55 571.24,483.35 571.31,519.85C571.38,549.72 571.47,558.48 571.72,559.75C574.89,575.81 583.99,585.82 604.45,595.75C605.86,596.44 607.11,597.00 607.23,597.00C607.35,597.00 608.15,597.35 609.02,597.78C609.88,598.21 611.16,598.76 611.86,599.01C614.40,599.93 615.15,600.22 616.31,600.72L617.50,601.23L617.50,602.84C617.50,604.03 617.38,604.59 617.03,605.02L616.57,605.60L537.85,605.61C494.55,605.62 457.86,605.57 456.32,605.50ZM600.38,463.00C606.75,462.53 613.03,461.37 618.38,459.66C629.72,456.04 637.60,451.38 645.27,443.75C651.89,437.18 657.19,428.71 659.74,420.62C660.05,419.66 660.44,418.48 660.62,418.00C662.11,413.97 663.57,406.53 664.03,400.62C664.33,396.86 664.17,385.71 663.79,383.88C663.64,383.19 663.40,381.84 663.25,380.88C662.92,378.72 661.84,373.77 661.37,372.25C661.18,371.63 660.75,370.23 660.41,369.12C660.07,368.02 659.61,366.79 659.40,366.38C659.18,365.96 659.00,365.51 659.00,365.36C659.00,365.22 658.26,363.65 657.35,361.86C648.63,344.78 632.27,333.74 611.62,331.03C610.52,330.88 608.67,330.63 607.50,330.47C606.12,330.28 599.60,330.14 589.00,330.06L572.62,329.95L571.94,330.50L571.25,331.04L571.31,396.95L571.38,462.86L571.89,463.12C572.56,463.45 595.54,463.36 600.38,463.00Z"
def _column() -> str:
flutes = "".join(
f"M{fx - 11.5},855.5V738.5A11.5 11.5 0 0 1 {fx + 11.5},738.5V855.5Z"
for fx in (CX - 53.5, CX, CX + 53.5)
)
return (
# Abacus
"M453,633Q453,632 454,632H801Q802,632 802,633V653"
"A13 12 0 0 1 789,665H466A13 12 0 0 1 453,653Z"
# Echinus
"M493.5,677H761.5V683A16 16 0 0 1 745.5,699H509.5A16 16 0 0 1 493.5,683Z"
# Shaft with flared ends
"M520,710H735Q726,714 726,724V856Q726.5,870 735,873"
"H520Q528.5,870 529,856V724Q529,714 520,710Z"
+ flutes
# Base
+ "M487,905V900A16 16 0 0 1 503,884H752A16 16 0 0 1 768,900V905Z"
"M460,941.5V930A14 14 0 0 1 474,916H781A14 14 0 0 1 795,930V941.5Z"
)
def _bars() -> str:
# (offset of the bar centre from CX, top, bottom), mirrored on both sides.
bars = [(152.5, 741, 856), (212.5, 707, 889), (272.5, 757, 856)]
out = []
for off, top, bottom in bars:
for sign in (-1, 1):
x = CX + sign * off - 15
out.append(
f'<rect x="{x}" y="{top}" width="30" height="{bottom - top}" rx="6"/>'
)
return "".join(out)
def mark(fill: str, cx: float, cy: float, height: float) -> str:
"""The mark scaled to `height`, centred on (cx, cy)."""
x0, y0, x1, y1 = MARK_BOX
s = height / (y1 - y0)
mx, my = (x0 + x1) / 2, (y0 + y1) / 2
return (
f'<g fill="{fill}" transform="translate({cx:g} {cy:g}) scale({s:.6g}) '
f'translate({-mx:g} {-my:g})">'
f'<path d="{R_PATH}"/>'
f'<path fill-rule="evenodd" d="{_column()}"/>'
f"{_bars()}</g>"
)
def mark_width(height: float) -> float:
x0, y0, x1, y1 = MARK_BOX
return (x1 - x0) * height / (y1 - y0)
# "REMUS" in Noto Serif SemiBold, letter-spacing 18, font-size 100, as outlines.
# Cap height runs from y = 28.6 to the baseline at y = 100.
WORDMARK = [
"m 3.2,100 v -4.9 h 3.1 q 2.5,0 4.4,-1 1.9,-1.1 1.9,-5.2 V 39.8 q 0,-4.1 -1.9,-5.2 Q 8.8,33.5 6.3,33.5 H 3.2 v -4.9 h 30.2 q 13.7,0 20.2,4.8 6.5,4.7 6.5,14 0,5.3 -2.1,9 -2,3.7 -5.3,6 -3.2,2.3 -6.6,3.6 l 12.6,21 q 2.5,4.2 4.8,6.2 2.4,1.9 5.4,1.9 h 0.3 V 100 H 66.7 Q 60.6,100 56.8,99.3 53,98.6 50.5,96.7 48.1,94.8 45.9,91 L 33.4,68.8 h -7.2 v 20.1 q 0,4.1 1.9,5.2 1.9,1 4.4,1 h 3.1 V 100 Z M 32.3,63.4 q 7.6,0 10.4,-3.7 2.9,-3.8 2.9,-11.3 0,-7.8 -3.1,-11 -3,-3.3 -10.4,-3.3 h -5.9 v 29.3 z",
"m 89.999973,100 v -4.9 h 3.1 q 2.5,0 4.4,-1 1.9,-1.1 1.9,-5.2 V 40.2 q 0,-4.4 -1.9,-5.5 -1.8,-1.2 -4.4,-1.2 h -3.1 v -4.9 h 53.499997 l 0.5,18.1 h -6.3 l -0.5,-4.6 q -0.4,-3.5 -2.1,-5.6 -1.6,-2.2 -5.2,-2.2 h -16.8 v 25.6 h 23.8 v 5.6 h -23.8 v 28.8 h 19.7 q 3.6,0 5.3,-2.2 1.7,-2.3 2.3,-5.6 l 0.7,-4.6 h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5.3,-2.4 12.1,-2.4 10.2,0 15.2,3.4 5.1,3.4 5.1,8 0,3.5 -2.8,5.6 -2.7,2.1 -7.9,2.1 0,-2.9 -1.1,-6 -1,-3.2 -3.4,-5.3 -2.3,-2.1 -6.3,-2.1 -4.7,0 -7.8,2.7 -3,2.6 -3,7.3 0,3.3 1.4,5.8 1.4,2.5 4.9,4.8 3.5,2.3 9.9,4.9 9.7,3.9 14.3,8.7 4.6,4.8 4.6,12.3 0,6.4 -3.3,11.2 -3.2,4.7 -9.1,7.4 -5.8,2.6 -13.8,2.6 z",
]
WM_X0, WM_X1 = 3.2, 425.3
WM_CAP_TOP, WM_BASELINE = 28.6, 100.0
def wordmark(fill: str, cx: float, cap_top: float, cap_height: float) -> str:
"""The wordmark with its cap height box at cap_top, centred on cx."""
s = cap_height / (WM_BASELINE - WM_CAP_TOP)
mx = (WM_X0 + WM_X1) / 2
paths = "".join(f'<path d="{d}"/>' for d in WORDMARK)
return (
f'<g fill="{fill}" transform="translate({cx:g} {cap_top:g}) scale({s:.6g}) '
f'translate({-mx:g} {-WM_CAP_TOP:g})">{paths}</g>'
)
def wordmark_width(cap_height: float) -> float:
return (WM_X1 - WM_X0) * cap_height / (WM_BASELINE - WM_CAP_TOP)
def svg(w: float, h: float, body: str, bg: str | None = None) -> str:
back = f'<rect width="{w:g}" height="{h:g}" fill="{bg}"/>' if bg else ""
return (
f'<svg xmlns="http://www.w3.org/2000/svg" width="{w:g}" height="{h:g}" '
f'viewBox="0 0 {w:g} {h:g}">{back}{body}</svg>\n'
)
def lockup_horizontal(fill: str, cx: float, cy: float, mark_h: float) -> tuple[str, float]:
cap = mark_h * 0.3
gap = mark_h * 0.24
total = mark_width(mark_h) + gap + wordmark_width(cap)
left = cx - total / 2
body = mark(fill, left + mark_width(mark_h) / 2, cy, mark_h) + wordmark(
fill, left + mark_width(mark_h) + gap + wordmark_width(cap) / 2, cy - cap / 2, cap
)
return body, total
def lockup_stacked(fill: str, cx: float, cy: float, mark_h: float) -> tuple[str, float]:
cap = mark_h * 0.22
gap = mark_h * 0.2
total = mark_h + gap + cap
top = cy - total / 2
body = mark(fill, cx, top + mark_h / 2, mark_h) + wordmark(
fill, cx, top + mark_h + gap, cap
)
return body, total
def hero_bars(w: float, h: float) -> str:
"""A wide, quiet waveform in the mark's bar style, for the Steam hero."""
import math
bar, pitch = 36, 72
n = int(w // pitch)
x0 = (w - (n - 1) * pitch) / 2
out = []
for i in range(n):
t = i / (n - 1)
env = 0.35 + 0.65 * math.sin(math.pi * t) ** 2
wobble = 0.55 + 0.45 * abs(math.sin(i * 0.9) * math.cos(i * 0.37))
bh = h * 0.62 * env * wobble
x = x0 + i * pitch - bar / 2
out.append(
f'<rect x="{x:.1f}" y="{(h - bh) / 2:.1f}" width="{bar}" '
f'height="{bh:.1f}" rx="7"/>'
)
return f'<g fill="{MAROON_LIGHT}">{"".join(out)}</g>'
def variants() -> dict[str, str]:
x0, y0, x1, y1 = MARK_BOX
mw, mh = x1 - x0, y1 - y0
v: dict[str, str] = {}
# Bare mark, tight bounds, for use inside the app and in documents.
v["remus-mark.svg"] = svg(mw, mh, mark(CREAM, mw / 2, mh / 2, mh))
v["remus-mark-maroon.svg"] = svg(mw, mh, mark(MAROON, mw / 2, mh / 2, mh))
# Full-bleed square, the composition of the source artwork.
v["remus-square.svg"] = svg(1024, 1024, mark(CREAM, 512, 512, 512), MAROON)
# Desktop / Flatpak app icon: rounded tile on a 128 grid. The margins are
# kept thin so the mark stays legible at 16 to 32 px. The mark sits 1 unit
# above centre because its wide base reads heavier than the R.
v["remus-icon.svg"] = svg(
128,
128,
f'<rect x="2" y="2" width="124" height="124" rx="24" fill="{MAROON}"/>'
+ mark(CREAM, 64, 63, 100),
)
# Lockups with the wordmark, transparent background.
for name, fill in (("", CREAM), ("-maroon", MAROON)):
body, w = lockup_horizontal(fill, 0, 0, 400)
pad = 0
v[f"remus-logo{name}.svg"] = svg(
w + 2 * pad, 400 + 2 * pad, f'<g transform="translate({w / 2 + pad:g} {200 + pad})">{body}</g>'
)
body, h = lockup_stacked(fill, 0, 0, 400)
sw = max(mark_width(400), wordmark_width(400 * 0.22))
v[f"remus-logo-stacked{name}.svg"] = svg(
sw + 2 * pad, h + 2 * pad, f'<g transform="translate({sw / 2 + pad:g} {h / 2 + pad:g})">{body}</g>'
)
# Steam library artwork, for the non-Steam shortcut on SteamOS.
v["steam-capsule-portrait.svg"] = svg(
600, 900, lockup_stacked(CREAM, 300, 450, 330)[0], MAROON
)
v["steam-capsule-wide.svg"] = svg(
920, 430, lockup_horizontal(CREAM, 460, 215, 210)[0], MAROON
)
v["steam-hero.svg"] = svg(3840, 1240, hero_bars(3840, 1240), MAROON)
v["steam-logo.svg"] = svg(1280, 720, lockup_horizontal(CREAM, 640, 360, 300)[0])
v["steam-icon.svg"] = v["remus-square.svg"]
return v
def main() -> None:
here = Path(__file__).resolve().parent
out = here / "svg"
out.mkdir(exist_ok=True)
v = variants()
for name, text in v.items():
(out / name).write_text(text)
# The Flatpak manifest installs the icon from here under the app ID.
(here.parent / "flatpak" / "me.anshorei.Fettleshed.Remus.svg").write_text(v["remus-icon.svg"])
if __name__ == "__main__":
main()