Add the Green Man generator and restyle its page to match the index

greenman-src/ holds the kit source; uv run build.py there rewrites
greenman/. deploy skips *-src/. The page now uses the index's ink,
bone and gold with the same serif, and no longer loads web fonts.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GrX9qMoNihcWLX3xoJhabw
This commit is contained in:
Eric WagonerandClaude Fable 5.2 committed 2026-11-10 18:29:29 -05:00
1 parent a7c04e5cb7
commit 9c3c361858
59 files changed
+1640 -41

No files matched your search

+157
View File
@@ -0,0 +1,157 @@
"""SVG drawings generated from the manifest. Units are mm (viewBox in mm); y is flipped for SVG."""
import numpy as np
from shapely.geometry import Polygon, MultiPolygon, LineString, Point, box
from shapely import affinity
import geom as G, manifest as M
from geom import TOP
VB = (-130.0, -(TOP+156), 260.0, TOP+156+104) # x, y, w, h for the full mask, front or back view
BUILD = dict(base='#d9d6cc', base_s='#5b5850', L='#2f6b2f', M='#4c8a3c', S='#77ad4e', T='#93c25c', leaf_s='#1d4a1f', vein='#1d4a1f',
bark='#6b4a2b', bark_s='#3e2a16', ridge='#8f6d42', nut='#9a6a34', cap='#5a3d22', tendril='#2e6b2f', strap='#2b2b2b',
patch='#bdb7a3', wire='#777', glasses='#8a8a8a')
GHOST = dict(base='#eceae4', base_s='#9a978e', L='#e3e2dc', M='#e3e2dc', S='#e3e2dc', T='#e3e2dc', leaf_s='#b3b1a9', vein='#c4c2ba',
bark='#dddbd4', bark_s='#b3b1a9', ridge='#c9c7bf', nut='#dddbd4', cap='#d0cec6', tendril='#cfcdc5', strap='#bcbab2',
patch='#e6e3d8', wire='#bbb', glasses='#b8b8b8')
HL = '#c8321e'
def f(v):
s = f'{v:.2f}'.rstrip('0').rstrip('.')
return '0' if s == '-0' else s # keep output identical across platforms
def path(geom, mirror=False):
"""SVG path data for a shapely polygon / multipolygon (y flipped; optionally x mirrored for the back view)."""
sx = -1 if mirror else 1
if geom.geom_type == 'MultiPolygon': return ' '.join(path(g, mirror) for g in geom.geoms)
if geom.geom_type != 'Polygon': return ''
out = []
for ring in [geom.exterior] + list(geom.interiors):
c = list(ring.coords)
out.append('M' + ' L'.join(f'{f(sx*x)} {f(-y)}' for x, y in c[:-1]) + ' Z')
return ' '.join(out)
def line(ls, mirror=False):
sx = -1 if mirror else 1
return 'M' + ' L'.join(f'{f(sx*x)} {f(-y)}' for x, y in ls.coords)
def _leaf(p, pal, mirror, hl):
size = p['part']; tone = p.get('tone')
fill = (pal.get(tone) if tone else None) or pal[size]
edge = (pal.get('edge_' + tone) if tone else None) or pal.get('edge')
vein = (pal.get('vein_' + tone) if tone else None) or pal['vein']
s = f'<path d="{path(p["shape"], mirror)}" fill="{fill}" stroke="{HL if hl else edge or pal["leaf_s"]}" stroke-width="{0.9 if hl else (pal.get("edge_w", 1.0) if edge else 0.45)}" stroke-linejoin="round"/>'
v = ' '.join(line(G.place(l, p['x'], p['y'], p['ang'], p['flip']), mirror) for l in G.vein_lines(size, p.get('variant', 0)))
return s + f'<path d="{v}" fill="none" stroke="{vein}" stroke-width="{pal.get("vein_w", 0.35)}" stroke-linecap="round"/>'
def _strip(p, pal, mirror, hl):
s = f'<path d="{path(p["shape"], mirror)}" fill="{pal["bark"]}" stroke="{HL if hl else pal["bark_s"]}" stroke-width="{0.9 if hl else 0.5}"/>'
x = np.linspace(-G.STRIP_L/2+4, G.STRIP_L/2-4, 60); grooves = []
for k in range(5):
y = -7 + k*3.5 + 1.6*np.sin(x*0.09+k) + 0.7*np.sin(x*0.31+2*k)
keep = np.abs(y) < (11 - 5*(np.abs(x)/(G.STRIP_L/2))**1.6) - 1.5
seg = [(a, b + G.STRIP_Y) for a, b, kk in zip(x, y, keep) if kk]
if len(seg) > 2: grooves.append(line(LineString(seg), mirror))
s += f'<path d="{" ".join(grooves)}" fill="none" stroke="{pal["ridge"]}" stroke-width="0.7" stroke-linecap="round"/>'
for kx in (-52, -26, -5, 16, 40, 58):
s += f'<ellipse cx="{f((-1 if mirror else 1)*kx)}" cy="{f(-G.STRIP_Y)}" rx="4.2" ry="2.6" fill="{pal["bark"]}" stroke="{pal["ridge"]}" stroke-width="0.6"/>'
return s
def _knot(p, pal, mirror, hl):
cx, cy = G.KNOT_C; s = ''
for r, w in ((G.KNOT_R, 0.9 if hl else 0.5), (14, 0.7), (8, 0.7)):
s += f'<circle cx="{f(cx)}" cy="{f(-cy)}" r="{r}" fill="{pal["bark"]}" stroke="{(HL if hl else pal["bark_s"]) if r == G.KNOT_R else pal["ridge"]}" stroke-width="{w}"/>'
s += f'<ellipse cx="{f(cx)}" cy="{f(-cy)}" rx="3.6" ry="2.4" fill="{pal["bark_s"]}"/>'
if pal.get('gloss'): s += f'<circle cx="{f(cx-1)}" cy="{f(-cy-0.8)}" r="0.9" fill="#fff"/>'
return s
def _acorn(p, pal, mirror, hl):
w, l = G.ACORN[p['part']]; e = affinity.scale(Point(0, 0).buffer(1, 32), w/2, l/2)
cap = affinity.scale(e, 1.14, 1.0).intersection(box(-w, l*0.08, w, l)) # cap covers the upper ~40%
tfm = lambda g: G.place(g, p['x'], p['y'], p['ang'])
stroke = HL if hl else pal['bark_s']; sw = 0.9 if hl else 0.45
s = f'<path d="{path(tfm(e), mirror)}" fill="{pal["nut"]}" stroke="{stroke}" stroke-width="{sw}"/>'
if pal.get('gloss'):
s += f'<path d="{path(tfm(affinity.translate(affinity.scale(Point(0,0).buffer(1, 12), w*0.09, l*0.13), -w*0.2, -l*0.18)), mirror)}" fill="#fff" opacity="0.8"/>'
s += f'<path d="{path(tfm(cap), mirror)}" fill="{pal["cap"]}" stroke="{stroke}" stroke-width="{sw}"/>'
if pal.get('cap_hi'):
dots = [Point(dx, l*0.2+dy).buffer(0.9, 6) for dy in (l*0.02, l*0.12, l*0.22) for dx in np.linspace(-w*0.36, w*0.36, 5)]
s += ''.join(f'<path d="{path(tfm(d), mirror)}" fill="{pal["cap_hi"]}"/>' for d in dots if cap.contains(d))
return s
def _poly(p, pal, mirror, hl, fill, stroke, sw=0.45, dash=None):
d = f' stroke-dasharray="{dash}"' if dash else ''
return f'<path d="{path(p["shape"], mirror)}" fill="{fill}" stroke="{HL if hl else stroke}" stroke-width="{0.9 if hl else sw}" stroke-linejoin="round"{d}/>'
def _part(p, pal, mirror, hl):
k = p['part']
if k in 'LMST': return _leaf(p, pal, mirror, hl)
if k == 'STRIP': return _strip(p, pal, mirror, hl)
if k == 'KNOT': return _knot(p, pal, mirror, hl)
if k in ('AL', 'AS', 'AF'): return _acorn(p, pal, mirror, hl)
if k == 'TWIG': return _poly(p, pal, mirror, hl, pal['bark'], pal['bark_s'])
if k == 'SPIRAL': return _poly(p, pal, mirror, hl, pal['tendril'], pal.get('tendril_s') or pal['leaf_s'], 0.4)
if k == 'STRAP': return _poly(p, pal, mirror, hl, pal['strap'], pal['strap'], 0.3)
if k == 'PATCH': return _poly(p, pal, mirror, hl, pal['patch'], pal['base_s'], 0.4, '1.5 1')
if k == 'WIRE': return f'<circle cx="{f((-1 if mirror else 1)*p["x"])}" cy="{f(-p["y"])}" r="1.4" fill="{HL if hl else pal["wire"]}"/>'
return ''
def _base(base, pal, mirror, slits=True):
s = f'<path d="{path(base["outline"], mirror)}" fill="{pal["base"]}" stroke="{pal["base_s"]}" stroke-width="0.6" fill-rule="evenodd" stroke-linejoin="round"/>'
return s
def _glasses(pal):
s = ''.join(f'<path d="{path(G.lens(sg))}" fill="none" stroke="{pal["glasses"]}" stroke-width="1.1"/>' for sg in (-1, 1))
s += f'<path d="M{f(-G.BRIDGE/2-1)} {f(-(G.LENS_H/2-6))} Q0 {f(-(G.LENS_H/2+1))} {f(G.BRIDGE/2+1)} {f(-(G.LENS_H/2-6))}" fill="none" stroke="{pal["glasses"]}" stroke-width="1.1"/>'
for sg in (-1, 1):
s += f'<path d="M{f(sg*(G.FRAME_W/2-3))} {f(-(TOP-4))} L{f(sg*(G.FRAME_W/2+30))} {f(-(TOP-3))}" stroke="{pal["glasses"]}" stroke-width="1.6" stroke-linecap="round" fill="none"/>'
return s
def scene(view='front', done=(), hl=None, palette=None, numbers=False, glasses=True, base=None, hang_wire=True, vb=None, tones=None, extra=''):
"""One picture of the mask. done = steps already on (ghosted unless palette given); hl = step being added now."""
base = base or G.base_glasses(); mirror = view == 'back'
order = list(M.STEPS); show = set(done) | ({hl} if hl else set())
parts = [p for p in M.PLACEMENTS if p['step'] in show]
def pal_for(p):
if palette: return palette
return BUILD if p['step'] == hl else GHOST
backs = sorted([p for p in parts if p['face'] == 'back'], key=lambda p: -p['z'])
fronts = sorted([p for p in parts if p['face'] != 'back'], key=lambda p: p['z'])
for p in parts: p['tone'] = tones.get(p['id'].rsplit('-', 1)[0]) if tones else None
body = []
bpal = palette or (BUILD if (hl in (None, 'strap') or not done) else GHOST)
if view == 'front':
body += [_part(p, pal_for(p), False, p['step'] == hl and not palette) for p in backs if p['part'] != 'PATCH']
body.append(_base(base, bpal, False))
for p in fronts:
if p['part'] == 'AF' and hang_wire:
w = next(q for q in M.PLACEMENTS if q['id'] == p['onto'][0])
body.append(f'<path d="M{f(w["x"])} {f(-w["y"])} Q{f(p["x"])} {f(-w["y"]+2)} {f(p["x"])} {f(-(p["y"]+G.ACORN["AF"][1]/2))}" fill="none" stroke="{pal_for(p)["wire"]}" stroke-width="0.5"/>')
body.append(_part(p, pal_for(p), False, p['step'] == hl and not palette))
if glasses and base['kind'] == 'glasses': body.append(_glasses(bpal))
else:
body.append(_base(base, bpal, True))
for p in sorted(backs, key=lambda p: p['z']): body.append(_part(p, pal_for(p), True, p['step'] == hl and not palette))
if 'strap' in show: # the elastic as seen from behind: through the slit, tail lying on the patch, strap leaving sideways
sp = BUILD if hl == 'strap' else GHOST
for sg in (-1, 1):
x0 = -sg*G.SLIT_X; out = -sg*(G.FRAME_W/2+23)
body.append(f'<rect x="{f(min(x0, out+(-sg)*30))}" y="{f(-G.SLIT_Y1)}" width="{f(abs(out-x0)+30)}" height="{f(G.SLIT_Y1-G.SLIT_Y0)}" fill="{sp["strap"]}" opacity="0.9"/>')
body.append(f'<rect x="{f(min(x0, out))}" y="{f(-G.SLIT_Y1+2)}" width="{f(abs(out-x0))}" height="{f(G.SLIT_Y1-G.SLIT_Y0-4)}" fill="#6a6a6a" stroke="#fff" stroke-width="0.3" stroke-dasharray="1 1"/>')
if numbers and hl:
seq = [p for p in M.step_placements(hl) if p['footprint'] is not None and p['part'] not in ('STRAP',) and (p['face'] == 'back') == mirror]
for i, p in enumerate(seq):
c = p['footprint'].centroid; x = (-1 if mirror else 1)*c.x
body.append(f'<circle cx="{f(x)}" cy="{f(-c.y)}" r="3.3" fill="#fff" stroke="{HL}" stroke-width="0.6"/><text x="{f(x)}" y="{f(-c.y+1.25)}" font-size="3.6" font-weight="700" text-anchor="middle" fill="{HL}" font-family="Inter, Helvetica, Arial, sans-serif">{i+1}</text>')
v = vb or VB
return f'<svg xmlns="http://www.w3.org/2000/svg" viewBox="{f(v[0])} {f(v[1])} {f(v[2])} {f(v[3])}" role="img">{"".join(body)}{extra}</svg>'
if __name__ == '__main__':
steps = list(M.STEPS)
html = '<html><body style="margin:0;background:#fff;display:grid;grid-template-columns:repeat(3,420px)">'
html += f'<div>{scene("front", done=steps, palette=BUILD)}</div>'
html += f'<div>{scene("back", done=["strap","strip","back","twigs"], palette=BUILD)}</div>'
html += f'<div>{scene("front", done=steps[:6], hl="front", numbers=True)}</div>'
html += f'<div>{scene("back", done=["strap","strip"], hl="back", numbers=True)}</div>'
html += f'<div>{scene("front", done=steps[:8], hl="tendrils", numbers=True)}</div>'
html += f'<div>{scene("front", done=steps[:9], hl="cheeks", numbers=True)}</div>'
open(G.__file__.replace('geom.py', 'work/preview.html'), 'w').write(html + '</body></html>')