"""Génère illustrations/06-parapluies.svg : trois parapluies sous la pluie.
Le couple sous le grand rouge, son fils (3 ans) sous le bleu, sa fille (1 an et demi)
sous le rose. Il pleut ; de temps en temps une pilule tombe à la place d'une goutte,
rebondit sur un parapluie et roule jusqu'au bord."""
import math, random, sys

out = sys.argv[1]
random.seed(11)
GROUND = 452

# ---------------------------------------------------------------- parapluies
def dome_point(cx, cy, r, h, t):
    p = [(cx - r, cy), (cx - r, cy - 1.35 * h), (cx + r, cy - 1.35 * h), (cx + r, cy)]
    x = sum(c * pt[0] for c, pt in zip([(1 - t) ** 3, 3 * t * (1 - t) ** 2, 3 * t * t * (1 - t), t ** 3], p))
    y = sum(c * pt[1] for c, pt in zip([(1 - t) ** 3, 3 * t * (1 - t) ** 2, 3 * t * t * (1 - t), t ** 3], p))
    return x, y

def dome_y(cx, cy, r, h, x):
    best = min((abs(dome_point(cx, cy, r, h, i / 400)[0] - x), i / 400) for i in range(401))
    return dome_point(cx, cy, r, h, best[1])[1]

def umbrella(cx, cy, r, h, c1, c2, shaft_to, n=6):
    tip = (cx, cy - h)
    xs = [cx - r + 2 * r * k / n for k in range(n + 1)]
    g = [f'<path d="M{cx - r} {cy}C{cx - r} {cy - 1.35 * h:.1f} {cx + r} {cy - 1.35 * h:.1f} {cx + r} {cy}Z" fill="{c1}"/>']
    for k in range(n):
        if k % 2:
            a, b = xs[k], xs[k + 1]
            ca = ((a + cx) / 2 - (cx - a) * .25, cy - h * .9)
            cb = ((b + cx) / 2 - (cx - b) * .25, cy - h * .9)
            g.append(f'<path d="M{tip[0]} {tip[1]}Q{ca[0]:.1f} {ca[1]:.1f} {a:.1f} {cy}Q{(a + b) / 2:.1f} {cy - 7} {b:.1f} {cy}'
                     f'Q{cb[0]:.1f} {cb[1]:.1f} {tip[0]} {tip[1]}Z" fill="{c2}"/>')
    # festons du bord + baleines
    scal = f"M{xs[0]:.1f} {cy}" + "".join(f"Q{(a + b) / 2:.1f} {cy - 7} {b:.1f} {cy}" for a, b in zip(xs, xs[1:]))
    g.append(f'<path d="{scal}L{cx + r} {cy + 3}L{cx - r} {cy + 3}Z" fill="#000" opacity=".12"/>')
    ribs = "".join(f"M{tip[0]} {tip[1]}Q{(x + cx) / 2 - (cx - x) * .25:.1f} {cy - h * .9:.1f} {x:.1f} {cy}" for x in xs[1:-1])
    g.append(f'<path d="{ribs}" fill="none" stroke="#000" stroke-opacity=".15" stroke-width="1"/>')
    g.append(f'<path d="M{cx - r * .7:.1f} {cy - h * .55:.1f}Q{cx - r * .45:.1f} {cy - h * .95:.1f} {cx - r * .1:.1f} {cy - h * 1.0:.1f}" fill="none" stroke="#FFF" stroke-opacity=".45" stroke-width="3" stroke-linecap="round"/>')
    g.append(f'<path d="M{cx} {tip[1] - 7}V{tip[1] + 2}" stroke="#55555F" stroke-width="2.4" stroke-linecap="round"/>')
    for x in xs:
        g.append(f'<circle cx="{x:.1f}" cy="{cy + .5}" r="1.4" fill="#55555F"/>')
    shaft = (f'<path d="M{cx} {cy}V{shaft_to}" stroke="#6A6A74" stroke-width="2.2"/>'
             f'<path d="M{cx} {shaft_to - 2}V{shaft_to + 8}Q{cx} {shaft_to + 15} {cx - 6} {shaft_to + 15}Q{cx - 11} {shaft_to + 15} {cx - 11} {shaft_to + 9}" '
             f'fill="none" stroke="#7A4E2E" stroke-width="4" stroke-linecap="round"/>')
    return shaft, "".join(g)

def splashes(cx, cy, r, h, n):
    out_ = []
    for _ in range(n):
        t = random.uniform(.12, .88)
        x, y = dome_point(cx, cy, r, h, t)
        d = random.uniform(0, 1.2)
        dur = random.uniform(.8, 1.3)
        drops = ""
        for dx, dy in ((-6, -7), (0, -10), (6, -7)):
            drops += (f'<circle r="1.3" fill="#E6F2FF" class="gicle" style="--dx:{dx}px;--dy:{dy}px;'
                      f'animation-duration:{dur:.2f}s;animation-delay:{-d:.2f}s"/>')
        out_.append(f'<g transform="translate({x:.1f} {y - 1:.1f})">{drops}</g>')
    return "".join(out_)

# ---------------------------------------------------------------- pilules
css = []
def pill(cx, cy, r, h, x0, direction, delay, colA, cycle=8, spread=1.0):
    name = f"pil{len(css)}"
    y_land = dome_y(cx, cy, r, h, x0)
    frames = [(0, x0, -30, 0, 1), (11, x0, y_land - 4, 200, 1)]
    xb = x0 + direction * 8
    frames.append((15, xb, dome_y(cx, cy, r, h, xb) - 20, 300, 1))
    x1 = x0 + direction * 14
    frames.append((19, x1, dome_y(cx, cy, r, h, x1) - 4, 380, 1))
    edge = cx + direction * r
    for k in range(1, 6):
        x = x1 + (edge - x1) * k / 5
        frames.append((19 + 3 * k, x, dome_y(cx, cy, r, h, x) - 4, 380 + 120 * k, 1))
    frames.append((44, edge + direction * 18 * spread, GROUND - 4, 1200, 1))
    frames.append((48, edge + direction * 24 * spread, GROUND - 12, 1300, 1))
    frames.append((52, edge + direction * 28 * spread, GROUND - 4, 1380, 1))
    frames.append((72, edge + direction * 28 * spread, GROUND - 4, 1380, 1))
    frames.append((80, edge + direction * 28 * spread, GROUND - 4, 1380, 0))
    frames.append((99.9, x0, -30, 0, 0))
    frames.append((100, x0, -30, 0, 1))
    body = "".join(f"{p}%{{transform:translate({x:.1f}px,{y:.1f}px) rotate({rot}deg);opacity:{o}}}" for p, x, y, rot, o in frames)
    css.append(f"@keyframes {name}{{{body}}}")
    return (f'<g style="animation:{name} {cycle}s linear infinite;animation-delay:{delay}s">'
            f'<path d="M0-3.4H-4.4A3.4 3.4 0 0 0-4.4 3.4H0Z" fill="{colA}"/>'
            f'<path d="M0-3.4H4.4A3.4 3.4 0 0 1 4.4 3.4H0Z" fill="#FFFFFF"/>'
            f'<rect x="-7.8" y="-3.4" width="15.6" height="6.8" rx="3.4" fill="none" stroke="#5A5A66" stroke-width=".7"/>'
            f'<path d="M-5.5-1.6H4" stroke="#FFF" stroke-opacity=".7" stroke-width="1" stroke-linecap="round"/></g>')

# ---------------------------------------------------------------- pluie
def rain_layer(n, color, width, length, op, dur):
    lines = []
    for _ in range(n):
        x, y = random.uniform(-10, 410), random.uniform(0, 500)
        L = length * random.uniform(.7, 1.2)
        for yy in (y, y - 500):
            lines.append(f"M{x:.1f} {yy:.1f}l-2 {L:.1f}")
    return (f'<g style="animation:pluie {dur}s linear infinite" opacity="{op}">'
            f'<path d="{"".join(lines)}" stroke="{color}" stroke-width="{width}" stroke-linecap="round"/></g>')

# ---------------------------------------------------------------- personnages
LUI_TETE = '''
    <ellipse cx="-15.6" cy="2" rx="3.3" ry="5.2" fill="#C9907A"/><ellipse cx="15.6" cy="2" rx="3.3" ry="5.2" fill="#C9907A"/>
    <path d="M-15-4C-15-16-8-21 0-21C8-21 15-16 15-4V4C15 14 8 21 0 21C-8 21-15 14-15 4Z" fill="#E3AE90"/>
    <path d="M-15 1C-15 14-8 22.5 0 22.5C8 22.5 15 14 15 1C13 8.5 9.5 12 6 12Q3 9.5 0 10Q-3 9.5-6 12C-9.5 12-13 8.5-15 1Z" fill="#5A4030" opacity=".9"/>
    <path d="M-6.5 10.4Q0 7.2 6.5 10.4Q0 9.2-6.5 10.4Z" fill="#4A3326"/>
    <path d="M-5 13Q0 17 5 12.6" fill="none" stroke="#A85E58" stroke-width="1.4" stroke-linecap="round"/>
    <path d="M-2.6 7.3Q0 8.7 2.6 7.3" fill="none" stroke="#B07A60" stroke-width="1" stroke-linecap="round"/>
    <path d="M-9-.8Q-6 1.6-3-.8M3-.8Q6 1.6 9-.8" fill="none" stroke="#2A1E18" stroke-width="1.3" stroke-linecap="round"/>
    <path d="M-10.8-6.2Q-6.6-8.8-2.4-7M2.4-7Q6.6-8.8 10.8-6.2" fill="none" stroke="#3A2A1F" stroke-width="2.3" stroke-linecap="round"/>
    <g fill="#BFD9F2" fill-opacity=".15" stroke="#C9B48A" stroke-width="1.1"><circle cx="-6" cy="-1" r="5.6"/><circle cx="6" cy="-1" r="5.6"/></g>
    <path d="M-.5-1.8Q0-2.8.5-1.8M-11.6-1.6L-15.2-2.4M11.6-1.6L15.2-2.4" fill="none" stroke="#C9B48A" stroke-width="1.1"/>
    <path d="M-15.6-2C-17-13-14.5-21-9-25.5C-6-31.5 2-33.5 8-30.5C14-29.5 18-23.5 16.6-15.5C16.7-9.5 16.2-5.5 15.6-2C14.6-8.5 13-12.5 10.5-13.6C7.5-16.4 2-15.6-2-16.6C-7-15.8-11-13.8-13.4-10C-14.5-8-15.1-5.5-15.6-2Z" fill="#3E2A1F"/>
    <path d="M-10-25Q-7-31.5-2-31Q2-35 6.5-31.5Q11.5-32.5 13-27.5Q17-26 16.5-21" fill="#3E2A1F"/>
    <path d="M-8-21Q-4-27.5 2-27M1-20.5Q6-27 11-24M-11.5-16.5Q-9.5-22-5-23.5M7-17Q11-20.5 14-18" fill="none" stroke="#6E5038" stroke-width="1.1" stroke-linecap="round"/>
    <path d="M-3-31Q0-33.5 3-32.6M6-31Q9.5-31.5 12-28.5" fill="none" stroke="#8A6A4C" stroke-width="1.3" stroke-linecap="round"/>'''

ELLE_TETE = '''
    <path d="M-14-6C-16-18-8-22 0-22C8-22 16-18 14-6C16 6 18 18 16 30C14 36 10 34 9 30C10 22 8 14 6 10H-6C-8 16-10 24-12 32C-14 38-20 36-19 28C-18 16-16 6-14-6Z" fill="#2A1A14"/>
    <path d="M-16 6Q-19 16-15 24M13 4Q16 14 13 22M-14 14Q-17 22-16 30" fill="none" stroke="#4A3024" stroke-width="1.1" stroke-linecap="round"/>
    <path d="M-12-4C-12-13-6-17 0-17C6-17 12-13 12-4V2C12 11 6 17 0 17C-6 17-12 11-12 2Z" fill="#C98E6E"/>
    <path d="M-13-2C-14-14-7-20 0-20C7-20 14-14 13-2C12-9 9-13 5-14Q0-15.5-5-14C-9-13-12-9-13-2Z" fill="#2A1A14"/>
    <path d="M-8-19Q-11-24-8-27M0-20Q0-26 4-27M7-18Q11-22 14-20" fill="none" stroke="#2A1A14" stroke-width=".9" stroke-linecap="round"/>
    <ellipse cx="-7" cy="5" rx="3" ry="1.8" fill="#E07A8A" opacity=".45"/><ellipse cx="7" cy="5" rx="3" ry="1.8" fill="#E07A8A" opacity=".45"/>
    <path d="M-9-5Q-6-7.2-2.5-5.6M2.5-5.6Q6-7.2 9-5" fill="none" stroke="#2A1A14" stroke-width="1.9" stroke-linecap="round"/>
    <path d="M-8-.5Q-5.5 1.8-3-.5M3-.5Q5.5 1.8 8-.5" fill="none" stroke="#2A1A14" stroke-width="1.3" stroke-linecap="round"/>
    <path d="M-2 6.2Q0 7.3 2 6.2" fill="none" stroke="#A8705A" stroke-width="1" stroke-linecap="round"/>
    <path d="M-5 10Q0 15 5 10Q0 11.5-5 10Z" fill="#FFF8F4" stroke="#B8596A" stroke-width="1" stroke-linejoin="round"/>
    <g transform="translate(-12.8 7)"><path d="M0-4.5V4.5M-4.5 0H4.5M-3.2-3.2L3.2 3.2M-3.2 3.2L3.2-3.2" stroke="#E8C15A" stroke-width="1.1" stroke-linecap="round"/><circle r="2" fill="#E8C15A"/></g>
    <g transform="translate(12.8 7)"><path d="M0-4.5V4.5M-4.5 0H4.5M-3.2-3.2L3.2 3.2M-3.2 3.2L3.2-3.2" stroke="#E8C15A" stroke-width="1.1" stroke-linecap="round"/><circle r="2" fill="#E8C15A"/></g>'''

def kid_face(cx, cy, r, girl):
    skin = "#F0C7A6"
    g = f'<circle cx="{cx}" cy="{cy}" r="{r}" fill="{skin}"/>'
    g += f'<ellipse cx="{cx - r:.1f}" cy="{cy + 1}" rx="2.4" ry="3.2" fill="#E2B08E"/><ellipse cx="{cx + r:.1f}" cy="{cy + 1}" rx="2.4" ry="3.2" fill="#E2B08E"/>'
    if girl:
        g += (f'<path d="M{cx - r - 1:.1f} {cy - 1}C{cx - r:.1f} {cy - r - 4:.1f} {cx + r:.1f} {cy - r - 4:.1f} {cx + r + 1:.1f} {cy - 1}'
              f'Q{cx + r - 2:.1f} {cy - r * .55:.1f} {cx + 3} {cy - r * .6:.1f}Q{cx} {cy - r * .2:.1f} {cx - 3} {cy - r * .6:.1f}Q{cx - r + 2:.1f} {cy - r * .55:.1f} {cx - r - 1:.1f} {cy - 1}Z" fill="#3A2419"/>')
        g += (f'<path d="M{cx} {cy - r - 2:.1f}q-6-8 0-12q6 4 0 12Z" fill="#3A2419"/><path d="M{cx - 3} {cy - r - 3:.1f}h6" stroke="#F28CB8" stroke-width="3" stroke-linecap="round"/>'
              f'<path d="M{cx - r:.1f} {cy + 2}q-3 4 0 7M{cx + r:.1f} {cy + 2}q3 4 0 7" fill="none" stroke="#3A2419" stroke-width="1.6" stroke-linecap="round"/>')
    else:
        g += (f'<path d="M{cx - r - 1:.1f} {cy}C{cx - r - 2:.1f} {cy - r - 3:.1f} {cx + r + 2:.1f} {cy - r - 3:.1f} {cx + r + 1:.1f} {cy}'
              f'Q{cx + r - 2:.1f} {cy - r * .45:.1f} {cx + 4} {cy - r * .5:.1f}L{cx + 1} {cy - r * .3:.1f}L{cx - 2} {cy - r * .55:.1f}Q{cx - r + 2:.1f} {cy - r * .45:.1f} {cx - r - 1:.1f} {cy}Z" fill="#5A3A26"/>'
              f'<path d="M{cx - 2} {cy - r - 1:.1f}q3-5 6-3" fill="none" stroke="#5A3A26" stroke-width="2" stroke-linecap="round"/>')
    g += (f'<circle cx="{cx - r * .4:.1f}" cy="{cy + 1}" r="1.5" fill="#2A1E18"/><circle cx="{cx + r * .4:.1f}" cy="{cy + 1}" r="1.5" fill="#2A1E18"/>'
          f'<circle cx="{cx - r * .4 + .5:.1f}" cy="{cy + .4}" r=".5" fill="#FFF"/><circle cx="{cx + r * .4 + .5:.1f}" cy="{cy + .4}" r=".5" fill="#FFF"/>'
          f'<ellipse cx="{cx - r * .62:.1f}" cy="{cy + r * .4:.1f}" rx="2.4" ry="1.5" fill="#F08A8A" opacity=".5"/><ellipse cx="{cx + r * .62:.1f}" cy="{cy + r * .4:.1f}" rx="2.4" ry="1.5" fill="#F08A8A" opacity=".5"/>'
          f'<path d="M{cx - 3.5} {cy + r * .42:.1f}Q{cx} {cy + r * .42 + 5:.1f} {cx + 3.5} {cy + r * .42:.1f}Z" fill="#B8505A"/>')
    return g

# ---------------------------------------------------------------- assemblage
U_COUPLE = (150, 205, 100, 70)
U_GARCON = (281, 336, 42, 30)
U_FILLE = (360, 346, 34, 26)

shaft_c, can_c = umbrella(*U_COUPLE, "#E2473B", "#F26B57", 300)
shaft_g, can_g = umbrella(*U_GARCON, "#3E8FD8", "#64AAEE", 398)
shaft_f, can_f = umbrella(*U_FILLE, "#F28CB8", "#F8B0CF", 398)

pills = "".join([
    pill(*U_COUPLE, 112, -1, 0, "#E2473B"),
    pill(*U_GARCON, 296, 1, 0, "#3E8FD8"),
    pill(*U_COUPLE, 76, -1, -3.4, "#F4C430"),
    pill(*U_FILLE, 368, 1, -5.6, "#9B6BD6", spread=.2),
])

svg = f'''<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 500" width="400" height="500">
<title>Trois parapluies sous la pluie (et quelques pilules)</title>
<defs>
  <linearGradient id="ciel" x1="0" y1="0" x2="0" y2="1">
    <stop offset="0" stop-color="#9FB1C4"/><stop offset=".7" stop-color="#C9D4DF"/><stop offset="1" stop-color="#D6DEE6"/>
  </linearGradient>
  <linearGradient id="sol" x1="0" y1="0" x2="0" y2="1">
    <stop offset="0" stop-color="#8F9CAB"/><stop offset="1" stop-color="#5E6B7B"/>
  </linearGradient>
  <filter id="flou" x="-30%" y="-30%" width="160%" height="160%"><feGaussianBlur stdDeviation="4"/></filter>
</defs>
<style>
  @keyframes pluie{{from{{transform:translateY(0)}}to{{transform:translateY(500px)}}}}
  .gicle{{animation:gicle 1s ease-out infinite}}
  @keyframes gicle{{0%{{transform:translate(0,0) scale(.6);opacity:0}}10%{{opacity:1}}60%{{transform:translate(var(--dx),var(--dy)) scale(1);opacity:.9}}100%{{transform:translate(calc(var(--dx) * 1.4),0px) scale(.4);opacity:0}}}}
  .ombrelle{{animation:ombrelle 3s ease-in-out infinite alternate;transform-origin:150px 300px}}
  @keyframes ombrelle{{from{{transform:rotate(-1.5deg)}}to{{transform:rotate(1.5deg)}}}}
  .couple{{animation:couple 3.6s ease-in-out infinite}}
  @keyframes couple{{0%,100%{{transform:translateY(0)}}50%{{transform:translateY(1.5px)}}}}
  .saut{{animation:saut 4s ease-in-out infinite}}
  @keyframes saut{{0%,20%,100%{{transform:translateY(0)}}4%{{transform:translateY(2px)}}10%{{transform:translateY(-17px)}}16%{{transform:translateY(0)}}18%{{transform:translateY(2px)}}}}
  .eclabousse{{animation:eclabousse 4s ease-out infinite}}
  @keyframes eclabousse{{0%,15%{{transform:translate(0,0);opacity:0}}16%{{opacity:1}}26%{{transform:translate(var(--dx),var(--dy));opacity:1}}34%,100%{{transform:translate(calc(var(--dx) * 1.5),6px);opacity:0}}}}
  .ronds{{animation:ronds 2s ease-out infinite}}
  @keyframes ronds{{from{{transform:scale(.2);opacity:.9}}to{{transform:scale(1.4);opacity:0}}}}
  .dandine{{animation:dandine 1.6s ease-in-out infinite alternate;transform-origin:352px 452px}}
  @keyframes dandine{{from{{transform:rotate(-3deg)}}to{{transform:rotate(3deg)}}}}
  {"".join(css)}
</style>

<!-- ciel gris doux + immeubles au loin -->
<rect width="400" height="500" fill="url(#ciel)"/>
<g fill="#B3C0CE">
  <path d="M0 330V170H40V150L60 136L80 150V170H120V330Z"/>
  <path d="M120 330V190H170V176H176V190H220V330Z"/>
  <path d="M220 330V160L240 148H300L320 160V330Z"/>
  <path d="M320 330V182H360V170H366V182H400V330Z"/>
</g>
<g fill="#C9D4DF">
  {"".join(f'<rect x="{x}" y="{y}" width="8" height="12" rx="1"/>' for x in range(10, 400, 26) for y in range(186, 320, 28))}
</g>

<!-- pluie de fond -->
{rain_layer(70, "#FFFFFF", 1, 12, .45, 1.1)}

<!-- trottoir mouillé -->
<rect x="0" y="420" width="400" height="80" fill="url(#sol)"/>
<path d="M0 436H400M0 464H400M0 492H400" stroke="#FFFFFF" stroke-opacity=".12" stroke-width="1"/>
<g filter="url(#flou)" opacity=".35">
  <ellipse cx="150" cy="470" rx="80" ry="10" fill="#E2473B"/><ellipse cx="281" cy="470" rx="34" ry="6" fill="#3E8FD8"/><ellipse cx="360" cy="470" rx="28" ry="5" fill="#F28CB8"/>
</g>
<!-- flaque du petit garçon -->
<ellipse cx="281" cy="452" rx="46" ry="7.5" fill="#8DB4D6" opacity=".75"/>
<ellipse cx="281" cy="452" rx="46" ry="7.5" fill="none" stroke="#DDEBF7" stroke-width="1" opacity=".7"/>
<g transform="translate(262 452) scale(1 .25)"><circle r="14" fill="none" stroke="#FFF" stroke-width="2" class="ronds"/></g>
<g transform="translate(300 453) scale(1 .25)"><circle r="12" fill="none" stroke="#FFF" stroke-width="2" class="ronds" style="animation-delay:-1s"/></g>

<!-- ============ NOUS DEUX sous le grand parapluie rouge ============ -->
<g class="couple">
  <!-- lui : jambes, parka marine -->
  <path d="M150 360L148 444H170L175 380L180 444H202L200 360Z" fill="#2A2E3D"/>
  <ellipse cx="159" cy="448" rx="13" ry="5" fill="#3A3030"/><ellipse cx="191" cy="448" rx="13" ry="5" fill="#3A3030"/>
  <path d="M168 254H182V266H168Z" fill="#D9A285"/>
  <path d="M150 266Q175 258 200 266Q210 272 210 290L214 364Q175 372 136 364L140 290Q140 272 150 266Z" fill="#2C3550"/>
  <path d="M154 266Q175 252 196 266Q188 272 175 272Q162 272 154 266Z" fill="#232B44"/>
  <path d="M170 266L175 278L180 266Z" fill="#F1EEE6"/>
  <path d="M175 278V364" stroke="#4A5578" stroke-width="1.4"/>
  <path d="M146 326H162V340H146ZM188 326H204V340H188Z" fill="none" stroke="#4A5578" stroke-width="1.1"/>
  <path d="M204 274Q220 310 210 342" fill="none" stroke="#2C3550" stroke-width="15" stroke-linecap="round"/>
  <ellipse cx="210" cy="347" rx="6" ry="7" fill="#E3AE90"/>

  <!-- elle : jambes, bottes, trench beige -->
  <path d="M112 390L110 434H124L128 400L132 434H146L144 390Z" fill="#3A2E2E"/>
  <path d="M108 430H125V452H106Q105 444 108 430ZM131 430H148Q151 444 150 452H131Z" fill="#6B4430"/>
  <path d="M123 290H133V302H123Z" fill="#C98E6E"/>
  <path d="M108 302Q128 294 148 302Q156 308 156 322L160 394Q128 400 96 394L100 322Q100 308 108 302Z" fill="#C9A97A"/>
  <path d="M117 300L128 326L139 300Z" fill="#5F7A5A"/>
  <path d="M116 302L128 330M140 302L128 330" stroke="#B08E60" stroke-width="2"/>
  <path d="M98 348Q128 354 158 348" fill="none" stroke="#A8865A" stroke-width="5"/>
  <rect x="123" y="346" width="10" height="8" rx="1.5" fill="none" stroke="#7A5E3A" stroke-width="1.4"/>
  <g fill="#8A6E48"><circle cx="120" cy="336" r="1.4"/><circle cx="136" cy="336" r="1.4"/><circle cx="120" cy="364" r="1.4"/><circle cx="136" cy="364" r="1.4"/></g>
  <path d="M104 310Q92 340 102 366" fill="none" stroke="#C9A97A" stroke-width="12" stroke-linecap="round"/>

  <!-- le grand parapluie (manche tenu par lui) -->
  <g class="ombrelle">{shaft_c}{can_c}
    {splashes(*U_COUPLE, 10)}
  </g>
  <!-- lui tient le manche ; elle lui prend le bras -->
  <path d="M148 274Q132 296 146 306" fill="none" stroke="#2C3550" stroke-width="15" stroke-linecap="round"/>
  <ellipse cx="150" cy="306" rx="6.5" ry="7" fill="#E3AE90"/>
  <path d="M145 304H155M145 308H155" stroke="#D4D4DC" stroke-width="1.4"/>
  <path d="M148 310Q160 330 150 300" fill="none" stroke="#C9A97A" stroke-width="10" stroke-linecap="round"/>
  <ellipse cx="146" cy="296" rx="5" ry="6" fill="#C98E6E"/>
  <path d="M142.5 294H149" stroke="#E8C15A" stroke-width="1.3"/>

  <!-- têtes -->
  <g transform="translate(175 240) scale(.82)">{LUI_TETE}</g>
  <g transform="translate(127 277) rotate(8) scale(.85)">{ELLE_TETE}</g>
</g>

<!-- ============ SON FILS (3 ans) qui saute dans la flaque ============ -->
<g class="saut">
  <path d="M271 416H279V440H271ZM283 416H291V440H283Z" fill="#2F3E5C"/>
  <path d="M267 434H281V452H266Q265 444 267 434ZM282 434H296Q298 444 297 452H282Z" fill="#D9342B"/>
  <path d="M268 437H280M283 437H295" stroke="#F06A5E" stroke-width="1.5"/>
  <path d="M264 372Q280 366 296 372Q302 378 302 390L306 422Q280 428 254 422L258 390Q258 378 264 372Z" fill="#F4C430"/>
  <path d="M266 370Q280 360 294 370Q288 376 280 376Q272 376 266 370Z" fill="#E0AE1C"/>
  <path d="M280 378V424" stroke="#D49F12" stroke-width="1.2"/>
  <g fill="#7A5A1E"><rect x="276" y="386" width="8" height="2.4" rx="1.2"/><rect x="276" y="398" width="8" height="2.4" rx="1.2"/><rect x="276" y="410" width="8" height="2.4" rx="1.2"/></g>
  {shaft_g}
  <path d="M263 378Q262 392 276 396M297 378Q300 392 286 396" fill="none" stroke="#F4C430" stroke-width="9" stroke-linecap="round"/>
  <circle cx="278" cy="397" r="4" fill="#F0C7A6"/><circle cx="285" cy="396" r="4" fill="#F0C7A6"/>
  {kid_face(280, 356, 13, False)}
  {can_g}
  {splashes(*U_GARCON, 5)}
</g>
<!-- éclaboussures quand il retombe -->
<g transform="translate(281 448)" fill="#CFE3F5">
  <circle r="2.2" class="eclabousse" style="--dx:-30px;--dy:-20px"/><circle r="1.8" class="eclabousse" style="--dx:-18px;--dy:-28px"/>
  <circle r="2" class="eclabousse" style="--dx:26px;--dy:-22px"/><circle r="1.6" class="eclabousse" style="--dx:36px;--dy:-14px"/>
  <circle r="1.5" class="eclabousse" style="--dx:6px;--dy:-30px"/>
</g>

<!-- ============ SA FILLE (1 an et demi) qui se dandine ============ -->
<g class="dandine">
  <path d="M346 420H352V438H346ZM355 420H361V438H355Z" fill="#F4F0F4"/>
  <path d="M342 434H353V452H341Q340 444 342 434ZM354 434H365Q367 444 366 452H354Z" fill="#F4C430"/>
  <g fill="#FFFFFF"><circle cx="347" cy="442" r="1.3"/><circle cx="360" cy="446" r="1.3"/></g>
  <path d="M338 386Q352 380 366 386Q372 392 372 404L376 428Q352 434 328 428L332 404Q332 392 338 386Z" fill="#F28CB8"/>
  <g fill="#FFFFFF" opacity=".85"><circle cx="342" cy="398" r="1.8"/><circle cx="356" cy="394" r="1.8"/><circle cx="364" cy="408" r="1.8"/><circle cx="348" cy="412" r="1.8"/><circle cx="338" cy="420" r="1.8"/><circle cx="360" cy="422" r="1.8"/></g>
  {shaft_f}
  <path d="M368 390Q372 398 362 400" fill="none" stroke="#F28CB8" stroke-width="8" stroke-linecap="round"/>
  <circle cx="361" cy="400" r="3.6" fill="#F0C7A6"/>
  <path d="M336 390Q326 402 330 412" fill="none" stroke="#F28CB8" stroke-width="8" stroke-linecap="round"/>
  <circle cx="330" cy="414" r="3.4" fill="#F0C7A6"/>
  {kid_face(352, 373, 12, True)}
  {can_f}
  {splashes(*U_FILLE, 4)}
</g>

<!-- pluie de devant -->
{rain_layer(45, "#F4F8FC", 1.3, 16, .6, .8)}

<!-- les pilules, de temps en temps, à la place des gouttes -->
{pills}
</svg>
'''
open(out, "w").write(svg)
print("ok", len(svg))
