feat(dev): issues 0100-0104 — dev_console binary + work_tab + DoD user-facing + frontmatter migration de 146 issues + taxonomia canonica
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -2,6 +2,11 @@
|
||||
|
||||
Rasteriza un icono Phosphor SVG sobre un fondo redondeado del color accent
|
||||
y exporta un .ico con multiples resoluciones (16, 24, 32, 48, 64, 128, 256).
|
||||
|
||||
Funciones publicas reutilizables:
|
||||
_find_registry_root — localiza la raiz del registry
|
||||
_render_glyph_white — rasteriza un SVG Phosphor como glyph blanco RGBA
|
||||
_make_icon_image — compone fondo redondeado + glyph en un PIL.Image
|
||||
"""
|
||||
import io
|
||||
import os
|
||||
@@ -14,8 +19,23 @@ from PIL import Image, ImageDraw
|
||||
DEFAULT_SIZES = [16, 24, 32, 48, 64, 128, 256]
|
||||
|
||||
|
||||
def _find_registry_root() -> Path:
|
||||
"""Descubre la raiz del registry caminando hacia arriba hasta encontrar registry.db."""
|
||||
def _find_registry_root(registry_root: str | None = None) -> Path:
|
||||
"""Descubre la raiz del registry.
|
||||
|
||||
Prioridad: argumento explicito > FN_REGISTRY_ROOT env > caminar hacia arriba
|
||||
desde el archivo hasta encontrar registry.db.
|
||||
|
||||
Args:
|
||||
registry_root: Ruta absoluta opcional. Si se pasa, se devuelve directamente.
|
||||
|
||||
Returns:
|
||||
Path resuelto a la raiz del registry.
|
||||
|
||||
Raises:
|
||||
FileNotFoundError: Si no se puede localizar registry.db.
|
||||
"""
|
||||
if registry_root is not None:
|
||||
return Path(registry_root).resolve()
|
||||
env_root = os.environ.get("FN_REGISTRY_ROOT")
|
||||
if env_root:
|
||||
return Path(env_root).resolve()
|
||||
@@ -35,7 +55,15 @@ def _hex_to_rgb(h: str) -> tuple[int, int, int]:
|
||||
|
||||
|
||||
def _render_glyph_white(svg_path: Path, size: int) -> Image.Image:
|
||||
"""Renderiza el SVG Phosphor como glyph blanco sobre fondo transparente."""
|
||||
"""Renderiza el SVG Phosphor como glyph blanco sobre fondo transparente.
|
||||
|
||||
Args:
|
||||
svg_path: Ruta al archivo .svg de Phosphor.
|
||||
size: Ancho/alto en pixels del output.
|
||||
|
||||
Returns:
|
||||
Imagen RGBA con el glyph en blanco sobre fondo transparente.
|
||||
"""
|
||||
svg = svg_path.read_text(encoding="utf-8")
|
||||
# Phosphor usa fill="currentColor" — forzar blanco.
|
||||
svg = svg.replace('fill="currentColor"', 'fill="#ffffff"')
|
||||
@@ -48,7 +76,16 @@ def _render_glyph_white(svg_path: Path, size: int) -> Image.Image:
|
||||
|
||||
|
||||
def _make_icon_image(svg_path: Path, accent_hex: str, size: int) -> Image.Image:
|
||||
"""Compone fondo redondeado con color accent + glyph blanco centrado al 70%."""
|
||||
"""Compone fondo redondeado con color accent + glyph blanco centrado al 70%.
|
||||
|
||||
Args:
|
||||
svg_path: Ruta al archivo .svg de Phosphor.
|
||||
accent_hex: Color de fondo en formato "#RRGGBB".
|
||||
size: Ancho/alto en pixels del canvas de salida.
|
||||
|
||||
Returns:
|
||||
Imagen RGBA lista para guardar como PNG o ICO.
|
||||
"""
|
||||
bg_color = _hex_to_rgb(accent_hex) + (255,)
|
||||
canvas = Image.new("RGBA", (size, size), (0, 0, 0, 0))
|
||||
draw = ImageDraw.Draw(canvas)
|
||||
@@ -113,8 +150,8 @@ def generate_app_icon(
|
||||
|
||||
# Resolver raiz de phosphor
|
||||
if phosphor_root is None:
|
||||
registry_root = _find_registry_root()
|
||||
phosphor_assets = registry_root / "sources" / "phosphor-core" / "assets"
|
||||
_root = _find_registry_root()
|
||||
phosphor_assets = _root / "sources" / "phosphor-core" / "assets"
|
||||
else:
|
||||
phosphor_assets = Path(phosphor_root)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user