""" LOGAR Branding & Installer Graphics Generator Generates clean, professional SVG, PNG, ICO, and BMP visual assets for LOGAR installers (Inno Setup & NSIS), application icons, root /assets library, and WebUI branding. Zero external dependencies required (uses standard library zlib and struct). """ import os import math import zlib import struct import shutil ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) ROOT_ASSETS_DIR = os.path.join(ROOT_DIR, "assets") COMPILATION_ASSETS_DIR = os.path.join(ROOT_DIR, "compilation", "assets") LICENSING_ASSETS_DIR = os.path.join(ROOT_DIR, "LOGAR-LICENSING", "assets") for d in (ROOT_ASSETS_DIR, COMPILATION_ASSETS_DIR, LICENSING_ASSETS_DIR): os.makedirs(d, exist_ok=True) def create_bmp_24bit(width: int, height: int, pixel_func) -> bytes: """Generates an uncompressed 24-bit RGB BMP image.""" row_bytes = width * 3 padding = (4 - (row_bytes % 4)) % 4 image_size = (row_bytes + padding) * height file_size = 14 + 40 + image_size # BITMAPFILEHEADER (14 bytes) header = struct.pack( "<2sIHHI", b"BM", file_size, 0, 0, 54 # Offset to pixel data ) # BITMAPINFOHEADER (40 bytes) info = struct.pack( " bytes: """Generates a standard 32-bit RGBA PNG image.""" raw_scanlines = bytearray() for y in range(height): raw_scanlines.append(0) # Filter type 0 (None) for x in range(width): r, g, b, a = pixel_func(x, y, width, height) raw_scanlines.extend(bytes([int(r) & 0xFF, int(g) & 0xFF, int(b) & 0xFF, int(a) & 0xFF])) compressed = zlib.compress(bytes(raw_scanlines), level=9) def chunk(tag: bytes, data: bytes) -> bytes: chk = tag + data crc = zlib.crc32(chk) & 0xFFFFFFFF return struct.pack(">I", len(data)) + chk + struct.pack(">I", crc) ihdr = struct.pack(">IIBBBBB", width, height, 8, 6, 0, 0, 0) png_bytes = b"\x89PNG\r\n\x1a\n" + chunk(b"IHDR", ihdr) + chunk(b"IDAT", compressed) + chunk(b"IEND", b"") return png_bytes def draw_logo_rgba(x: int, y: int, w: int, h: int) -> tuple: """Renders a sleek modern hexagon shield and pulse log streams.""" nx = (x - w / 2) / (w / 2) ny = (y - h / 2) / (h / 2) dist = math.sqrt(nx * nx + ny * ny) if dist > 0.98: return 0, 0, 0, 0 # Hexagon radius formula angle = math.atan2(ny, nx) hex_radius = 0.88 / (math.cos((angle % (math.pi / 3)) - (math.pi / 6)) + 0.001) if dist > hex_radius: if dist < hex_radius + 0.04: alpha = max(0.0, min(1.0, (hex_radius + 0.04 - dist) / 0.04)) return 11, 25, 44, int(alpha * 255) return 0, 0, 0, 0 # Gradient background: Dark Slate Blue to Navy grad_t = (ny + 1) / 2 bg_r = int(12 * (1 - grad_t) + 6 * grad_t) bg_g = int(24 * (1 - grad_t) + 14 * grad_t) bg_b = int(48 * (1 - grad_t) + 32 * grad_t) # Hexagon outer border (Cyber Cyan / Emerald highlight) if dist > hex_radius - 0.07: glow_t = (nx + 1) / 2 br = int(0 * (1 - glow_t) + 0 * glow_t) bg = int(229 * (1 - glow_t) + 160 * glow_t) bb = int(255 * (1 - glow_t) + 255 * glow_t) return br, bg, bb, 255 # Center stylized 'L' log symbol and dynamic telemetry bars # Bar 1 (Left Log Stream): x in [-0.42, -0.22], y in [-0.45, 0.45] if -0.42 <= nx <= -0.22 and -0.45 <= ny <= 0.45: v = (ny + 0.45) / 0.9 return int(0), int(220 * (1 - v) + 140 * v), int(255), 255 # Bar 2 (Bottom Base of 'L'): x in [-0.42, 0.35], y in [0.25, 0.45] if -0.42 <= nx <= 0.35 and 0.25 <= ny <= 0.45: v = (nx + 0.42) / 0.77 return int(0), int(220 * (1 - v) + 180 * v), int(255), 255 # Bar 3 (Central Stream Wave 1): x in [-0.10, 0.08], y in [-0.30, 0.12] if -0.10 <= nx <= 0.08 and -0.30 <= ny <= 0.12: return 0, 240, 255, 255 # Bar 4 (Central Stream Wave 2): x in [0.18, 0.36], y in [-0.50, 0.12] if 0.18 <= nx <= 0.36 and -0.50 <= ny <= 0.12: return 0, 180, 255, 255 # Subtle inner grid dots grid_x = (nx * 10) % 1 grid_y = (ny * 10) % 1 if 0.45 <= grid_x <= 0.55 and 0.45 <= grid_y <= 0.55: return bg_r + 20, bg_g + 30, bg_b + 50, 255 return bg_r, bg_g, bg_b, 255 def draw_wizard_header_white_bgr(x: int, y: int, w: int, h: int) -> tuple: """ Renders header BMP graphic with a pure white background (255, 255, 255) matching the installer wizard dialog background seamlessly. The logo is positioned on the left with clean alpha-blended edges. """ bg_r, bg_g, bg_b = 255, 255, 255 # Position emblem cleanly on the left (center x = 28, center y = h / 2) icon_center_x = 28 icon_center_y = h / 2 icon_radius = 22 dx = (x - icon_center_x) / icon_radius dy = (y - icon_center_y) / icon_radius d = math.sqrt(dx * dx + dy * dy) if d < 1.0: er, eg, eb, ea = draw_logo_rgba(int((dx + 1) * 32), int((dy + 1) * 32), 64, 64) alpha = ea / 255.0 r = int(er * alpha + bg_r * (1.0 - alpha)) g = int(eg * alpha + bg_g * (1.0 - alpha)) b = int(eb * alpha + bg_b * (1.0 - alpha)) return r, g, b return bg_r, bg_g, bg_b def draw_wizard_small_bgr(x: int, y: int, w: int, h: int) -> tuple: """Renders 55x55 square header BMP with centered logo on pure white background.""" bg_r, bg_g, bg_b = 255, 255, 255 cx = w / 2 cy = h / 2 rad = (min(w, h) / 2) - 4 dx = (x - cx) / rad dy = (y - cy) / rad d = math.sqrt(dx * dx + dy * dy) if d < 1.0: er, eg, eb, ea = draw_logo_rgba(int((dx + 1) * 32), int((dy + 1) * 32), 64, 64) alpha = ea / 255.0 r = int(er * alpha + bg_r * (1.0 - alpha)) g = int(eg * alpha + bg_g * (1.0 - alpha)) b = int(eb * alpha + bg_b * (1.0 - alpha)) return r, g, b return bg_r, bg_g, bg_b def draw_wizard_sidebar_bgr(x: int, y: int, w: int, h: int) -> tuple: """Renders 164x314 BMP sidebar graphic for NSIS / Inno Setup.""" t_y = y / h # Deep navy to midnight blue vertical gradient r = int(10 * (1 - t_y) + 4 * t_y) g = int(22 * (1 - t_y) + 12 * t_y) b = int(48 * (1 - t_y) + 26 * t_y) # Subtle telemetry grid / stream lines if int(x) % 18 == 0 or int(y) % 24 == 0: r = min(255, r + 8) g = min(255, g + 14) b = min(255, b + 25) # Decorative node glow in top region emblem_cx = w / 2 emblem_cy = 90 edx = (x - emblem_cx) / 44 edy = (y - emblem_cy) / 44 ed = math.sqrt(edx * edx + edy * edy) if ed < 0.98: er, eg, eb, ea = draw_logo_rgba(int((edx + 1) * 64), int((edy + 1) * 64), 128, 128) if ea > 128: return er, eg, eb # Glowing pulse lines streaming downwards from the emblem if 55 <= x <= 110 and y > 150: line_idx = int((x - 55) / 14) line_offset = (line_idx * 37 + int(y * 0.4)) % 100 if line_offset < 30: glow = math.sin((line_offset / 30) * math.pi) g = min(255, int(g + 160 * glow)) b = min(255, int(b + 220 * glow)) # Bottom accent band if y >= h - 4: accent_t = x / w return 0, int(220 * accent_t), 255 return r, g, b def generate_ico_file(png_images: list) -> bytes: """Packs multiple PNG images into a valid Windows .ico container.""" count = len(png_images) header = struct.pack(" str: """Generates a high-quality SVG vector graphic for LOGAR.""" bg_polygon = "" if transparent_bg else """ """ return f""" {bg_polygon} """ def generate_svg_banner() -> str: """Generates a wide SVG banner with emblem and modern typography.""" return """ LOGAR Fleet Log Aggregation & Telemetry Hub ZERO-STATE FORWARDERS • MUTUAL TLS 1.3 • TEMPORAL PERSISTENCE """ def main(): print("[*] Generating comprehensive branding assets for LOGAR...") # 1. Generate SVG Logos svg_logo_dark = generate_svg_logo(transparent_bg=False) svg_logo_trans = generate_svg_logo(transparent_bg=True) svg_banner = generate_svg_banner() # 2. Generate PNG images across multiple dimensions png_sizes = [16, 32, 48, 64, 128, 256, 512] png_buffers = [] png_dict = {} for s in png_sizes: png_data = create_png_rgba(s, s, draw_logo_rgba) png_buffers.append((s, s, png_data)) png_dict[s] = png_data # 3. Generate Windows ICO File (multi-res 16..256) ico_data = generate_ico_file(png_buffers[:-1]) # 4. Generate BMP files for installers header_bmp_data = create_bmp_24bit(150, 57, draw_wizard_header_white_bgr) small_bmp_data = create_bmp_24bit(55, 55, draw_wizard_small_bgr) sidebar_bmp_data = create_bmp_24bit(164, 314, draw_wizard_sidebar_bgr) # 5. Write to target directories for target_dir in (ROOT_ASSETS_DIR, COMPILATION_ASSETS_DIR, LICENSING_ASSETS_DIR): # SVGs with open(os.path.join(target_dir, "logo.svg"), "w", encoding="utf-8") as f: f.write(svg_logo_dark) with open(os.path.join(target_dir, "logo_dark.svg"), "w", encoding="utf-8") as f: f.write(svg_logo_dark) with open(os.path.join(target_dir, "logo_transparent.svg"), "w", encoding="utf-8") as f: f.write(svg_logo_trans) with open(os.path.join(target_dir, "logo_banner.svg"), "w", encoding="utf-8") as f: f.write(svg_banner) # PNGs with open(os.path.join(target_dir, "logo.png"), "wb") as f: f.write(png_dict[512]) for s in png_sizes: with open(os.path.join(target_dir, f"logo_{s}x{s}.png"), "wb") as f: f.write(png_dict[s]) # ICOs with open(os.path.join(target_dir, "logo.ico"), "wb") as f: f.write(ico_data) with open(os.path.join(target_dir, "favicon.ico"), "wb") as f: f.write(ico_data) # BMPs with open(os.path.join(target_dir, "wizard_header.bmp"), "wb") as f: f.write(header_bmp_data) with open(os.path.join(target_dir, "wizard_small.bmp"), "wb") as f: f.write(small_bmp_data) with open(os.path.join(target_dir, "wizard_sidebar.bmp"), "wb") as f: f.write(sidebar_bmp_data) print(f"[+] Populated asset repository: {target_dir}") print("[+] All LOGAR branding assets, icons, and banners generated successfully!") if __name__ == "__main__": main()