Repository Public
1// =============================================================================2// SP BOUCHER | SOFTWARE & RESEARCH3// ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// PROJECT METADATA7// -----------------------------------------------------------------------------8// Project : Immo-Ka iOS9// File : ImmoKa/Design/Brand/BrandMark.swift10// Description : le symbole d'Immo-Ka, « Larmier » — une maison québécoise11// vue de face (pignon, avant-toits retroussés, cheminée) et12// sa porte rouge entrouverte, charnières à gauche. Dessiné13// pièce par pièce (une Shape par partie) sur la grille 64 ×14// 64 du système de marque : mêmes cotes que15// `/tmp/immoka-v2/brand/README.md` et le web16// (`brand/geometry.ts`). Logo, indicateur de chargement,17// illustrations d'états vides.18// Module : ImmoKa19// Repository : https://git.spboucher.ai/immo-ka-ios-v320// Project Website : https://www.immo-ka.com21// Created : 2026-11-2522// Last Modified : 2026-11-2523//24// =============================================================================25// AUTHOR & PROFESSIONAL AFFILIATION26// =============================================================================27//28// Author : Simon-Pierre Boucher29// Position : Professor of Finance30// Institution : Université du Québec en Outaouais (UQO)31// Department : Département des sciences administratives32// Organization : SP Boucher33//34// Website : https://spboucher.ai35// Git : https://git.spboucher.ai36//37// =============================================================================38// OFFICIAL CONTACT DIRECTORY39// =============================================================================40//41// General : info@spboucher.ai42// Professional : contact@spboucher.ai43// Direct : simon@spboucher.ai44// Research : research@spboucher.ai45// Development : dev@spboucher.ai46// Support : support@spboucher.ai47// Security/Admin : admin@spboucher.ai48// Notifications : notifications@spboucher.ai49//50// Preferred Contact: support@spboucher.ai51//52// =============================================================================53// COPYRIGHT & INTELLECTUAL PROPERTY54// =============================================================================55//56// Copyright (c) 202657// Simon-Pierre Boucher58//59// All rights reserved where applicable.60//61// This file is governed by the applicable project license,62// copyright notices, institutional agreements and relevant law.63//64// Unless expressly authorized by the applicable license or65// rights holder, copying, redistribution, sublicensing,66// publication and commercial exploitation are not permitted.67//68// Existing third-party rights and notices remain unaffected.69//70// =============================================================================71// CONFIDENTIALITY & SECURITY72// =============================================================================73//74// Classification : Public75// Distribution : Public repository; use is governed by the project license76// Security Contact : admin@spboucher.ai77//78// Access to this source does not independently grant permission79// to redistribute or disclose confidential materials.80//81// Do not embed credentials, private keys, access tokens,82// certificates or confidential personal information.83//84// =============================================================================85// LICENSE & MAINTENANCE86// =============================================================================87//88// License : None specified (no license file in this repository)89// Maintainer : Simon-Pierre Boucher90// Technical Contact: dev@spboucher.ai91//92// =============================================================================93// END OF SP BOUCHER SOURCE HEADER94// =============================================================================9596import SwiftUI9798/// Géométrie canonique du symbole (viewBox 0 0 64 64). Source unique pour le logo, l'icône, les marqueurs de99/// carte et la façade de la transition.100enum BrandGeometry {101 static let box: CGFloat = 64102 /// faîte du toit103 static let apex = CGPoint(x: 32, y: 6.5)104 /// murs : du dessous des avant-toits jusqu'au sol105 static let walls = CGRect(x: 11, y: 31.5, width: 42, height: 26.5)106 /// embrasure de la porte (ce qui est révélé) : 18 × 30, rapport 0,6107 static let opening = CGRect(x: 23, y: 28, width: 18, height: 30)108 /// embrasure de la variante micro (≤ 20 pt) : porte plus large, pas de poignée109 static let openingMicro = CGRect(x: 21.5, y: 27, width: 21, height: 31)110 static let openingRadius: CGFloat = 1.5111 /// battant du logo au repos (40°) : bord libre en x 36,5, de y 31,3 à y 55,2112 static let restFreeX: CGFloat = 36.5113 static let restTopInset: CGFloat = 3.3114 static let restBottomInset: CGFloat = 2.8115 /// poignée : réserve ronde de rayon 1,5, à 75,6 % de la largeur apparente du battant, en y 44,2116 static let handleFraction: CGFloat = (33.2 - 23) / 13.5117 static let handleY: CGFloat = 44.2118 static let handleRadius: CGFloat = 1.5119 /// seuil : le sol devant la maison120 static let thresholdY: CGFloat = 59.5121 static let thresholdStroke: CGFloat = 3122123 // angles des états, en degrés (système de marque, § 4)124 static let closedAngle: Double = 0125 static let hoverAngle: Double = 22126 /// bouton Explorer au repos127 static let exploreAngle: Double = 34128 /// entrouverte : l'angle du logo129 static let ajarAngle: Double = 40130 /// états vides : la porte vient se poser à 44°131 static let settledAngle: Double = 44132 /// petite maison d'une carte de propriété sous le doigt133 static let cardAngle: Double = 46134 static let openAngle: Double = 86135 /// angle final dans la transition136 static let transitionAngle: Double = 84137138 /// Projection de la maison animable : distance focale 0,8 × 64 = 51,2 unités, point de fuite à 40 % de la139 /// largeur et 47 % de la hauteur de l'embrasure.140 static let focal: CGFloat = 51.2141 static let vanishing = CGPoint(x: 0.40, y: 0.47)142143 /// Bord libre du battant pour un angle, en unités de grille dans l'embrasure : abscisse, retraits haut et bas.144 /// `s = p / (p + L·sin θ)` ; `x' = ox + (L·cos θ − ox)·s` ; `y' = oy + (y − oy)·s`.145 /// À 40° exactement (le logo au repos), on reprend le battant dessiné à la main, un peu plus large.146 static func freeEdge(angle: Double, opening o: CGRect = opening) -> (x: CGFloat, top: CGFloat, bottom: CGFloat) {147 if angle == ajarAngle, o == opening { return (restFreeX - o.minX, restTopInset, restBottomInset) }148 let t = max(0, min(90, angle)) * .pi / 180149 let L = o.width, H = o.height150 let ox = L * vanishing.x, oy = H * vanishing.y151 let s = focal / (focal + L * CGFloat(sin(t)))152 let x = ox + (L * CGFloat(cos(t)) - ox) * s153 return (x, oy - oy * s, (H - oy) - (H - oy) * s)154 }155156 /// Largeur apparente du battant (unités de grille) : 18 fermé, 12,6 à 40° (13,5 pour le logo), 3,3 à 84°.157 static func panelWidth(angle: Double, opening o: CGRect = opening) -> CGFloat { max(0, freeEdge(angle: angle, opening: o).x) }158159 /// Assombrissement du battant qui tourne : noir à 30 % × θ / 90.160 static func panelShade(angle: Double) -> Double { 0.30 * max(0, min(1, angle / 90)) }161}162163/// Silhouette : toit à avant-toits retroussés, cheminée et murs, d'un seul contour.164struct HouseSilhouetteShape: Shape {165 func path(in rect: CGRect) -> Path {166 var p = Path()167 p.move(to: CGPoint(x: 32, y: 6.5))168 p.addLine(to: CGPoint(x: 41.5, y: 15.3))169 // cheminée, sur le versant droit170 p.addLine(to: CGPoint(x: 41.5, y: 9.5))171 p.addLine(to: CGPoint(x: 47, y: 9.5))172 p.addLine(to: CGPoint(x: 47, y: 20.4))173 p.addLine(to: CGPoint(x: 49.7, y: 22.9))174 // avant-toit droit, retroussé (le larmier)175 p.addCurve(to: CGPoint(x: 59.8, y: 27.9), control1: CGPoint(x: 52.7, y: 25.7), control2: CGPoint(x: 55.7, y: 27.2))176 p.addCurve(to: CGPoint(x: 59.5, y: 31.5), control1: CGPoint(x: 62.1, y: 28.3), control2: CGPoint(x: 61.9, y: 31.5))177 p.addLine(to: CGPoint(x: 53, y: 31.5))178 p.addLine(to: CGPoint(x: 53, y: 58))179 p.addLine(to: CGPoint(x: 11, y: 58))180 p.addLine(to: CGPoint(x: 11, y: 31.5))181 p.addLine(to: CGPoint(x: 4.5, y: 31.5))182 // avant-toit gauche183 p.addCurve(to: CGPoint(x: 4.2, y: 27.9), control1: CGPoint(x: 2.1, y: 31.5), control2: CGPoint(x: 1.9, y: 28.3))184 p.addCurve(to: CGPoint(x: 14.3, y: 22.9), control1: CGPoint(x: 8.3, y: 27.2), control2: CGPoint(x: 11.3, y: 25.7))185 p.closeSubpath()186 return p.applying(.grid(in: rect))187 }188}189190/// Embrasure de la porte : coins hauts arrondis. C'est une réserve dans la silhouette.191struct HouseOpeningShape: Shape {192 var micro = false193 func path(in rect: CGRect) -> Path {194 let o = micro ? BrandGeometry.openingMicro : BrandGeometry.opening195 let r = BrandGeometry.openingRadius196 var p = Path()197 p.move(to: CGPoint(x: o.minX, y: o.maxY))198 p.addLine(to: CGPoint(x: o.minX, y: o.minY + r))199 p.addArc(tangent1End: CGPoint(x: o.minX, y: o.minY), tangent2End: CGPoint(x: o.minX + r, y: o.minY), radius: r)200 p.addLine(to: CGPoint(x: o.maxX - r, y: o.minY))201 p.addArc(tangent1End: CGPoint(x: o.maxX, y: o.minY), tangent2End: CGPoint(x: o.maxX, y: o.minY + r), radius: r)202 p.addLine(to: CGPoint(x: o.maxX, y: o.maxY))203 p.closeSubpath()204 return p.applying(.grid(in: rect))205 }206}207208/// Maison évidée de son embrasure (remplissage pair-impair).209struct HouseBodyShape: Shape {210 var micro = false211 func path(in rect: CGRect) -> Path {212 var p = HouseSilhouetteShape().path(in: rect)213 p.addPath(HouseOpeningShape(micro: micro).path(in: rect))214 return p215 }216}217218/// Battant de la porte : charnières à gauche, il s'ouvre vers l'intérieur (le bord libre s'éloigne et219/// rapetisse). `angle` en degrés, animable ; la poignée est une réserve ronde.220struct HousePanelShape: Shape {221 var angle: Double222 var micro = false223224 var animatableData: Double {225 get { angle }226 set { angle = newValue }227 }228229 func path(in rect: CGRect) -> Path {230 let o = micro ? BrandGeometry.openingMicro : BrandGeometry.opening231 let e = BrandGeometry.freeEdge(angle: angle, opening: o)232 let w = e.x233 guard w > 0.15 else { return Path() }234 var p = Path()235 p.move(to: CGPoint(x: o.minX, y: o.minY))236 p.addLine(to: CGPoint(x: o.minX + w, y: o.minY + e.top))237 p.addLine(to: CGPoint(x: o.minX + w, y: o.maxY - e.bottom))238 p.addLine(to: CGPoint(x: o.minX, y: o.maxY))239 p.closeSubpath()240 if !micro, w > 5 {241 // poignée : réserve dont la largeur suit le raccourci du battant242 let squeeze = w / o.width243 let rx = BrandGeometry.handleRadius * max(0.45, min(1, squeeze / 0.75)), ry = BrandGeometry.handleRadius244 let cx = o.minX + w * BrandGeometry.handleFraction245 p.addEllipse(in: CGRect(x: cx - rx, y: BrandGeometry.handleY - ry, width: rx * 2, height: ry * 2))246 }247 return p.applying(.grid(in: rect))248 }249}250251/// Seuil : le sol devant la maison (trait à bouts ronds).252struct HouseThresholdShape: Shape {253 func path(in rect: CGRect) -> Path {254 var p = Path()255 p.move(to: CGPoint(x: 4, y: BrandGeometry.thresholdY))256 p.addLine(to: CGPoint(x: 60, y: BrandGeometry.thresholdY))257 return p.applying(.grid(in: rect))258 }259}260261extension CGAffineTransform {262 /// De la grille 64 × 64 du symbole vers un rectangle (carré inscrit, centré).263 static func grid(in rect: CGRect) -> CGAffineTransform {264 let s = min(rect.width, rect.height) / BrandGeometry.box265 return CGAffineTransform(translationX: rect.midX - 32 * s, y: rect.midY - 32 * s).scaledBy(x: s, y: s)266 }267}268269/// Le symbole complet. `angle` = ouverture de la porte en degrés (0 fermée, 40 entrouverte, 84 ouverte).270struct BrandMark<Interior: View>: View {271 var angle: Double272 /// vrai : posé sur un fond sombre fixe (maison chaux, porte rouge clair), quel que soit le thème273 var onDark = false274 /// une seule couleur (pictogramme)275 var mono: Color?276 var showsThreshold = true277 /// ce que la porte révèle (transparent pour le symbole : l'embrasure est une réserve)278 @ViewBuilder var interior: () -> Interior279280 var body: some View {281 GeometryReader { geo in282 let side = min(geo.size.width, geo.size.height)283 let micro = side <= 20284 let house = mono ?? (onDark ? Theme.chalk : Theme.house)285 let door = mono ?? (onDark ? Color(hex: 0xEA5A61) : Theme.door)286 let grid = CGAffineTransform.grid(in: CGRect(origin: .zero, size: geo.size))287 let opening = (micro ? BrandGeometry.openingMicro : BrandGeometry.opening).applying(grid)288 ZStack(alignment: .topLeading) {289 interior()290 .frame(width: opening.width, height: opening.height)291 .clipShape(HouseOpeningClip())292 .offset(x: opening.minX, y: opening.minY)293 HouseBodyShape(micro: micro).fill(house, style: FillStyle(eoFill: true))294 HousePanelShape(angle: angle, micro: micro).fill(door, style: FillStyle(eoFill: true))295 HousePanelShape(angle: angle, micro: micro)296 .fill(Color.black.opacity(mono == nil ? BrandGeometry.panelShade(angle: angle) : 0), style: FillStyle(eoFill: true))297 if showsThreshold {298 HouseThresholdShape()299 .stroke(house, style: StrokeStyle(lineWidth: (micro ? 4 : BrandGeometry.thresholdStroke) * side / 64, lineCap: .round))300 }301 }302 }303 .aspectRatio(1, contentMode: .fit)304 }305}306307/// Découpe de l'intérieur aux coins hauts de l'embrasure.308private struct HouseOpeningClip: Shape {309 func path(in rect: CGRect) -> Path {310 let r = min(rect.width, rect.height) * BrandGeometry.openingRadius / BrandGeometry.opening.width311 return Path(roundedRect: rect, cornerRadii: RectangleCornerRadii(topLeading: r, topTrailing: r))312 }313}314315/// L'angle est une donnée animable : pendant une animation, le dessin reçoit les angles intermédiaires316/// (le battant pivote réellement, il ne saute pas à sa position finale).317extension BrandMark: @MainActor Animatable {318 var animatableData: Double {319 get { angle }320 set { angle = newValue }321 }322}323324extension BrandMark where Interior == Color {325 init(angle: Double = BrandGeometry.ajarAngle, onDark: Bool = false, mono: Color? = nil, showsThreshold: Bool = true) {326 self.init(angle: angle, onDark: onDark, mono: mono, showsThreshold: showsThreshold) { Color.clear }327 }328}329330/// Signature : symbole et logotype (« Immo » couleur du texte, trait d'union fin et atténué, « Ka » rouge).331struct BrandLogo: View {332 var height: CGFloat = 30333 var showsWordmark = true334335 var body: some View {336 // texte à 72 % de la hauteur du symbole ; écart symbole–texte de 26 % ; interlettrage −0,022 em337 let em = height * 0.72338 HStack(spacing: height * 0.26) {339 BrandMark(angle: BrandGeometry.ajarAngle).frame(width: height, height: height)340 if showsWordmark {341 HStack(alignment: .lastTextBaseline, spacing: em * 0.05) {342 Text("Immo").foregroundStyle(Theme.ink)343 // trait d'union fin et atténué : largeur 0,28 em, épaisseur 0,07 em, remonté de 0,28 em344 Rectangle().fill(Theme.ink.opacity(0.45)).frame(width: em * 0.28, height: max(1, em * 0.07))345 .alignmentGuide(.lastTextBaseline) { d in d[.bottom] + em * 0.28 }346 Text("Ka").foregroundStyle(Theme.accent)347 }348 .font(.editorial(em, weight: .medium))349 .tracking(-0.022 * em)350 }351 }352 .accessibilityElement(children: .ignore)353 .accessibilityLabel("Immo-Ka")354 }355}356357/// Indicateur de chargement (attente réelle seulement) : la porte de la maison respire.358struct BrandLoader: View {359 var size: CGFloat = 34360 var label: String = "Chargement"361 @State private var open = false362 @Environment(\.accessibilityReduceMotion) private var reduceMotion363364 var body: some View {365 BrandMark(angle: reduceMotion ? BrandGeometry.hoverAngle : (open ? 58 : 6))366 .frame(width: size, height: size)367 .onAppear {368 guard !reduceMotion else { return }369 // la porte respire entre 6° et 58° en 1,6 s370 withAnimation(.easeInOut(duration: 0.8).repeatForever(autoreverses: true)) { open = true }371 }372 .accessibilityElement(children: .ignore)373 .accessibilityLabel(label)374 }375}376377/// Illustrations d'états vides : porte fermée = aucun résultat, entrouverte = invitation,378/// plusieurs maisons = comparer, maison et cœur = favoris vides.379struct BrandIllustration: View {380 enum Kind { case closed, ajar, many, heart }381 let kind: Kind382 var size: CGFloat = 76383 @State private var settled = false384 @Environment(\.accessibilityReduceMotion) private var reduceMotion385386 private func angle(_ target: Double) -> Double { settled || reduceMotion ? target : 0 }387388 var body: some View {389 HStack(alignment: .bottom, spacing: size * 0.1) {390 if kind == .many {391 BrandMark(angle: 0).frame(width: size * 0.62, height: size * 0.62).opacity(0.4)392 }393 BrandMark(angle: kind == .closed ? 0 : angle(kind == .many ? 48 : BrandGeometry.settledAngle))394 .frame(width: size, height: size)395 .overlay(alignment: .topTrailing) {396 if kind == .heart {397 Image(systemName: "heart.fill").font(.system(size: size * 0.26)).foregroundStyle(Theme.accent)398 .offset(x: size * 0.2, y: -size * 0.02)399 }400 }401 if kind == .many {402 BrandMark(angle: angle(24)).frame(width: size * 0.62, height: size * 0.62).opacity(0.4)403 }404 }405 .onAppear {406 // la porte vient se poser à son angle avec son poids : 520 ms, léger dépassement407 withAnimation(.spring(response: 0.52, dampingFraction: 0.62).delay(0.12)) { settled = true }408 }409 .accessibilityHidden(true)410 }411}412