"""Second batch of thread looks (greyscale strips) plus the noir pushpin (real colours)."""
from svg_common import grey, num, svg_document
from threads import _band
SOURCE_SCALE = 4
def _capsule_dashes(height, dash_pattern_px, stroke_px, lightness=0.5, opacity=1.0):
"""CSS round-capped dashes: each dash grows by half the stroke at both ends. The first cap starts at x = 0."""
stroke = stroke_px * SOURCE_SCALE
centre_y = height / 2
position = stroke / 2
shapes = ""
for index, length_px in enumerate(dash_pattern_px):
length = length_px * SOURCE_SCALE
if index % 2 == 0:
shapes += (f'')
position += length
return shapes
def _glowing_dashes(height, dash_pattern_px, core_px):
"""Dashes with a faked glow: two wider, fainter copies under a bright core."""
halo_wide = _capsule_dashes(height, dash_pattern_px, core_px * 2.6, 0.5, 0.12)
halo_near = _capsule_dashes(height, dash_pattern_px, core_px * 1.7, 0.5, 0.25)
return halo_wide + halo_near + _capsule_dashes(height, dash_pattern_px, core_px)
def red_string(length, height):
return _band(length, height, height, 0.5) + _band(length, height, height * 0.25, 1.0, 0.25, -height * 0.15)
def broken_ink(length, height):
return _glowing_dashes(height, [14, 3, 2, 3], 2.2)
def gutter_line(length, height):
return _band(length, height, height, 0.0) + _band(length, height, height * 4 / 9, 0.5)
def copper_pipe(length, height):
return (_band(length, height, height, 0.0) + _band(length, height, height * 4.5 / 7, 0.5)
+ _band(length, height, height * 1.3 / 7, 1.0, 0.56, -height * 0.1))
def data_line(length, height):
return _glowing_dashes(height, [12, 4, 2, 4], 2.5)
def nav_route(length, height):
return _band(length, height, height * 1 / 2.2, 0.5, 0.4) + _capsule_dashes(height, [1, 6], 2.2)
def travel_route(length, height):
return _capsule_dashes(height, [7, 6], 2.4)
def yarn(length, height):
return _band(length, height, height, 0.5) + _capsule_dashes(height, [2, 7], 4.5, 1.0)
def construction_tape(length, height):
"""Black tape with slanted 'yellow' (mid grey) stripes inside a black edge."""
edge = height / 6
stripe_width, slant = length / 2, height * 0.5
left = (length - stripe_width - slant) / 2
stripe = (f'')
return _band(length, height, height, 0.0) + stripe
# thread look -> (maker, drawn width in px, repeat length in px)
MORE_THREAD_LOOKS = {
"red_string": (red_string, 1.8, 8), "broken_ink": (broken_ink, 6, 22), "gutter_line": (gutter_line, 9, 8),
"copper_pipe": (copper_pipe, 7, 8), "data_line": (data_line, 6, 22), "nav_route": (nav_route, 2.2, 7),
"travel_route": (travel_route, 2.4, 13), "yarn": (yarn, 4.5, 9), "construction_tape": (construction_tape, 6, 14),
}
PIN_SIZE_SOURCE, PIN_SIZE_PX = 32, 13
def pushpin_svg(colours):
"""A round red pushpin head seen from above, in real colours (mockup: thread colour, dark rim, pale glint)."""
body = (f''
f''
f''
f'')
return svg_document(PIN_SIZE_SOURCE, PIN_SIZE_SOURCE, body)