Repository Public
1#!/usr/bin/env python32# =============================================================================3# SP BOUCHER | SOFTWARE & RESEARCH4# ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5# =============================================================================6#7# Project : Groupe Ka — app iOS native8# File : Scripts/marque.py9# Module : Scripts10# Repository : https://git.spboucher.ai/groupe-ka-ios11# Project Website : Not specified12# Created : 2026-12-0313# Last Modified : 2026-12-0314#15# Author : Simon-Pierre Boucher16# Position : Professor of Finance17# Institution : Université du Québec en Outaouais (UQO)18# Organization : SP Boucher19# Website : https://spboucher.ai20# Git : https://git.spboucher.ai21#22# Preferred Contact: contact@spboucher.ai23# Development : dev@spboucher.ai24# Support : support@spboucher.ai25# Security/Admin : admin@spboucher.ai26#27# Copyright (c) 202628# Simon-Pierre Boucher29# All rights reserved where applicable. This file is governed by the30# applicable project license, copyright notices and relevant law.31# Existing third-party rights and notices remain unaffected.32#33# License : None specified (no license file in this repository)34#35# Do not embed credentials, private keys, access tokens,36# certificates or confidential personal information.37#38# =============================================================================39# END OF SP BOUCHER SOURCE HEADER40# =============================================================================4142"""Icône de l'app et marque de l'écran de lancement : le symbole du Groupe Ka (la rotonde en plan, six baies,43la porte du haut ouverte), tracé avec la même géométrie que `symboleGroupe` du site (src/gabarit.ts).4445usage : python3 Scripts/marque.py (demande rsvg-convert : brew install librsvg)46Écrit GroupeKa/Resources/Assets.xcassets/{AppIcon.appiconset,LaunchMark.imageset} et l'icône du widget.47"""48import math49import os50import subprocess51import tempfile5253RACINE = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..")54ASSETS = os.path.join(RACINE, "GroupeKa", "Resources", "Assets.xcassets")55N = 656R = 23.0575859def pol(r, a):60 return r * math.cos(math.radians(a)), r * math.sin(math.radians(a))616263def angle(i):64 return -90 + 360 / N * i656667def demi(i):68 return 14 if i % N == 0 else 7 # la baie du haut est plus large : c'est la porte ouverte697071def symbole(encre, sol=None, ombre=None, epaisseur=6.5):72 """Le symbole dans une grille 64 × 64, centré en (32, 32)."""73 s = ""74 if sol:75 s += f'<circle cx="32" cy="32" r="{R}" fill="{sol}"/>'76 if ombre:77 # ombre portée du mur sur le sol : la pièce moins la pièce décalée (lumière d'en haut à gauche)78 ri = R - epaisseur / 279 s += (f'<clipPath id="piece"><circle cx="32" cy="32" r="{ri}"/></clipPath>'80 f'<path clip-path="url(#piece)" fill="{ombre}" fill-rule="evenodd" '81 f'd="M{32 - ri} 32a{ri} {ri} 0 1 0 {2 * ri} 0a{ri} {ri} 0 1 0 {-2 * ri} 0Z'82 f'M{32 - ri + 1.6} 34.2a{ri} {ri} 0 1 0 {2 * ri} 0a{ri} {ri} 0 1 0 {-2 * ri} 0Z"/>')83 arcs = ""84 for i in range(N):85 x0, y0 = pol(R, angle(i) + demi(i))86 x1, y1 = pol(R, angle(i + 1) - demi(i + 1))87 arcs += f'<path d="M{32 + x0:.2f} {32 + y0:.2f}A{R} {R} 0 0 1 {32 + x1:.2f} {32 + y1:.2f}"/>'88 hx, hy = pol(R, -90 - 14)89 fx, _ = pol(R, -90 + 14)90 arcs += f'<path d="M{32 + hx:.2f} {32 + hy - 2:.2f}v{fx - hx + 2:.2f}" stroke-width="4" stroke-linecap="round"/>'91 s += f'<g fill="none" stroke="{encre}" stroke-width="{epaisseur}">{arcs}</g>'92 return s939495def svg(taille, fond, contenu, echelle=0.72):96 # le symbole occupe `echelle` du côté ; le reste est la marge de l'icône97 k = taille * echelle / 6498 d = (taille - 64 * k) / 299 f = f'<rect width="{taille}" height="{taille}" fill="{fond}"/>' if fond else ""100 return (f'<svg xmlns="http://www.w3.org/2000/svg" width="{taille}" height="{taille}" viewBox="0 0 {taille} {taille}">'101 f'{f}<g transform="translate({d} {d}) scale({k})">{contenu}</g></svg>')102103104def png(source, sortie, taille):105 with tempfile.NamedTemporaryFile("w", suffix=".svg", delete=False) as t:106 t.write(source)107 subprocess.run(["rsvg-convert", "-w", str(taille), "-h", str(taille), t.name, "-o", sortie], check=True)108 os.unlink(t.name)109 print(os.path.relpath(sortie, RACINE))110111112def main():113 icone = os.path.join(ASSETS, "AppIcon.appiconset")114 marque = os.path.join(ASSETS, "LaunchMark.imageset")115 os.makedirs(icone, exist_ok=True)116 os.makedirs(marque, exist_ok=True)117 # clair : encre sur papier, le sol un ton plus clair ; sombre : l'inverse ; teinté : niveaux de gris sur noir118 png(svg(1024, "#f4f2ec", symbole("#1a1b1e", sol="#fbfaf6", ombre="#1a1b1e1c")), os.path.join(icone, "icon-1024.png"), 1024)119 png(svg(1024, "#111214", symbole("#efede6", sol="#18191c", ombre="#00000080")), os.path.join(icone, "icon-1024-dark.png"), 1024)120 png(svg(1024, "#000000", symbole("#ffffff", sol="#262626")), os.path.join(icone, "icon-1024-tinted.png"), 1024)121 for nom, encre in (("launch-mark", "#1a1b1e"), ("launch-mark-dark", "#efede6")):122 for k in (1, 2, 3):123 png(svg(96 * k, None, symbole(encre), echelle=1.0), os.path.join(marque, f"{nom}@{k}x.png"), 96 * k)124125126if __name__ == "__main__":127 main()128