Repository Public
1# =============================================================================2# SP BOUCHER | SOFTWARE & RESEARCH3# ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4# =============================================================================5#6# Project : SP ID & Card Vault7# File : scripts/make_icon.py8# Module : Scripts9# Repository : https://git.spboucher.ai/sp-id-card-vault10# Project Website : Not specified11# Created : 2026-12-0212# Last Modified : 2026-12-0213#14# Author : Simon-Pierre Boucher15# Position : Professor of Finance16# Institution : Université du Québec en Outaouais (UQO)17# Organization : SP Boucher18# Website : https://spboucher.ai19# Git : https://git.spboucher.ai20#21# Preferred Contact: contact@spboucher.ai22# Development : dev@spboucher.ai23# Support : support@spboucher.ai24# Security/Admin : admin@spboucher.ai25#26# Copyright (c) 202627# Simon-Pierre Boucher28# All rights reserved where applicable. This file is governed by the29# applicable project license, copyright notices and relevant law.30# Existing third-party rights and notices remain unaffected.31#32# License : None specified (no license file in this repository)33#34# Do not embed credentials, private keys, access tokens,35# certificates or confidential personal information.36#37# =============================================================================38# END OF SP BOUCHER SOURCE HEADER39# =============================================================================4041"""Draws the SP Vault app icon (a secured card inside a vault door) at 1024 px.42usage: python3 scripts/make_icon.py -> SPVault/Resources/Assets.xcassets/AppIcon.appiconset/AppIcon.png"""43import math44from pathlib import Path45from PIL import Image, ImageChops, ImageDraw, ImageFilter4647S = 4 # supersampling48N = 1024 * S49C = N // 2505152def radial(size, inner, outer, center=(0.5, 0.5), radius=0.75):53 img = Image.new("RGB", (size, size))54 px = img.load()55 cx, cy, r = center[0] * size, center[1] * size, radius * size56 step = 857 small = Image.new("RGB", (size // step, size // step))58 sp = small.load()59 for y in range(size // step):60 for x in range(size // step):61 t = min(1.0, math.hypot(x * step - cx, y * step - cy) / r)62 t = t * t * (3 - 2 * t)63 sp[x, y] = tuple(int(inner[i] + (outer[i] - inner[i]) * t) for i in range(3))64 return small.resize((size, size), Image.BICUBIC)656667def ring(draw, radius, width, fill):68 draw.ellipse([C - radius, C - radius, C + radius, C + radius], outline=fill, width=width)697071def main():72 base = radial(N, (16, 28, 54), (4, 6, 12), center=(0.5, 0.32), radius=0.85)73 layer = Image.new("RGBA", (N, N), (0, 0, 0, 0))74 d = ImageDraw.Draw(layer)7576 # Vault door: recessed disc, titanium rim, graduations.77 R = int(N * 0.375)78 d.ellipse([C - R, C - R, C + R, C + R], fill=(9, 14, 26, 255))79 for i, (w, col) in enumerate([(int(N * 0.030), (196, 202, 212, 255)), (int(N * 0.006), (60, 68, 84, 255))]):80 ring(d, R - i * int(N * 0.034), w, col)81 for k in range(60):82 a = math.radians(k * 6)83 long = k % 5 == 084 r0, r1 = R - int(N * 0.052), R - int(N * (0.085 if long else 0.068))85 d.line([C + r0 * math.sin(a), C - r0 * math.cos(a), C + r1 * math.sin(a), C - r1 * math.cos(a)],86 fill=(150, 158, 172, 255) if long else (86, 94, 110, 255), width=int(N * (0.006 if long else 0.003)))87 ring(d, int(R * 0.70), int(N * 0.004), (54, 62, 80, 255))88 # Four locking bolts.89 for k in range(4):90 a = math.radians(45 + k * 90)91 bx, by = C + (R + int(N * 0.012)) * math.sin(a), C - (R + int(N * 0.012)) * math.cos(a)92 rr = int(N * 0.028)93 d.ellipse([bx - rr, by - rr, bx + rr, by + rr], fill=(178, 185, 197, 255), outline=(40, 46, 60, 255), width=int(N * 0.004))9495 # The card, electric blue, slightly turned.96 cw, ch = int(N * 0.46), int(N * 0.46 / 1.586)97 card = Image.new("RGBA", (cw, ch), (0, 0, 0, 0))98 cd = ImageDraw.Draw(card)99 grad = Image.new("RGB", (cw, ch))100 gp = ImageDraw.Draw(grad)101 for x in range(cw):102 t = x / cw103 gp.line([x, 0, x, ch], fill=(int(70 - 44 * t), int(150 - 66 * t), int(255 - 20 * t)))104 mask = Image.new("L", (cw, ch), 0)105 ImageDraw.Draw(mask).rounded_rectangle([0, 0, cw - 1, ch - 1], radius=int(cw * 0.065), fill=255)106 card.paste(grad, (0, 0), mask)107 cd.rounded_rectangle([0, 0, cw - 1, ch - 1], radius=int(cw * 0.065), outline=(190, 220, 255, 150), width=int(N * 0.003))108 chip = [int(cw * 0.10), int(ch * 0.30), int(cw * 0.27), int(ch * 0.52)]109 cd.rounded_rectangle(chip, radius=int(cw * 0.02), fill=(240, 244, 250, 240))110 cd.line([chip[0], (chip[1] + chip[3]) // 2, chip[2], (chip[1] + chip[3]) // 2], fill=(120, 150, 200, 255), width=int(N * 0.002))111 cd.line([(chip[0] + chip[2]) // 2, chip[1], (chip[0] + chip[2]) // 2, chip[3]], fill=(120, 150, 200, 255), width=int(N * 0.002))112 cd.rounded_rectangle([int(cw * 0.10), int(ch * 0.72), int(cw * 0.62), int(ch * 0.78)], radius=int(ch * 0.03), fill=(255, 255, 255, 170))113 cd.rounded_rectangle([int(cw * 0.70), int(ch * 0.72), int(cw * 0.90), int(ch * 0.78)], radius=int(ch * 0.03), fill=(255, 255, 255, 110))114 card = card.rotate(9, resample=Image.BICUBIC, expand=True)115116 shadow = Image.new("RGBA", (N, N), (0, 0, 0, 0))117 sh = Image.new("RGBA", card.size, (8, 40, 120, 190))118 shadow.paste(sh, (C - card.width // 2, C - card.height // 2 + int(N * 0.03)), card.split()[3])119 shadow = shadow.filter(ImageFilter.GaussianBlur(N * 0.03))120121 out = base.convert("RGBA")122 out = Image.alpha_composite(out, layer)123 out = Image.alpha_composite(out, shadow)124 out.alpha_composite(card, (C - card.width // 2, C - card.height // 2))125126 # Cold light from above on the rim.127 glow = Image.new("L", (N, N), 0)128 ImageDraw.Draw(glow).ellipse([C - R, C - R - int(N * 0.02), C + R, C + R - int(N * 0.02)], outline=255, width=int(N * 0.012))129 fade = Image.linear_gradient("L").resize((N, N)).point(lambda v: max(0, 255 - int(v * 2.4)))130 glow = ImageChops.multiply(glow, fade).filter(ImageFilter.GaussianBlur(N * 0.006))131 out = Image.composite(Image.new("RGBA", (N, N), (255, 255, 255, 255)), out, glow.point(lambda v: int(v * 0.55)))132133 target = Path(__file__).resolve().parent.parent / "SPVault/Resources/Assets.xcassets/AppIcon.appiconset/AppIcon.png"134 out.convert("RGB").resize((1024, 1024), Image.LANCZOS).save(target)135 print(target)136137138if __name__ == "__main__":139 main()140