"""Second batch of background tiles (real colours, transparent ground) from the mockup's PATTERNS."""
from svg_common import LEAF_PATH, MockupRandom, num, wrapped_copies
def rain_tile(pattern):
"""Short slanted rain streaks."""
random = MockupRandom(3)
streaks = ""
for _ in range(18):
x, y, length = random.next() * 120, random.next() * 160, 8 + random.next() * 14
opacity = 0.25 + random.next() * 0.4
streaks += (f'')
return 120, 160, wrapped_copies(streaks, 120, 160)
def contour_tile(pattern):
"""Five nested wavy rings, like height lines on a map."""
rings = ""
for ring in range(1, 6):
size = ring * 15
rings += (f'')
return 200, 200, rings
def halftone_tile(pattern):
"""One halftone dot."""
return 10, 10, f''
def gears_tile(pattern):
"""Three gear outlines: a dashed thick ring for the teeth, a rim and a hub."""
def gear(x, y, radius):
return (f''
f''
f'')
return 220, 220, gear(60, 60, 34) + gear(118, 104, 22) + gear(180, 180, 28)
def starfield_tile(pattern):
"""Thirty stars and a faint hex-grid trace."""
random = MockupRandom(5)
stars = ""
for _ in range(30):
x, y = random.next() * 180, random.next() * 180
radius = 0.6 if random.next() < 0.85 else 1.3
opacity = 0.35 + random.next() * 0.6
stars += f''
hexes = (f'')
return 180, 180, wrapped_copies(stars, 180, 180) + hexes
def sprigs_tile(pattern):
"""Pressed flowers and leaves."""
random = MockupRandom(9)
sprigs = ""
for index in range(6):
x, y = random.next() * 200, random.next() * 200
if index % 2:
petals = "".join(f''
for angle in (0, 72, 144, 216, 288))
sprigs += (f'{petals}'
f'')
else:
sprigs += (f'')
return 200, 200, wrapped_copies(sprigs, 200, 200)
MORE_TILE_MAKERS = {"rain": rain_tile, "contour": contour_tile, "halftone": halftone_tile,
"gears": gears_tile, "starfield": starfield_tile, "sprigs": sprigs_tile}