import hashlib import math import random class LogoGenerator: """ Physical SVG Generator for project branding (Nana Banana Plugin). Generates geometric patterns without LLM calls to ensure zero-token cost. """ @staticmethod def generate_svg(seed_text: str, width: int = 512, height: int = 512) -> str: # Create a deterministic random based on seed seed_hash = int(hashlib.md5(seed_text.encode()).hexdigest(), 16) rng = random.Random(seed_hash) # Color palette (Tron/Cyberpunk theme as per Style Guide) colors = ["#00f0ff", "#ff007f", "#7000ff", "#39ff14", "#ffb703"] bg_color = "#0b0c10" # Start SVG svg = ( f'' ) # Glow filter and gradient definitions svg += ( "" '' '' "" '' '' "" "" '' '' '' "" "" ) svg += f'' # Cyberpunk Tech Grid Lines for i in range(20, width, 40): svg += f'' for j in range(20, height, 40): svg += f'' # Concentric Center Circles cx_center, cy_center = width // 2, height // 2 svg += f'' svg += f'' # Generate 5-9 geometric shapes for richer aesthetics for _ in range(rng.randint(5, 10)): shape_type = rng.choice(["circle", "rect", "poly", "ring", "hexagon", "crosshair"]) color = rng.choice(colors) opacity = rng.uniform(0.3, 0.7) # 40% chance of glow effect glow = ' filter="url(#neon-glow)"' if rng.random() < 0.4 else "" if shape_type == "circle": cx, cy = rng.randint(50, width - 50), rng.randint(50, height - 50) r = rng.randint(20, 100) svg += f'' elif shape_type == "rect": x, y = rng.randint(50, width - 150), rng.randint(50, height - 150) w, h = rng.randint(40, 180), rng.randint(40, 180) fill_color = "url(#cyber-grad)" if rng.random() < 0.3 else color svg += ( f'' ) elif shape_type == "ring": cx, cy = rng.randint(50, width - 50), rng.randint(50, height - 50) r = rng.randint(30, 90) svg += f'' elif shape_type == "hexagon": cx, cy = rng.randint(50, width - 50), rng.randint(50, height - 50) r = rng.randint(30, 100) points = [] for i in range(6): angle_deg = 60 * i angle_rad = math.radians(angle_deg) px = cx + r * math.cos(angle_rad) py = cy + r * math.sin(angle_rad) points.append(f"{px:.1f},{py:.1f}") svg += f'' elif shape_type == "crosshair": cx, cy = rng.randint(55, width - 55), rng.randint(55, height - 55) r = rng.randint(15, 40) svg += f'' svg += f'' svg += f'' else: # Triangle/Polygon points = [] for _ in range(3): points.append(f"{rng.randint(50, width - 50)},{rng.randint(50, height - 50)}") svg += f'' svg += "" return svg def generate_logo_svg(seed: str) -> str: return LogoGenerator.generate_svg(seed)