takethestreet/tools/farola.py
2026-10-14 12:39:14 +02:00

32 lines
2.1 KiB
Python

import sys
NAR, AMA, INK = "#f04e23", "#f2b705", "#111"
def estrella(cx, cy, r, col, borde=None, bw=0):
k = r * .22
d = (f"M{cx},{cy - r} Q{cx + k},{cy - k} {cx + r},{cy} Q{cx + k},{cy + k} {cx},{cy + r} "
f"Q{cx - k},{cy + k} {cx - r},{cy} Q{cx - k},{cy - k} {cx},{cy - r} Z")
b = f' stroke="{borde}" stroke-width="{bw}" stroke-linejoin="round"' if borde else ""
return f'<path d="{d}" fill="{col}"{b}/>'
def farola(ink=INK, rell=NAR, fondo=None, brillo="#fff"):
bg = f'<rect width="100" height="100" fill="{fondo}"/>' if fondo else ""
eje = "M27,99 V38 Q27,15 50,15 H62"
cabeza = "M56,9 Q60,4 74,4 Q90,4 94,12 Q96,18 88,20 H62 Q54,20 54,15 Q54,11 56,9 Z"
luz = f'<path d="M63,22 H88 L98,90 H50 Z" fill="{AMA}" opacity=".28"/><path d="M68,22 H83 L88,90 H58 Z" fill="{rell}" opacity=".35"/>'
gotas = "".join(f'<path d="M{x - w},{y0} L{x + w},{y0} L{x + w * .7},{y1} Q{x},{y1 + w * 1.7} {x - w * .7},{y1} Z" fill="{ink}"/>'
for x, w, y0, y1 in ((23.5, 2.2, 60, 72), (65, 1.8, 20, 28), (90, 1.5, 19, 25)))
return (f'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" width="100" height="100">{bg}{luz}'
f'<path d="{eje}" fill="none" stroke="{ink}" stroke-width="17" stroke-linecap="round"/>'
f'<path d="{cabeza}" fill="{ink}" stroke="{ink}" stroke-width="7" stroke-linejoin="round"/>'
f'{gotas}'
f'<path d="{eje}" fill="none" stroke="{rell}" stroke-width="8" stroke-linecap="round"/>'
f'<path d="{cabeza}" fill="{rell}"/>'
f'<path d="M24.5,80 V52 M24.5,46 V43" stroke="{brillo}" stroke-width="2.4" stroke-linecap="round"/>'
f'<path d="M62,10 Q66,7 74,7" fill="none" stroke="{brillo}" stroke-width="2.4" stroke-linecap="round"/>'
f'{estrella(76, 52, 13, AMA, ink, 2.5)}{estrella(62, 74, 7, brillo, ink, 2)}</svg>\n')
if __name__ == "__main__":
d = sys.argv[1]
open(f"{d}/simbolo.svg", "w").write(farola())
open(f"{d}/simbolo-negativo.svg", "w").write(farola(fondo=INK, ink="#fff"))
open(f"{d}/simbolo-naranja.svg", "w").write(farola(fondo=NAR, rell="#fff", brillo=NAR))