Files
Reims-Go/scripts/brand/diagrams.py
T
NwflowerandClaude Opus 5.5 05396e26d1 docs(readme): simplify README and replace screenshots with diagrams
Restructure both READMEs around download, features, quick start, FAQ and
community, and drop details that belong in docs/. Replace the four UI
screenshots in the feature section with diagrams of the GPU path, the
install flow and the Windows/macOS channels, drawn by
scripts/brand/diagrams.py in Chinese and English, light and dark.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-01 08:24:41 -07:00

216 lines
11 KiB
Python

"""Draws the README feature diagrams.
Three diagrams explain what the feature screenshots could not show: how
guest Metal graphics reach the host GPU, how few clicks an install takes,
and which channels connect Windows and macOS. Run from the repository root:
python scripts/brand/diagrams.py
It writes .github/readme/feature-{gpu,install,interop}-{zh,en}-{light,dark}.svg
and needs only the standard library. Text is drawn with system fonts, so
leave room in every box: widths differ between Windows, macOS and Linux.
"""
from pathlib import Path
from xml.sax.saxutils import escape
ROOT = Path(__file__).resolve().parents[2]
OUT = ROOT / ".github/readme"
FONT = ("-apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', "
"'Microsoft YaHei', 'Noto Sans CJK SC', sans-serif")
MONO = "ui-monospace, 'SFMono-Regular', Consolas, 'Liberation Mono', monospace"
THEMES = {
"light": dict(ink="#16182e", muted="#5d6382", card="#ffffff", line="#dfe3ee",
zone="#f4f6fb", zone2="#eef3ff"),
"dark": dict(ink="#f4f5fa", muted="#a3a8bf", card="#1b2030", line="#2f3650",
zone="#141824", zone2="#162038"),
}
BLUE, VIOLET, PINK, ORANGE = "#3b8cff", "#6d5dfc", "#ff7a9a", "#ff9f0a"
def text(x, y, s, size, fill, weight=400, anchor="middle", mono=False):
family = MONO if mono else FONT
return (f'<text x="{x}" y="{y}" font-family="{family}" font-size="{size}" '
f'font-weight="{weight}" fill="{fill}" text-anchor="{anchor}">{escape(s)}</text>')
def lines(x, y, rows, size, fill, gap=1.45):
return "".join(text(x, y + i * size * gap, r, size, fill) for i, r in enumerate(rows))
def arrow(x1, x2, y, color, both=False, head=11):
"""A horizontal arrow from x1 to x2; heads are polygons, not markers."""
def tip(x, d):
return f'<path d="M{x} {y}L{x - d * head} {y - head * 0.62}L{x - d * head} {y + head * 0.62}Z" fill="{color}"/>'
d = 1 if x2 > x1 else -1
a = x1 + (d * head if both else 0)
out = f'<path d="M{a} {y}H{x2 - d * head}" stroke="{color}" stroke-width="3" stroke-linecap="round"/>'
out += tip(x2, d)
if both:
out += tip(x1, -d)
return out
def svg(w, h, body, label):
return (f'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 {w} {h}" width="{w}" height="{h}" '
f'role="img" aria-label="{escape(label)}">{body}</svg>\n')
# How guest Metal calls reach the host GPU (upstream reims-vgpu README, "Developing").
GPU = {
"zh": dict(
label="显卡加速示意图:macOS 的 Metal 调用经虚拟显卡和 metal2vulkan 交给 Windows 独显执行",
guest="macOS 虚拟机", host="Windows 主机",
boxes=[("Metal 应用", ["游戏、剪辑软件", "和界面动画"]),
("Reims 客体驱动", ["把 Metal 调用", "打包成命令流"]),
("虚拟显卡", ["reims-graphics-pci"]),
("metal2vulkan", ["把命令流", "翻译成 Vulkan"]),
("你的独立显卡", ["经 Vulkan 驱动执行"])],
note="渲染结果直接显示在 Windows 上的虚拟机窗口里"),
"en": dict(
label="GPU acceleration: macOS Metal calls reach the Windows GPU through the virtual GPU and metal2vulkan",
guest="macOS VM", host="Windows host",
boxes=[("Metal apps", ["Games, editors", "and UI animation"]),
("Guest driver", ["Packs Metal calls", "into a command stream"]),
("Virtual GPU", ["reims-graphics-pci"]),
("metal2vulkan", ["Translates the", "stream to Vulkan"]),
("Your GPU", ["Runs it through", "its Vulkan driver"])],
note="Frames show up directly in the VM window on Windows"),
}
def gpu(lang, theme):
t, c = GPU[lang], THEMES[theme]
W, H, bw, gap, x0, top, bh = 1200, 360, 196, 40, 32, 104, 150
mid = x0 + 2 * (bw + gap) + bw / 2
b = [f'<rect x="12" y="12" width="{mid - 12}" height="{H - 70}" rx="22" fill="{c["zone"]}"/>',
f'<rect x="{mid}" y="12" width="{W - 12 - mid}" height="{H - 70}" rx="22" fill="{c["zone2"]}"/>',
f'<path d="M{mid} 24V{H - 70}" stroke="{c["line"]}" stroke-width="2" stroke-dasharray="6 8"/>',
text(40, 58, t["guest"], 20, c["muted"], 600, "start"),
text(W - 40, 58, t["host"], 20, c["muted"], 600, "end")]
accents = [VIOLET, VIOLET, BLUE, BLUE, ORANGE]
for i, (title, sub) in enumerate(t["boxes"]):
x = x0 + i * (bw + gap)
device = i == 2
fill = f'url(#gpu-dev-{theme})' if device else c["card"]
stroke = "none" if device else c["line"]
ink = "#ffffff" if device else c["ink"]
sub_ink = "#ffffff" if device else c["muted"]
b.append(f'<rect x="{x}" y="{top}" width="{bw}" height="{bh}" rx="18" fill="{fill}" stroke="{stroke}" stroke-width="1.5"/>')
if not device:
b.append(f'<rect x="{x + 24}" y="{top}" width="{bw - 48}" height="4" rx="2" fill="{accents[i]}"/>')
b.append(text(x + bw / 2, top + 58, title, 21, ink, 700))
b.append(lines(x + bw / 2, top + 92, sub, 15, sub_ink, 1.5) if not device else
text(x + bw / 2, top + 94, sub[0], 15, sub_ink, 400, mono=True))
if i < 4:
b.append(arrow(x + bw + 6, x + bw + gap - 6, top + bh / 2, BLUE))
b.append(text(W / 2, H - 22, t["note"], 17, c["muted"]))
defs = (f'<defs><linearGradient id="gpu-dev-{theme}" x1="0" y1="0" x2="1" y2="1">'
f'<stop offset="0" stop-color="{BLUE}"/><stop offset="1" stop-color="{VIOLET}"/></linearGradient></defs>')
return svg(W, H, defs + "".join(b), t["label"])
# The install flow in the app; "click" steps are the only ones that need the user.
INSTALL = {
"zh": dict(
label="装机流程示意图:下载、准备虚拟机自动完成,之后只需点三下",
auto="自动", click="点一下",
steps=[("下载安装包", ["直接从 Apple 下载", "支持断点续传"], "auto"),
("准备虚拟机", ["生成虚拟磁盘", "和 OpenCore 引导盘"], "auto"),
("启动虚拟机", ["自动进入", "macOS 恢复环境"], "click"),
("开始安装", ["点键盘图标,抹盘", "和安装命令自动键入"], "click"),
("完成", ["看到设置助理后", "退出恢复模式"], "click")],
note="全程不用手动敲命令"),
"en": dict(
label="Install flow: downloading and preparing the VM are automatic, then it takes three clicks",
auto="Automatic", click="One click",
steps=[("Download", ["Straight from Apple,", "resumes if interrupted"], "auto"),
("Prepare the VM", ["Creates the disk and", "OpenCore boot image"], "auto"),
("Start the VM", ["Boots straight into", "macOS Recovery"], "click"),
("Install", ["Click the keyboard icon;", "the commands type in"], "click"),
("Finish", ["At Setup Assistant,", "exit recovery mode"], "click")],
note="No commands to type by hand"),
}
def install(lang, theme):
t, c = INSTALL[lang], THEMES[theme]
W, H, bw, gap, x0, top, bh = 1200, 330, 208, 30, 22, 30, 236
b = []
for i, (title, sub, kind) in enumerate(t["steps"]):
x = x0 + i * (bw + gap)
cx = x + bw / 2
color = BLUE if kind == "auto" else PINK
b.append(f'<rect x="{x}" y="{top}" width="{bw}" height="{bh}" rx="18" fill="{c["card"]}" stroke="{c["line"]}" stroke-width="1.5"/>')
b.append(f'<circle cx="{cx}" cy="{top + 46}" r="22" fill="{color}"/>')
b.append(text(cx, top + 54, str(i + 1), 21, "#ffffff", 700))
b.append(text(cx, top + 110, title, 21, c["ink"], 700))
b.append(lines(cx, top + 144, sub, 15, c["muted"], 1.5))
label = t[kind]
pw = 22 + len(label) * (15 if lang == "zh" else 8.6)
b.append(f'<rect x="{cx - pw / 2}" y="{top + bh - 46}" width="{pw}" height="28" rx="14" fill="{color}" fill-opacity="0.14"/>')
b.append(text(cx, top + bh - 27, label, 14, color, 700))
if i < 4:
b.append(arrow(x + bw + 4, x + bw + gap - 4, top + bh / 2, c["muted"], head=9))
b.append(text(W / 2, H - 22, t["note"], 17, c["muted"]))
return svg(W, H, "".join(b), t["label"])
# Host <-> guest channels: Guest Tools (clipboard, WebDAV share, text input) and SSH forwarding.
INTEROP = {
"zh": dict(
label="互通示意图:剪贴板、共享文件夹、拖拽传文件、输入法和 SSH 连接 Windows 与 macOS",
win="Windows", mac="macOS",
rows=[("剪贴板", "文字和图片", "剪贴板", True),
("共享目录", "共享文件夹", "~/Desktop/ReimsShare", True),
("拖进窗口的文件", "发送文件", "共享文件夹", False),
("Windows 输入法", "中文与 emoji", "当前输入框", False),
("终端 / VS Code", "SSH 端口转发", "SSH 登录", False)],
note="剪贴板、共享和输入法由 Guest Tools 提供,只在本机回环地址上通信"),
"en": dict(
label="Windows and macOS interop: clipboard, shared folder, drag-and-drop, IME input and SSH",
win="Windows", mac="macOS",
rows=[("Clipboard", "Text and images", "Clipboard", True),
("Shared folder", "Shared folder", "~/Desktop/ReimsShare", True),
("Files dropped on window", "Send files", "Shared folder", False),
("Windows IME", "Any language, emoji", "Focused text field", False),
("Terminal / VS Code", "SSH forwarding", "SSH login", False)],
note="Clipboard, sharing and text input go through Guest Tools on the loopback address only"),
}
def interop(lang, theme):
t, c = INTEROP[lang], THEMES[theme]
W, H, top, step, ph = 1200, 470, 104, 60, 42
lx, rx, pw = 40, 880, 280
b = [f'<rect x="12" y="12" width="364" height="{H - 70}" rx="22" fill="{c["zone"]}"/>',
f'<rect x="{W - 376}" y="12" width="364" height="{H - 70}" rx="22" fill="{c["zone2"]}"/>',
text(lx + pw / 2, 60, t["win"], 22, c["ink"], 700),
text(rx + pw / 2, 60, t["mac"], 22, c["ink"], 700)]
colors = [BLUE, VIOLET, PINK, ORANGE, c["muted"]]
for i, (left, mid, right, both) in enumerate(t["rows"]):
y = top + i * step
cy = y + ph / 2
for x, s in ((lx, left), (rx, right)):
mono = s.startswith("~/")
b.append(f'<rect x="{x}" y="{y}" width="{pw}" height="{ph}" rx="12" fill="{c["card"]}" stroke="{c["line"]}" stroke-width="1.5"/>')
b.append(text(x + pw / 2, cy + 6, s, 15 if mono else 17, c["ink"], 500, mono=mono))
b.append(arrow(lx + pw + 14, rx - 14, cy + 8, colors[i], both=both))
b.append(text(W / 2, cy - 4, mid, 16, colors[i] if i < 4 else c["muted"], 700))
b.append(text(W / 2, H - 22, t["note"], 17, c["muted"]))
return svg(W, H, "".join(b), t["label"])
def main():
for name, draw in (("gpu", gpu), ("install", install), ("interop", interop)):
for lang in ("zh", "en"):
for theme in ("light", "dark"):
path = OUT / f"feature-{name}-{lang}-{theme}.svg"
path.write_text(draw(lang, theme), encoding="utf-8", newline="\n")
if __name__ == "__main__":
main()