#!/usr/bin/env python3 """Generate the original community Y mark (not the upstream logo), without dependencies.""" import json from pathlib import Path import struct import zlib ROOT = Path(__file__).resolve().parents[1] def png(size): raw = bytearray() segments = [(32, 29, 54, 54), (54, 54, 76, 29), (54, 54, 54, 80)] for y in range(size): raw.append(0) for x in range(size): coverage = 0 for dx, dy in [(0.25, 0.25), (0.75, 0.25), (0.25, 0.75), (0.75, 0.75)]: px, py = (x + dx) * 108 / size, (y + dy) * 108 / size for ax, ay, bx, by in segments: projection = max(0, min(1, ((px-ax)*(bx-ax)+(py-ay)*(by-ay))/((bx-ax)**2+(by-ay)**2))) if (px-ax-projection*(bx-ax))**2 + (py-ay-projection*(by-ay))**2 <= 4.5**2: coverage += 1 break raw.extend(round(background + (255-background)*coverage/4) for background in (108, 58, 237)) def chunk(name, data): return struct.pack(">I", len(data)) + name + data + struct.pack(">I", zlib.crc32(name+data)) return b"\x89PNG\r\n\x1a\n" + chunk(b"IHDR", struct.pack(">IIBBBBB", size, size, 8, 2, 0, 0, 0)) + chunk(b"IDAT", zlib.compress(raw, 9)) + chunk(b"IEND", b"") if __name__ == "__main__": folder = ROOT / "ios/Sources/Assets.xcassets/AppIcon.appiconset" folder.mkdir(parents=True, exist_ok=True) (folder / "AppIcon.png").write_bytes(png(1024)) (folder / "Contents.json").write_text(json.dumps({"images": [ {"filename": "AppIcon.png", "idiom": "universal", "platform": "ios", "size": "1024x1024"} ], "info": {"author": "Yuvomi Mobile contributors", "version": 1}}, indent=2) + "\n")