|
| 1 | +"""Render the README's highlight tiles. |
| 2 | +
|
| 3 | + python tools/highlights-svg.py docs/assets/highlights.svg |
| 4 | +
|
| 5 | +Each tile names one claim from "Why subenum" and the flag behind it; keep |
| 6 | +them in step with that section. |
| 7 | +""" |
| 8 | +import sys |
| 9 | +from xml.sax.saxutils import escape |
| 10 | + |
| 11 | +BG, EDGE = "#0E1726", "#22304A" |
| 12 | +FG, MUTED, DIM = "#E8ECF2", "#94A3BA", "#6F7E97" |
| 13 | +AMBER, GREEN, RED, BLUE = "#F2B441", "#4CC9A0", "#F47C7C", "#7AB8FF" |
| 14 | +SANS = "ui-sans-serif, -apple-system, 'Segoe UI', Helvetica, Arial, sans-serif" |
| 15 | +MONO = "ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace" |
| 16 | + |
| 17 | +W, TW, TH, GAP = 860, 424, 96, 12 |
| 18 | +H = 2 * TH + GAP |
| 19 | + |
| 20 | + |
| 21 | +def icon_stats(x, y): |
| 22 | + # a stacked outcome bar: resolved / nxdomain / timeout / refused |
| 23 | + segs = [(GREEN, 14), (BLUE, 10), (AMBER, 6), (RED, 4)] |
| 24 | + out, cx = [], x |
| 25 | + for c, w in segs: |
| 26 | + out.append(f'<rect x="{cx}" y="{y + 13}" width="{w}" height="14" rx="2" fill="{c}"/>') |
| 27 | + cx += w + 2 |
| 28 | + return "".join(out) |
| 29 | + |
| 30 | + |
| 31 | +def icon_wild(x, y): |
| 32 | + # many answers in, few out: a funnel |
| 33 | + return (f'<path d="M{x} {y + 8}h40l-15 14v12l-10 4v-16z" fill="none" stroke="{AMBER}" ' |
| 34 | + f'stroke-width="2.4" stroke-linejoin="round"/>' |
| 35 | + f'<text x="{x + 20}" y="{y + 4}" text-anchor="middle" fill="{AMBER}" font-family="{MONO}" ' |
| 36 | + f'font-size="13" font-weight="700">* * *</text>') |
| 37 | + |
| 38 | + |
| 39 | +def icon_rate(x, y): |
| 40 | + # a gauge pinned under its limit |
| 41 | + y -= 8 |
| 42 | + return (f'<path d="M{x + 2} {y + 32}a18 18 0 0 1 36 0" fill="none" stroke="{EDGE}" stroke-width="5" stroke-linecap="round"/>' |
| 43 | + f'<path d="M{x + 2} {y + 32}a18 18 0 0 1 27 -15.6" fill="none" stroke="{GREEN}" stroke-width="5" stroke-linecap="round"/>' |
| 44 | + f'<path d="M{x + 20} {y + 32}l9 -11" stroke="{FG}" stroke-width="2.4" stroke-linecap="round"/>' |
| 45 | + f'<circle cx="{x + 20}" cy="{y + 32}" r="3" fill="{FG}"/>') |
| 46 | + |
| 47 | + |
| 48 | +def icon_resolvers(x, y): |
| 49 | + # a shield with a check |
| 50 | + return (f'<path d="M{x + 20} {y + 4}l15 6v10c0 9-6.5 15-15 18c-8.5-3-15-9-15-18v-10z" fill="none" ' |
| 51 | + f'stroke="{BLUE}" stroke-width="2.4" stroke-linejoin="round"/>' |
| 52 | + f'<path d="M{x + 13} {y + 21}l5 5l9 -10" fill="none" stroke="{GREEN}" stroke-width="2.6" ' |
| 53 | + f'stroke-linecap="round" stroke-linejoin="round"/>') |
| 54 | + |
| 55 | + |
| 56 | +tiles = [ |
| 57 | + (icon_stats, "Every query accounted for", "Each lookup classified, with a verdict CI can gate on", "-stats"), |
| 58 | + (icon_wild, "Wildcards fingerprinted, not reported", "Rotating CDN pools too; wildcard branches skipped", "-force"), |
| 59 | + (icon_rate, "A rate limit that holds on the wire", "Retries, record types and probes all count", "-rate"), |
| 60 | + (icon_resolvers, "Resolvers that cannot lie to you", "Every hit re-checked; resolvers hiding names benched", "-r"), |
| 61 | +] |
| 62 | + |
| 63 | +parts = [] |
| 64 | +for i, (icon, title, desc, flag) in enumerate(tiles): |
| 65 | + x = (i % 2) * (TW + GAP) |
| 66 | + y = (i // 2) * (TH + GAP) |
| 67 | + chip_w = 16 + 7.8 * len(flag) |
| 68 | + parts.append( |
| 69 | + f'<rect x="{x + 0.5}" y="{y + 0.5}" width="{TW - 1}" height="{TH - 1}" rx="12" fill="{BG}" stroke="{EDGE}"/>' |
| 70 | + + icon(x + 18, y + 26) |
| 71 | + + f'<text x="{x + 76}" y="{y + 30}" fill="{FG}" font-family="{SANS}" font-size="15" font-weight="650">{escape(title)}</text>' |
| 72 | + + f'<text x="{x + 76}" y="{y + 51}" fill="{MUTED}" font-family="{SANS}" font-size="13">{escape(desc)}</text>' |
| 73 | + + f'<rect x="{x + 76}" y="{y + 62}" width="{chip_w}" height="22" rx="6" fill="#1A2740"/>' |
| 74 | + + f'<text x="{x + 76 + chip_w / 2}" y="{y + 77.5}" text-anchor="middle" fill="{AMBER}" font-family="{MONO}" font-size="13" font-weight="600">{escape(flag)}</text>' |
| 75 | + ) |
| 76 | + |
| 77 | +label = "; ".join(f"{t}: {d} ({f})" for _, t, d, f in tiles) |
| 78 | +svg = (f'<svg xmlns="http://www.w3.org/2000/svg" width="{W}" height="{H}" viewBox="0 0 {W} {H}" role="img" ' |
| 79 | + f'aria-label="{escape(label)}">\n' + "\n".join(parts) + "\n</svg>\n") |
| 80 | +open(sys.argv[1], "w", encoding="utf-8", newline="\n").write(svg) |
| 81 | +print(W, H, len(svg)) |
0 commit comments