"""Write app/templates/partials/area_art.html: one line drawing per research area.
python scripts/build_area_art.py
Edit a drawing here and re-run; the template is generated. The plotted ones
(elliptic curve, helix, flow round a cylinder, spectrogram, galaxy, filtered
signal) are computed so they are what they claim to be.
viewBox 0 0 160 96. Classes (styled in styles.css, section 15):
s ink stroke h annotation stroke (--note)
p paper-filled shape hf annotation shape with a pale fill
d ink dot dh annotation dot
t small mono label th annotation label tk strong label
tb larger label tl label on an annotation fill
draw redrawn on hover (needs pathLength="1") faint lower contrast
"""
import math
import random
import sys
OUT = sys.argv[1] if len(sys.argv) > 1 else "app/templates/partials/area_art.html"
def f(v):
s = f"{v:.1f}"
return s[:-2] if s.endswith(".0") else s
def poly(points):
return "M" + " L".join(f"{f(x)} {f(y)}" for x, y in points)
def smooth(points):
"""Catmull-Rom through points, as cubic beziers."""
d = [f"M{f(points[0][0])} {f(points[0][1])}"]
for i in range(len(points) - 1):
p0 = points[max(i - 1, 0)]
p1, p2 = points[i], points[i + 1]
p3 = points[min(i + 2, len(points) - 1)]
c1 = (p1[0] + (p2[0] - p0[0]) / 6, p1[1] + (p2[1] - p0[1]) / 6)
c2 = (p2[0] - (p3[0] - p1[0]) / 6, p2[1] - (p3[1] - p1[1]) / 6)
d.append(f"C{f(c1[0])} {f(c1[1])} {f(c2[0])} {f(c2[1])} {f(p2[0])} {f(p2[1])}")
return " ".join(d)
def tri(cx, cy, dx, dy, size=3.2):
"""A small filled arrowhead centred on (cx, cy), pointing along (dx, dy)."""
n = math.hypot(dx, dy)
ux, uy = dx / n, dy / n
px, py = -uy, ux
tip = (cx + ux * size, cy + uy * size)
b1 = (cx - ux * size + px * size * .8, cy - uy * size + py * size * .8)
b2 = (cx - ux * size - px * size * .8, cy - uy * size - py * size * .8)
return f''
art = {}
# ── Natural Language Processing: next-word prediction with attention ─────────
art["nlp"] = """
next word?
Thecatsaton
mat
p = .81
"""
# ── Computer Vision: a detector's boxes over a cat and a ball ────────────────
art["cv"] = """
cat 0.97
ball .88
"""
# ── Machine Learning: points, a fitted line, a falling loss ─────────────────
pts = [(22, 74), (28, 75), (34, 66), (42, 67), (48, 57), (56, 59), (62, 48), (70, 50),
(78, 39), (86, 41), (94, 30), (100, 33)]
dots = "".join(f'' for x, y in pts)
art["ml"] = f"""
{dots}
y = wx + b
loss
"""
# ── Artificial Intelligence: a question answered by reasoning step by step ──
art["ai"] = """
is 97 prime?
√97 < 10
try 2, 3, 5, 7
none divide 97
→ yes, prime ✓
"""
# ── Robotics: a two-link arm carrying a block toward its target ─────────────
art["robotics"] = """
θ
"""
# ── High Energy Physics: e⁻e⁺ → γ → μ⁻μ⁺, as a Feynman diagram ──────────────
wave = "M48 48 q4 -7 8 0" + " t8 0" * 7
art["hep"] = f"""
{tri(31, 30, 1, 1)}{tri(31, 66, -1, 1)}{tri(129, 30, 1, -1)}{tri(129, 66, -1, -1)}
e⁻e⁺μ⁻μ⁺
γ
"""
# ── Astrophysics: a two-armed spiral galaxy ──────────────────────────────────
random.seed(7)
cx, cy = 78, 47
arm_paths, arm_dots = [], []
for a in (0, math.pi):
line = []
th = 0.0
while th <= 3.25 * math.pi:
r = 5.2 * math.exp(0.22 * th)
x = cx + r * math.cos(th + a)
y = cy + 0.52 * r * math.sin(th + a)
line.append((x, y))
if th > 0.6:
for _ in range(1):
jx, jy = random.gauss(0, 1.6), random.gauss(0, 1.0)
rad = max(0.7, 1.7 - th / 8)
arm_dots.append(f'')
th += 0.3
arm_paths.append(smooth(line))
stars = [(14, 14), (150, 16), (12, 70), (22, 88), (140, 76), (128, 8)]
sparkle = "".join(
f''
for x, y in stars[:3]) + "".join(f'' for x, y in stars[3:])
art["astro"] = f"""
{''.join(arm_dots)}
{sparkle}
z = 1.2
"""
# ── Quantum Computing: a Bell-pair circuit ──────────────────────────────────
art["quant_ph"] = """
|0⟩|0⟩
H
|00⟩ + |11⟩
"""
# ── Mathematics: the chord rule on an elliptic curve ─────────────────────────
def ex(x):
return 18 + (x + 1.45) * 26
def ey(y):
return 48 - y * 18.5
root = -1.324718
upper, lower = [], []
xs = [root + (1.75 - root) * (i / 18) ** 1.6 for i in range(19)]
for x in xs:
y = math.sqrt(max(x ** 3 - x + 1, 0))
upper.append((ex(x), ey(y)))
lower.append((ex(x), ey(-y)))
curve = smooth(list(reversed(upper)) + lower[1:])
P, Q, R = (-1.2, 0.687), (1.2, -1.236), (0.642, -0.788)
S = (0.642, 0.788)
art["math"] = f"""
PQ
P+Q
y²=x³−x+1
"""
# ── Computational Biology: a DNA double helix ────────────────────────────────
a_pts, b_pts, rungs = [], [], []
for i in range(0, 133):
x = 14 + i
phase = 2 * math.pi * i / 66
a_pts.append((x, 48 + 22 * math.sin(phase)))
b_pts.append((x, 48 - 22 * math.sin(phase)))
for k, i in enumerate(range(3, 133, 6)):
x = 14 + i
phase = 2 * math.pi * i / 66
ya, yb = 48 + 22 * math.sin(phase), 48 - 22 * math.sin(phase)
if abs(ya - yb) > 5:
cls = "h" if k % 3 == 0 else "s faint"
rungs.append(f'')
art["bio"] = f"""
{''.join(rungs)}
A–TG–C
"""
# ── Neuroscience: a neuron and the spikes it fires ──────────────────────────
spike = "l2 -14 l2.5 20 l2 -6"
art["neuro"] = f"""
"""
# ── Economics & Game Theory: the prisoner's dilemma ─────────────────────────
art["econ"] = """
CDCD
3, 30, 55, 0
1, 1
Nash
"""
# ── Cryptography & Security: plaintext in, ciphertext out ────────────────────
art["crypto"] = """
hello
9f 2c a71e 0b d4
key
e3 4a 9c 01 7f b2 58 c6 0d
"""
# ── Systems & Networking: servers passing messages ──────────────────────────
nodes = [(26, 24), (80, 14), (134, 24), (44, 72), (116, 72)]
edges = [(0, 1), (1, 2), (0, 3), (2, 4), (3, 4), (1, 3), (1, 4)]
edge_d = " ".join(f"M{nodes[a][0]} {nodes[a][1]} L{nodes[b][0]} {nodes[b][1]}" for a, b in edges)
servers = "".join(
f''
f''
f'' for x, y in nodes)
def along(a, b, t):
return nodes[a][0] + (nodes[b][0] - nodes[a][0]) * t, nodes[a][1] + (nodes[b][1] - nodes[a][1]) * t
packets = "".join(tri(*along(a, b, t), nodes[b][0] - nodes[a][0], nodes[b][1] - nodes[a][1], 3)
.replace('class="dk"', 'class="dh"') for a, b, t in ((0, 1, .5), (1, 4, .55), (3, 4, .5)))
art["systems"] = f"""
{packets}
{servers}
12 ms
"""
# ── Human-Computer Interaction: a click on an interface ─────────────────────
art["hci"] = """
Aa
Sign up
Later
"""
# ── Speech & Audio: a spoken word and its spectrogram ────────────────────────
wave_pts = []
for i in range(0, 133, 2):
x = 14 + i
t = i / 132
env = math.exp(-((t - .27) / .11) ** 2) + .8 * math.exp(-((t - .68) / .13) ** 2) + .04
y = 30 - 21 * env * math.sin(2 * math.pi * 11 * t) * math.cos(2 * math.pi * 3.1 * t + .4)
wave_pts.append((x, y))
cells = []
for col in range(22):
t = (col + .5) / 22
env = math.exp(-((t - .27) / .12) ** 2) + .8 * math.exp(-((t - .68) / .14) ** 2)
for row in range(5):
formant = (1.0, .75, .5, .62, .3)[row] if t < .47 else (.85, .55, .7, .35, .25)[row]
v = min(.92, .06 + env * formant)
if v > .1:
cells.append(f'')
art["audio"] = f"""
{''.join(cells)}
hello
"""
# ── Physics — General: flow around a cylinder, with vortices shed behind ────
cxp, cyp, Rc = 56, 48, 11
def stream_y(x, psi):
lo = math.sqrt(max(Rc * Rc - x * x, 0)) + 1e-6
hi = 80.0
def g(y):
return y * (1 - Rc * Rc / (x * x + y * y)) - psi
for _ in range(60):
mid = (lo + hi) / 2
if g(mid) > 0:
hi = mid
else:
lo = mid
return (lo + hi) / 2
lines = []
for psi in (2.5, 8, 15, 23, 32):
for sign in (1, -1):
p = []
for i in range(0, 141, 10):
x = 10 + i - cxp
y = stream_y(x, psi)
p.append((cxp + x, cyp - sign * y))
lines.append(f'')
def spiral(x0, y0, turns, r1, sign):
p = []
n = 26
for i in range(n + 1):
th = turns * 2 * math.pi * i / n
r = r1 * (1 - i / (n + 6))
p.append((x0 + r * math.cos(th) * sign, y0 + r * math.sin(th)))
return f''
art["pde"] = f"""
{''.join(lines)}
{spiral(88, 42, 1.4, 6.5, 1)}{spiral(108, 55, 1.4, 6.5, -1)}{spiral(130, 42, 1.4, 6.5, 1)}
"""
# ── Condensed Matter: an antiferromagnet, one spin flipped ──────────────────
atoms, links, spins = [], [], []
for j in range(3):
for i in range(6):
x, y = 22 + 23 * i, 22 + 26 * j
if i < 5:
links.append(f"M{x} {y} H{x + 23}")
if j < 2:
links.append(f"M{x} {y} V{y + 26}")
up = (i + j) % 2 == 0
flipped = (i, j) == (3, 1)
if flipped:
up = not up
cls = "hf" if flipped else "p"
atoms.append(f'')
y0, y1 = (y + 4.2, y - 4.2) if up else (y - 4.2, y + 4.2)
head = f"M{x - 2.4} {f(y1 + (2.6 if up else -2.6))} L{x} {f(y1)} L{x + 2.4} {f(y1 + (2.6 if up else -2.6))}"
spins.append(f'')
art["cond_mat"] = f"""
{''.join(atoms)}{''.join(spins)}
"""
# ── Software Engineering: a function and its passing test ───────────────────
art["se"] = """
1234
def add(a, b):
return a + b
assert add(2, 2) == 4
✓ 1 passed
"""
# ── Signal Processing: a noisy signal, filtered, and its spectrum ───────────
random.seed(3)
noisy, clean = [], []
for i in range(0, 133, 2):
x = 14 + i
s = 13 * math.sin(2 * math.pi * 2.5 * i / 132)
clean.append((x, 32 - s))
noisy.append((x, 32 - s - random.gauss(0, 4.2)))
bars = []
heights = [3, 4, 6, 9, 26, 10, 5, 4, 3, 7, 4, 3, 2, 3, 2, 2]
for k, h in enumerate(heights):
cls = "hf" if k == 4 else "p"
bars.append(f'')
art["acl_acl"] = f"""
{''.join(bars)}
FFT
"""
# Fallback for an area without a drawing: a paper.
fallback = """
"""
order = ["nlp", "cv", "ml", "ai", "robotics", "hep", "astro", "quant_ph", "math", "bio",
"neuro", "econ", "crypto", "systems", "hci", "audio", "pde", "cond_mat", "se", "acl_acl"]
parts = ["""{#
One small drawing per research area, for the area pickers (onboarding and
/interests). An area's name alone often means nothing to someone outside it,
so each shows the field doing its typical thing: a detector's box round a cat,
a line fitted to points, a Feynman diagram.
GENERATED by scripts/build_area_art.py — edit the drawing there and re-run.
Inline SVG, not images: it takes the page's colours in both themes, scales
without blur, and Hugging Face refuses binary files in pushed history. Purely
decorative (aria-hidden) — the area's name and description carry the meaning.
Classes are styled in styles.css (section 15, "Area drawings").
#}
{% macro area_art(key) -%}
\n{%- endmacro %}\n")
open(OUT, "w").write("\n".join(parts))
print("wrote", OUT, sum(len(v) for v in art.values()), "bytes of drawing")