spb/prisme Public MIT
Navigateur iOS intelligent — chaque page comprise localement avant d'être affichée. SwiftUI · WebKit · Foundation Models, 100% on-device.
Swift 96.7%
JavaScript 3.3%
1//2// PrismMark.swift3// Prisme4//5// Author: Simon-Pierre Boucher <contact@spboucher.ai>6//78import SwiftUI910/// The Prisme logo, drawn in code so it adapts to light/dark and any size.11/// Same geometry as the app icon (Design/icon/prisme-icon.svg): a white beam12/// enters a glass prism and exits as a spectrum fan.13struct PrismMark: View {14 var body: some View {15 Canvas { context, size in16 let s = min(size.width, size.height) / 10241718 func point(_ x: CGFloat, _ y: CGFloat) -> CGPoint {19 CGPoint(x: x * s, y: y * s)20 }21 func polygon(_ pts: [(CGFloat, CGFloat)]) -> Path {22 var path = Path()23 path.move(to: point(pts[0].0, pts[0].1))24 for p in pts.dropFirst() { path.addLine(to: point(p.0, p.1)) }25 path.closeSubpath()26 return path27 }2829 // Spectrum fan (clipped by the canvas, like the icon).30 let origin: (CGFloat, CGFloat) = (614, 470)31 let boundaries: [(CGFloat, CGFloat)] = [32 (1211, 248), (1238, 348), (1250, 451),33 (1244, 555), (1223, 657), (1185, 753), (1132, 843),34 ]35 let colors: [Color] = [36 Color(red: 1.00, green: 0.23, blue: 0.36),37 Color(red: 1.00, green: 0.62, blue: 0.11),38 Color(red: 1.00, green: 0.88, blue: 0.40),39 Color(red: 0.24, green: 0.86, blue: 0.52),40 Color(red: 0.22, green: 0.71, blue: 1.00),41 Color(red: 0.55, green: 0.36, blue: 0.96),42 ]43 for (index, color) in colors.enumerated() {44 let band = polygon([origin, boundaries[index], boundaries[index + 1]])45 context.fill(band, with: .color(color.opacity(0.95)))46 }4748 // Incoming beam, stopping on the left face. Light stays white in49 // both color schemes; a soft shadow keeps it visible on light50 // backgrounds.51 let beam = polygon([(82, 132), (142, 98), (398, 488), (372, 510)])52 context.drawLayer { layer in53 layer.addFilter(.shadow(color: .black.opacity(0.22), radius: 7 * s, y: 2 * s))54 layer.fill(beam, with: .color(.white))55 }56 context.stroke(beam, with: .color(.black.opacity(0.10)), lineWidth: 2 * s)5758 // Internal refraction.59 let inner = polygon([(386, 494), (614, 462), (614, 478), (390, 508)])60 context.fill(inner, with: .color(.white.opacity(0.9)))61 context.stroke(inner, with: .color(.black.opacity(0.08)), lineWidth: 1.5 * s)6263 // Glass triangle.64 let prism = polygon([(512, 268), (292, 688), (732, 688)])65 context.fill(prism, with: .color(.primary.opacity(0.07)))66 context.stroke(67 prism,68 with: .color(.primary.opacity(0.75)),69 style: StrokeStyle(lineWidth: 10 * s, lineCap: .round, lineJoin: .round)70 )71 }72 }73}7475#Preview {76 PrismMark()77 .frame(width: 160, height: 160)78 .padding()79}80