mirror of
https://github.com/jestr-ai/jestr-apps.git
synced 2026-08-12 08:24:10 +02:00
72 lines
2.6 KiB
Python
72 lines
2.6 KiB
Python
#!/usr/bin/env python3
|
|
"""Draw the README callout onto the side panel screenshot.
|
|
|
|
`media/side-panel.png` is the raw 357x770 capture. The README wants it labelled,
|
|
so this widens the canvas by a gutter on the right, sets the caption there, and
|
|
curves an arrow back onto the Reddit row — pressing an app opens its offline
|
|
copy, and Reddit is the example.
|
|
|
|
The arrow crosses the SharePoint card on its way in, so it is stroked twice: a
|
|
white halo underneath, the accent on top. Accent #C72453 is the toggle crimson,
|
|
sampled from the capture itself.
|
|
|
|
Run after replacing the screenshot: python3 scripts/annotate-panel.py
|
|
|
|
Outputs (generated, do not hand-edit):
|
|
media/side-panel-annotated.png the image README.md embeds
|
|
"""
|
|
import base64
|
|
import pathlib
|
|
import subprocess
|
|
|
|
ROOT = pathlib.Path(__file__).resolve().parent.parent
|
|
BASE = ROOT / "media/side-panel.png"
|
|
OUT = ROOT / "media/side-panel-annotated.png"
|
|
|
|
W, H = 357, 770 # the capture; the callout coordinates below assume this size
|
|
GUTTER = 232
|
|
CW = W + GUTTER
|
|
|
|
ACCENT = "#C72453"
|
|
INK = "#3D2A31"
|
|
|
|
# Reddit's icon and name sit at x 29-117, y 490-513, with "29 communities" right
|
|
# under them at y 515 — hence a fill-only wash, which cannot look clipped.
|
|
ARROW = "M 432 455 C 360 452, 250 460, 150 490"
|
|
|
|
b64 = base64.b64encode(BASE.read_bytes()).decode()
|
|
|
|
svg = f"""<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
|
|
width="{CW}" height="{H}" viewBox="0 0 {CW} {H}">
|
|
<defs>
|
|
<marker id="head" viewBox="0 0 10 10" refX="8.5" refY="5"
|
|
markerWidth="5.2" markerHeight="5.2" orient="auto-start-reverse">
|
|
<path d="M0,0.6 L10,5 L0,9.4 L2.6,5 Z" fill="{ACCENT}"/>
|
|
</marker>
|
|
</defs>
|
|
|
|
<rect width="{CW}" height="{H}" fill="#ffffff"/>
|
|
<image x="0" y="0" width="{W}" height="{H}" xlink:href="data:image/png;base64,{b64}"/>
|
|
|
|
<rect x="24" y="487" width="101" height="27" rx="8" fill="{ACCENT}" fill-opacity="0.12"/>
|
|
|
|
<path d="{ARROW}" fill="none" stroke="#ffffff" stroke-opacity="0.85"
|
|
stroke-width="7" stroke-linecap="round"/>
|
|
<path d="{ARROW}" fill="none" stroke="{ACCENT}" stroke-width="2.6"
|
|
stroke-linecap="round" marker-end="url(#head)"/>
|
|
|
|
<g font-family="Helvetica Neue, Helvetica, Arial, sans-serif" text-anchor="middle"
|
|
font-size="18" font-weight="700" fill="{INK}">
|
|
<text x="{W + GUTTER / 2}" y="410">Press to open</text>
|
|
<text x="{W + GUTTER / 2}" y="433">the offline app</text>
|
|
</g>
|
|
</svg>
|
|
"""
|
|
|
|
subprocess.run(
|
|
["rsvg-convert", "-w", str(CW), "-h", str(H), "-o", str(OUT)],
|
|
input=svg.encode(),
|
|
check=True,
|
|
)
|
|
print(f"{OUT.relative_to(ROOT)} {CW}x{H}")
|