TableTower/tools/theme_art/frame_styles_more.py

110 lines
6.5 KiB
Python
Raw Normal View History

"""Nine more frame looks from the wardrobe mockup (second batch). Same rules as frame_styles.py."""
from frame_wobble import wobbly_corner, wobbly_edge
from frames import FrameStyle, Stroke
from svg_common import grey, num
def _place(inner, card_corner, box_corner_px):
"""Place a mockup ornament (drawn in screen px, 4x here) so its box corner sits `box_corner_px`
from the card corner. `card_corner` is the card corner's position in the corner art (source units)."""
shift = card_corner - box_corner_px * 4
return f'<g transform="translate({num(shift)} {num(shift)}) scale(4)">{inner}</g>'
def folder(colours):
"""Manila folder: a darker folder-back rim and a paperclip."""
clip = ('<path d="M7 50 V10 a5 5 0 0 1 10 0 V44 a3 3 0 0 1 -6 0 V16" fill="none" stroke="#9aa0a6" '
'stroke-width="2.2" stroke-linecap="round" transform="translate(22 0) scale(-1 1)"/>')
return FrameStyle(band_mid=50, radius=46, corner_size=(112, 216), band_inside_px=-1.5,
strokes=[Stroke(16, 0.0, 0.35), Stroke(12, 0.5)],
corner_fixed=_place(clip, 56, 14),
notes=["paperclip on all four corners (mockup: one)", "no folder tab, no tilt, no drop shadow"])
def eldritch(colours):
"""Doubled thin rule with a faint halo; tentacle curls (trim) with glowing suckers."""
card_corner = 89.5
tentacle = ('<path d="M54 10 C34 6 14 12 10 30 C7 44 20 50 27 42 C32 36 26 30 21 34" fill="none" '
f'stroke="{grey(0.5)}" stroke-width="4" stroke-linecap="round"/>')
suckers = "".join(f'<circle cx="{x}" cy="{num(y + 4.5)}" r="{num(1.7 - index * 0.2)}" fill="{colours["glow"]}"/>'
for index, (x, y) in enumerate(((40, 10), (28, 10), (16, 18), (11, 30))))
return FrameStyle(band_mid=84, radius=46, corner_size=(232, 232), band_inside_px=-1.375,
strokes=[Stroke(40, 1.0, 0.05), Stroke(26, 1.0, 0.07),
Stroke(5, 0.5, 1.0, -8.5), Stroke(5, 0.5, 1.0, 8.5)],
corner_extras=_place(tentacle, card_corner, 22),
corner_fixed=_place(suckers, card_corner, 22),
notes=["tentacles on all four corners (mockup: two)",
"halo is the trim's highlight, not the green glow colour"])
def comic(colours):
"""A thick, square black panel line."""
return FrameStyle(band_mid=40, radius=0, corner_size=(112, 112), band_inside_px=2,
strokes=[Stroke(16, 0.5)], notes=["no hard black offset shadow"])
def brass(colours):
"""Polished brass: light and dark metal bands, rivet heads on the corners."""
shading = [Stroke(32, 0.0), Stroke(28, 0.82), Stroke(22, 0.62), Stroke(14, 0.38), Stroke(6, 0.68)]
rivet = ('<circle cx="42" cy="42" r="11" fill="#6b4a1a"/>'
'<circle cx="39.6" cy="39.6" r="4.8" fill="#fbe2a2"/>')
return FrameStyle(band_mid=40, radius=16, corner_size=(112, 112), band_inside_px=3.5,
strokes=shading, corner_fixed=rivet,
notes=["the metal shine runs along the band, not as one diagonal sweep across the card"])
def chamfer(colours):
"""A steel panel with 45 degree cut corners; the cut-off card corner is covered in the dark colour."""
band_mid, cut = 40, 56
diagonal = 2 * band_mid + cut
cover_start = band_mid - 12
cover = (f'<polygon points="{cover_start},{cover_start} {cover_start},{diagonal - cover_start} '
f'{diagonal - cover_start},{cover_start}" fill="#000000"/>')
return FrameStyle(band_mid=band_mid, radius=0, chamfer=cut, corner_size=(128, 128), band_inside_px=1,
strokes=[Stroke(8, 0.5), Stroke(2, 1.0, 0.5)], corner_under=cover,
notes=["the cut corner is filled with the dark colour (BG_DEEP) to hide the round card corner",
"no hazard stripe (it belongs to the header)"])
def hud(colours):
"""A faint thin outline with bright L-shaped corner brackets."""
bracket = f'<path d="M12,108 V12 H108" fill="none" stroke="{grey(0.5)}" stroke-width="9.6"/>'
return FrameStyle(band_mid=24, radius=40, corner_size=(128, 128),
strokes=[Stroke(4, 0.5, 0.45)], corner_extras=bracket, band_half_px=1.2,
notes=["brackets are 24 px (mockup: 16 px) so the corner is big enough to read"])
def map_rule(colours):
"""Three thin ink rules (a card border and a doubled outer rule) with a diamond on each corner."""
diamond = f'<path d="M7 0 L10 7 L7 14 L4 7Z" fill="{grey(0.5)}"/>'
return FrameStyle(band_mid=32, radius=50, corner_size=(112, 112), band_inside_px=-2.5,
strokes=[Stroke(4, 0.5, 1.0, offset) for offset in (-12, 0, 12)],
corner_extras=f'<g transform="translate(2 2) scale(4)">{diamond}</g>',
notes=["the three rules are evenly spaced (mockup: double rule a little further out)"])
def story(colours):
"""A wobbly hand-drawn band with a dashed stitch line running inside it."""
band_mid, radius, half_width, edge_length = 48, 72, 8, 168
corner_width = corner_height = band_mid + radius + 24
stitch = Stroke(4, 1.0, 0.6, 0, "16 12")
return FrameStyle(band_mid=band_mid, radius=radius, corner_size=(corner_width, corner_height),
edge_length=edge_length, band_inside_px=-2, strokes=[stitch], band_half_px=2,
corner_under=wobbly_corner(band_mid, radius, corner_width, corner_height, half_width, 2, 1.5),
edge_under=wobbly_edge(band_mid, edge_length, half_width, 2, 1.5),
notes=["the stitch is inside the band, in the trim's highlight (mockup: amber accent, "
"inside the card)", "all corners share one radius (mockup: four different ones)"])
def bevel(colours):
"""A 90s window edge, made symmetric: black line, white line, light grey body, white line, black line."""
return FrameStyle(band_mid=32, radius=0, corner_size=(96, 96), band_inside_px=3, highlight=1.0,
strokes=[Stroke(32, 0.0), Stroke(24, 1.0), Stroke(16, 0.75)],
notes=["symmetric bevel (true light-top-left / dark-bottom-right needs unmirrored corners)",
"needs highlight 1.0 so l=0.75 maps to #c0c0c0 and white stays white"])
MORE_FRAME_STYLES = {"folder": folder, "eldritch": eldritch, "comic": comic, "brass": brass,
"chamfer": chamfer, "hud": hud, "map": map_rule, "story": story, "bevel": bevel}