"""Big background scenes (1920 x 1080, transparent ground) from the mockup's SCENES.
Most scenes are drawn in the mockup's 960 x 450 spread space and scaled by 2. Bottom-anchored
scenes are shifted down 180 px so their floor, hills or trees touch the bottom edge.
"""
from scene_floor import PerspectiveFloor, floor_svg
from scene_paint import (SCENE_HEIGHT, SCENE_WIDTH, in_spread_space, radial_gradient, soft_ellipse_glow,
vertical_gradient)
from svg_common import css_colour, num, svg_document
def vapor_scene(scene):
"""A pale wireframe floor and a soft pink-to-periwinkle sun."""
floor = PerspectiveFloor(-96, 1056, 207, 260, 58)
grid = floor_svg(floor, scene["s1"], 26, 2.08, 52, 2, opacity=0.8)
defs = vertical_gradient("vapor_sun", [(0, scene["s2"], 1), (1, scene["s3"], 1)])
sun = ''
return defs, in_spread_space(sun + grid, 180), "bottom"
def synth_scene(scene):
"""Blue light bars, a striped setting sun and a glowing pink grid floor."""
bar_fade = "".join(f''
for offset, opacity in ((0, 0), (0.15, 1), (0.85, 1), (1, 0)))
defs = f'{bar_fade}'
bars = ""
for top in range(60, 320, 13):
bars += f''
bars += f''
defs += vertical_gradient("synth_sun", [(0, scene["s1"], 1), (0.52, "#fa8057", 1), (1, scene["s2"], 1)])
sun_top, sun_size = 52, 250
stripes = f''
stripe_top = sun_top
while stripe_top < sun_top + sun_size:
stripes += f''
stripe_top += 14
defs += f'{stripes}'
sun = (f'')
halo = "".join(f'' for grow in range(3, 28, 6))
floor = PerspectiveFloor(-480, 1440, 150, 180, 55)
grid = floor_svg(floor, scene["s2"], 22, 2.2, 46, 2, glow_width=3, ground_colour="#14051a")
return defs, in_spread_space(bars + halo + sun + grid, 180), "bottom"
def _cloud(defs_needed, x, y, width, opacity):
"""Three soft ellipses, matching the mockup's three-layer CSS cloud."""
height = width * 0.42
layers = [ # sub-box (x, y, w, h), centre within it, solid-until offset
((x, y + height * 0.1, width * 0.55, height * 0.9), (0.30, 0.65), 0.70),
((x + width * 0.45 * 0.4, y, width * 0.55, height), (0.55, 0.40), 0.72),
((x + width * 0.55, y + height * 0.2, width * 0.45, height * 0.8), (0.78, 0.66), 0.70),
]
shapes = ""
for (box_x, box_y, box_w, box_h), (centre_x, centre_y), solid_until in layers:
radius_x = min(centre_x, 1 - centre_x) * box_w
radius_y = min(centre_y, 1 - centre_y) * box_h
gradient_id = f"cloud_soft_{int(solid_until * 100)}"
defs_needed[gradient_id] = radial_gradient(gradient_id, [(solid_until, "#ffffff", 1), (1, "#ffffff", 0)])
shapes += (f'')
return f'{shapes}'
def clouds_scene(scene):
"""Sun glare in the top right and five soft clouds."""
glare_colour, glare_opacity = css_colour(scene["s1"])
defs = radial_gradient("sky_glare", [(0, "#ffffff", 1), (0.25, glare_colour, glare_opacity),
(0.65, glare_colour, 0)], radius=0.707)
body = ''
defs_needed = {}
for x, y, width, opacity in ((300, 330, 260, .95), (-40, 360, 240, .9), (600, 20, 150, .7),
(250, 40, 120, .55), (820, 250, 180, .85)):
body += _cloud(defs_needed, x, y, width, opacity)
return defs + "".join(defs_needed.values()), in_spread_space(body, 90), "center"
def aero_scene(scene):
"""Glossy glare, a green hill with a white rim, light swooshes and glass bubbles."""
defs = radial_gradient("aero_glare", [(0, "#ffffff", 0.95), (0.65, "#ffffff", 0)], radius=0.707)
defs += radial_gradient("aero_bubble", [(0, "#ffffff", 1), (0.14, "#ffffff", 1), (0.34, "#ffffff", 0.15),
(0.70, "#74e4ff", 0.35), (1, "#ffffff", 0.8)],
centre=(0.32, 0.28), radius=0.99)
body = ''
body += (f''
''
''
'')
for left, top, radius in ((300, 80, 46), (880, 60, 30), (560, 300, 22), (120, 300, 34), (700, 170, 16)):
centre_x, centre_y = left + radius, top + radius
body += (f''
f'')
return defs, in_spread_space(body, 180), "bottom"
"""Dark edges (a vignette)."""
def vignette_scene(scene):
"""Dark edges and a faint red arched window glow at the top."""
# CSS radial-gradient(70% 80% at 50% 40%, transparent 40%, s1): radii are 70% / 80% of the scene.
centre, radii = (SCENE_WIDTH * 0.5, SCENE_HEIGHT * 0.4), (SCENE_WIDTH * 0.7, SCENE_HEIGHT * 0.8)
defs = radial_gradient("gothic_vignette", [(0.4, scene["s1"], 0), (1, scene["s1"], 1)])
body = (f'')
# The red arch "window glow" read as a stray red patch (playtest 2026-11-14),
# so the stand-in is the vignette alone; a real window is the user's art.
return defs, body, "center"
def woods_scene(scene):
"""Two soft light patches and dark pines standing on the bottom edge."""
defs_one, glow_one = soft_ellipse_glow("woods_light_a", scene["s1"], (SCENE_WIDTH * 0.25, SCENE_HEIGHT * 0.2),
(SCENE_WIDTH * 0.3, SCENE_HEIGHT * 0.4))
defs_two, glow_two = soft_ellipse_glow("woods_light_b", scene["s1"], (SCENE_WIDTH * 0.7, SCENE_HEIGHT * 0.6),
(SCENE_WIDTH * 0.25, SCENE_HEIGHT * 0.35))
pine = "M0 0 L-30 0 L-8 -40 L-24 -40 L-4 -80 L-16 -80 L0 -120 L16 -80 L4 -80 L24 -40 L8 -40 L30 0Z"
trees = "".join(f''
for x, size in ((40, 1), (120, 1.3), (880, 1.2), (940, 0.9)))
body = glow_one + glow_two + in_spread_space(f'{trees}', 180)
return defs_one + defs_two, body, "bottom"
SCENE_MAKERS = {"vapor": vapor_scene, "synth": synth_scene, "clouds": clouds_scene,
"aero": aero_scene, "vignette": vignette_scene, "woods": woods_scene}
from scenes_more import MORE_SCENE_MAKERS # noqa: E402 (second batch)
SCENE_MAKERS.update(MORE_SCENE_MAKERS)
def make_background_scene(scene):
"""Return (svg_text, meta) for a scene, or (None, None) for 'glow' / 'none' (the app's fill does those)."""
maker = SCENE_MAKERS.get(scene["kind"])
if maker is None:
return None, None
defs, body, anchor = maker(scene)
return svg_document(SCENE_WIDTH, SCENE_HEIGHT, body, defs), {"anchor": anchor}