TableTower/tools/theme_art/frame_styles.py
RobinFiredrake 61a548902f Theme tiers 1-2: theme folders, mascot recolour, background scene and tile, frame sets, picture threads, sounds; nine new built-in themes
- ThemeAssets loads a theme's files; FrameSet + GradientMap (3-stop) generalise the card frame;
  ThreadStrip draws threads from a picture; BoardBackdrop draws scene and tile; MascotArt
  recolours Morgan by role (logo SVG now uses the Keep File importer); SoundBoard plays
  roll / card turn / thread / click / ambient with View > Sound levels.
- Vaporwave, Synthwave, Cozy Autumn, Rustic, Woodsy, Sky Blue, Frutiger Aero, Gothic, Terminal:
  generated art (tools/theme_art), sounds (tools/theme_sounds), settings (tools/theme_defs).
- Ten OFL fonts; --theme=<id> flag; docs/THEMES.md format spec; test_theme_assets.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 15:05:40 -06:00

116 lines
6.8 KiB
Python

"""The nine frame looks from the wardrobe mockup, as band profiles plus ornaments.
Greyscale meaning (see the gradient map in docs/THEMES.md): black = dark backing, mid grey = trim
or card colour, white = highlight. Source units are 4x screen pixels.
"""
from frames import FrameStyle, Stroke
from svg_common import LEAF_PATH, MAPLE_LEAF_PATH, grey, num
def _scaled_ornament(card_corner_in_box, band_mid, inner):
"""Place a mockup ornament (drawn in screen px) so its card-corner point lands on the band corner."""
shift = band_mid - card_corner_in_box * 4
return f'<g transform="translate({num(shift)} {num(shift)}) scale(4)">{inner}</g>'
def memphis(colours):
"""Flat ink outline; squiggle and triangle on the corners."""
ornament = (f'<path d="M4 22 q5 -8 10 0 t10 0" fill="none" stroke="{colours["thread"]}" stroke-width="3.5" '
f'stroke-linecap="round"/><path d="M14 2 l10 14 h-20z" fill="{colours["accent"]}" '
f'stroke="{colours["trim"]}" stroke-width="2"/>')
return FrameStyle(band_mid=64, radius=40, corner_size=(160, 160),
strokes=[Stroke(12, 0.5)],
corner_fixed=_scaled_ornament(16, 64, ornament),
notes=["no hard plum drop shadow (mirrored corners cannot offset one way)"])
def neon(colours):
"""A bright tube with a soft halo on both sides, faked with stacked strokes."""
halo = [Stroke(64, 0.5, 0.05), Stroke(48, 0.5, 0.09), Stroke(34, 0.5, 0.15), Stroke(22, 0.5, 0.3)]
return FrameStyle(band_mid=40, radius=28, corner_size=(112, 112), edge_length=32,
strokes=halo + [Stroke(10, 0.5, 1.0), Stroke(4, 1.0, 0.85)])
def leaf(colours):
"""Rust edge with a maple leaf on the corners."""
ornament = (f'<path d="{MAPLE_LEAF_PATH}" transform="translate(20 20) rotate(-30) scale(1.55)" '
f'fill="{colours["accent"]}" stroke="{colours["trim_dark"]}" stroke-width=".8"/>'
f'<path d="M14 30 L26 12" stroke="{colours["trim_dark"]}" stroke-width="1.2"/>')
return FrameStyle(band_mid=64, radius=32, corner_size=(176, 176),
strokes=[Stroke(16, 0.0, 0.5), Stroke(12, 0.5), Stroke(3, 1.0, 0.35)],
corner_fixed=_scaled_ornament(15, 64, ornament),
notes=["leaf shows on all four corners (mockup: two)"])
def plank(colours):
"""A thick wood frame: darker in the middle, grain along the band, mitred corners, nail heads."""
shading = [Stroke(40, 0.0), Stroke(36, 0.5), Stroke(30, 0.43), Stroke(22, 0.37), Stroke(14, 0.33)]
grain = [Stroke(1.5, 0.1, 0.45, offset) for offset in (-12, -5, 6, 13)]
shine = [Stroke(1.5, 1.0, 0.22, offset) for offset in (-16, 16)]
mitre = '<path d="M20,20 L60,60" stroke="#000000" stroke-width="2" stroke-opacity=".7"/>'
nail_x = 44
nail = (f'<circle cx="{nail_x}" cy="{nail_x}" r="12" fill="#2a2522"/>'
f'<circle cx="{nail_x - 3}" cy="{nail_x - 3}" r="4" fill="#9a8f86"/>')
return FrameStyle(band_mid=40, radius=0, corner_size=(112, 112), edge_length=128,
strokes=shading + grain + shine, band_inside_px=3,
corner_extras=mitre, corner_fixed=nail,
notes=["one nail per corner; the mockup's grain is drawn as straight lines along the band"])
def vine(colours):
"""A thin dark-wood edge; a vine curl (trim) with leaves on the corners."""
curl = ('<path d="M50 6 C30 2 12 8 8 26 C5 40 16 48 24 40 C30 33 22 26 17 31" fill="none" '
f'stroke="{grey(0.5)}" stroke-width="2.5" stroke-linecap="round"/>')
leaves = (f'<path d="{LEAF_PATH}" transform="translate(36 6) rotate(70) scale(.75)" fill="{colours["accent"]}"/>'
f'<path d="{LEAF_PATH}" transform="translate(6 18) rotate(-10) scale(.75)" fill="{colours["accent"]}"/>'
f'<path d="{LEAF_PATH}" transform="translate(9 44) rotate(40) scale(.6)" fill="{colours["glow"]}"/>')
return FrameStyle(band_mid=72, radius=40, corner_size=(216, 216),
strokes=[Stroke(12, 0.0, 0.4), Stroke(9, 0.5), Stroke(2, 1.0, 0.3)],
corner_extras=_scaled_ornament(18, 72, curl),
corner_fixed=_scaled_ornament(18, 72, leaves),
notes=["all four corners match, so the leaf-cut shape (two round, two sharp corners) is lost",
"vine shows on all four corners (mockup: two)"])
def cloud(colours):
"""A round white rim with a cloud puff on the corner."""
puff = ('<g fill="#ffffff"><circle cx="50" cy="26" r="12"/><circle cx="34" cy="18" r="15"/>'
'<circle cx="18" cy="26" r="11"/><rect x="16" y="24" width="36" height="14" rx="7"/></g>')
return FrameStyle(band_mid=48, radius=64, corner_size=(288, 176),
strokes=[Stroke(16, 0.0, 0.08), Stroke(8, 1.0)], band_inside_px=-2,
corner_fixed=f'<g transform="scale(4)">{puff}</g>',
notes=["cloud puff shows on all four corners (mockup: top right only)",
"no soft blue drop shadow"])
def glass(colours):
"""Frosted glass rim: a faint wide band with a bright thin line."""
return FrameStyle(band_mid=40, radius=52, corner_size=(128, 128), band_inside_px=-1,
strokes=[Stroke(22, 0.0, 0.08), Stroke(14, 0.5, 0.45), Stroke(4, 1.0, 0.95)],
notes=["no backdrop blur and no blue drop shadow"])
def stone(colours):
"""A thick carved stone band, blocks with mortar joints, cracks on the corner."""
shading = [Stroke(36, 0.0), Stroke(32, 0.63), Stroke(26, 0.58), Stroke(18, 0.53), Stroke(10, 0.5)]
joint = '<rect x="38" y="47" width="36" height="2.5" fill="#000000" fill-opacity=".6"/>'
crack = ('<path d="M0 0 L14 6 L10 14 L22 22 L18 30 M10 14 L2 20" fill="none" '
f'stroke="{grey(0.12)}" stroke-width="1.6" stroke-opacity=".9"/>')
corner_joints = ('<path d="M38,150 L74,150 M150,38 L150,74" stroke="#000000" stroke-width="2.5" '
'stroke-opacity=".6"/>')
return FrameStyle(band_mid=56, radius=80, corner_size=(168, 168), edge_length=96,
strokes=shading, edge_extras=joint,
corner_extras=corner_joints + f'<g transform="translate(64 64) scale(2.4)">{crack}</g>',
notes=["all four corners are rounded the same; the mockup's pointed top (round top, square "
"bottom) needs separate top and bottom corners"])
def ascii_box(colours):
"""A double-line box, like box-drawing characters."""
return FrameStyle(band_mid=34, radius=0, corner_size=(128, 128), edge_length=32,
strokes=[Stroke(4, 0.5, 1.0, -4), Stroke(4, 0.5, 1.0, 4)])
FRAME_STYLES = {"memphis": memphis, "neon": neon, "leaf": leaf, "plank": plank, "vine": vine,
"cloud": cloud, "glass": glass, "stone": stone, "ascii": ascii_box}