Repository Public
1#!/usr/bin/env bash2# =============================================================================3# SP BOUCHER | INFRASTRUCTURE & AUTOMATION4# ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5# =============================================================================6#7# Project : SP Browser8# File : Assets/Brand/build-icons.sh9# Module : Assets10# Repository : https://git.spboucher.ai/sp-browser11# Created : 2026-11-1712# Last Modified : 2026-11-1713#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: support@spboucher.ai22# Technical Contact: dev@spboucher.ai23# Security/Admin : admin@spboucher.ai24#25# Copyright (c) 202626# Simon-Pierre Boucher27# All rights reserved where applicable. This file is governed by the28# applicable project license, copyright notices and relevant law.29# Existing third-party rights and notices remain unaffected.30#31# License : None specified (no license file in this repository)32#33# Do not embed credentials, private keys, access tokens,34# certificates or confidential personal information.35#36# =============================================================================37# END OF SP BOUCHER SOURCE HEADER38# =============================================================================3940# SP Browser41# File: Assets/Brand/build-icons.sh42# Description: Régénère tous les PNG et le catalogue d'assets à partir des sources SVG.43#44# Author: Simon-Pierre Boucher45# Contact: contact@spboucher.ai46#47# SP Browser — régénère tous les PNG et le catalogue d'assets à partir des sources SVG.48# Idempotent : relancer le script réécrit exactement les mêmes fichiers.49# Dépendance unique : rsvg-convert (librsvg). Usage : Assets/Brand/build-icons.sh50set -euo pipefail5152BRAND_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"53ROOT_DIR="$(cd "$BRAND_DIR/../.." && pwd)"54RENDERS="$BRAND_DIR/Renders"55CONCEPTS="$BRAND_DIR/Concepts"56XCASSETS="$ROOT_DIR/SPBrowser/Resources/Assets.xcassets"5758RSVG="${RSVG:-$(command -v rsvg-convert || true)}"59[ -x "${RSVG:-}" ] || RSVG="/opt/homebrew/bin/rsvg-convert"60[ -x "$RSVG" ] || { echo "erreur : rsvg-convert introuvable (brew install librsvg)" >&2; exit 1; }6162FULL="$BRAND_DIR/SPBrowserIcon.svg"63SMALL="$BRAND_DIR/SPBrowserIcon-Small.svg"64MARK="$BRAND_DIR/SPBrowserIcon-NoBackground.svg"65MONO="$BRAND_DIR/SPBrowserIcon-Mono.svg"66MENU="$BRAND_DIR/SPBrowserMenuBar.svg"6768render() { # render <svg> <px> <sortie.png>69 "$RSVG" -w "$2" -h "$2" "$1" -o "$3"70}71# Variante simplifiée pour les fichiers de 16 et 32 px, icône complète au-delà.72source_for() { if [ "$1" -le 32 ]; then echo "$SMALL"; else echo "$FULL"; fi; }7374# 0. Validation XML des sources75if command -v xmllint >/dev/null 2>&1; then76 for f in "$BRAND_DIR"/*.svg "$CONCEPTS"/*.svg; do xmllint --noout "$f"; done77fi7879mkdir -p "$RENDERS" "$XCASSETS/AppIcon.appiconset" "$XCASSETS/MenuBarIcon.imageset" \80 "$XCASSETS/BrandMark.imageset" "$XCASSETS/AccentColor.colorset"8182# 1. Concepts (512 px)83for f in "$CONCEPTS"/concept-*.svg; do render "$f" 512 "${f%.svg}.png"; done8485# 2. Rendus de référence86for s in 16 32 64 128 256 512 1024; do87 render "$(source_for "$s")" "$s" "$RENDERS/icon_${s}.png"88done89render "$MARK" 512 "$RENDERS/mark_512.png"90render "$MONO" 512 "$RENDERS/mono_512.png"9192# 3. Aperçus sur fond clair et sombre (SVG d'assemblage temporaire, à partir des PNG)93preview() { # preview <nom> <fond> <fond2> <couleur du glyphe monochrome>94 local wrapper="$RENDERS/.preview-$1.svg"95 cat > "$wrapper" <<SVG96<?xml version="1.0" encoding="UTF-8"?>97<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="1400" height="720" viewBox="0 0 1400 720">98 <defs>99 <linearGradient id="bg" x1="0" y1="0" x2="0" y2="1">100 <stop offset="0" stop-color="$2"/><stop offset="1" stop-color="$3"/>101 </linearGradient>102 </defs>103 <rect width="1400" height="720" fill="url(#bg)"/>104 <image x="64" y="104" width="512" height="512" xlink:href="icon_512.png"/>105 <image x="640" y="104" width="256" height="256" xlink:href="icon_256.png"/>106 <image x="928" y="232" width="128" height="128" xlink:href="icon_128.png"/>107 <image x="1088" y="296" width="64" height="64" xlink:href="icon_64.png"/>108 <image x="1184" y="328" width="32" height="32" xlink:href="icon_32.png"/>109 <image x="1248" y="344" width="16" height="16" xlink:href="icon_16.png"/>110 <image x="656" y="424" width="192" height="192" xlink:href="mark_512.png"/>111 <image x="928" y="424" width="192" height="192" xlink:href="$4"/>112</svg>113SVG114 "$RSVG" "$wrapper" -o "$RENDERS/preview-$1.png"115 rm -f "$wrapper"116}117# Version blanche du monochrome pour l'aperçu sombre (même tracé, couleur remplacée)118sed 's/#000000/#FFFFFF/g' "$MONO" > "$RENDERS/.mono-white.svg"119render "$RENDERS/.mono-white.svg" 512 "$RENDERS/.mono_white_512.png"120preview light "#FFFFFF" "#E9ECF2" "mono_512.png"121preview dark "#1E2533" "#0B0E14" ".mono_white_512.png"122rm -f "$RENDERS/.mono-white.svg" "$RENDERS/.mono_white_512.png"123124# 4. Catalogue Xcode125cat > "$XCASSETS/Contents.json" <<'JSON'126{127 "info" : {128 "author" : "xcode",129 "version" : 1130 }131}132JSON133134# 4a. AppIcon (macOS) : 16/32/128/256/512 pt en @1x et @2x135APPICON="$XCASSETS/AppIcon.appiconset"136rm -f "$APPICON"/*.png137for pt in 16 32 128 256 512; do138 render "$(source_for "$pt")" "$pt" "$APPICON/icon_${pt}x${pt}.png"139 px2=$((pt * 2))140 render "$(source_for "$px2")" "$px2" "$APPICON/icon_${pt}x${pt}@2x.png"141done142{143 echo '{'144 echo ' "images" : ['145 first=1146 for pt in 16 32 128 256 512; do147 for scale in 1 2; do148 [ "$first" = 1 ] || echo ' },'149 first=0150 suffix=""; [ "$scale" = 2 ] && suffix="@2x"151 echo ' {'152 echo " \"filename\" : \"icon_${pt}x${pt}${suffix}.png\","153 echo ' "idiom" : "mac",'154 echo " \"scale\" : \"${scale}x\","155 echo " \"size\" : \"${pt}x${pt}\""156 done157 done158 echo ' }'159 echo ' ],'160 echo ' "info" : {'161 echo ' "author" : "xcode",'162 echo ' "version" : 1'163 echo ' }'164 echo '}'165} > "$APPICON/Contents.json"166167# 4b. Glyphe de barre des menus (image modèle, 18 pt)168MENUSET="$XCASSETS/MenuBarIcon.imageset"169render "$MENU" 18 "$MENUSET/MenuBarIcon.png"170render "$MENU" 36 "$MENUSET/MenuBarIcon@2x.png"171render "$MENU" 54 "$MENUSET/MenuBarIcon@3x.png"172cat > "$MENUSET/Contents.json" <<'JSON'173{174 "images" : [175 { "filename" : "MenuBarIcon.png", "idiom" : "universal", "scale" : "1x" },176 { "filename" : "MenuBarIcon@2x.png", "idiom" : "universal", "scale" : "2x" },177 { "filename" : "MenuBarIcon@3x.png", "idiom" : "universal", "scale" : "3x" }178 ],179 "info" : {180 "author" : "xcode",181 "version" : 1182 },183 "properties" : {184 "template-rendering-intent" : "template"185 }186}187JSON188189# 4c. Symbole de marque (64 pt) pour la page de démarrage190MARKSET="$XCASSETS/BrandMark.imageset"191render "$MARK" 64 "$MARKSET/BrandMark.png"192render "$MARK" 128 "$MARKSET/BrandMark@2x.png"193render "$MARK" 192 "$MARKSET/BrandMark@3x.png"194cat > "$MARKSET/Contents.json" <<'JSON'195{196 "images" : [197 { "filename" : "BrandMark.png", "idiom" : "universal", "scale" : "1x" },198 { "filename" : "BrandMark@2x.png", "idiom" : "universal", "scale" : "2x" },199 { "filename" : "BrandMark@3x.png", "idiom" : "universal", "scale" : "3x" }200 ],201 "info" : {202 "author" : "xcode",203 "version" : 1204 },205 "properties" : {206 "template-rendering-intent" : "original"207 }208}209JSON210211# 4d. Couleur d'accent : #2F6BFF (clair), #5B8CFF (sombre)212cat > "$XCASSETS/AccentColor.colorset/Contents.json" <<'JSON'213{214 "colors" : [215 {216 "color" : {217 "color-space" : "srgb",218 "components" : { "alpha" : "1.000", "blue" : "0xFF", "green" : "0x6B", "red" : "0x2F" }219 },220 "idiom" : "universal"221 },222 {223 "appearances" : [224 { "appearance" : "luminosity", "value" : "dark" }225 ],226 "color" : {227 "color-space" : "srgb",228 "components" : { "alpha" : "1.000", "blue" : "0xFF", "green" : "0x8C", "red" : "0x5B" }229 },230 "idiom" : "universal"231 }232 ],233 "info" : {234 "author" : "xcode",235 "version" : 1236 }237}238JSON239240# 5. Contrôle des JSON241while IFS= read -r -d '' j; do242 if command -v python3 >/dev/null 2>&1; then243 python3 -m json.tool "$j" >/dev/null244 else245 plutil -convert json -o /dev/null "$j"246 fi247done < <(find "$XCASSETS" -name Contents.json -print0)248249echo "SP Browser : assets régénérés."250echo " rendus : $RENDERS"251echo " catalogue : $XCASSETS"252