56 lines
3.5 KiB
Python
56 lines
3.5 KiB
Python
import sys
|
|
NAR, LUZ, CLARA, INK, BL = "#f04e23", "#f45a1c", "#ffb03a", "#111", "#fff"
|
|
|
|
# La luz baja de la cabeza, llega al suelo y se abre en un charco (naranja por fuera, claro en el centro).
|
|
CONOS = {
|
|
"recta": "M57,33 H77 L98,92 H36 Z",
|
|
"onda-suave": "M57,33 H77 C82,46 85,55 85,62 C85,69 88,73 89,76 H41 C42,72 45,69 45,62 C45,54 51,45 57,33 Z",
|
|
"campana": "M57,33 H77 C78,52 82,66 92,76 H38 C48,66 56,52 57,33 Z",
|
|
"onda": "M57,33 H77 C86,42 80,52 86,61 C90,67 91,72 90,76 H40 C39,72 41,67 44,61 C48,52 44,42 57,33 Z",
|
|
}
|
|
CHARCO = {"onda-suave": 24, "campana": 27, "onda": 25}
|
|
|
|
def luz_(cono, luz, clara, ink, suelo=False):
|
|
out = f'<path d="{CONOS[cono]}" fill="{luz}"/>'
|
|
if cono in CHARCO:
|
|
rx, ry = CHARCO[cono], 5.5
|
|
out += (f'<ellipse cx="65" cy="76" rx="{rx}" ry="{ry}" fill="{luz}"/>'
|
|
f'<ellipse cx="65" cy="76" rx="{rx * .62:.1f}" ry="{ry * .55:.1f}" fill="{clara}"/>')
|
|
if cono == "recta":
|
|
out += f'<ellipse cx="67" cy="86" rx="22" ry="5" fill="{ink}" opacity=".25"/>'
|
|
if suelo:
|
|
out += f'<path d="M8,84 H92" stroke="{ink}" stroke-width="3"/>'
|
|
return out
|
|
|
|
def farola(estilo="aro", ink=INK, luz=LUZ, fondo=None, papel=BL, clara=CLARA, cono="campana", suelo=False):
|
|
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'<g clip-path="url(#c)">{luz_(cono, luz, clara, ink, suelo)}</g>'
|
|
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"/>'
|
|
return defs + cono + f'<g clip-path="url(#c)">{poste}</g>' + cabeza + aro
|
|
pegatina = f'<circle cx="50" cy="50" r="48" fill="{luz}"/>'
|
|
poste = f'<path d="M33,99 V38 Q33,22 49,22 H58" fill="none" stroke="{ink}" stroke-width="9"/>'
|
|
cabeza = f'<rect x="52" y="17" width="30" height="11" rx="3" fill="{ink}"/>'
|
|
rayos = "".join(f'<path d="M{x0},{y0} L{x1},{y1}" stroke="{papel}" stroke-width="4" stroke-linecap="round"/>'
|
|
for x0, y0, x1, y1 in ((58, 35, 50, 52), (67, 36, 67, 56), (76, 35, 84, 52)))
|
|
return f'<defs><clipPath id="c"><circle cx="50" cy="50" r="48"/></clipPath></defs>{pegatina}<g clip-path="url(#c)">{poste}</g>{cabeza}{rayos}'
|
|
|
|
def svg(cuerpo, fondo=None):
|
|
bg = f'<rect width="100" height="100" fill="{fondo}"/>' if fondo else ""
|
|
return f'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" width="100" height="100">{bg}{cuerpo}</svg>\n'
|
|
|
|
if __name__ == "__main__":
|
|
d = sys.argv[1]
|
|
open(f"{d}/simbolo.svg", "w").write(svg(farola()))
|
|
open(f"{d}/simbolo-negativo.svg", "w").write(svg(farola(ink=BL, papel=INK), INK))
|
|
open(f"{d}/simbolo-naranja.svg", "w").write(svg(farola(luz=BL, papel=NAR, clara="#ffe2a8"), NAR))
|
|
open(f"{d}/simbolo-pegatina.svg", "w").write(svg(farola("pegatina")))
|
|
# Propuestas que no se usan, para tenerlas a mano
|
|
import os
|
|
os.makedirs(f"{d}/propuestas", exist_ok=True)
|
|
for n, (cono, suelo) in enumerate((("onda-suave", False), ("campana", False), ("onda", False), ("campana", True)), 1):
|
|
open(f"{d}/propuestas/farola-{n}-{cono}{'-suelo' if suelo else ''}.svg", "w").write(svg(farola(cono=cono, suelo=suelo)))
|
|
open(f"{d}/propuestas/farola-recta.svg", "w").write(svg(farola(cono="recta")))
|