Farola con la luz ondeando como una bandera; el dibujo a todo lo ancho y más bajo en móvil

This commit is contained in:
hacklab 2026-10-14 12:56:17 +02:00
parent 8f798b33fd
commit 3e9f2af4af
13 changed files with 32 additions and 24 deletions

View file

@ -1,21 +1,29 @@
import sys
NAR, LUZ, INK, BL = "#f04e23", "#f45a1c", "#111", "#fff"
def onda(a, b, amp):
def ctrl(a, b, amp):
(x0, y0), (x1, y1) = a, b
dx, dy = x1 - x0, y1 - y0
L = (dx * dx + dy * dy) ** .5
px, py = -dy / L * amp, dx / L * amp
c1 = (x0 + dx / 3 + px, y0 + dy / 3 + py)
c2 = (x0 + dx * 2 / 3 - px, y0 + dy * 2 / 3 - py)
return f"C{c1[0]:.1f},{c1[1]:.1f} {c2[0]:.1f},{c2[1]:.1f} {x1},{y1}"
return (x0 + dx / 3 + px, y0 + dy / 3 + py), (x0 + dx * 2 / 3 - px, y0 + dy * 2 / 3 - py)
def c(p1, p2, fin):
return f"C{p1[0]:.1f},{p1[1]:.1f} {p2[0]:.1f},{p2[1]:.1f} {fin[0]},{fin[1]}"
def bandera(a, b, cc, d, amp, amp_b):
der = ctrl(b, cc, amp)
izq = ctrl(a, d, amp)
abajo = ctrl(cc, d, amp_b)
return (f"M{a[0]},{a[1]} H{b[0]} {c(der[0], der[1], cc)} {c(abajo[0], abajo[1], d)} "
f"{c(izq[1], izq[0], a)} Z")
def farola(estilo="aro", ink=INK, luz=LUZ, fondo=None, papel=BL):
bg = f'<rect width="100" height="100" fill="{fondo}"/>' if fondo else ""
if estilo == "aro":
defs = '<defs><clipPath id="c"><circle cx="50" cy="50" r="42"/></clipPath></defs>'
cono = f'<path d="M57,33 H77 {onda((77, 33), (98, 92), 3.5)} H36 {onda((36, 92), (57, 33), 3.5)} Z" fill="{luz}" clip-path="url(#c)"/>'
suelo = f'<ellipse cx="67" cy="86" rx="22" ry="5" fill="{ink}" clip-path="url(#c)" opacity=".25"/>'
cono = f'<path d="{bandera((57, 33), (77, 33), (94, 84), (42, 84), -7, 5)}" fill="{luz}" clip-path="url(#c)"/>'
suelo = ""
poste = f'<path d="M37,96 V40 Q37,25 52,25 H60" fill="none" stroke="{ink}" stroke-width="8"/>'
cabeza = f'<rect x="55" y="21" width="27" height="11" rx="3" fill="{ink}"/>'
aro = f'<circle cx="50" cy="50" r="45" fill="none" stroke="{ink}" stroke-width="7"/>'