50 lines
3.1 KiB
Python
50 lines
3.1 KiB
Python
# Genera el símbolo: un faro dentro de un aro grueso, como un emblema de tienda de graffiti.
|
|
# La luz es amarilla: un haz horizontal que se abre hacia los dos lados y un halo en círculo.
|
|
import sys
|
|
INK, BL, NAR, ROJO = "#111", "#fff", "#f04e23", "#e3141b"
|
|
LUZ, CLARA = "#ffc21a", "#fff4b8"
|
|
CX, CY = 50, 36 # centro de la linterna
|
|
|
|
def luz_(luz, clara):
|
|
# Haz: dos cuñas horizontales que se ensanchan hacia fuera, y ondas en círculo alrededor.
|
|
haz = (f'<path d="M{CX},{CY - 3} L0,{CY - 17} V{CY + 17} L{CX},{CY + 3} L100,{CY + 17} V{CY - 17} Z" fill="{luz}" opacity=".9"/>')
|
|
ondas = "".join(f'<circle cx="{CX}" cy="{CY}" r="{r}" fill="none" stroke="{luz}" stroke-width="{w}" opacity="{o}"/>'
|
|
for r, w, o in ((19, 3, .9), (27, 2.2, .55)))
|
|
halo = f'<circle cx="{CX}" cy="{CY}" r="12" fill="{luz}"/><circle cx="{CX}" cy="{CY}" r="6.5" fill="{clara}"/>'
|
|
return haz + ondas + halo
|
|
|
|
def torre(ink, raya, clip):
|
|
# Torre que se estrecha hacia arriba, en espiral negra y roja (franjas en diagonal), la linterna y el tejado en punta.
|
|
forma = "M42,46 H58 L65,100 H35 Z"
|
|
cuerpo = f'<clipPath id="{clip}t"><path d="{forma}"/></clipPath><path d="{forma}" fill="{ink}"/>'
|
|
franjas = "".join(f'<path d="M30,{y + 9} L70,{y - 3} V{y + 6} L30,{y + 18} Z" fill="{raya}"/>' for y in (50, 68, 86))
|
|
balcon = f'<rect x="39" y="43" width="22" height="4" rx="1" fill="{ink}"/>'
|
|
linterna = f'<path d="M44,43 V31 M56,43 V31" stroke="{ink}" stroke-width="2.6"/>'
|
|
tejado = f'<path d="M41,31 L50,21 L59,31 Z" fill="{ink}"/>'
|
|
return cuerpo + f'<g clip-path="url(#{clip}t)">{franjas}</g>' + balcon + linterna + tejado
|
|
|
|
def faro(estilo="aro", ink=INK, luz=LUZ, raya=ROJO, clara=CLARA, clip="c", grueso=7, fondo_aro=None):
|
|
if estilo == "aro":
|
|
defs = f'<clipPath id="{clip}"><circle cx="50" cy="50" r="42"/></clipPath>'
|
|
fondo = f'<circle cx="50" cy="50" r="47" fill="{fondo_aro}"/>' if fondo_aro else ""
|
|
dentro = f'<g clip-path="url(#{clip})">{luz_(luz, clara)}{torre(ink, raya, clip)}</g>'
|
|
aro = f'<circle cx="50" cy="50" r="45" fill="none" stroke="{ink}" stroke-width="{grueso}"/>'
|
|
return defs + fondo + dentro + aro
|
|
# Pegatina: círculo amarillo, la luz en blanco
|
|
defs = f'<clipPath id="{clip}"><circle cx="50" cy="50" r="48"/></clipPath>'
|
|
return defs + f'<circle cx="50" cy="50" r="48" fill="{luz}"/><g clip-path="url(#{clip})">{luz_(BL, BL)}{torre(ink, raya, clip)}</g>'
|
|
|
|
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'
|
|
|
|
def simbolo_mapa():
|
|
# El mismo faro para el <symbol id="faro"> del mapa estático: fondo blanco y aro más grueso.
|
|
return faro(clip="fc", grueso=9, fondo_aro=BL)
|
|
|
|
if __name__ == "__main__":
|
|
d = sys.argv[1]
|
|
open(f"{d}/simbolo.svg", "w").write(svg(faro()))
|
|
open(f"{d}/simbolo-negativo.svg", "w").write(svg(faro(ink=BL), INK))
|
|
open(f"{d}/simbolo-naranja.svg", "w").write(svg(faro(luz=BL, raya=BL, ink=INK, clara="#ffe2a8"), NAR))
|
|
open(f"{d}/simbolo-pegatina.svg", "w").write(svg(faro("pegatina")))
|