Create professional technical architecture diagrams using pure SVG, rendered to high-res PNG via Playwright.
| Approach | Lines/Arrows | Text Quality | Precision |
|---|---|---|---|
| ---------- | ------------- | ------------- | ----------- |
| SVG (this skill) | ✅ Perfect: , , | ✅ Crisp at any size | ✅ Pixel-perfect |
| CSS absolute positioning | ❌ Hacky: borders, pseudo-elements | ✅ OK | ❌ Hard to align |
| AI image generation | ❌ No control | ❌ Garbled text | ❌ No precision |
Identify:
Write a single HTML file with an inline SVG. Standard canvas: 1600×1000px.
<!DOCTYPE html>
<html><head>
<meta charset="UTF-8">
<style>
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');
* { margin: 0; padding: 0; box-sizing: border-box; }
body { width: 1600px; height: 1000px; background: #fafafa; overflow: hidden; }
</style>
</head><body>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1600 1000" width="1600" height="1000">
<defs>
<!-- Arrow markers — one per color -->
<marker id="arr-indigo" markerWidth="8" markerHeight="6" refX="7" refY="3" orient="auto">
<path d="M0,0 L8,3 L0,6 Z" fill="#6366f1"/>
</marker>
<!-- Shadow filter -->
<filter id="shadow" x="-4%" y="-4%" width="108%" height="108%">
<feDropShadow dx="0" dy="2" stdDeviation="4" flood-color="#000" flood-opacity="0.08"/>
</filter>
</defs>
<!-- Diagram content here -->
</svg>
</body></html>
Filled header card (module title):
<rect x="X" y="Y" width="W" height="40" rx="10" fill="#6366f1" filter="url(#shadow)"/>
<text x="CENTER" y="Y+25" text-anchor="middle" font-size="13" font-weight="700" fill="#fff">🔄 Module Name</text>
Outlined detail card (sub-component):
<rect x="X" y="Y" width="W" height="65" rx="10" fill="#fff" stroke="#6366f1" stroke-width="2" filter="url(#shadow)"/>
<text x="X+20" y="Y+22" font-size="12" font-weight="700" fill="#6366f1">Component Title</text>
<text x="X+20" y="Y+40" font-size="11" fill="#6b7280">Description line 1</text>
<text x="X+20" y="Y+55" font-size="10" fill="#9ca3af">Metadata / specs</text>
Connection line (with arrow):
<line x1="FROM_X" y1="FROM_Y" x2="TO_X" y2="TO_Y" stroke="#6366f1" stroke-width="2" marker-end="url(#arr-indigo)"/>
Curved connection (L-shape or bend):
<path d="M startX,startY L midX,midY L endX,endY" stroke="#6366f1" stroke-width="2" fill="none" marker-end="url(#arr-indigo)"/>
Dashed feedback line:
<path d="M x1,y1 L x2,y2" stroke="#8b5cf6" stroke-width="2" fill="none" stroke-dasharray="6,4" marker-end="url(#arr-purple)"/>
Connection label:
<text x="MID_X" y="MID_Y-5" font-size="10" fill="#6366f1" font-weight="500">label text</text>
from playwright.sync_api import sync_playwright
with sync_playwright() as p:
browser = p.chromium.launch()
page = browser.new_page(
viewport={"width": 1600, "height": 1000},
device_scale_factor=4, # 4x ultra-high res (default)
)
page.goto("file:///path/to/diagram.html", wait_until="networkidle")
page.wait_for_timeout(1500)
page.screenshot(path="diagram.png", full_page=True)
browser.close()
Or use the bundled script: scripts/screenshot.py
See references/design-system.md for the complete color palette, card styles, arrow markers, and text sizing rules.
elements with Y offset +15px each or per color — define in , reference with marker-end L-segments for bendsfont-family="Inter, 'PingFang SC', 'Microsoft YaHei', sans-serif" — set on root or first blockPingFang SC / Microsoft YaHei fallbackTwo complete working examples are included:
references/example-hermes.html — Hermes Agent architecture (6 modules, medium complexity)references/example-openclaw.html — OpenClaw platform architecture (12 modules, high complexity, demonstrates proper vertical card spacing for Agent Loop steps)Output MEDIA: for inline delivery, or openclaw message send --channel telegram --target for Telegram.
If PNG exceeds ~1MB for Telegram delivery, convert to JPEG (quality=95):
from PIL import Image
img = Image.open("diagram.png")
img.save("diagram.jpg", "JPEG", quality=95, optimize=True)
Default is 4x (6400×4000px for 1600×1000 canvas). Always use maximum resolution.
共 1 个版本