Repository Public License
1// ORIX Arcade2// File: DesignSystem/Backgrounds.swift3// Description: Ambient aurora background, confetti burst and the ORIX logo mark and wordmark.4//5// Author: Simon-Pierre Boucher6// Contact: contact@spboucher.ai7import SwiftUI89/// Deep midnight backdrop with slow drifting colour glows. Static when Reduce Motion is on.10struct AuroraBackground: View {11 var theme: GameTheme = .orix12 var intensity: Double = 113 @State private var drift = false1415 var body: some View {16 GeometryReader { geo in17 let w = geo.size.width, h = geo.size.height18 ZStack {19 LinearGradient(colors: [OrixColor.midnight, OrixColor.void], startPoint: .top, endPoint: .bottom)20 glow(theme.primary, 0.30 * intensity, w * 1.5)21 .offset(x: drift ? -w * 0.35 : -w * 0.15, y: drift ? -h * 0.36 : -h * 0.28)22 glow(theme.secondary, 0.22 * intensity, w * 1.3)23 .offset(x: drift ? w * 0.40 : w * 0.22, y: drift ? h * 0.08 : h * 0.20)24 glow(theme.deep, 0.9 * intensity, w * 1.6)25 .offset(x: drift ? -w * 0.1 : w * 0.1, y: h * 0.45)26 }27 .frame(width: w, height: h)28 .clipped()29 }30 .ignoresSafeArea()31 .onAppear {32 guard !OrixAppearance.reduceMotion else { return }33 withAnimation(.easeInOut(duration: 9).repeatForever(autoreverses: true)) { drift = true }34 }35 .accessibilityHidden(true)36 }3738 private func glow(_ color: Color, _ opacity: Double, _ size: CGFloat) -> some View {39 Circle()40 .fill(RadialGradient(colors: [color.opacity(opacity), color.opacity(0)], center: .center, startRadius: 0, endRadius: size / 2))41 .frame(width: size, height: size)42 }43}4445/// One-shot confetti burst drawn in a single Canvas (no per-particle views).46struct ConfettiBurst: View {47 var colors: [Color] = [OrixColor.gold, OrixColor.iris, OrixColor.cyan, OrixColor.success, Color(hex: 0xFF5E7E)]48 var count = 7049 @State private var start = Date()5051 var body: some View {52 if OrixAppearance.reduceMotion {53 Color.clear54 } else {55 TimelineView(.animation) { timeline in56 Canvas { context, size in57 let t = timeline.date.timeIntervalSince(start)58 guard t < 3.2 else { return }59 var rng = SeededRNG(seed: 0xC0FFEE)60 for index in 0..<count {61 let angle = rng.double(in: -Double.pi * 0.95 ... -Double.pi * 0.05)62 let speed = rng.double(in: 260...720)63 let spin = rng.double(in: -6...6)64 let w = rng.double(in: 5...10), h = rng.double(in: 8...16)65 let delay = rng.double(in: 0...0.18)66 let life = t - delay67 guard life > 0 else { continue }68 let drag = 1 - exp(-life * 2.2)69 let x = size.width / 2 + cos(angle) * speed * drag / 2.270 let y = size.height * 0.42 + sin(angle) * speed * drag / 2.2 + 240 * life * life71 let alpha = max(0, 1 - life / 2.8)72 var piece = context73 piece.translateBy(x: x, y: y)74 piece.rotate(by: .radians(spin * life))75 piece.opacity = alpha76 piece.fill(Path(roundedRect: CGRect(x: -w / 2, y: -h / 2, width: w, height: h), cornerRadius: 2),77 with: .color(colors[index % colors.count]))78 }79 }80 }81 .allowsHitTesting(false)82 .accessibilityHidden(true)83 .onAppear { start = Date() }84 }85 }86}8788/// The ORIX mark: an open orbit ring with a four-point spark at its heart.89struct OrixLogoMark: View {90 var progress: CGFloat = 191 var lineWidth: CGFloat = 0.139293 var body: some View {94 GeometryReader { geo in95 let side = min(geo.size.width, geo.size.height)96 ZStack {97 Circle()98 .trim(from: 0.06, to: 0.06 + 0.86 * progress)99 .stroke(AngularGradient(colors: [Color(hex: 0x8B7BFF), Color(hex: 0x4DD8FF), Color(hex: 0x3DE8C5), Color(hex: 0xFFB341), Color(hex: 0xFF5E7E), Color(hex: 0x8B7BFF)],100 center: .center),101 style: StrokeStyle(lineWidth: side * lineWidth, lineCap: .round))102 .rotationEffect(.degrees(-58))103 .padding(side * lineWidth / 2)104 SparkShape()105 .fill(LinearGradient(colors: [.white, Color(hex: 0xCFd6FF)], startPoint: .top, endPoint: .bottom))106 .frame(width: side * 0.42, height: side * 0.42)107 .scaleEffect(progress)108 .opacity(Double(progress))109 .shadow(color: OrixColor.cyan.opacity(0.8), radius: side * 0.08)110 Circle()111 .fill(Color(hex: 0xFFC94D))112 .frame(width: side * 0.13, height: side * 0.13)113 .offset(x: side * 0.33, y: -side * 0.33)114 .opacity(Double(progress))115 }116 .frame(width: side, height: side)117 .frame(maxWidth: .infinity, maxHeight: .infinity)118 }119 .aspectRatio(1, contentMode: .fit)120 .accessibilityHidden(true)121 }122}123124nonisolated struct SparkShape: Shape {125 func path(in rect: CGRect) -> Path {126 var path = Path()127 let c = CGPoint(x: rect.midX, y: rect.midY)128 let r = min(rect.width, rect.height) / 2129 let inner = r * 0.26130 for index in 0..<8 {131 let angle = Double(index) * .pi / 4 - .pi / 2132 let radius = index.isMultiple(of: 2) ? r : inner133 let point = CGPoint(x: c.x + cos(angle) * radius, y: c.y + sin(angle) * radius)134 if index == 0 { path.move(to: point) } else { path.addLine(to: point) }135 }136 path.closeSubpath()137 return path138 }139}140141struct OrixWordmark: View {142 var size: CGFloat = 22143144 var body: some View {145 HStack(spacing: size * 0.32) {146 Text("ORIX").font(.system(size: size, weight: .black, design: .rounded)).tracking(size * 0.16)147 .foregroundStyle(OrixColor.textPrimary)148 Text("ARCADE").font(.system(size: size, weight: .medium, design: .rounded)).tracking(size * 0.2)149 .foregroundStyle(LinearGradient(colors: [OrixColor.iris, OrixColor.cyan], startPoint: .leading, endPoint: .trailing))150 }151 .accessibilityElement(children: .ignore)152 .accessibilityLabel("ORIX Arcade")153 }154}155