SPB Git

Repository Public

BrandSymbol.swift 6.6 KB 132 lines swift

1//2//  Fabri-Ka iOS v23//  File: FabriKa/Design/Brand/BrandSymbol.swift4//  Description: le symbole « Enseigne » dessiné nativement sur sa grille 64 × 64 (brand/README.md, section 2) :5//               la platine, le bras, la jambe de force, les deux attaches et la plaque qui pend. Variante micro6//               (sans jambe) sous 28 points. Mot-symbole « Fabri-Ka ».7//8//  Author: Simon-Pierre Boucher9//  Contact: contact@spboucher.ai10//1112import SwiftUI1314struct BrandSymbol: View {15    enum Style {16        /// potence fer, plaque laiton17        case color18        /// une seule couleur19        case mono(Color)20    }2122    var style: Style = .color23    /// variante micro (16 à 24 points) : pas de jambe, pièces épaissies24    var micro = false25    /// angle de la plaque autour du bras, en degrés (mouvements du logo)26    var swing: Double = 02728    var body: some View {29        Canvas { ctx, size in30            let s = min(size.width, size.height) / 6431            let ox = (size.width - 64 * s) / 2, oy = (size.height - 64 * s) / 232            func pt(_ x: CGFloat, _ y: CGFloat) -> CGPoint { CGPoint(x: ox + x * s, y: oy + y * s) }33            func rect(_ x: CGFloat, _ y: CGFloat, _ w: CGFloat, _ h: CGFloat) -> CGRect {34                CGRect(x: ox + x * s, y: oy + y * s, width: w * s, height: h * s)35            }36            let (iron, plaque): (Color, Color) = switch style {37            case .color: (Theme.iron, Theme.plaque)38            case .mono(let c): (c, c)39            }40            func line(_ a: CGPoint, _ b: CGPoint, _ w: CGFloat) {41                var p = Path(); p.move(to: a); p.addLine(to: b)42                ctx.stroke(p, with: .color(iron), style: StrokeStyle(lineWidth: w * s, lineCap: .round))43            }44            // la plaque : carré plein de 40, sans réserve ; elle bascule autour du bras (écrasement vertical)45            let k = CGFloat(cos(swing * .pi / 180))46            if micro {47                ctx.fill(Path(roundedRect: rect(4, 1, 7.5, 34), cornerRadius: 3.75 * s), with: .color(iron))48                line(pt(7.75, 7), pt(57, 7), 6)49                line(pt(30, 8), pt(30, 8 + 13 * k), 4); line(pt(50, 8), pt(50, 8 + 13 * k), 4)50                ctx.fill(Path(roundedRect: rect(20, 7 + 13 * k, 40, 40 * k), cornerRadius: 4 * s), with: .color(plaque))51            } else {52                ctx.fill(Path(roundedRect: rect(4, 3, 6.5, 34), cornerRadius: 3.25 * s), with: .color(iron))53                line(pt(7.25, 10), pt(57.5, 10), 5.5)54                line(pt(7.5, 30), pt(21, 12), 3.5)55                line(pt(29, 12), pt(29, 10 + 11 * k), 3.5); line(pt(51, 12), pt(51, 10 + 11 * k), 3.5)56                ctx.fill(Path(roundedRect: rect(20, 10 + 10 * k, 40, 40 * k), cornerRadius: 4 * s), with: .color(plaque))57            }58        }59        .aspectRatio(1, contentMode: .fit)60        .accessibilityHidden(true)61    }62}6364/// Mot-symbole : « Fabri » à l'encre, trait d'union fin et atténué, « Ka » en laiton (New York, graisse 500).65struct Wordmark: View {66    var size: CGFloat = 246768    var body: some View {69        HStack(alignment: .center, spacing: size * 0.28) {70            BrandSymbol().frame(width: size * 1.39, height: size * 1.39)71            HStack(alignment: .firstTextBaseline, spacing: size * 0.05) {72                Text("Fabri").foregroundStyle(Theme.ink)73                Rectangle().fill(Theme.ink.opacity(0.45))74                    .frame(width: size * 0.28, height: max(1, size * 0.07))75                    .alignmentGuide(.firstTextBaseline) { d in d[.bottom] + size * 0.28 }76                Text("Ka").foregroundStyle(Theme.brand)77            }78            .font(.system(size: size, weight: .medium, design: .serif))79            .tracking(-0.022 * size)80            .offset(y: size * 0.07)81        }82        .accessibilityElement(children: .ignore)83        .accessibilityLabel("Fabri-Ka")84    }85}8687/// La boutique sur la carte : une plaque pendue à un bout de bras, terminée par une pointe ; ancre en bas au centre.88/// Repos : plaque de papier bordée de fer, cœur laiton. Sélection : plaque laiton pleine, liseré clair, plus grande.89struct StoreMarker: View {90    var selected = false91    /// angle de la plaque (un battement à la sélection)92    var swing: Double = 09394    var body: some View {95        Canvas { ctx, size in96            let w: CGFloat = selected ? 38 : 30, h: CGFloat = selected ? 51 : 4197            let s = min(size.width / w, size.height / h)98            func p(_ x: CGFloat, _ y: CGFloat) -> CGPoint { CGPoint(x: x * s, y: y * s) }99            let cx = w / 2100            // le bout de bras et ses deux attaches101            var arm = Path(); arm.move(to: p(cx - 9, 3)); arm.addLine(to: p(cx + 9, 3))102            ctx.stroke(arm, with: .color(Theme.iron), style: StrokeStyle(lineWidth: 3 * s, lineCap: .round))103            var hooks = Path()104            hooks.move(to: p(cx - 5.5, 3)); hooks.addLine(to: p(cx - 5.5, 10))105            hooks.move(to: p(cx + 5.5, 3)); hooks.addLine(to: p(cx + 5.5, 10))106            ctx.stroke(hooks, with: .color(Theme.iron), style: StrokeStyle(lineWidth: 2 * s, lineCap: .round))107            // la plaque et sa pointe108            let bottom: CGFloat = selected ? 41 : 33, tip: CGFloat = selected ? 49.5 : 39.5, half: CGFloat = 5109            var body = Path()110            body.move(to: p(7, 9)); body.addLine(to: p(w - 7, 9))111            body.addQuadCurve(to: p(w - 3, 13), control: p(w - 3, 9))112            body.addLine(to: p(w - 3, bottom - 4))113            body.addQuadCurve(to: p(w - 7, bottom), control: p(w - 3, bottom))114            body.addLine(to: p(cx + half, bottom)); body.addLine(to: p(cx, tip)); body.addLine(to: p(cx - half, bottom))115            body.addLine(to: p(7, bottom))116            body.addQuadCurve(to: p(3, bottom - 4), control: p(3, bottom))117            body.addLine(to: p(3, 13))118            body.addQuadCurve(to: p(7, 9), control: p(3, 9))119            body.closeSubpath()120            ctx.fill(body, with: .color(selected ? Theme.plaque : Theme.plaquePaper))121            ctx.stroke(body, with: .color(selected ? Theme.plaquePaper : Theme.iron), style: StrokeStyle(lineWidth: (selected ? 2 : 1.5) * s, lineJoin: .round))122            // le cœur123            let c: CGFloat = selected ? 10.88 : 8.16, cy: CGFloat = selected ? 25 : 21124            ctx.fill(Path(roundedRect: CGRect(x: (cx - c / 2) * s, y: (cy - c / 2) * s, width: c * s, height: c * s), cornerRadius: 1.5 * s),125                     with: .color(selected ? Theme.plaqueInk : Theme.plaque))126        }127        .frame(width: selected ? 38 : 30, height: selected ? 51 : 41)128        .rotation3DEffect(.degrees(swing), axis: (x: 1, y: 0, z: 0), anchor: .top, perspective: 0.5)129        .accessibilityHidden(true)130    }131}132
Files main
Menu

Theme