Repository Public
1#!/usr/bin/env python32# =============================================================================3# SP BOUCHER | SOFTWARE & RESEARCH4# ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5# =============================================================================6#7# PROJECT METADATA8# -----------------------------------------------------------------------------9# Project : SP Keyboard10# File : Scripts/make_icon.py11# Description : Draws the original SP Keyboard app icon (1024 px, opaque):12# an aurora over deep night, a glass key cap carrying the13# letters SP and a four-point star. Pure Pillow, no external14# artwork. usage: make_icon.py [output.png]15# Module : Scripts16# Repository : https://git.spboucher.ai/sp-keyboard17# Created : 2026-12-0118# Last Modified : 2026-12-0119#20# =============================================================================21# AUTHOR & PROFESSIONAL AFFILIATION22# =============================================================================23#24# Author : Simon-Pierre Boucher25# Position : Professor of Finance26# Institution : Université du Québec en Outaouais (UQO)27# Department : Département des sciences administratives28# Organization : SP Boucher29#30# Website : https://spboucher.ai31# Git : https://git.spboucher.ai32#33# =============================================================================34# OFFICIAL CONTACT DIRECTORY35# =============================================================================36#37# General : info@spboucher.ai38# Professional : contact@spboucher.ai39# Direct : simon@spboucher.ai40# Research : research@spboucher.ai41# Development : dev@spboucher.ai42# Support : support@spboucher.ai43# Security/Admin : admin@spboucher.ai44# Notifications : notifications@spboucher.ai45#46# Preferred Contact: support@spboucher.ai47#48# =============================================================================49# COPYRIGHT & INTELLECTUAL PROPERTY50# =============================================================================51#52# Copyright (c) 202653# Simon-Pierre Boucher54#55# All rights reserved where applicable.56#57# This file is governed by the applicable project license,58# copyright notices, institutional agreements and relevant law.59#60# Unless expressly authorized by the applicable license or61# rights holder, copying, redistribution, sublicensing,62# publication and commercial exploitation are not permitted.63#64# Existing third-party rights and notices remain unaffected.65#66# =============================================================================67# CONFIDENTIALITY & SECURITY68# =============================================================================69#70# Classification : Public71# Distribution : Public repository; use is governed by the project license72# Security Contact : admin@spboucher.ai73#74# Access to this source does not independently grant permission75# to redistribute or disclose confidential materials.76#77# Do not embed credentials, private keys, access tokens,78# certificates or confidential personal information.79#80# =============================================================================81# LICENSE & MAINTENANCE82# =============================================================================83#84# License : None specified (no license file in this repository)85# Maintainer : Simon-Pierre Boucher86# Technical Contact: dev@spboucher.ai87#88# =============================================================================89# END OF SP BOUCHER SOURCE HEADER90# =============================================================================9192import math93import sys94from pathlib import Path9596from PIL import Image, ImageDraw, ImageFilter, ImageFont9798SIZE = 102499OUT = Path(sys.argv[1]) if len(sys.argv) > 1 else Path(__file__).resolve().parent.parent / "Resources/Assets.xcassets/AppIcon.appiconset/AppIcon-1024.png"100101102def lerp(a, b, t):103 return tuple(int(round(a[i] + (b[i] - a[i]) * t)) for i in range(3))104105106def gradient(size, stops, angle_deg):107 """Linear gradient through colour stops along an angle."""108 w, h = size109 img = Image.new("RGB", size)110 px = img.load()111 a = math.radians(angle_deg)112 dx, dy = math.cos(a), math.sin(a)113 lo = min(0, w * dx) + min(0, h * dy)114 hi = max(0, w * dx) + max(0, h * dy)115 for y in range(h):116 for x in range(w):117 t = ((x * dx + y * dy) - lo) / (hi - lo)118 pos = t * (len(stops) - 1)119 i = min(int(pos), len(stops) - 2)120 px[x, y] = lerp(stops[i], stops[i + 1], pos - i)121 return img122123124def blob(center, radius, color, alpha):125 layer = Image.new("RGBA", (SIZE, SIZE), (0, 0, 0, 0))126 d = ImageDraw.Draw(layer)127 cx, cy = center128 d.ellipse([cx - radius, cy - radius * 0.7, cx + radius, cy + radius * 0.7], fill=color + (alpha,))129 return layer.filter(ImageFilter.GaussianBlur(radius * 0.45))130131132def star(center, outer, inner):133 cx, cy = center134 pts = []135 for i in range(8):136 r = outer if i % 2 == 0 else inner137 a = i * math.pi / 4 - math.pi / 2138 pts.append((cx + math.cos(a) * r, cy + math.sin(a) * r))139 return pts140141142def main():143 base = gradient((SIZE, SIZE), [(4, 16, 25), (11, 30, 58), (26, 16, 64), (6, 35, 31)], 65).convert("RGBA")144 for center, radius, color, alpha in [145 ((250, 300), 430, (34, 230, 240), 150), ((760, 260), 420, (139, 92, 246), 160),146 ((820, 760), 430, (244, 114, 182), 140), ((240, 800), 420, (52, 211, 153), 135),147 ]:148 base = Image.alpha_composite(base, blob(center, radius, color, alpha))149150 # Glass key cap.151 box = [172, 212, 852, 832]152 radius = 150153 glow = Image.new("RGBA", (SIZE, SIZE), (0, 0, 0, 0))154 ImageDraw.Draw(glow).rounded_rectangle([box[0] - 8, box[1] - 8, box[2] + 8, box[3] + 8], radius + 8, fill=(155, 232, 255, 150))155 base = Image.alpha_composite(base, glow.filter(ImageFilter.GaussianBlur(34)))156 mask = Image.new("L", (SIZE, SIZE), 0)157 ImageDraw.Draw(mask).rounded_rectangle(box, radius, fill=255)158 glass = gradient((SIZE, SIZE), [(22, 38, 74), (30, 22, 78), (14, 44, 60)], 80).convert("RGBA")159 sheen = Image.new("RGBA", (SIZE, SIZE), (0, 0, 0, 0))160 ImageDraw.Draw(sheen).ellipse([60, 60, 980, 520], fill=(255, 255, 255, 46))161 glass = Image.alpha_composite(glass, sheen.filter(ImageFilter.GaussianBlur(60)))162 glass.putalpha(mask.point(lambda v: int(v * 0.86)))163 base = Image.alpha_composite(base, glass)164165 # Iridescent border.166 ring = gradient((SIZE, SIZE), [(34, 230, 240), (139, 92, 246), (244, 114, 182), (52, 211, 153)], 35).convert("RGBA")167 ring_mask = Image.new("L", (SIZE, SIZE), 0)168 d = ImageDraw.Draw(ring_mask)169 d.rounded_rectangle(box, radius, fill=255)170 d.rounded_rectangle([box[0] + 12, box[1] + 12, box[2] - 12, box[3] - 12], radius - 12, fill=0)171 ring.putalpha(ring_mask)172 base = Image.alpha_composite(base, ring)173174 # Letters "SP" filled with the aurora spectrum.175 font = None176 for path, index in [("/System/Library/Fonts/SFNSRounded.ttf", 0), ("/System/Library/Fonts/SFNS.ttf", 0), ("/System/Library/Fonts/Helvetica.ttc", 1)]:177 try:178 font = ImageFont.truetype(path, 400, index=index)179 if path.endswith("SFNSRounded.ttf") or path.endswith("SFNS.ttf"):180 try:181 font.set_variation_by_axes([800])182 except Exception:183 pass184 break185 except Exception:186 continue187 text_mask = Image.new("L", (SIZE, SIZE), 0)188 td = ImageDraw.Draw(text_mask)189 bbox = td.textbbox((0, 0), "SP", font=font)190 tw, th = bbox[2] - bbox[0], bbox[3] - bbox[1]191 td.text(((SIZE - tw) / 2 - bbox[0], 540 - th / 2 - bbox[1]), "SP", font=font, fill=255)192 letters = gradient((SIZE, SIZE), [(120, 245, 250), (190, 160, 255), (255, 150, 205), (120, 240, 190)], 20).convert("RGBA")193 letters.putalpha(text_mask)194 shadow = Image.new("RGBA", (SIZE, SIZE), (139, 92, 246, 0))195 shadow.putalpha(text_mask.point(lambda v: int(v * 0.8)))196 base = Image.alpha_composite(base, shadow.filter(ImageFilter.GaussianBlur(26)))197 base = Image.alpha_composite(base, letters)198199 # Four-point star, top right of the key.200 spark = Image.new("RGBA", (SIZE, SIZE), (0, 0, 0, 0))201 ImageDraw.Draw(spark).polygon(star((742, 318), 92, 26), fill=(255, 255, 255, 255))202 base = Image.alpha_composite(base, spark.filter(ImageFilter.GaussianBlur(16)))203 base = Image.alpha_composite(base, spark)204205 OUT.parent.mkdir(parents=True, exist_ok=True)206 base.convert("RGB").save(OUT, "PNG") # opaque: App Store Connect refuses an alpha channel207 print(f"{OUT} {base.size[0]}x{base.size[1]}")208209210if __name__ == "__main__":211 main()212