SPB Git

Repository Public

BrandSymbol.swift 3.4 KB 78 lines swift

1//2//  Food-Ka iOS v23//  File: FoodKa/Design/Brand/BrandSymbol.swift4//  Description: le symbole « Tablette » dessiné nativement (grille 64 × 64 de brand/README.md) : le rond et le haut5//               posés sur la tablette, l'étiquette glissée dessous avec ses deux réserves alignées à droite.6//7//  Author: Simon-Pierre Boucher8//  Contact: contact@spboucher.ai9//1011import SwiftUI1213struct BrandSymbol: View {14    enum Style {15        /// produits et tablette à l'encre, étiquette betterave16        case color17        /// une seule couleur18        case mono(Color)19    }2021    var style: Style = .color22    /// glissement de l'étiquette vers la droite, en unités de la grille (mouvement du logo)23    var slide: CGFloat = 02425    var body: some View {26        Canvas { ctx, size in27            let s = min(size.width, size.height) / 6428            let ox = (size.width - 64 * s) / 2, oy = (size.height - 64 * s) / 229            func r(_ x: CGFloat, _ y: CGFloat, _ w: CGFloat, _ h: CGFloat) -> CGRect {30                CGRect(x: ox + x * s, y: oy + y * s, width: w * s, height: h * s)31            }32            let (inkColor, tagColor): (Color, Color) = switch style {33            case .color: (Theme.ink, Theme.brand)34            case .mono(let c): (c, c)35            }36            // le rond et le haut37            var goods = Path(ellipseIn: r(9, 8.5, 17, 17))38            goods.addPath(Path(roundedRect: r(31.5, 4.5, 15, 23.5),39                               cornerRadii: RectangleCornerRadii(topLeading: 2.5 * s, bottomLeading: 0, bottomTrailing: 0, topTrailing: 2.5 * s)))40            ctx.fill(goods, with: .color(inkColor))41            // la tablette42            var shelf = Path()43            shelf.move(to: CGPoint(x: ox + 5.5 * s, y: oy + 28 * s))44            shelf.addLine(to: CGPoint(x: ox + 58.5 * s, y: oy + 28 * s))45            ctx.stroke(shelf, with: .color(inkColor), style: StrokeStyle(lineWidth: 5 * s, lineCap: .round))46            // l'étiquette et ses deux réserves (de vrais trous)47            var tag = Path(roundedRect: r(20 + slide, 34, 38, 24), cornerRadius: 3.5 * s)48            tag.addPath(Path(roundedRect: r(34.5 + slide, 39.5, 18.5, 7.5), cornerRadius: 2 * s))49            tag.addPath(Path(roundedRect: r(42 + slide, 50, 11, 3.5), cornerRadius: 1.75 * s))50            ctx.fill(tag, with: .color(tagColor), style: FillStyle(eoFill: true))51        }52        .aspectRatio(1, contentMode: .fit)53        .accessibilityHidden(true)54    }55}5657/// Mot-symbole : « Food » à l'encre, trait d'union fin et atténué, « Ka » en betterave (New York, graisse 500).58struct Wordmark: View {59    var size: CGFloat = 246061    var body: some View {62        HStack(alignment: .center, spacing: size * 0.2) {63            BrandSymbol().frame(width: size * 1.35, height: size * 1.35)64            HStack(alignment: .firstTextBaseline, spacing: size * 0.05) {65                Text("Food").foregroundStyle(Theme.ink)66                Rectangle().fill(Theme.ink.opacity(0.45))67                    .frame(width: size * 0.28, height: max(1, size * 0.07))68                    .alignmentGuide(.firstTextBaseline) { d in d[.bottom] + size * 0.28 }69                Text("Ka").foregroundStyle(Theme.brand)70            }71            .font(.system(size: size, weight: .medium, design: .serif))72            .tracking(-0.022 * size)73        }74        .accessibilityElement(children: .ignore)75        .accessibilityLabel("Food-Ka")76    }77}78
Files main
Menu

Theme