"""Aspecto del Space: la paleta y los componentes del portafolio, con una escena de campiña propia. Todo es local: las fuentes (``fuentes/``, incrustadas en el CSS) y los dibujos (SVG) viajan con el Space, así que visitarlo no contacta con terceros (la prueba de escucha promete anonimato). """ from __future__ import annotations import base64 import html import math import random from pathlib import Path import gradio as gr PORTAFOLIO = "https://chispa4013.github.io/" CARPETA_FUENTES = Path(__file__).resolve().parent / "fuentes" # Silueta de ave con las alas en «M», vista de frente (caja 64 x 32) _AVE = "M2 14 C14 6 24 8 32 18 C40 8 50 6 62 14 C52 12 42 14 34 24 L32 29 L30 24 C22 14 12 12 2 14 Z" # Paleta del portafolio: (claro, oscuro) CLARO = dict(bg="#f1f4ec", surface="#fbfcf7", ink="#1b2a20", mute="#55665a", line="#d8e0d0", brand="#2f6b4f", brand_ink="#ffffff", soft="#e3ebde", hover="#285c43") OSCURO = dict(bg="#0b1410", surface="#112019", ink="#e5efe6", mute="#96aa9c", line="#213329", brand="#7fc29b", brand_ink="#0b1410", soft="#182a20", hover="#93d0ab") SOMBRA = ("0 1px 2px rgba(22,32,46,.05), 0 8px 24px rgba(22,32,46,.07)", "0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25)") # Colores de la escena (propios de AVIA, no del portafolio): campiña de amanecer / noche de luna ESCENA_CLARA = dict(cielo_a="#e2eee6", cielo_b="#f7f1dc", astro="#fff1bd", brillo="rgba(255,226,150,.55)", c3="#cfe0cc", copa3="#bdd5bc", c2="#b7d1b2", copa2="#a3c4a4", c1="#98bb97", copa1="#6a9d7d", tronco="#6f6a52", juncos="#5b8f6b", espadana="#9a7b55") ESCENA_OSCURA = dict(cielo_a="#08131a", cielo_b="#17302e", astro="#c9d8e2", brillo="rgba(170,200,225,.13)", c3="#1b3b40", copa3="#1a383c", c2="#173630", copa2="#15322d", c1="#112b24", copa1="#0d211b", tronco="#09140f", juncos="#0a1913", espadana="#3a3026") _c, _o = CLARO, OSCURO TEMA = gr.themes.Base( primary_hue=gr.themes.colors.emerald, neutral_hue=gr.themes.colors.stone, radius_size=gr.themes.sizes.radius_md, font=[gr.themes.Font(f) for f in ("Rubik", "ui-sans-serif", "system-ui", "sans-serif")], font_mono=[gr.themes.Font(f) for f in ("ui-monospace", "Consolas", "monospace")], ).set( body_background_fill="transparent", body_background_fill_dark="transparent", body_text_color=_c["ink"], body_text_color_dark=_o["ink"], body_text_color_subdued=_c["mute"], body_text_color_subdued_dark=_o["mute"], background_fill_primary=_c["surface"], background_fill_primary_dark=_o["surface"], background_fill_secondary=_c["soft"], background_fill_secondary_dark=_o["soft"], border_color_primary=_c["line"], border_color_primary_dark=_o["line"], border_color_accent=_c["brand"], border_color_accent_dark=_o["brand"], color_accent_soft=_c["soft"], color_accent_soft_dark=_o["soft"], link_text_color=_c["brand"], link_text_color_dark=_o["brand"], link_text_color_hover=_c["hover"], link_text_color_hover_dark=_o["hover"], link_text_color_active=_c["brand"], link_text_color_active_dark=_o["brand"], link_text_color_visited=_c["brand"], link_text_color_visited_dark=_o["brand"], block_background_fill=_c["surface"], block_background_fill_dark=_o["surface"], block_border_width="1px", block_radius="18px", block_border_color=_c["line"], block_border_color_dark=_o["line"], block_shadow=SOMBRA[0], block_shadow_dark=SOMBRA[1], # Etiquetas discretas, como el resto de la página block_title_background_fill="transparent", block_title_background_fill_dark="transparent", block_title_text_color=_c["mute"], block_title_text_color_dark=_o["mute"], block_title_text_weight="500", block_title_padding="0 0 4px 0", block_label_background_fill="transparent", block_label_background_fill_dark="transparent", block_label_text_color=_c["mute"], block_label_text_color_dark=_o["mute"], block_label_border_width="0px", block_label_shadow="none", input_background_fill=_c["bg"], input_background_fill_dark=_o["bg"], input_background_fill_focus=_c["bg"], input_background_fill_focus_dark=_o["bg"], input_border_color=_c["line"], input_border_color_dark=_o["line"], input_border_color_focus=_c["brand"], input_border_color_focus_dark=_o["brand"], input_radius="10px", input_shadow="none", input_shadow_dark="none", input_shadow_focus="none", input_shadow_focus_dark="none", slider_color=_c["brand"], slider_color_dark=_o["brand"], # Botones: primario relleno y secundario con borde, como .btn.p y .btn.s del portafolio button_border_width="1px", button_large_radius="10px", button_medium_radius="10px", button_small_radius="10px", button_primary_background_fill=_c["brand"], button_primary_background_fill_dark=_o["brand"], button_primary_background_fill_hover=_c["hover"], button_primary_background_fill_hover_dark=_o["hover"], button_primary_border_color=_c["brand"], button_primary_border_color_dark=_o["brand"], button_primary_text_color=_c["brand_ink"], button_primary_text_color_dark=_o["brand_ink"], button_secondary_background_fill="transparent", button_secondary_background_fill_dark="transparent", button_secondary_background_fill_hover=_c["soft"], button_secondary_background_fill_hover_dark=_o["soft"], button_secondary_border_color=_c["brand"], button_secondary_border_color_dark=_o["brand"], button_secondary_text_color=_c["brand"], button_secondary_text_color_dark=_o["brand"], # Opciones de los Radio y casillas como los «chips» del portafolio checkbox_background_color=_c["surface"], checkbox_background_color_dark=_o["surface"], checkbox_background_color_selected=_c["brand"], checkbox_background_color_selected_dark=_o["brand"], checkbox_border_color=_c["line"], checkbox_border_color_dark=_o["line"], checkbox_border_color_selected=_c["brand"], checkbox_border_color_selected_dark=_o["brand"], checkbox_label_background_fill=_c["surface"], checkbox_label_background_fill_dark=_o["surface"], checkbox_label_background_fill_hover=_c["soft"], checkbox_label_background_fill_hover_dark=_o["soft"], checkbox_label_background_fill_selected=_c["brand"], checkbox_label_background_fill_selected_dark=_o["brand"], checkbox_label_border_color=_c["line"], checkbox_label_border_color_dark=_o["line"], checkbox_label_border_color_selected=_c["brand"], checkbox_label_border_color_selected_dark=_o["brand"], checkbox_label_text_color=_c["ink"], checkbox_label_text_color_dark=_o["ink"], checkbox_label_text_color_selected=_c["brand_ink"], checkbox_label_text_color_selected_dark=_o["brand_ink"], checkbox_label_shadow="none", ) def _fuentes_css() -> str: """``@font-face`` con las fuentes incrustadas en base64 (si faltan los ficheros, se usan las del sistema).""" definiciones = (("Rubik", "400 500", "rubik.woff2"), ("Fraunces", "700", "fraunces-700.woff2"), ("Raleway", "700", "raleway-700.woff2")) css = [] for familia, peso, archivo in definiciones: ruta = CARPETA_FUENTES / archivo if ruta.exists(): datos = base64.b64encode(ruta.read_bytes()).decode("ascii") css.append(f'@font-face {{ font-family: "{familia}"; font-weight: {peso}; font-style: normal; ' f'font-display: swap; src: url(data:font/woff2;base64,{datos}) format("woff2"); }}') return "\n".join(css) def _variables(p: dict[str, str], e: dict[str, str]) -> str: base = (f"--bg: {p['bg']}; --surface: {p['surface']}; --ink: {p['ink']}; --mute: {p['mute']}; " f"--line: {p['line']}; --brand: {p['brand']}; --brand-ink: {p['brand_ink']}; --soft: {p['soft']};") escena = " ".join(f"--{k.replace('_', '-')}: {v};" for k, v in e.items()) return f"{base} {escena}" _ESTILO = """ :root { VAR_CLARO --sh: SOMBRA_CLARA; --serif: Fraunces, Georgia, "Times New Roman", serif; --titulo: Raleway, system-ui, sans-serif; } .dark { VAR_OSCURO --sh: SOMBRA_OSCURA; } /* Todo transparente: la escena (fija, detrás) hace de fondo */ body, .gradio-container, .gradio-container .main, .gradio-container .wrap { background: transparent !important; } .gradio-container { width: 100% !important; max-width: 1000px !important; margin: 0 auto !important; padding: 0 24px !important; } .gradio-container .main, .gradio-container .main > .wrap, .gradio-container .contain { width: 100% !important; max-width: none !important; padding-left: 0 !important; padding-right: 0 !important; } .gradio-container .gap, .gradio-container .form { --layout-gap: 16px; } /* ===== Escena: campiña con colinas en capas, árboles, juncos, un mosquitero cantando y aves ===== */ #cielo { position: fixed !important; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; padding: 0 !important; margin: 0 !important; border: 0 !important; box-shadow: none !important; min-height: 0 !important; background: linear-gradient(180deg, var(--cielo-a) 0%, var(--cielo-b) 100%) !important; } #cielo .astro { position: absolute; top: 9vh; right: 15vw; width: clamp(48px, 6vw, 84px); aspect-ratio: 1; border-radius: 50%; background: var(--astro); box-shadow: 0 0 90px 36px var(--brillo); } #cielo .cerro { position: absolute; left: 0; bottom: 0; width: 100%; display: block; } #cielo .cerro.c3 { height: 46vh; fill: var(--c3); } #cielo .cerro.c2 { height: 34vh; fill: var(--c2); } #cielo .cerro.c1 { height: 22vh; fill: var(--c1); } #cielo .arbol { position: absolute; bottom: var(--b); left: var(--x); height: var(--h); width: calc(var(--h) * .68); display: block; } #cielo .arbol .copa { fill: var(--copa); } #cielo .arbol .tr { fill: var(--tronco); } #cielo .arbol .rm { fill: none; stroke: var(--tronco); stroke-width: 2.4; stroke-linecap: round; } #cielo .a3 { --copa: var(--copa3); } #cielo .a2 { --copa: var(--copa2); } #cielo .a1 { --copa: var(--copa1); } #cielo .juncos { position: absolute; bottom: -1px; width: clamp(120px, 22vw, 320px); height: 26vh; transform-origin: 50% 100%; animation: mecer 7s ease-in-out infinite alternate; } #cielo .juncos.izq { left: 0; } #cielo .juncos.der { right: 0; animation-delay: -3s; } #cielo .juncos .hoja { fill: none; stroke: var(--juncos); stroke-width: 3; stroke-linecap: round; } #cielo .juncos .espadana { fill: var(--espadana); } @keyframes mecer { from { transform: rotate(-1.6deg); } to { transform: rotate(1.6deg); } } #cielo .rama { position: absolute; top: 16vh; right: 0; width: clamp(180px, 26vw, 360px); } #cielo .rama .tronco { fill: none; stroke: var(--tronco); stroke-linecap: round; } #cielo .rama .hoja-r { fill: var(--juncos); opacity: .8; } #cielo .rama .cuerpo { fill: var(--brand); } #cielo .rama .ojo { fill: var(--bg); } #cielo .rama .onda { fill: none; stroke: var(--brand); stroke-width: 2.6; stroke-linecap: round; opacity: 0; animation: cantar 2.6s ease-out infinite; transform-box: fill-box; transform-origin: 100% 50%; } #cielo .rama .onda:nth-of-type(2) { animation-delay: .35s; } #cielo .rama .onda:nth-of-type(3) { animation-delay: .7s; } @keyframes cantar { 0% { opacity: 0; transform: scale(.6); } 25% { opacity: .75; } 100% { opacity: 0; transform: scale(1.25) translateX(-8px); } } #cielo .ave { position: absolute; top: var(--top); left: 0; width: var(--tam); opacity: var(--op); animation: cruzar var(--dur) linear var(--retraso) infinite; will-change: transform; } #cielo .ave.vuelta { animation-name: cruzar-vuelta; } #cielo .vuelta .giro { transform: scaleX(-1); } #cielo .ave svg, #cielo .bandada svg { display: block; width: 100%; fill: var(--brand); transform-origin: 50% 100%; animation: aletear var(--aleteo) ease-in-out infinite alternate; } #cielo .bandada { position: absolute; top: var(--top); left: 0; width: 0; height: 0; animation: cruzar-bandada var(--dur) linear var(--retraso) infinite; will-change: transform; } #cielo .bandada.vuelta { animation-name: cruzar-bandada-vuelta; } #cielo .bandada svg { position: absolute; left: var(--x); top: var(--y); width: var(--t); opacity: .5; animation-delay: var(--r); } @keyframes cruzar { from { transform: translate(-14vw, 0); } to { transform: translate(114vw, -9vh); } } @keyframes cruzar-vuelta { from { transform: translate(114vw, -6vh); } to { transform: translate(-14vw, 3vh); } } @keyframes cruzar-bandada { from { transform: translate(-18vw, 5vh); } to { transform: translate(118vw, -9vh); } } @keyframes cruzar-bandada-vuelta { from { transform: translate(118vw, -4vh); } to { transform: translate(-18vw, 6vh); } } @keyframes aletear { from { transform: translateY(0) scaleY(1); } to { transform: translateY(-6px) scaleY(.5); } } @media (max-width: 640px) { #cielo .ave { width: calc(var(--tam) * .65); } #cielo .arbol.opc { display: none; } #cielo .rama { top: 8vh; width: 190px; } } @media (prefers-reduced-motion: reduce) { #cielo *, .gracias * { animation: none !important; } #cielo .ave { left: var(--pos); } #cielo .bandada { left: 30vw; } } /* Mis bloques HTML a ras con los componentes de Gradio */ .gradio-container .html-container { padding: 0 !important; } /* Barra superior */ .barra { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 60px; border-bottom: 1px solid var(--line); } .barra .marca { display: flex; align-items: center; gap: 10px; font-family: var(--titulo); font-weight: 700; letter-spacing: .02em; color: var(--ink); text-decoration: none; } .barra .marca svg { width: 30px; fill: var(--brand); } .barra nav { display: flex; align-items: center; gap: 18px; font-size: 15px; } .barra nav a { color: var(--mute); text-decoration: none; } .barra nav a:hover { color: var(--ink); } .barra .tema { background: var(--surface); border: 1px solid var(--line); color: var(--ink); border-radius: 10px; width: 36px; height: 36px; cursor: pointer; font-size: 16px; } /* Aviso de fase de pruebas: un botón que despliega la explicación */ .barra { position: relative; z-index: 30; } .beta { position: relative; } .beta summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--brand); color: var(--brand); font-size: 13px; font-weight: 500; line-height: 1.2; background: color-mix(in srgb, var(--brand) 10%, transparent); user-select: none; } .beta summary::-webkit-details-marker { display: none; } .beta summary:hover, .beta[open] summary { background: var(--brand); color: var(--brand-ink); } .beta summary i { width: 8px; height: 8px; border-radius: 50%; background: #e0a030; animation: latido 1.8s ease-in-out infinite; } .beta .beta-nota { position: absolute; right: -60px; top: calc(100% + 10px); width: min(320px, 82vw); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; box-shadow: var(--sh); color: var(--ink); font-size: 14px; line-height: 1.5; } .beta .beta-nota b { font-weight: 500; color: var(--brand); } @keyframes latido { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .45; transform: scale(.8); } } @media (max-width: 760px) { .barra nav { gap: 10px; } .beta .beta-nota { position: fixed; left: 18px; right: 18px; top: 66px; width: auto; } } @media (prefers-reduced-motion: reduce) { .beta summary i { animation: none; } } /* Portada: título compacto para que las opciones se vean enseguida */ .intro { padding: 26px 0 8px; } .intro h1 { font-family: var(--serif); font-weight: 700; font-size: clamp(38px, 6vw, 54px); letter-spacing: -.02em; line-height: 1.05; margin: 0; } .intro .rol { font-family: var(--titulo); font-weight: 700; font-size: clamp(15px, 2vw, 18px); color: var(--brand); margin: 8px 0 10px; } .intro .lead { max-width: 62ch; color: var(--mute); margin: 0; } @media (max-width: 760px) { .gradio-container { padding: 0 18px !important; } .intro { padding-top: 18px; } } .cab-vista h2 { font-family: var(--serif); font-weight: 700; font-size: 30px; letter-spacing: -.01em; margin: 0 0 8px; line-height: 1.15; } .sub { color: var(--mute); margin: 0 0 20px; max-width: 62ch; } .cab-vista { padding: 8px 0 4px; } /* Tarjetas: las de opción y la del audio de referencia, como las de «proyectos» */ .opciones { gap: 20px !important; margin-top: 18px; } .opcion, .referencia { background: var(--surface) !important; border: 1px solid var(--line) !important; border-radius: 18px !important; padding: 22px !important; box-shadow: var(--sh); gap: 14px !important; } .opcion { transition: transform .2s; } .opcion:hover { transform: translateY(-2px); } .referencia { margin-top: 20px; } .icono { width: 46px; height: 46px; border-radius: 12px; background: var(--soft); display: grid; place-items: center; margin-bottom: 14px; } .icono svg { width: 26px; height: 26px; fill: none; stroke: var(--brand); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; } .opcion h3, .referencia h3 { font-family: var(--titulo); font-size: 20px; margin: 0 0 6px; } .opcion p, .referencia p { color: var(--mute); margin: 0; } .opcion .block, .referencia .block { border: 0 !important; box-shadow: none !important; background: transparent !important; padding: 0 !important; } .referencia .block.audio-block, .referencia [data-testid="waveform-controls"] { background: transparent !important; } .referencia .cabecera-ref { display: flex; gap: 14px; align-items: flex-start; } .referencia .cabecera-ref .icono { margin: 0; flex: none; } .credito { font-size: 13px; color: var(--mute); } .credito a, .creditos a { color: var(--brand); margin: 0 !important; padding: 0 !important; } .opciones { align-items: stretch !important; } .opcion > div:first-child { flex-grow: 1; } .opcion button { margin-top: auto; flex: 0 0 auto !important; min-height: 44px; } .gradio-container .md { padding-left: 4px !important; padding-right: 4px !important; } /* Opciones de los Radio como los «chips» del portafolio */ .gradio-container label:has(input[type="radio"]) { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 14px !important; cursor: pointer; font-size: 14px; position: relative; } .gradio-container label:has(input[type="radio"]) input { position: absolute; opacity: 0; pointer-events: none; } .gradio-container label:has(input[type="radio"]:checked) { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); } .gradio-container label:has(input[type="radio"]:checked) span { color: var(--brand-ink) !important; } .gradio-container label:has(input[type="radio"]:focus-visible) { outline: 2px solid var(--brand); outline-offset: 3px; } button.volver { width: auto !important; align-self: flex-start; margin: 14px 0 4px; border: 1px solid var(--brand) !important; } .gradio-container button { font-weight: 500 !important; letter-spacing: 0 !important; } .progreso { display: flex; align-items: center; gap: 12px; font-weight: 500; } .progreso .barra-p { flex: 1; height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; } .progreso .barra-p i { display: block; height: 100%; background: var(--brand); border-radius: 99px; transition: width .4s; } .gracias { text-align: center; padding: 24px 8px 8px; } .gracias .ave-grande { width: 84px; fill: var(--brand); } .gracias h2 { font-family: var(--serif); font-size: 30px; margin: 8px 0; } .creditos { padding: 8px 4px 16px; } .creditos h3 { font-family: var(--titulo); font-size: 18px; margin: 0 0 6px; } .creditos p { color: var(--mute); margin: 0 0 10px; } .creditos ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; } .creditos li { background: var(--soft); border-radius: 12px; padding: 10px 14px; font-size: 14px; } .creditos li b { font-weight: 500; color: var(--brand); } /* Pie, como footer.lic */ .pie { color: var(--mute); font-size: 14px; line-height: 1.6; padding: 36px 0 44px; margin-top: 28px; border-top: 1px solid var(--line); } .pie p { max-width: 72ch; margin: 0 0 12px; } .pie a { color: var(--brand); margin: 0 !important; padding: 0 !important; } .pie a.btn { display: inline-block; padding: 11px 20px !important; border-radius: 10px; text-decoration: none; font-weight: 500; border: 1px solid var(--brand); transition: transform .15s; margin-top: 6px !important; } .pie a.btn:hover { transform: translateY(-1px); background: var(--brand); color: var(--brand-ink); } footer.svelte-1rjryqp, .gradio-container > footer { opacity: .7; } """ def css() -> str: """CSS completo del Space: fuentes incrustadas + estilo con la paleta del portafolio.""" texto = (_ESTILO.replace("VAR_CLARO", _variables(CLARO, ESCENA_CLARA)).replace("VAR_OSCURO", _variables(OSCURO, ESCENA_OSCURA)) .replace("SOMBRA_CLARA", SOMBRA[0]).replace("SOMBRA_OSCURA", SOMBRA[1])) return _fuentes_css() + "\n" + texto # -------------------------------------------------------------------------------------------- # Escena # -------------------------------------------------------------------------------------------- def _cerro(rng: random.Random, base: float, amplitud: float, ondas: float) -> str: """Silueta de colina: curva suave de 17 puntos en una caja de 1600 x 300, cerrada por abajo.""" fase = rng.uniform(0, 6) puntos = [(x, base + amplitud * math.sin(x / 1600 * math.pi * 2 * ondas + fase) + rng.uniform(-amplitud, amplitud) * .25) for x in range(0, 1700, 100)] d = f"M{puntos[0][0]} {puntos[0][1]:.0f}" for (x0, y0), (x1, y1) in zip(puntos, puntos[1:]): d += f" Q{x0} {y0:.0f} {(x0 + x1) / 2:.0f} {(y0 + y1) / 2:.0f}" return f'' def _arbol(rng: random.Random, capa: str, x: float, bajo: float, alto: float, opcional: bool = False) -> str: """Árbol de copa redonda (círculos que se solapan) sobre un tronco que llega hasta abajo.""" circulos = "".join( f'' for _ in range(rng.randint(5, 8))) lado = rng.choice((-1, 1)) rama = (f'' f'') return (f'') def _juncos(rng: random.Random, lado: str) -> str: """Mata de juncos con espadañas, que se mece despacio.""" hojas, espadanas = [], [] for i in range(15): x = 20 + i * 11 + rng.uniform(-4, 4) punta_x = x + rng.uniform(-30, 30) alto = rng.uniform(70, 190) hojas.append(f'') for _ in range(3): x = rng.uniform(40, 170) punta_x = x + rng.uniform(-12, 12) alto = rng.uniform(150, 215) hojas.append(f'') espadanas.append(f'') return (f'') def _rama_con_mosquitero() -> str: """Rama que entra por la derecha con un mosquitero cantando y sus ondas de sonido.""" hojas = "".join(f'' for x, y, r in ((228, 44, -25), (204, 52, 20), (252, 38, -10), (196, 88, 35), (180, 96, -15), (235, 58, 30))) return f"""""" def _ave_planeando(rng: random.Random, i: int, cerca: float) -> str: duracion = 74 - 44 * cerca + rng.uniform(-4, 4) estilo = (f"--top:{rng.uniform(3, 60):.1f}vh;--tam:{22 + 40 * cerca:.0f}px;--dur:{duracion:.1f}s;" f"--retraso:-{rng.uniform(0, duracion):.1f}s;--op:{0.22 + 0.30 * cerca:.2f};" f"--aleteo:{rng.uniform(0.6, 1.2):.2f}s;--pos:{rng.uniform(4, 88):.0f}%") sentido = "vuelta" if i % 3 == 2 else "ida" return (f'
' f'
') def _bandada(rng: random.Random, n: int, top: float, dur: float, retraso: float, sentido: str) -> str: """Grupo de aves pequeñas que cruza el cielo a la vez, cada una con su propio aleteo.""" aves = "".join( f'' for _ in range(n)) return f'
{aves}
' def cielo_html(semilla: int = 11) -> str: """Escena fija detrás de la página: sol o luna, colinas en capas, árboles, juncos, un mosquitero cantando en una rama y aves (sueltas y en bandada) que cruzan el cielo. Es propia de AVIA: una campiña de amanecer, con el mismo lenguaje de siluetas en capas que usa el portafolio pero con otro paisaje y otros colores. """ rng = random.Random(semilla) c3, c2, c1 = (f'' for c, base, amp, ondas in (("c3", 105, 34, 1.4), ("c2", 120, 30, 2.1), ("c1", 135, 26, 2.8))) lejanos = "".join(_arbol(rng, "a3", 4 + i * 11 + rng.uniform(-3, 3), rng.uniform(12, 16), rng.uniform(13, 19), opcional=i % 2 == 1) for i in range(9)) medios = "".join(_arbol(rng, "a2", 3 + i * 14 + rng.uniform(-4, 4), rng.uniform(5, 9), rng.uniform(19, 28), opcional=i % 2 == 0) for i in range(7)) cercanos = "".join(_arbol(rng, "a1", x, rng.uniform(-3, 0), alto) for x, alto in ((-3, 56), (9, 40), (86, 44), (95, 58))) aves = "".join(_ave_planeando(rng, i, rng.random()) for i in range(7)) bandadas = _bandada(rng, 18, 30, 96, 30, "ida") + _bandada(rng, 11, 14, 130, 80, "vuelta") # De atrás adelante: colina lejana + sus árboles, colina media + sus árboles, colina cercana + los árboles de primer plano return (f'
{c3}{lejanos}{c2}{medios}{c1}{cercanos}' f'{_juncos(rng, "izq")}{_juncos(rng, "der")}{_rama_con_mosquitero()}{aves}{bandadas}') # -------------------------------------------------------------------------------------------- # Bloques de contenido # -------------------------------------------------------------------------------------------- def barra_html() -> str: """Barra superior: marca, enlace al portafolio y cambio de tema claro/oscuro.""" return f"""
AVIA
""" def intro_html() -> str: """Título compacto de la portada (para que las opciones queden a la vista).""" return """

AVIA

Artificial Vocalization of Avian Species

Un modelo de difusión dibuja el espectrograma de un canto de ave y un vocoder lo convierte en sonido. ¿Qué quieres hacer?

""" _ICONOS = { # Barras de una onda de sonido "onda": '', # Auriculares "auriculares": (''), # Ave sobre una rama "ave": (''), } def opcion_html(icono: str, titulo: str, texto: str) -> str: return f'
{_ICONOS[icono]}

{titulo}

{texto}

' def referencia_html(titulo: str, texto: str) -> str: """Cabecera de la tarjeta del audio original (el reproductor y el crédito van debajo).""" return (f'
{_ICONOS["ave"]}
' f'

{titulo}

{texto}

') def _enlace(url: str, texto: str) -> str: return f'{html.escape(texto)}' def credito_html(info: dict) -> str: """Línea de crédito de una grabación de Xeno-canto (autor, número, licencia y qué se le ha hecho).""" from avia.escucha import etiqueta_licencia partes = [f'Grabación de {html.escape(info["autor"])}', _enlace(info["url"], f"XC{info['grabacion']}"), _enlace(info["licencia"], etiqueta_licencia(info["licencia"]))] nota = f'
{html.escape(info["nota"])}' if info.get("nota") else "" return f'

{" · ".join(partes)}{nota}

' def creditos_prueba_html(clips: list[dict]) -> str: """Autores de los clips reales que ha escuchado una persona, en el orden en que los oyó. ``clips`` son diccionarios con ``posicion``, ``grabacion``, ``autor``, ``licencia`` y ``url``. Sin clips (una prueba preparada sin créditos) muestra solo el agradecimiento general. """ from avia.escucha import etiqueta_licencia if not clips: return ('

Grabaciones reales

Los clips reales proceden de grabaciones de ' 'Xeno-canto (CC BY-NC-SA). ' 'Gracias a todas las personas que las comparten.

') elementos = "".join( f'
  • Clip {c["posicion"]} · {html.escape(c["autor"])} · {_enlace(c["url"], "XC" + str(c["grabacion"]))}' f' · {_enlace(c["licencia"], etiqueta_licencia(c["licencia"]))}
  • ' for c in clips) return ('

    Las grabaciones reales que has escuchado

    ' '

    Estos clips eran reales (pasados por el mismo vocoder que los generados); los demás los generó el modelo. ' 'Gracias a sus autores, de Xeno-canto:

    ' f'
      {elementos}
    ') def cabecera_vista_html(titulo: str, texto: str) -> str: return f'

    {titulo}

    {texto}

    ' def pie_html(repo_modelos: str) -> str: return f"""""" def progreso_html(i: int, total: int) -> str: """Barra de progreso de la prueba: ``i`` es el índice (desde 0) del clip actual.""" return (f'
    Clip {i + 1} de {total}' f'
    ') def gracias_html() -> str: return (f'

    ¡Gracias!

    ' "

    Tus respuestas se han guardado. Ya puedes volver al inicio o cerrar la página.

    ")