# Generates src/ui/LogoData.h: the LYNX SHARE logo (by w3teal) embedded in the exe: the app icon (the mark on its dark # tile) for the window/taskbar icon, LYNX-drawn title bars and the About box, and the mark alone for the plugin-editor # header button. # Source of truth: resources/brand/lynx-share-logo.svg (+ its small-size form lynx-share-logo-small.svg); # tools/make_logo.py renders them to the PNGs read here. Embedded: the icon at 512 px, its small-size form at 128 px with # the stem (drawn at 21-32 physical pixels) and without it (20 px and less), the mark at 512 px and its small-size form # at 128 px, and where the mark's ring sits in the mark pictures. # Usage: python3 tools/make_logo_data.py (from the repository root). scripts/check-logo.py fails when the header drifts. import hashlib, io from PIL import Image SRC = "resources/lynx_badge.png" SMALL = "resources/brand/lynx-share-logo-small.png" TINY = "resources/brand/lynx-share-logo-tiny.png" MARK = "resources/lynx_logo.png" MARK_SMALL = "resources/brand/lynx-share-mark-small.png" def png(path, size): img = Image.open(path).convert("RGBA").resize((size, size), Image.LANCZOS) out = io.BytesIO() img.save(out, "PNG", optimize=True) return out.getvalue() def array(name, data): lines = ["inline constexpr unsigned char %s[] = {" % name] for i in range(0, len(data), 24): lines.append(", ".join(str(b) for b in data[i:i + 24]) + ",") return lines + ["};"] def sha(path): return hashlib.sha256(open(path, "rb").read()).hexdigest() # the mark's ring: its left, right and bottom edges are the circle's (the ears and the stem rise above it) a = Image.open(MARK).convert("RGBA").getchannel("A") x0, y0, x1, y1 = a.point(lambda v: 255 if v >= 128 else 0).getbbox() r = (x1 - x0) / 2.0 disc = ((x0 + x1) / 2.0 / a.width, (y1 - r) / a.height, r / a.width) lines = ["#pragma once", "", "// LYNX SHARE logo by w3teal. png512: the app icon %s (512 px); pngSmall / pngTiny: its small-size form" % SRC, "// %s with and without the stem (128 px); markPng512: the mark without the tile %s (512 px);" % (SMALL, MARK), "// markSmall: its small-size form %s (128 px). All with transparency." % MARK_SMALL, "// Generated by tools/make_logo_data.py - do not edit by hand (scripts/check-logo.py verifies it).", "// source-sha256: " + sha(SRC), "// small-sha256: " + sha(SMALL), "// tiny-sha256: " + sha(TINY), "// mark-sha256: " + sha(MARK), "// mark-small-sha256: " + sha(MARK_SMALL), "", "namespace lynx::logo", "{", "// where the mark's ring sits in markPng512 and markSmall (fractions of the side): centre x, centre y, radius", "inline constexpr float discX = %.4ff, discY = %.4ff, discR = %.4ff;" % disc] sizes = {} for name, path, size in (("png512", SRC, 512), ("pngSmall", SMALL, 128), ("pngTiny", TINY, 128), ("markPng512", MARK, 512), ("markSmall", MARK_SMALL, 128)): data = png(path, size) sizes[name] = len(data) lines += array(name, data) lines += ["} // namespace lynx::logo", ""] open("src/ui/LogoData.h", "w").write("\n".join(lines)) print(sizes, "disc", disc)