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

+148
View File
@@ -0,0 +1,148 @@
"""Geometry for the Green Man mask kit. All units mm. Origin = centre of the eye line, +x = wearer's left
as seen from the front (viewer's right), +y = up. Everything else in the kit is generated from this file
and manifest.py."""
import numpy as np
from scipy.interpolate import splprep, splev
from shapely.geometry import Polygon, Point, LineString, box
from shapely.ops import unary_union
from shapely import affinity
# ---- reference glasses (the frames the mask was built around) ----
FRAME_W = 139.7 # outer width of the frame front
LENS_W, LENS_H = 57.15, 41.9
BRIDGE = FRAME_W - 2*LENS_W - 6.0
LENS_CX = BRIDGE/2 + LENS_W/2
TOP = LENS_H/2 + 4 # y of the frame's top bar; the brow band starts here
BAND_TOP = TOP + 56 # top of the band at the centre line
def _mirror(p): return affinity.scale(p, xfact=-1, origin=(0, 0))
def lens(sgn):
cx = sgn*LENS_CX; w, h = LENS_W-8, LENS_H-8
p = Polygon([(cx-sgn*w/2, h/2), (cx+sgn*w/2, h/2), (cx+sgn*(w/2-6), -h/2+3), (cx+sgn*4, -h/2), (cx-sgn*(w/2-2), -h/2+4)])
return p.buffer(4, join_style=1)
_band = Polygon([(-FRAME_W/2-22, TOP), (-FRAME_W/2-22, TOP+22), (-FRAME_W/2-10, TOP+44), (-40, TOP+52), (0, TOP+56),
(40, TOP+52), (FRAME_W/2+10, TOP+44), (FRAME_W/2+22, TOP+22), (FRAME_W/2+22, TOP)])
_nose = Polygon([(-9, TOP+2), (9, TOP+2), (6, TOP-10), (7, -8), (12, -34), (0, -48), (-12, -34), (-7, -8), (-6, TOP-10)])
_cheek = Polygon([(-FRAME_W/2-24, TOP+6), (-FRAME_W/2+4, TOP+6), (-FRAME_W/2+2, -6), (-FRAME_W/2-6, -24), (-FRAME_W/2-18, -18), (-FRAME_W/2-26, -2)])
SLIT_X = FRAME_W/2 + 2 # side strap slit centre (x = +/-)
SLIT_Y0, SLIT_Y1, SLIT_W = TOP+8, TOP+28, 3.0
PATCH_W, PATCH_H = 30.0, 36.0 # 2 mm reinforcement patch on the back, centred on the slit
def band_top(x):
"""y of the band's top edge at x (piecewise linear, matches _band)."""
xs = [0, 40, FRAME_W/2+10, FRAME_W/2+22]; ys = [TOP+56, TOP+52, TOP+44, TOP+22]
return float(np.interp(abs(x), xs, ys))
def base_glasses():
"""As-built base: brow band + nose strip + cheek tabs. Worn behind the glasses; nothing surrounds the lenses."""
outline = unary_union([_band, _nose, _cheek, _mirror(_cheek)]).buffer(5, join_style=1).buffer(-5, join_style=1)
return dict(kind='glasses', outline=outline, holes=[], **_common())
def base_plain():
"""No-glasses variant (UNTESTED): same band, nose and cheeks, joined under the eyes, with eye holes."""
under = box(-FRAME_W/2-4, -30, FRAME_W/2+4, TOP+2)
outline = unary_union([_band, _nose, _cheek, _mirror(_cheek), under]).buffer(8, join_style=1).buffer(-8, join_style=1)
eye = affinity.scale(Point(0, 0).buffer(1, 48), 23, 12) # 46 x 24 mm
holes = [affinity.translate(affinity.rotate(eye, 6*s), 32*s, 0) for s in (-1, 1)] # 64 mm between centres
return dict(kind='plain', outline=outline.difference(unary_union(holes)), holes=holes, **_common())
def _common():
slits = [box(s*SLIT_X-SLIT_W/2, SLIT_Y0, s*SLIT_X+SLIT_W/2, SLIT_Y1) for s in (-1, 1)]
patches = [box(s*SLIT_X-PATCH_W/2, (SLIT_Y0+SLIT_Y1)/2-PATCH_H/2, s*SLIT_X+PATCH_W/2, (SLIT_Y0+SLIT_Y1)/2+PATCH_H/2) for s in (-1, 1)]
top_slit = box(-12, TOP+45, 12, TOP+48) # optional second strap, only if the mask nods forward
return dict(slits=slits, patches=patches, top_slit=top_slit)
# zones on the glasses base where nothing raised may be glued (the frame and its arms rest here)
def frame_zone(): return box(-FRAME_W/2-1, -LENS_H/2-4, FRAME_W/2+1, TOP+2)
def arm_zones(): return [box(min(s*(FRAME_W/2-2), s*(FRAME_W/2+40)), TOP-6, max(s*(FRAME_W/2-2), s*(FRAME_W/2+40)), TOP+3) for s in (-1, 1)]
# ---- oak leaves ----
LEAF = {'L': (95, 65), 'M': (70, 48), 'S': (48, 33), 'T': (30, 21)} # blade length, width
STEM_L, STEM_W = 12.0, 5.0
# Two deliberately different leaf shapes per size, so a crown of them does not look stamped out.
# A: broad white-oak leaf, four shallow rounded lobes a side, nearly symmetric.
# B: slimmer leaf with three long lobes a side cut almost to the midrib, the lobes alternating left and right,
# and a large rounded end lobe.
# Each entry is (right half, left half) as (fraction of width, fraction of length) control points.
_A = [(0.00,0.00),(0.06,0.04),(0.26,0.12),(0.40,0.22),(0.30,0.28),(0.16,0.33),(0.36,0.40),(0.52,0.50),(0.46,0.56),
(0.20,0.60),(0.38,0.66),(0.50,0.74),(0.40,0.80),(0.18,0.84),(0.28,0.89),(0.30,0.94),(0.14,0.985),(0.00,1.00)]
_BR = [(0.00,0.00),(0.07,0.04),(0.17,0.10),(0.34,0.17),(0.50,0.25),(0.40,0.31),(0.15,0.36),(0.16,0.42),(0.36,0.47),
(0.58,0.56),(0.46,0.63),(0.15,0.67),(0.16,0.72),(0.34,0.76),(0.44,0.84),(0.38,0.93),(0.20,0.99),(0.00,1.00)]
_BL = [(0.00,0.00),(0.07,0.05),(0.15,0.15),(0.32,0.24),(0.46,0.33),(0.36,0.39),(0.15,0.43),(0.16,0.50),(0.36,0.56),
(0.54,0.65),(0.42,0.71),(0.15,0.75),(0.17,0.80),(0.36,0.84),(0.42,0.90),(0.32,0.96),(0.16,0.995),(0.00,1.00)]
_CTRL = {0: (_A, _A), 1: (_BR, _BL)}
_WIDTH = {0: 1.0, 1: 0.90} # B is a little slimmer overall
# lobe tips the side veins run to: (fraction of width, fraction of length), right half then left half
_VEIN = {0: ([(0.40,0.22),(0.52,0.50),(0.50,0.74),(0.30,0.92)],)*2,
1: ([(0.50,0.25),(0.58,0.56),(0.44,0.84)], [(0.46,0.33),(0.54,0.65),(0.42,0.90)])}
def _half(L, W, ctrl, rng, jitter):
pts = np.array([(x*W*(1+rng.uniform(-jitter, jitter)*(x > 0)), y*L) for x, y in ctrl])
tck, _ = splprep(pts.T, s=0, k=3); u = np.linspace(0, 1, 200)
x, y = splev(u, tck); return np.clip(x, 0, None), y
def oak(size, variant=0):
"""Leaf polygon WITH its stem, one piece. Blade base at (0,0), tip at +y, stem tab from y=-STEM_L to 0."""
L, W = LEAF[size]; W = W*_WIDTH[variant]
rng = np.random.default_rng({'L': 10, 'M': 20, 'S': 30, 'T': 40}[size] + variant)
cr, cl = _CTRL[variant]
xr, yr = _half(L, W, cr, rng, 0.04); xl, yl = _half(L, W, cl, rng, 0.04)
blade = Polygon(list(zip(xr, yr)) + [(-a, b) for a, b in reversed(list(zip(xl, yl)))][1:]).buffer(0)
sw = STEM_W if size != 'T' else 4.0
stem = box(-sw/2, -STEM_L, sw/2, L*0.06)
leaf = unary_union([blade, stem]).buffer(0.6, join_style=1).buffer(-0.6, join_style=1)
assert leaf.geom_type == 'Polygon' and leaf.is_valid, f'leaf {size}{variant} is not one piece'
# 2 mm foam tears where a lobe joins the midrib by less than about 5 mm (3 mm on the tiny tip leaves)
neck = {'L': 2.5, 'M': 2.5, 'S': 2.0, 'T': 1.4}[size]
assert leaf.buffer(-neck).geom_type == 'Polygon', f'leaf {size}{variant}: a lobe is joined by less than {2*neck:.0f} mm'
return leaf
def vein_lines(size, variant=0):
L, W = LEAF[size]; W = W*_WIDTH[variant]
out = [LineString([(0, -STEM_L*0.8), (0, 0.97*L)])]
for s, tips in zip((1, -1), _VEIN[variant]):
for wx, ly in tips: out.append(LineString([(0, L*(ly-0.13)), (s*W*wx*0.85, L*ly)]))
return out
def stem_tab(size):
sw = STEM_W if size != 'T' else 4.0
return box(-sw/2, -STEM_L, sw/2, 0)
def place(geom, x, y, angle=0.0, flip=False):
"""angle: 0 = tip up, positive = tip leans toward +x (clockwise as drawn)."""
g = affinity.scale(geom, xfact=-1, origin=(0, 0)) if flip else geom
return affinity.translate(affinity.rotate(g, -angle, origin=(0, 0)), x, y)
# ---- printed parts, front-view outlines ----
STRIP_L = 136.0
def strip_poly(L=STRIP_L):
"""Brow strip as printed: straight, 22 mm tall at the centre tapering to 12 mm. Centre at (0,0)."""
x = np.linspace(-L/2, L/2, 120); half = 11 - 5*(np.abs(x)/(L/2))**1.6
top = half + 1.2*np.sin(x*0.22) + 0.6*np.sin(x*0.53+1); bot = -half + 1.0*np.sin(x*0.19+2)
return Polygon(list(zip(x, top)) + list(zip(x[::-1], bot[::-1]))).buffer(1.5, join_style=1).buffer(-1.5, join_style=1)
STRIP_Y = TOP + 16 # strip centre line on the band
KNOT_R = 21.0
KNOT_C = (0.0, TOP + 16 + 11 + 1 + KNOT_R) # sits on the band just above the strip, touching its top edge
ACORN = {'AL': (30.0, 37.0), 'AS': (22.0, 29.0), 'AF': (27.0, 31.0)} # width, length as printed
def acorn_poly(kind):
w, l = ACORN[kind]; return affinity.scale(Point(0, 0).buffer(1, 32), w/2, l/2)
def spiral_path(n=80):
"""Small tendril, 65 x 26 mm as printed. Stem end at (0,0), runs toward +y then curls."""
L, turns = 48.0, 1.3
t = np.linspace(0, 1, 60); xs = t*L; ys = 10*np.sin(t*np.pi*1.4)
ts = np.linspace(0, 1, n); ang = ts*2*np.pi*turns; rad = 14*(1-0.72*ts)
sx = L + rad*np.sin(ang); sy = 10*np.sin(np.pi*1.4) + rad*(1-np.cos(ang))
pts = np.column_stack([np.concatenate([xs, sx[1:]]), np.concatenate([ys, sy[1:]])])
return LineString([(y, x) for x, y in pts]) # rotate so the stem runs along +y
def twig_paths():
t = np.linspace(0, 1, 40); main = np.column_stack([6*np.sin(t*np.pi*2.2), t*85])
p0 = main[18]; t2 = np.linspace(0, 1, 25); b1 = np.column_stack([p0[0]+t2*22+4*np.sin(t2*np.pi*1.5), p0[1]+t2*38])
p1 = main[30]; t3 = np.linspace(0, 1, 20); b2 = np.column_stack([p1[0]-t3*18, p1[1]+t3*26])
return [LineString(main), LineString(b1), LineString(b2)]