A tiny friend in your Mac's notch and on your iPhone that keeps an eye on your AI coding agents: Claude Code, Codex, Cursor, Gemini CLI, Antigravity and more. Approve from the notch or your Lock Screen.
Swift ai-agentsanthropicantigravityclaudeclaude-codecodexcursordynamic-islandgemini-cliiosiphonlinuxmacosmacos-appmenubar-appnotchopen-sourceswiftswiftuiwindows
Mochi wardrobe: outfits, seasons and physics (#195)
Louisb5d2242126f9
diff --git a/.github/workflows/build.yml b/.github/workflows/build.ymlindex 92d1bc3b..8f1fb928 100644--- a/.github/workflows/build.yml+++ b/.github/workflows/build.yml@@ -42,6 +42,9 @@ jobs:- name: GitHub activity testsrun: bash scripts/test-github-activity.sh+ - name: Wardrobe tests+ run: bash scripts/test-wardrobe.sh+- name: Buildrun: |xcodebuild \diff --git a/NotchBuddy/NotchBuddy.xcodeproj/project.pbxproj b/NotchBuddy/NotchBuddy.xcodeproj/project.pbxprojindex 2d201e05..aa91f517 100644--- a/NotchBuddy/NotchBuddy.xcodeproj/project.pbxproj+++ b/NotchBuddy/NotchBuddy.xcodeproj/project.pbxproj@@ -13,6 +13,7 @@091EC3B2F1060D7EE1317E4E /* IslandWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D710BD7834228045869D0184 /* IslandWindowController.swift */; };0A267EE2955C7AD8E02A296C /* N8nPoller.swift in Sources */ = {isa = PBXBuildFile; fileRef = B89DA1A0C21AE3535A1760BB /* N8nPoller.swift */; };0D68A4C4E3422487DB7B2262 /* IslandScreenGeometry.swift in Sources */ = {isa = PBXBuildFile; fileRef = 78BC1357785CA1B099A33969 /* IslandScreenGeometry.swift */; };+ 0E6E7A12CB5CA4E499DED934 /* MochiOutfitDrawing.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34C2BC327511DB0B86D4D62E /* MochiOutfitDrawing.swift */; };0E83C1DD4D20E7FB7A904450 /* VercelPoller.swift in Sources */ = {isa = PBXBuildFile; fileRef = 71718D1B87A39A4879DD2A9D /* VercelPoller.swift */; };0E9CE475EC53C67DAB00F8E5 /* BotEngine.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4540F630F8BA04AFFFA3979 /* BotEngine.swift */; };118FC4AE0AC74D84B4A134D8 /* VercelPoller.swift in Sources */ = {isa = PBXBuildFile; fileRef = 71718D1B87A39A4879DD2A9D /* VercelPoller.swift */; };@@ -59,6 +60,7 @@8C32A0C3EAF536D3836F61D5 /* GreetingCanvasView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C581F7B1A9F14B281B60063E /* GreetingCanvasView.swift */; };8D1C01F283FA7806119A1C85 /* SettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C1A7D5CBE2AC084A10C5FF3 /* SettingsView.swift */; };8FC5907E9506DC79EB1DDC3C /* ChatMarkdown.swift in Sources */ = {isa = PBXBuildFile; fileRef = D797CC384B5BC70D34F121BC /* ChatMarkdown.swift */; };+ 94A742758D0FF79124E26B21 /* MochiWardrobe.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0BB15BD82E4A0B729045880 /* MochiWardrobe.swift */; };94E0849D13762C6EC8548FEF /* ClaudePlanCardView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4263B550838CC5614569D13 /* ClaudePlanCardView.swift */; };967B525F7D3837F31D740D18 /* ResendPoller.swift in Sources */ = {isa = PBXBuildFile; fileRef = 61B5FDDE03F5F711146937E2 /* ResendPoller.swift */; };9C653B8291EFFA414565E8A8 /* MusicController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F142FB3952B5F0639383047 /* MusicController.swift */; };@@ -85,11 +87,13 @@E776C7D1DE5C62EA8D4BA3E3 /* FileDropView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3232F258523DD8D09B670363 /* FileDropView.swift */; };E7A5D23F455565FE1E210398 /* PillCatalog.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3B6A38B5686C4A1F15AB5D29 /* PillCatalog.swift */; };E81575CE4433C6F88E424A8F /* LocalChat.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8790ACE9F73BD74640A0F20C /* LocalChat.swift */; };+ E85D8AC2617F7742C2547E11 /* MochiOutfitDrawing.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34C2BC327511DB0B86D4D62E /* MochiOutfitDrawing.swift */; };E9C21D11BCB72C392436D19E /* ClaudePlanGauge.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8BF22817EC70748F2D1FB2E7 /* ClaudePlanGauge.swift */; };EB23ED9F1C12EA8B54A76A91 /* ResendPoller.swift in Sources */ = {isa = PBXBuildFile; fileRef = 61B5FDDE03F5F711146937E2 /* ResendPoller.swift */; };ECECA2F225E82B7C951658D7 /* UploadSequenceEngine.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6FD65943C32E150F1CD65C31 /* UploadSequenceEngine.swift */; };ED5D9A334DE08C0EB81DE322 /* AskQuestion.swift in Sources */ = {isa = PBXBuildFile; fileRef = EBB84A66045EB20CAC93A8A6 /* AskQuestion.swift */; };F06EE0A97CB77096A337AA8B /* sounds in Resources */ = {isa = PBXBuildFile; fileRef = C066E2B991AA4F56B2724263 /* sounds */; };+ F11A2EBCBF7352536B2CB93D /* MochiWardrobe.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0BB15BD82E4A0B729045880 /* MochiWardrobe.swift */; };FAD78D74C6906D4EC8AA4101 /* UploadSequenceEngine.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6FD65943C32E150F1CD65C31 /* UploadSequenceEngine.swift */; };FBBC4CDE82B5886A83A27D7A /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 506824380E9C80B9BC6DCE72 /* Assets.xcassets */; };FEFEF1EBAB0E6CA74A33C10B /* SafeWebURL.swift in Sources */ = {isa = PBXBuildFile; fileRef = B2FDED98F7F6C755A72C97A3 /* SafeWebURL.swift */; };@@ -103,6 +107,7 @@2EF78999D68D56ADE4CEFBE2 /* StripePoller.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StripePoller.swift; sourceTree = "<group>"; };3104222B3F17BA5E8DEA5277 /* CalcomPoller.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CalcomPoller.swift; sourceTree = "<group>"; };3232F258523DD8D09B670363 /* FileDropView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileDropView.swift; sourceTree = "<group>"; };+ 34C2BC327511DB0B86D4D62E /* MochiOutfitDrawing.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MochiOutfitDrawing.swift; sourceTree = "<group>"; };3B6A38B5686C4A1F15AB5D29 /* PillCatalog.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PillCatalog.swift; sourceTree = "<group>"; };3DB24C2469551040FBAA4DBF /* DiffEngine.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DiffEngine.swift; sourceTree = "<group>"; };4DC2A07E42245A8CF3BBD2AB /* CoucouAppStore.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CoucouAppStore.app; sourceTree = BUILT_PRODUCTS_DIR; };@@ -128,6 +133,7 @@BE03E03D1804B0B92C5C2DAD /* NotionPoller.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotionPoller.swift; sourceTree = "<group>"; };BFE88A53AEAA637F866D479D /* ChatMarkdownView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatMarkdownView.swift; sourceTree = "<group>"; };C066E2B991AA4F56B2724263 /* sounds */ = {isa = PBXFileReference; lastKnownFileType = folder; name = sounds; path = Resources/sounds; sourceTree = SOURCE_ROOT; };+ C0BB15BD82E4A0B729045880 /* MochiWardrobe.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MochiWardrobe.swift; sourceTree = "<group>"; };C2E4F18AA940EFF7E047B9F7 /* AppState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppState.swift; sourceTree = "<group>"; };C581F7B1A9F14B281B60063E /* GreetingCanvasView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GreetingCanvasView.swift; sourceTree = "<group>"; };D4540F630F8BA04AFFFA3979 /* BotEngine.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BotEngine.swift; sourceTree = "<group>"; };@@ -173,6 +179,8 @@FA02B08886939FF6FE0475DD /* IslandViewContent.swift */,D710BD7834228045869D0184 /* IslandWindowController.swift */,8790ACE9F73BD74640A0F20C /* LocalChat.swift */,+ 34C2BC327511DB0B86D4D62E /* MochiOutfitDrawing.swift */,+ C0BB15BD82E4A0B729045880 /* MochiWardrobe.swift */,4F142FB3952B5F0639383047 /* MusicController.swift */,B89DA1A0C21AE3535A1760BB /* N8nPoller.swift */,F1BD8F3CAA60CF37640759E1 /* NotchBuddyApp.swift */,@@ -356,6 +364,8 @@065FCE817315454DE3F85F25 /* IslandViewContent.swift in Sources */,091EC3B2F1060D7EE1317E4E /* IslandWindowController.swift in Sources */,6D158183870434FEDF07E050 /* LocalChat.swift in Sources */,+ E85D8AC2617F7742C2547E11 /* MochiOutfitDrawing.swift in Sources */,+ 94A742758D0FF79124E26B21 /* MochiWardrobe.swift in Sources */,5C6D0BC8C546718CAA82BF90 /* MusicController.swift in Sources */,0A267EE2955C7AD8E02A296C /* N8nPoller.swift in Sources */,06BF5FD95E03010CAFDBF2D0 /* NotchBuddyApp.swift in Sources */,@@ -404,6 +414,8 @@68A950E3C23FD612639D9776 /* IslandViewContent.swift in Sources */,C61DDE2EC5FDDB39E4AA3B34 /* IslandWindowController.swift in Sources */,E81575CE4433C6F88E424A8F /* LocalChat.swift in Sources */,+ 0E6E7A12CB5CA4E499DED934 /* MochiOutfitDrawing.swift in Sources */,+ F11A2EBCBF7352536B2CB93D /* MochiWardrobe.swift in Sources */,9C653B8291EFFA414565E8A8 /* MusicController.swift in Sources */,160EDB9D06275E2607DA5151 /* N8nPoller.swift in Sources */,DE05D09A32117582AC93A24A /* NotchBuddyApp.swift in Sources */,diff --git a/NotchBuddy/Sources/App/AppState.swift b/NotchBuddy/Sources/App/AppState.swiftindex 11b3dd78..7953f272 100644--- a/NotchBuddy/Sources/App/AppState.swift+++ b/NotchBuddy/Sources/App/AppState.swift@@ -53,6 +53,27 @@ final class AppState: ObservableObject {didSet { UserDefaults.standard.set(soundEnabled, forKey: "soundEnabled") }}+ // Mochi outfit selection — persisted+ @Published var mochiOutfitSelection: Outfit = .auto {+ didSet { Outfit.stored = mochiOutfitSelection }+ }+ // Transient: outfit preview while hovering in wardrobe (overrides resolvedOutfit in BotCanvasView)+ var wardrobePreviewOutfit: Outfit? = nil+ // Per-day seasonal cache — avoids recomputing Easter and date math on every frame+ private var _seasonalCache: (dayOfYear: Int, year: Int, outfit: Outfit)?+ var resolvedOutfit: Outfit {+ if let preview = wardrobePreviewOutfit { return preview }+ guard mochiOutfitSelection == .auto else { return mochiOutfitSelection }+ let cal = Calendar.current+ let now = Date()+ let day = cal.ordinality(of: .day, in: .year, for: now) ?? 0+ let year = cal.component(.year, from: now)+ if let c = _seasonalCache, c.dayOfYear == day && c.year == year { return c.outfit }+ let outfit = Outfit.seasonal(for: now, calendar: cal)+ _seasonalCache = (dayOfYear: day, year: year, outfit: outfit)+ return outfit+ }+// Claude model used by the chat and the search — persistedstatic let defaultClaudeModel = "claude-sonnet-4-6"@Published var claudeModel: String = AppState.defaultClaudeModel {@@ -373,6 +394,7 @@ final class AppState: ObservableObject {if let v = ud.object(forKey: "soundEnabled") as? Bool { soundEnabled = v }if let v = ud.object(forKey: "soundVolume") as? Double { soundVolume = v }+ mochiOutfitSelection = Outfit.storedif let v = ud.string(forKey: "claudeModel"),!v.trimmingCharacters(in: .whitespaces).isEmpty { claudeModel = v }if let v = ud.string(forKey: "chatProvider"), let p = ChatProvider(rawValue: v) { chatProvider = p }diff --git a/NotchBuddy/Sources/App/BotCanvasView.swift b/NotchBuddy/Sources/App/BotCanvasView.swiftindex 23b1edde..a0374815 100644--- a/NotchBuddy/Sources/App/BotCanvasView.swift+++ b/NotchBuddy/Sources/App/BotCanvasView.swift@@ -57,12 +57,35 @@ struct BotCanvasView: View {#endif}()engine.setDancing(dancing)+ let isWardrobe = state.mode == .expanded && state.view == .wardrobe+ let isFocusMain = state.focusId == state.mainPillId || state.focusId == nil+ let showOutfit = isFocusMain || state.mode != .expanded || isWardrobe+ engine.setOutfit(showOutfit ? state.resolvedOutfit : .none,+ animated: state.view != .wardrobe)engine.update(dt: dt)var ctx = contextengine.applyDance(&ctx, size: size)- engine.drawHandsBehind(context: ctx, size: size)- engine.draw(context: ctx, size: size)+ // Rigid-roll: when Mochi wears an outfit (presence > 0.05) and is rolling,+ // rotate the entire body+accessories context around the body center so the+ // whole character genuinely turns. Particles/badge (drawHandsAndExtras) are+ // drawn outside the rotated context and do not spin.+ if engine.outfit != .none && engine.outfitPresence > 0.05 && abs(engine.roll) > 0.001 {+ let center = engine.bodyCenter(size: size)+ var rigidCtx = ctx+ rigidCtx.translateBy(x: center.x, y: center.y)+ rigidCtx.rotate(by: .radians(engine.roll))+ rigidCtx.translateBy(x: -center.x, y: -center.y)+ engine.drawHandsBehind(context: rigidCtx, size: size)+ engine.drawOutfitBehind(context: rigidCtx, size: size)+ engine.draw(context: rigidCtx, size: size)+ engine.drawOutfitFront(context: rigidCtx, size: size)+ } else {+ engine.drawHandsBehind(context: ctx, size: size)+ engine.drawOutfitBehind(context: ctx, size: size)+ engine.draw(context: ctx, size: size)+ engine.drawOutfitFront(context: ctx, size: size)+ }engine.drawHandsAndExtras(context: ctx, size: size)}}@@ -116,6 +139,10 @@ struct BotCanvasView: View {}.onAppear {engine.setState(state.effectiveState, force: true)+ let isWardrobe = state.mode == .expanded && state.view == .wardrobe+ let isFocusMain = state.focusId == state.mainPillId || state.focusId == nil+ let showOutfit = isFocusMain || state.mode != .expanded || isWardrobe+ engine.setOutfit(showOutfit ? state.resolvedOutfit : .none, animated: false)}}diff --git a/NotchBuddy/Sources/App/BotEngine.swift b/NotchBuddy/Sources/App/BotEngine.swiftindex da21a138..81d16bde 100644--- a/NotchBuddy/Sources/App/BotEngine.swift+++ b/NotchBuddy/Sources/App/BotEngine.swift@@ -175,7 +175,8 @@ final class BotEngine: ObservableObject {// Animation state (mirrors prototype 's' object)var yaw: CGFloat = 0var pitch: CGFloat = 0- var roll: CGFloat = 0+ var roll: CGFloat = 0+ var rollTurns: CGFloat = 1var tilt: CGFloat = 0var open: CGFloat = 1 // eye open amountvar sx: CGFloat = 1 // scale X@@ -186,8 +187,20 @@ final class BotEngine: ObservableObject {var morph: CGFloat = 0 // morph to rect (for upload bucket)var hands: CGFloat = 0var blush: CGFloat = 0+ var outfit: Outfit = .nonevar es: CGFloat = 1 // eye scalevar badgeS: CGFloat = 0 // badge scale+ var outfitPresence: CGFloat = 0 // 0=hidden, 1=fully visible (animated)+ private var outfitTarget: Outfit = .none++ // Physical spring (hat/pompom lag) — updated in update()+ var physDx: CGFloat = 0 // horizontal lag (-1..1)+ var physDy: CGFloat = 0 // vertical lag (-1..1)+ private var physVx: CGFloat = 0+ private var physVy: CGFloat = 0+ private var prevYaw: CGFloat = 0+ private var prevOy: CGFloat = 0+ private var prevRoll: CGFloat = 0// Targetsvar tgYaw: CGFloat = 0@@ -323,6 +336,7 @@ final class BotEngine: ObservableObject {}func squash() {+ physVy += 0.6anim("sy", keys: [TweenKey(target: 0.78, duration: 70, ease: Ease.out),TweenKey(target: 1.1, duration: 130, ease: Ease.out),@@ -370,6 +384,8 @@ final class BotEngine: ObservableObject {slapTimes.append(now)SoundEngine.shared.play("slap")squash()+ physVy -= 1.2+ physVx += Bool.random() ? 0.7 : -0.7if slapTimes.count >= 3 {slapTimes = []NotificationCenter.default.post(name: .botDizzy, object: nil)@@ -465,8 +481,42 @@ final class BotEngine: ObservableObject {func doRoll(duration: CGFloat, turns: CGFloat) {roll = 0+ rollTurns = turnsanim("roll", keys: [TweenKey(target: .pi * 2 * turns, duration: duration, ease: Ease.inOut)]) { [weak self] inself?.roll = 0+ self?.squash()+ }+ }++ func setOutfit(_ newOutfit: Outfit, animated: Bool = true) {+ guard newOutfit != outfitTarget else { return }+ outfitTarget = newOutfit+ tweens.removeValue(forKey: "outfitPresence")+ locks.remove("outfitPresence")+ if !animated {+ outfit = newOutfit+ outfitPresence = newOutfit != .none ? 1 : 0+ } else if newOutfit == .none {+ // Exit: fade out then clear outfit+ anim("outfitPresence", keys: [TweenKey(target: 0, duration: 180, ease: Ease.inOut)]) { [weak self] in+ self?.outfit = .none+ }+ } else if outfit == .none {+ // Enter: set outfit then animate in (Ease.back applied to position offsets in drawing code)+ outfit = newOutfit+ outfitPresence = 0+ anim("outfitPresence", keys: [TweenKey(target: 1, duration: 350, ease: Ease.inOut)]) { [weak self] in+ self?.squash()+ }+ } else {+ // Change: exit old, set new, enter+ anim("outfitPresence", keys: [TweenKey(target: 0, duration: 180, ease: Ease.inOut)]) { [weak self] in+ guard let self else { return }+ self.outfit = newOutfit+ self.anim("outfitPresence", keys: [TweenKey(target: 1, duration: 350, ease: Ease.inOut)]) { [weak self] in+ self?.squash()+ }+ }}}@@ -476,6 +526,7 @@ final class BotEngine: ObservableObject {let tok = greetTokenwaveStart = now + 0.45 // wave begins at 0.45swaveUntil = now + 1.55 // wave ends at 1.55s+ physVx += 0.2// 0s: happy eyes for full greeting (2s — no gap, no flicker)eyeOverride = .happy@@ -585,6 +636,7 @@ final class BotEngine: ObservableObject {TweenKey(target: 1, duration: 500, ease: Ease.inOut),])case .proud:+ squash()emit(.star, count: 5)anim("tilt", keys: [TweenKey(target: -0.14, duration: 220, ease: Ease.out),@@ -796,6 +848,21 @@ final class BotEngine: ObservableObject {dancingLevel = max(dancingTarget, dancingLevel - CGFloat(dt) / 0.5)}+ // Phys spring for hat/pompom lag+ let yawVel = (yaw - prevYaw) / CGFloat(dt)+ let oyVel = (oy - prevOy) / CGFloat(dt)+ let rollVel = (roll - prevRoll) / CGFloat(dt)+ prevYaw = yaw; prevOy = oy; prevRoll = roll+ // Centrifugal physDx impulse when rigidly rolling with an outfit+ let centrifugal: CGFloat = (outfit != .none && outfitPresence > 0.05) ? rollVel * 0.18 : 0+ let tDx = max(-1, min(1, -yawVel * 0.35 - tilt * 2 + centrifugal))+ let tDy = max(-1, min(1, oyVel * 0.50))+ let stiff: CGFloat = 60, damp: CGFloat = 9+ physVx += (stiff * (tDx - physDx) - damp * physVx) * dtCG+ physVy += (stiff * (tDy - physDy) - damp * physVy) * dtCG+ physDx += physVx * dtCG+ physDy += physVy * dtCG+lastTime = now}@@ -839,7 +906,8 @@ final class BotEngine: ObservableObject {let bodyPath = mochiPath(rx: rx, ry: ry, morph: morph, R: R)// Body fill- drawBody(ctx: &ctx, path: bodyPath, R: R, rx: rx, ry: ry)+ drawBody(ctx: &ctx, path: bodyPath, R: R, rx: rx, ry: ry,+ pumpkinColors: outfit == .pumpkin && !isMini)// Blush — always shows a floor proportional to tint (prototype behaviour)let blushVal = max(blush, tint * 0.5) * (1 - morph)@@ -1014,6 +1082,49 @@ final class BotEngine: ObservableObject {drawParticles(context: context, size: size, R: R, cx: cx, cy: cy)}+ func drawOutfitBehind(context: GraphicsContext, size: CGSize) {+ guard outfit != .none, !isMini else { return }+ let W = size.width, H = size.height, R = W * 0.3+ let cx = W / 2 + ox * R+ let cy = H / 2 + particleOverhang / 2 + oy * R + R * 0.06+ // Rigid roll: accessories see roll=0 (they rotate with the body via context transform)+ let outfitRoll: CGFloat = outfitPresence > 0.05 ? 0 : roll+ let mH = MochiH(R: R, yaw: yaw, pitch: pitch, physDx: physDx, physDy: physDy, roll: outfitRoll)+ drawOutfitBehindStatic(context: context, outfit: outfit, H: mH,+ cx: cx, cy: cy, tilt: tilt, sx: sx, sy: sy,+ roll: outfitRoll, morph: morph, isMini: isMini,+ presence: outfitPresence, rollTurns: rollTurns)+ }++ func drawOutfitFront(context: GraphicsContext, size: CGSize) {+ guard outfit != .none, !isMini else { return }+ let W = size.width, H = size.height, R = W * 0.3+ let cx = W / 2 + ox * R+ let cy = H / 2 + particleOverhang / 2 + oy * R + R * 0.06+ // Rigid roll: accessories see roll=0 (they rotate with the body via context transform)+ let outfitRoll: CGFloat = outfitPresence > 0.05 ? 0 : roll+ let mH = MochiH(R: R, yaw: yaw, pitch: pitch, physDx: physDx, physDy: physDy, roll: outfitRoll)+ drawOutfitFrontStatic(context: context, outfit: outfit, H: mH,+ cx: cx, cy: cy, tilt: tilt, sx: sx, sy: sy,+ roll: outfitRoll, morph: morph, isMini: isMini,+ presence: outfitPresence, rollTurns: rollTurns)+ }++ /// World-space center of Mochi's body (used by BotCanvasView for rigid-roll transform)+ func bodyCenter(size: CGSize) -> CGPoint {+ let W = size.width, R = W * 0.3+ let cx = W / 2 + ox * R+ let cy = size.height / 2 + particleOverhang / 2 + oy * R + R * 0.06+ return CGPoint(x: cx, y: cy)+ }++ var outfitFollowsRoll: Bool {+ switch outfit {+ case .sunglasses, .roundGlasses, .bow, .scarf, .pumpkin: return true+ default: return false+ }+ }+// MARK: - Private draw helpersprivate func mochiPath(rx: CGFloat, ry: CGFloat, morph: CGFloat, R: CGFloat) -> Path {@@ -1086,16 +1197,17 @@ final class BotEngine: ObservableObject {return CGPoint(x: kx * W, y: ky * H)}- private func drawBody(ctx: inout GraphicsContext, path: Path, R: CGFloat, rx: CGFloat, ry: CGFloat) {- if let bc = bodyColor {+ private func drawBody(ctx: inout GraphicsContext, path: Path, R: CGFloat, rx: CGFloat, ry: CGFloat,+ pumpkinColors: Bool = false) {+ if let bc = bodyColor, !pumpkinColors {// Mini bots: flat solid fill — no gradient, no reflection, no highlightctx.fill(path, with: .color(Color(cgColor: bc)))} else {// Main bot: linear gradient body- let c0 = cgColorToTuple(MochiConst.baseTop)- let c1 = cgColorToTuple(MochiConst.baseBottom)+ let top: Color = pumpkinColors ? Color(hex: "#FFA94D") : Color(red: 0.929, green: 0.929, blue: 0.937)+ let bot: Color = pumpkinColors ? Color(hex: "#E8590C") : Color(red: 0.769, green: 0.773, blue: 0.792)ctx.fill(path, with: .linearGradient(- Gradient(colors: [colorFromTuple(c0), colorFromTuple(c1)]),+ Gradient(colors: [top, bot]),startPoint: CGPoint(x: rx*0.7, y: -ry*0.85),endPoint: CGPoint(x: -rx*0.8, y: ry*0.9)))@@ -1159,29 +1271,30 @@ final class BotEngine: ObservableObject {}ctx.clip(to: path)- for sd in [-1.0, 1.0] {- let eyeYaw = CGFloat(sd) * MochiConst.eyeSp + yaw- var eyePitch = MochiConst.eyeP + pitch + roll- // Wrap pitch for roll-through effect+ // Build eye frames: use mEyeFrames for position/foreshortening, but keep roll in eyePitch+ // When an outfit is rigidly rotating, the whole body turns — eyes do NOT add roll+ let rigidRoll = outfit != .none && outfitPresence > 0.05+ let mH = MochiH(R: R, yaw: yaw, pitch: pitch)+ for f in mEyeFrames(mH) {+ // Re-derive pitch with roll for the roll-through effect (illusion, outfit=none only)+ var eyePitch = MochiConst.eyeP + pitch + (rigidRoll ? 0 : roll)eyePitch = ((eyePitch + .pi).truncatingRemainder(dividingBy: .pi*2) + .pi*2).truncatingRemainder(dividingBy: .pi*2) - .pi-let cp = cos(eyePitch)- guard cos(eyeYaw) * cp > 0.04 else { continue } // behind head-- let ex = sin(eyeYaw) * cp * rx- let ey = -sin(eyePitch) * ry + (morph > 0 ? ry * 0.14 * morph : 0)+ let eyeYaw = f.sd * MochiConst.eyeSp + yaw+ guard cos(eyeYaw) * cp > 0.04 else { continue }- let fx = lerp(max(0.18, cos(eyeYaw)), 1, morph * 0.7)- let fy = lerp(max(0.18, cp), 1, morph * 0.7)+ let ey = f.y + (morph > 0 ? ry * 0.14 * morph : 0)+ let fx = lerp(f.fx, 1, morph * 0.7)+ let fy = lerp(f.fy, 1, morph * 0.7)let eyeMult: CGFloat = isMini ? 1.9 : 1.0let ew = R * MochiConst.eyeW * es * eyeMultlet eh = R * MochiConst.eyeH * es * eyeMultvar eyeCtx = ctx- eyeCtx.translateBy(x: ex, y: ey)+ eyeCtx.translateBy(x: f.x, y: ey)eyeCtx.scaleBy(x: fx, y: fy)- drawEyeShape(ctx: &eyeCtx, shape: shape, w: ew, h: eh, open: open, sd: CGFloat(sd), R: R)+ drawEyeShape(ctx: &eyeCtx, shape: shape, w: ew, h: eh, open: open, sd: f.sd, R: R)}}@@ -1413,50 +1526,52 @@ final class BotEngine: ObservableObject {private func setProperty(_ key: String, value: CGFloat) {switch key {- case "yaw": yaw = value- case "pitch": pitch = value- case "roll": roll = value- case "tilt": tilt = value- case "open": open = value- case "sx": sx = value- case "sy": sy = value- case "oy": oy = value- case "ox": ox = value- case "tint": tint = value- case "morph": morph = value- case "hands": hands = value- case "blush": blush = value- case "es": es = value- case "badgeS": badgeS = value+ case "yaw": yaw = value+ case "pitch": pitch = value+ case "roll": roll = value+ case "tilt": tilt = value+ case "open": open = value+ case "sx": sx = value+ case "sy": sy = value+ case "oy": oy = value+ case "ox": ox = value+ case "tint": tint = value+ case "morph": morph = value+ case "hands": hands = value+ case "blush": blush = value+ case "es": es = value+ case "badgeS": badgeS = value+ case "outfitPresence": outfitPresence = valuedefault: break}}private func getProperty(_ key: String) -> CGFloat {switch key {- case "yaw": return yaw- case "pitch": return pitch- case "roll": return roll- case "tilt": return tilt- case "open": return open- case "sx": return sx- case "sy": return sy- case "oy": return oy- case "ox": return ox- case "tint": return tint- case "morph": return morph- case "hands": return hands- case "blush": return blush- case "es": return es- case "badgeS": return badgeS- default: return 0+ case "yaw": return yaw+ case "pitch": return pitch+ case "roll": return roll+ case "tilt": return tilt+ case "open": return open+ case "sx": return sx+ case "sy": return sy+ case "oy": return oy+ case "ox": return ox+ case "tint": return tint+ case "morph": return morph+ case "hands": return hands+ case "blush": return blush+ case "es": return es+ case "badgeS": return badgeS+ case "outfitPresence": return outfitPresence+ default: return 0}}}// MARK: - Math helpers-private func lerp(_ a: CGFloat, _ b: CGFloat, _ t: CGFloat) -> CGFloat { a + (b-a) * t }+func lerp(_ a: CGFloat, _ b: CGFloat, _ t: CGFloat) -> CGFloat { a + (b-a) * t }private func clamp(_ v: CGFloat, _ lo: CGFloat, _ hi: CGFloat) -> CGFloat { max(lo, min(hi, v)) }private func cgColorToTuple(_ c: CGColor) -> (CGFloat, CGFloat, CGFloat) {diff --git a/NotchBuddy/Sources/App/IslandTypes.swift b/NotchBuddy/Sources/App/IslandTypes.swiftindex e4b0581b..60fbbe1a 100644--- a/NotchBuddy/Sources/App/IslandTypes.swift+++ b/NotchBuddy/Sources/App/IslandTypes.swift@@ -11,7 +11,7 @@ enum IslandMode: String, CaseIterable {enum IslandView: String, CaseIterable {case overview, empty, approval, question, error, finishedcase confused, upload, uploading, choose, mail, prompt- case searching, result, note, settings, greeting+ case searching, result, note, settings, greeting, wardrobe}// MARK: - Bot State@@ -188,6 +188,7 @@ enum IslandConst {.settings: ViewLayout(height: 160, botX: 54, botY: nil, botDiameter: 46, agentMode: .none),// Greeting: bot drawn by GreetingCanvasView; no BotPlacement needed.greeting: ViewLayout(height: 150, botX: 320, botY: 90, botDiameter: 0, agentMode: .none),+ .wardrobe: ViewLayout(height: 160, botX: 68, botY: nil, botDiameter: 58, agentMode: .none),]// Project colors — keyed by lowercase display name or slugdiff --git a/NotchBuddy/Sources/App/IslandViewContent.swift b/NotchBuddy/Sources/App/IslandViewContent.swiftindex 73ce2df7..b0831bc1 100644--- a/NotchBuddy/Sources/App/IslandViewContent.swift+++ b/NotchBuddy/Sources/App/IslandViewContent.swift@@ -25,6 +25,7 @@ struct IslandViewContent: View {case .note: NoteView(state: state)case .settings: SettingsIslandView(state: state)case .greeting: EmptyView() // GreetingCanvasView overlaid in IslandRootView+ case .wardrobe: WardrobeView(state: state)}}}@@ -3958,6 +3959,278 @@ struct ColumnAgentsView: View {}}+// MARK: - Wardrobe++struct WardrobeView: View {+ @ObservedObject var state: AppState+ @State private var hoveredOutfit: Outfit? = nil++ private let columns = Array(repeating: GridItem(.fixed(30), spacing: 5), count: 14)++ private var headerRight: String {+ // Hover takes priority: show hovered outfit name+ if let h = hoveredOutfit {+ if h == .auto {+ let seasonal = Outfit.seasonal(for: Date(), calendar: .current)+ let name = seasonal == .none ? "None" : seasonal.displayName+ return "Auto · follows the seasons (now: \(name))"+ }+ return h.displayName+ }+ // Fall back to current selection+ let sel = state.mochiOutfitSelection+ if sel == .auto {+ let seasonal = Outfit.seasonal(for: Date(), calendar: .current)+ let name = seasonal == .none ? "None" : seasonal.displayName+ return "Auto · \(name)"+ }+ return sel.displayName+ }++ var body: some View {+ VStack(alignment: .leading, spacing: 0) {+ // Header+ HStack(spacing: 6) {+ Text("Wardrobe")+ .font(.system(size: 12, weight: .semibold))+ .foregroundColor(Color(hex: "#F5F6F8"))+ Spacer(minLength: 4)+ Text(headerRight)+ .font(.system(size: 11))+ .foregroundColor(Color(hex: "#8E939C"))+ .lineLimit(1)+ }+ .padding(.top, 6)+ .padding(.horizontal, 10)++ // Grid+ let allOutfits = Outfit.allCases.filter { $0 != .auto }+ let withAuto = [Outfit.auto] + allOutfits+ ScrollView(.vertical, showsIndicators: false) {+ LazyVGrid(columns: columns, spacing: 5) {+ ForEach(withAuto, id: \.rawValue) { outfit in+ OutfitPillView(+ outfit: outfit,+ isSelected: state.mochiOutfitSelection == outfit,+ isHovered: hoveredOutfit == outfit,+ onHover: { h in+ hoveredOutfit = h ? outfit : nil+ if h {+ // Preview on main Mochi+ let preview: Outfit = outfit == .auto+ ? Outfit.seasonal(for: Date(), calendar: .current)+ : outfit+ state.wardrobePreviewOutfit = preview+ } else if hoveredOutfit == nil {+ state.wardrobePreviewOutfit = nil+ }+ },+ onTap: {+ guard state.mochiOutfitSelection != outfit else { return }+ state.mochiOutfitSelection = outfit+ SoundEngine.shared.play("pop")+ NotificationCenter.default.post(name: .triggerEmote, object: BotEmote.proud)+ },+ seasonalOutfit: outfit == .auto ? state.resolvedOutfit : .none+ )+ }+ }+ .padding(.vertical, 6)+ .padding(.horizontal, 8)+ }+ .frame(maxHeight: .infinity)+ .mask(+ LinearGradient(+ stops: [+ .init(color: .white, location: 0),+ .init(color: .white, location: 0.85),+ .init(color: .clear, location: 1)+ ],+ startPoint: .top, endPoint: .bottom+ )+ )+ }+ .padding(.leading, 108)+ .padding(.trailing, 12)+ .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)+ .onDisappear {+ state.wardrobePreviewOutfit = nil+ hoveredOutfit = nil+ }+ .onExitCommand {+ withAnimation(.spring(response: 0.3, dampingFraction: 0.8)) {+ state.view = .overview+ }+ }+ }+}++struct OutfitPillView: View {+ let outfit: Outfit+ let isSelected: Bool+ let isHovered: Bool+ let onHover: (Bool) -> Void+ let onTap: () -> Void+ var seasonalOutfit: Outfit = .none++ var body: some View {+ Canvas { context, size in+ drawOutfitIcon(context: context, size: size, outfit: outfit, seasonal: seasonalOutfit)+ }+ .frame(width: 30, height: 30)+ .background(+ RoundedRectangle(cornerRadius: 7)+ .fill(isHovered ? Color.white.opacity(0.10) : Color.white.opacity(0.06))+ )+ .overlay(+ RoundedRectangle(cornerRadius: 7)+ .stroke(isSelected ? Color.white.opacity(0.40) : Color.white.opacity(0.08), lineWidth: 1)+ )+ .onHover { onHover($0) }+ .onTapGesture { onTap() }+ }+}++private func drawOutfitIcon(context: GraphicsContext, size: CGSize, outfit: Outfit, seasonal: Outfit = .none) {+ let W = size.width, H = size.height+ let cx = W / 2, cy = H / 2+ let R: CGFloat = 6.5 // small scale for icon++ switch outfit {+ case .auto:+ let iconR: CGFloat = 10.0+ let rx = iconR * 1.14, ry = iconR * 0.88+ let mH = MochiH(R: iconR, yaw: 0, pitch: 0)+ let bodyPath = mochiOutfitPath(rx, ry)+ let iconCY = cy + iconR * 0.62++ // Draw the seasonal outfit behind body+ if seasonal != .none && seasonal != .auto {+ drawOutfitBehindStatic(context: context, outfit: seasonal, H: mH,+ cx: cx, cy: iconCY, tilt: 0, sx: 1, sy: 1,+ roll: 0, morph: 0, isMini: false)+ }+ // Body+ var ctx = context+ ctx.translateBy(x: cx, y: iconCY)+ ctx.fill(bodyPath, with: .linearGradient(+ Gradient(colors: [Color(red: 0.929, green: 0.929, blue: 0.937),+ Color(red: 0.769, green: 0.773, blue: 0.792)]),+ startPoint: CGPoint(x: rx*0.7, y: -ry*0.85),+ endPoint: CGPoint(x: -rx*0.8, y: ry*0.9)+ ))+ ctx.fill(bodyPath, with: .radialGradient(+ Gradient(stops: [.init(color: .clear, location: 0.6),+ .init(color: Color.black.opacity(0.2), location: 1)]),+ center: .zero, startRadius: iconR*0.15, endRadius: iconR*1.25+ ))+ // Eyes+ var eyeCtx = ctx; eyeCtx.clip(to: bodyPath)+ let ink = Color(red: 0.102, green: 0.082, blue: 0.071)+ for f in mEyeFrames(mH) {+ guard f.visible else { continue }+ var ec = eyeCtx; ec.translateBy(x: f.x, y: f.y); ec.scaleBy(x: f.fx, y: f.fy)+ let hh = max(f.h, f.w*0.3)+ var pill = Path()+ pill.addRoundedRect(in: CGRect(x: -f.w/2, y: -hh/2, width: f.w, height: hh),+ cornerSize: CGSize(width: min(f.w/2,hh/2), height: min(f.w/2,hh/2)))+ ec.fill(pill, with: .color(ink))+ }+ // Front outfit+ if seasonal != .none && seasonal != .auto {+ drawOutfitFrontStatic(context: context, outfit: seasonal, H: mH,+ cx: cx, cy: iconCY, tilt: 0, sx: 1, sy: 1,+ roll: 0, morph: 0, isMini: false)+ }+ // AUTO badge at bottom+ var badgeCtx = context+ let badgeCY = iconCY + ry * 0.72+ badgeCtx.translateBy(x: cx, y: badgeCY)+ let bw: CGFloat = 14, bh: CGFloat = 6.5+ var badge = Path()+ badge.addRoundedRect(in: CGRect(x: -bw/2, y: -bh/2, width: bw, height: bh),+ cornerSize: CGSize(width: bh/2, height: bh/2))+ badgeCtx.fill(badge, with: .color(Color.black.opacity(0.60)))+ badgeCtx.draw(Text("AUTO").font(.system(size: 4.2, weight: .semibold)).foregroundColor(.white),+ at: .zero)++ case .none:+ var ctx = context+ ctx.translateBy(x: cx, y: cy)+ // Circle with diagonal slash (⊘)+ var circle = Path()+ circle.addEllipse(in: CGRect(x: -R * 0.82, y: -R * 0.82, width: R * 1.64, height: R * 1.64))+ ctx.stroke(circle, with: .color(Color(hex: "#454850")), style: StrokeStyle(lineWidth: 1.4, lineCap: .round))+ var slash = Path()+ slash.move(to: CGPoint(x: -R * 0.56, y: R * 0.56))+ slash.addLine(to: CGPoint(x: R * 0.56, y: -R * 0.56))+ ctx.stroke(slash, with: .color(Color(hex: "#454850")), style: StrokeStyle(lineWidth: 1.4, lineCap: .round))++ default:+ // Small Mochi wearing the outfit+ let iconR: CGFloat = 10.0+ let rx = iconR * 1.14, ry = iconR * 0.88+ let mH = MochiH(R: iconR, yaw: 0, pitch: 0)+ let bodyPath = mochiOutfitPath(rx, ry)+ let iconCY = cy + iconR * 0.62++ // Draw outfit behind+ drawOutfitBehindStatic(context: context, outfit: outfit, H: mH,+ cx: cx, cy: iconCY, tilt: 0, sx: 1, sy: 1,+ roll: 0, morph: 0, isMini: false)++ // Draw body+ var ctx = context+ ctx.translateBy(x: cx, y: iconCY)+ let pumpkin = outfit == .pumpkin+ let top = pumpkin ? Color(hex: "#FFA94D") : Color(red: 0.929, green: 0.929, blue: 0.937)+ let bot = pumpkin ? Color(hex: "#E8590C") : Color(red: 0.769, green: 0.773, blue: 0.792)+ ctx.fill(bodyPath, with: .linearGradient(+ Gradient(colors: [top, bot]),+ startPoint: CGPoint(x: rx * 0.7, y: -ry * 0.85),+ endPoint: CGPoint(x: -rx * 0.8, y: ry * 0.9)+ ))+ ctx.fill(bodyPath, with: .radialGradient(+ Gradient(stops: [+ .init(color: .clear, location: 0),+ .init(color: .clear, location: 0.6),+ .init(color: Color.black.opacity(0.2), location: 1)+ ]),+ center: .zero, startRadius: iconR * 0.15, endRadius: iconR * 1.25+ ))+ ctx.fill(bodyPath, with: .radialGradient(+ Gradient(stops: [+ .init(color: Color.white.opacity(0.55), location: 0),+ .init(color: .clear, location: 1)+ ]),+ center: CGPoint(x: rx * 0.34, y: -ry * 0.46),+ startRadius: 0, endRadius: iconR * 0.42+ ))++ // Draw eyes+ var eyeCtx = ctx+ eyeCtx.clip(to: bodyPath)+ let ink = Color(red: 0.102, green: 0.082, blue: 0.071)+ for f in mEyeFrames(mH) {+ guard f.visible else { continue }+ var ec = eyeCtx+ ec.translateBy(x: f.x, y: f.y)+ ec.scaleBy(x: f.fx, y: f.fy)+ let hh = max(f.h, f.w * 0.3)+ var pill = Path()+ pill.addRoundedRect(+ in: CGRect(x: -f.w / 2, y: -hh / 2, width: f.w, height: hh),+ cornerSize: CGSize(width: min(f.w / 2, hh / 2), height: min(f.w / 2, hh / 2))+ )+ ec.fill(pill, with: .color(ink))+ }++ // Draw outfit front+ drawOutfitFrontStatic(context: context, outfit: outfit, H: mH,+ cx: cx, cy: iconCY, tilt: 0, sx: 1, sy: 1,+ roll: 0, morph: 0, isMini: false)+ }+}// MARK: - Card backgroundstruct CardBackground<Content: View>: View {diff --git a/NotchBuddy/Sources/App/IslandWindowController.swift b/NotchBuddy/Sources/App/IslandWindowController.swiftindex 7c48579b..9847e5a2 100644--- a/NotchBuddy/Sources/App/IslandWindowController.swift+++ b/NotchBuddy/Sources/App/IslandWindowController.swift@@ -488,6 +488,21 @@ final class IslandWindowController: NSWindowController {finishDrag()}+ NSEvent.addLocalMonitorForEvents(matching: .rightMouseDown) { [weak self] event in+ guard let self else { return event }+ MainActor.assumeIsolated {+ guard self.wasInIsland, self.isBotHit(event.locationInWindow) else { return }+ if self.state.mode == .expanded && self.state.view == .wardrobe {+ withAnimation(.spring(response: 0.3, dampingFraction: 0.8)) {+ self.state.view = .overview+ }+ } else {+ self.expand(to: .wardrobe)+ }+ }+ return event+ }+// Global hotkey to show islandNSEvent.addGlobalMonitorForEvents(matching: .keyDown) { [weak self] event inTask { @MainActor indiff --git a/NotchBuddy/Sources/App/MochiOutfitDrawing.swift b/NotchBuddy/Sources/App/MochiOutfitDrawing.swiftnew file mode 100644index 00000000..3da22273--- /dev/null+++ b/NotchBuddy/Sources/App/MochiOutfitDrawing.swift@@ -0,0 +1,1464 @@+import SwiftUI+import CoreGraphics++// MARK: - Constants (mirror JS)++private let kEXP: CGFloat = 2.7+private let kVIEW_TILT: CGFloat = -0.30+private let kACC_PITCH: CGFloat = 0.4+private let kEYE_W: CGFloat = 0.25+private let kEYE_H: CGFloat = 0.27+private let kEYE_SP: CGFloat = 0.37+private let kEYE_P: CGFloat = -0.12++// MARK: - MochiH (head geometry + physics)++struct MochiH {+ let R, rx, ry: CGFloat+ let yaw, pitch: CGFloat+ let view: CGFloat // = VIEW_TILT (-0.30)+ let physDx, physDy: CGFloat+ let roll: CGFloat++ init(R: CGFloat, yaw: CGFloat = 0, pitch: CGFloat = 0,+ physDx: CGFloat = 0, physDy: CGFloat = 0, roll: CGFloat = 0) {+ self.R = R+ self.rx = R * 1.14+ self.ry = R * 0.88+ self.yaw = yaw+ self.pitch = pitch+ self.view = kVIEW_TILT+ self.physDx = physDx+ self.physDy = physDy+ self.roll = roll+ }+}++// MARK: - EyeFrame (replaces mochiEyePositions)++struct EyeFrame {+ let sd: CGFloat // -1 left, +1 right+ let x, y: CGFloat+ let fx, fy: CGFloat+ let visible: Bool+ let w, h: CGFloat+}++func mEyeFrames(_ H: MochiH) -> [EyeFrame] {+ var out: [EyeFrame] = []+ for sdD: Double in [-1.0, 1.0] {+ let sd = CGFloat(sdD)+ let eyeYaw = sd * kEYE_SP + H.yaw+ let eyePitch = kEYE_P + H.pitch+ let cp = cos(eyePitch)+ let visible = cos(eyeYaw) * cp > 0.04+ out.append(EyeFrame(+ sd: sd,+ x: sin(eyeYaw) * cp * H.rx,+ y: -sin(eyePitch) * H.ry,+ fx: max(0.18, cos(eyeYaw)),+ fy: max(0.18, cp),+ visible: visible,+ w: H.R * kEYE_W,+ h: H.R * kEYE_H+ ))+ }+ return out+}++/// Backward-compat shim (used by existing callers that haven't been updated yet).+func mochiEyePositions(yaw: CGFloat, pitch: CGFloat, rx: CGFloat, ry: CGFloat)+ -> [(ex: CGFloat, ey: CGFloat, fx: CGFloat, fy: CGFloat)] {+ let H = MochiH(R: rx / 1.14, yaw: yaw, pitch: pitch)+ return mEyeFrames(H).filter { $0.visible }.map { (ex: $0.x, ey: $0.y, fx: $0.fx, fy: $0.fy) }+}++// MARK: - P3 (projected screen point with depth)++private struct P3 {+ let x, y, z: CGFloat+}++// MARK: - 3D helpers (faithful port)++// ringR(y) → radius of horizontal ring at head-local y+private func mRingR(_ y: CGFloat) -> CGFloat {+ let a = min(1, abs(y))+ return pow(1 - pow(a, kEXP), 1 / kEXP)+}++// rot(p, yaw, pitch) — rotate head-local (x right, y up, z viewer) by yaw then pitch+private func mRot3(_ p: (CGFloat, CGFloat, CGFloat), yaw: CGFloat, pitch: CGFloat) -> (CGFloat, CGFloat, CGFloat) {+ var (x, y, z) = p+ let cy = cos(yaw), sy = sin(yaw)+ let x1 = x * cy + z * sy+ let z1 = -x * sy + z * cy+ x = x1+ let cp = cos(pitch), sp = sin(pitch)+ let y2 = y * cp + z1 * sp+ let z2 = -y * sp + z1 * cp+ return (x, y2, z2)+}++// proj(H, p) — head-local -> screen (body space)+private func mProj(_ H: MochiH, _ p: (CGFloat, CGFloat, CGFloat)) -> P3 {+ let r = mRot3(p, yaw: H.yaw, pitch: H.view + H.pitch * kACC_PITCH)+ return P3(x: r.0 * H.rx, y: -r.1 * H.ry, z: r.2)+}++// surf(y, lon, s) — point on head surface at height y, longitude lon+private func mSurf(_ y: CGFloat, _ lon: CGFloat, _ s: CGFloat = 1) -> (CGFloat, CGFloat, CGFloat) {+ let r = mRingR(y) * s+ return (r * sin(lon), y, r * cos(lon))+}++// Shared: given projected ring points, return front arc ordered L→R via silhouette tangents+private func frontSilhouetteArc(_ pts: [P3]) -> [P3] {+ let n = pts.count+ guard n > 1 else { return pts }+ let minIdx = pts.indices.min(by: { pts[$0].x < pts[$1].x })!+ let maxIdx = pts.indices.max(by: { pts[$0].x < pts[$1].x })!+ guard minIdx != maxIdx else { return [pts[minIdx]] }+ // Arc A: minIdx→maxIdx going forward (+1 steps)+ var arcA: [P3] = []; var i = minIdx+ while true { arcA.append(pts[i]); if i == maxIdx { break }; i = (i+1)%n; if arcA.count > n { break } }+ // Arc B: minIdx→maxIdx going backward (-1 steps)+ var arcB: [P3] = []; i = minIdx+ while true { arcB.append(pts[i]); if i == maxIdx { break }; i = (i-1+n)%n; if arcB.count > n { break } }+ let zA = arcA.reduce(0) { $0+$1.z } / CGFloat(max(1, arcA.count))+ let zB = arcB.reduce(0) { $0+$1.z } / CGFloat(max(1, arcB.count))+ return zA >= zB ? arcA : arcB+}++// frontArc(H, y, s) — front arc of ring at height y, ordered left→right (silhouette tangent method)+private func mFrontArc(_ H: MochiH, y: CGFloat, s: CGFloat) -> [P3] {+ let n = 120+ let pts: [P3] = (0..<n).map { i in+ let lon = -.pi + CGFloat(i) / CGFloat(n) * 2 * .pi+ return mProj(H, mSurf(y, lon, s))+ }+ return frontSilhouetteArc(pts)+}++// proj with roll applied (for roll-following accessories)+private func mProjRoll(_ H: MochiH, _ p: (CGFloat, CGFloat, CGFloat)) -> P3 {+ let r = mRot3(p, yaw: H.yaw, pitch: H.view + H.pitch * kACC_PITCH + H.roll)+ return P3(x: r.0 * H.rx, y: -r.1 * H.ry, z: r.2)+}++// frontArc using roll projection (for scarf)+private func mFrontArcRoll(_ H: MochiH, y: CGFloat, s: CGFloat) -> [P3] {+ let n = 120+ let pts: [P3] = (0..<n).map { i in+ let lon = -.pi + CGFloat(i) / CGFloat(n) * 2 * .pi+ return mProjRoll(H, mSurf(y, lon, s))+ }+ return frontSilhouetteArc(pts)+}++// capClip(H, y, s) — path of the region ABOVE the front arc of ring y (what a cap covers)+private func mCapClip(_ H: MochiH, y: CGFloat, s: CGFloat, extraTop: CGFloat = 3) -> Path {+ let arc = mFrontArc(H, y: y, s: s)+ guard !arc.isEmpty else { return Path() }+ var p = Path()+ p.move(to: CGPoint(x: arc[0].x - H.rx, y: arc[0].y))+ for q in arc { p.addLine(to: CGPoint(x: q.x, y: q.y)) }+ p.addLine(to: CGPoint(x: arc.last!.x + H.rx, y: arc.last!.y))+ p.addLine(to: CGPoint(x: H.rx * 2, y: -H.ry * extraTop))+ p.addLine(to: CGPoint(x: -H.rx * 2, y: -H.ry * extraTop))+ p.closeSubpath()+ return p+}++// frontRun — front arc of a CLOSED ring, ordered left→right (silhouette tangent method)+private func mFrontRun(_ ring: [P3]) -> [P3] {+ frontSilhouetteArc(ring)+}++// invert(p, H) — complement of path p inside a large rect, with evenodd fill+private func mInvert(_ p: Path, H: MochiH) -> Path {+ var q = Path()+ q.addRect(CGRect(x: -H.rx * 4, y: -H.ry * 4, width: H.rx * 8, height: H.ry * 8))+ q.addPath(p)+ return q+}++// mochiOutfitPath — clean superellipse (n=96), same exponent as JS mochiPath+func mochiOutfitPath(_ rx: CGFloat, _ ry: CGFloat) -> Path {+ let n = 96+ let e: CGFloat = 2.0 / kEXP+ var p = Path()+ for i in 0...n {+ let a = CGFloat(i) / CGFloat(n) * .pi * 2+ let ca = cos(a), sa = sin(a)+ let x = rx * (ca >= 0 ? pow(ca, e) : -pow(-ca, e))+ let y = ry * (sa >= 0 ? pow(sa, e) : -pow(-sa, e))+ if i == 0 { p.move(to: CGPoint(x: x, y: y)) }+ else { p.addLine(to: CGPoint(x: x, y: y)) }+ }+ p.closeSubpath()+ return p+}++// ringPoints — all 120+1 projected points on ring (full circle, for frontRun)+private func mRingPoints(_ H: MochiH, y: CGFloat, s: CGFloat, n: Int = 72) -> [P3] {+ (0...n).map { i -> P3 in+ let lon = -.pi + CGFloat(i) / CGFloat(n) * 2 * .pi+ return mProj(H, mSurf(y, lon, s))+ }+}++// MARK: - pompom++private func drawPompom(_ ctx: inout GraphicsContext, x: CGFloat, y: CGFloat, r: CGFloat,+ base: Color = .white,+ shade: Color = Color(red: 0.835, green: 0.851, blue: 0.886)) {+ var g = ctx+ g.translateBy(x: x, y: y)+ // fluffy rim bumps+ let n = 11+ for i in 0..<n {+ let a = CGFloat(i) / CGFloat(n) * .pi * 2+ let br = r * (0.34 + 0.06 * sin(CGFloat(i) * 2.3))+ let bx = cos(a) * r * 0.78+ let by = sin(a) * r * 0.78+ var bump = Path()+ bump.addEllipse(in: CGRect(x: bx - br, y: by - br, width: br * 2, height: br * 2))+ g.fill(bump, with: .radialGradient(+ Gradient(stops: [.init(color: base, location: 0), .init(color: shade, location: 1)]),+ center: CGPoint(x: bx - br * 0.4, y: by - br * 0.5),+ startRadius: 0, endRadius: br * 1.3+ ))+ }+ var center = Path()+ center.addEllipse(in: CGRect(x: -r * 0.86, y: -r * 0.86, width: r * 0.86 * 2, height: r * 0.86 * 2))+ g.fill(center, with: .radialGradient(+ Gradient(stops: [+ .init(color: base, location: 0),+ .init(color: base, location: 0.7),+ .init(color: shade, location: 1)+ ]),+ center: CGPoint(x: -r * 0.3, y: -r * 0.35),+ startRadius: 0, endRadius: r * 1.05+ ))+}++// MARK: - fuzzyBand++private func drawFuzzyBand(_ ctx: inout GraphicsContext, arc: [P3], thick: CGFloat,+ base: Color = .white,+ shade: Color = Color(red: 0.855, green: 0.867, blue: 0.894)) {+ guard arc.count >= 2 else { return }+ // shade stroke+ var sp = Path()+ sp.move(to: CGPoint(x: arc[0].x, y: arc[0].y))+ for i in 1..<arc.count { sp.addLine(to: CGPoint(x: arc[i].x, y: arc[i].y)) }+ ctx.stroke(sp, with: .color(shade), style: StrokeStyle(lineWidth: thick, lineCap: .round, lineJoin: .round))+ // base stroke+ var bp = Path()+ bp.move(to: CGPoint(x: arc[0].x, y: arc[0].y))+ for i in 1..<arc.count { bp.addLine(to: CGPoint(x: arc[i].x, y: arc[i].y)) }+ ctx.stroke(bp, with: .color(base), style: StrokeStyle(lineWidth: thick * 0.78, lineCap: .round, lineJoin: .round))+ // bumps along the arc+ let step = max(2, arc.count / 16)+ for i in stride(from: 0, to: arc.count, by: step) {+ let q = arc[i]+ let r = thick * (0.32 + 0.1 * sin(CGFloat(i) * 1.7))+ var bump = Path()+ bump.addEllipse(in: CGRect(x: q.x - r, y: q.y - thick * 0.32 - r, width: r * 2, height: r * 2))+ ctx.fill(bump, with: .radialGradient(+ Gradient(stops: [.init(color: base, location: 0), .init(color: shade, location: 1)]),+ center: CGPoint(x: q.x - r * 0.3, y: q.y - thick * 0.35 - r * 0.3),+ startRadius: 0, endRadius: r * 1.2+ ))+ }+}++// MARK: - Body transform helper++func outfitBodyTransform(context: GraphicsContext, cx: CGFloat, cy: CGFloat,+ tilt: CGFloat, sx: CGFloat, sy: CGFloat) -> GraphicsContext {+ var ctx = context+ ctx.translateBy(x: cx, y: cy)+ if tilt != 0 { ctx.rotate(by: .radians(tilt)) }+ ctx.scaleBy(x: sx, y: sy)+ return ctx+}++// MARK: - Front dispatcher++func drawOutfitFrontStatic(+ context: GraphicsContext,+ outfit: Outfit, H: MochiH,+ cx: CGFloat, cy: CGFloat, tilt: CGFloat, sx: CGFloat, sy: CGFloat,+ roll: CGFloat, morph: CGFloat, isMini: Bool,+ presence: CGFloat = 1, rollTurns: CGFloat = 1+) {+ guard !isMini, outfit != .none, outfit != .auto else { return }+ let morphFade = 1 - min(1, max(0, (morph - 0.3) / 0.2))+ guard morphFade > 0.01 else { return }++ // Roll-following (glasses, bow, scarf, pumpkin): skip front pass when z < 0 → behind pass handles it.+ // bunnyEars: always in behind pass; not in this set.+ switch outfit {+ case .sunglasses, .roundGlasses, .bow, .scarf, .pumpkin:+ if mProjRoll(H, (0, 0, 1)).z < 0 { return }+ default: break+ }++ // Opacity: opaque early so movement carries the transition; drawLayer prevents ghost overlaps.+ let p = presence+ let posP = Ease.back(p)+ let layerOpacity = Double(morphFade * min(1, p * 2.5))+ guard layerOpacity > 0.005 else { return }++ let simplified = H.R < 16+ let baseCtx = outfitBodyTransform(context: context, cx: cx, cy: cy, tilt: tilt, sx: sx, sy: sy)+ let bodyPath = mochiOutfitPath(H.rx, H.ry)++ // ── Hat fly-off during roll (beanie, santaHat, partyHat, crown, witchHat) ──────────────────+ let isHatType: Bool+ switch outfit {+ case .beanie, .santaHat, .partyHat, .crown, .witchHat: isHatType = true+ default: isHatType = false+ }+ if isHatType && abs(H.roll) > 0.01 {+ let u = min(1, abs(H.roll) / (2 * .pi * max(1, rollTurns)))+ let flyHeight = H.ry * 0.45 * sin(u * .pi)+ let flyDrift = H.physDx * H.rx * 0.2 * sin(u * .pi)+ let swingAngle = sin(2 * .pi * u) * 0.35 // gentle flat swing, hat stays upright+ var c = baseCtx; c.opacity = layerOpacity+ c.translateBy(x: flyDrift, y: -flyHeight)+ c.rotate(by: .radians(swingAngle))+ c.drawLayer { lCtx in+ var l = lCtx+ switch outfit {+ case .beanie:+ drawBeaniesFront(ctx: &l, H: H, bodyPath: bodyPath, simplified: simplified)+ case .santaHat:+ drawSantaHatFront(ctx: &l, H: H, bodyPath: bodyPath)+ case .partyHat:+ drawPartyHatFront(ctx: &l, H: H, bodyPath: bodyPath, simplified: simplified)+ case .crown:+ var g = l; g.clip(to: bodyPath)+ g.clip(to: mCapClip(H, y: crownYb(H) - 0.1, s: 1))+ var g2 = g+ g2.clip(to: mInvert(mCapClip(H, y: crownYb(H), s: 1), H: H), style: FillStyle(eoFill: true))+ var shp = Path(); shp.addRect(CGRect(x: -H.rx*4, y: -H.ry*4, width: H.rx*8, height: H.ry*8))+ g2.fill(shp, with: .color(Color(red: 0.314, green: 0.196, blue: 0, opacity: 0.12)))+ drawCrownPart(ctx: &l, H: H, side: 1, simplified: simplified)+ case .witchHat:+ drawWitchHatFront(ctx: &l, H: H, bodyPath: bodyPath)+ default: break+ }+ }+ return+ }++ // ── Normal presence transitions (drawLayer eliminates ghost overlaps) ────────────────────────+ let hatScale = 0.85 + 0.15 * posP // hats / crown: scale up as they settle++ switch outfit {+ case .beanie:+ var c = baseCtx; c.opacity = layerOpacity+ c.translateBy(x: 0, y: -(1 - posP) * H.ry * 1.0); c.scaleBy(x: hatScale, y: hatScale)+ c.drawLayer { lCtx in var l = lCtx; drawBeaniesFront(ctx: &l, H: H, bodyPath: bodyPath, simplified: simplified) }++ case .santaHat:+ var c = baseCtx; c.opacity = layerOpacity+ c.translateBy(x: 0, y: -(1 - posP) * H.ry * 1.0); c.scaleBy(x: hatScale, y: hatScale)+ c.drawLayer { lCtx in var l = lCtx; drawSantaHatFront(ctx: &l, H: H, bodyPath: bodyPath) }++ case .partyHat:+ var c = baseCtx; c.opacity = layerOpacity+ c.translateBy(x: 0, y: -(1 - posP) * H.ry * 1.0); c.scaleBy(x: hatScale, y: hatScale)+ c.drawLayer { lCtx in var l = lCtx; drawPartyHatFront(ctx: &l, H: H, bodyPath: bodyPath, simplified: simplified) }++ case .crown:+ var c = baseCtx; c.opacity = layerOpacity+ c.translateBy(x: 0, y: -(1 - posP) * H.ry * 1.0); c.scaleBy(x: hatScale, y: hatScale)+ c.drawLayer { lCtx in+ var l = lCtx+ var g = l; g.clip(to: bodyPath)+ g.clip(to: mCapClip(H, y: crownYb(H) - 0.1, s: 1))+ var g2 = g+ g2.clip(to: mInvert(mCapClip(H, y: crownYb(H), s: 1), H: H), style: FillStyle(eoFill: true))+ var shp = Path(); shp.addRect(CGRect(x: -H.rx*4, y: -H.ry*4, width: H.rx*8, height: H.ry*8))+ g2.fill(shp, with: .color(Color(red: 0.314, green: 0.196, blue: 0, opacity: 0.12)))+ drawCrownPart(ctx: &l, H: H, side: 1, simplified: simplified)+ }++ case .witchHat:+ var c = baseCtx; c.opacity = layerOpacity+ c.translateBy(x: 0, y: -(1 - posP) * H.ry * 1.0); c.scaleBy(x: hatScale, y: hatScale)+ c.drawLayer { lCtx in var l = lCtx; drawWitchHatFront(ctx: &l, H: H, bodyPath: bodyPath) }++ case .sunglasses:+ var c = baseCtx; c.opacity = layerOpacity+ c.translateBy(x: 0, y: (1 - p) * 0.25 * H.ry)+ c.drawLayer { lCtx in var l = lCtx; drawSunglassesFront(ctx: &l, H: H, bodyPath: bodyPath) }++ case .roundGlasses:+ var c = baseCtx; c.opacity = layerOpacity+ c.translateBy(x: 0, y: (1 - p) * 0.25 * H.ry)+ c.drawLayer { lCtx in var l = lCtx; drawRoundGlassesFront(ctx: &l, H: H, bodyPath: bodyPath) }++ case .scarf:+ var c = baseCtx; c.opacity = layerOpacity+ c.translateBy(x: 0, y: (1 - p) * 0.3 * H.ry)+ c.drawLayer { lCtx in var l = lCtx; drawScarfFront(ctx: &l, H: H) }++ case .pumpkin:+ var c = baseCtx; c.opacity = layerOpacity+ c.drawLayer { lCtx in var l = lCtx; drawPumpkinFront(ctx: &l, H: H, bodyPath: bodyPath, simplified: simplified) }++ case .bow:+ var c = baseCtx; c.opacity = layerOpacity+ c.scaleBy(x: max(0.001, posP), y: max(0.001, posP))+ c.drawLayer { lCtx in var l = lCtx; drawBowFront(ctx: &l, H: H, bodyPath: bodyPath) }++ default:+ break+ }+}++// MARK: - Behind dispatcher++func drawOutfitBehindStatic(+ context: GraphicsContext,+ outfit: Outfit, H: MochiH,+ cx: CGFloat, cy: CGFloat, tilt: CGFloat, sx: CGFloat, sy: CGFloat,+ roll: CGFloat, morph: CGFloat, isMini: Bool,+ presence: CGFloat = 1, rollTurns: CGFloat = 1+) {+ guard !isMini, outfit != .none, outfit != .auto else { return }+ let morphFade = 1 - min(1, max(0, (morph - 0.3) / 0.2))+ guard morphFade > 0.01 else { return }++ let layerOpacity = Double(morphFade * min(1, presence * 2.5))+ guard layerOpacity > 0.005 else { return }++ let simplified = H.R < 16+ var ctx = outfitBodyTransform(context: context, cx: cx, cy: cy, tilt: tilt, sx: sx, sy: sy)+ let bodyPath = mochiOutfitPath(H.rx, H.ry)++ // Roll-following accessories (glasses, bow, scarf, pumpkin — not bunnyEars): behind when z < 0+ switch outfit {+ case .sunglasses, .roundGlasses, .bow, .scarf, .pumpkin:+ guard mProjRoll(H, (0, 0, 1)).z < 0 else { return }+ ctx.opacity = layerOpacity+ ctx.drawLayer { lCtx in+ var l = lCtx+ switch outfit {+ case .sunglasses: drawSunglassesFront(ctx: &l, H: H, bodyPath: bodyPath)+ case .roundGlasses: drawRoundGlassesFront(ctx: &l, H: H, bodyPath: bodyPath)+ case .scarf: drawScarfFront(ctx: &l, H: H)+ case .pumpkin: drawPumpkinFront(ctx: &l, H: H, bodyPath: bodyPath, simplified: simplified)+ case .bow: drawBowFront(ctx: &l, H: H, bodyPath: bodyPath)+ default: break+ }+ }+ return+ default: break+ }++ // Behind accessories: bunnyEars (always), crown back, witchHat back+ let posP = Ease.back(presence)+ let hatScale = 0.85 + 0.15 * posP+ switch outfit {+ case .bunnyEars:+ // Always behind body; no 3D roll — ears flatten/tilt during roll.+ let u: CGFloat = abs(H.roll) > 0.01+ ? min(1, abs(H.roll) / (2 * .pi * max(1, rollTurns)))+ : 0+ var c = ctx; c.opacity = layerOpacity+ // Presence transition: descend from above (same as hats)+ c.translateBy(x: 0, y: -(1 - posP) * H.ry * 1.0)+ c.scaleBy(x: hatScale, y: hatScale)+ c.drawLayer { lCtx in+ var l = lCtx+ drawBunnyEarsBack(ctx: &l, H: H, rollProgress: u)+ }++ case .crown:+ var c = ctx; c.opacity = layerOpacity+ if abs(H.roll) > 0.01 {+ let u = min(1, abs(H.roll) / (2 * .pi * max(1, rollTurns)))+ c.translateBy(x: H.physDx * H.rx * 0.2 * sin(u * .pi), y: -H.ry * 0.45 * sin(u * .pi))+ c.rotate(by: .radians(sin(2 * .pi * u) * 0.35))+ } else {+ c.translateBy(x: 0, y: -(1 - posP) * H.ry * 1.0); c.scaleBy(x: hatScale, y: hatScale)+ }+ c.drawLayer { lCtx in var l = lCtx; drawCrownPart(ctx: &l, H: H, side: -1, simplified: simplified) }++ case .witchHat:+ var c = ctx; c.opacity = layerOpacity+ if abs(H.roll) > 0.01 {+ let u = min(1, abs(H.roll) / (2 * .pi * max(1, rollTurns)))+ c.translateBy(x: H.physDx * H.rx * 0.2 * sin(u * .pi), y: -H.ry * 0.45 * sin(u * .pi))+ c.rotate(by: .radians(sin(2 * .pi * u) * 0.35))+ } else {+ c.translateBy(x: 0, y: -(1 - posP) * H.ry * 1.0); c.scaleBy(x: hatScale, y: hatScale)+ }+ c.drawLayer { lCtx in var l = lCtx; drawWitchHatBack(ctx: &l, H: H) }++ default:+ break+ }+}++// MARK: - Crown geometry helper++private func crownYb(_ H: MochiH) -> CGFloat { 0.46 }++// MARK: - Bunny ears (behind body)++// rollProgress: 0 = upright, 1 = max roll (ears fully flattened). Drawn with mProj (no 3D roll).+private func drawBunnyEarsBack(ctx: inout GraphicsContext, H: MochiH, rollProgress: CGFloat = 0) {+ let R = H.R+ let earH = R * 0.85++ for sd: CGFloat in [-1.0, 1.0] {+ // Standard projection — ears do not follow 3D roll+ let earRoot = mProj(H, (sd * 0.45, 0.92, 0))+ let earRootL = mProj(H, (sd * 0.45 - 0.22, 0.92, 0))+ let earRootR = mProj(H, (sd * 0.45 + 0.22, 0.92, 0))+ let visHW = max(R * 0.04, abs(earRootR.x - earRootL.x) / 2)++ // During roll: ears flatten (shrink height) and tilt outward+ let flatten = sin(rollProgress * .pi)+ let effEarH = earH * (1 - 0.8 * flatten)+ let tiltAngle = sd * 0.6 * flatten // left ear tilts left, right tilts right++ let earCX = earRoot.x+ let earCY = earRoot.y - effEarH * 0.65 + effEarH * 0.5 // visual centre of ear++ var eCtx = ctx+ eCtx.translateBy(x: earCX, y: earCY)+ eCtx.rotate(by: .radians(tiltAngle))++ var outer = Path()+ outer.addEllipse(in: CGRect(x: -visHW, y: -effEarH / 2, width: visHW * 2, height: effEarH))+ eCtx.fill(outer, with: .color(Color(hex: "#F9F0F0")))+ eCtx.stroke(outer, with: .color(Color.black.opacity(0.06)), lineWidth: 0.8)+ var inner = Path()+ inner.addEllipse(in: CGRect(x: -visHW * 0.50, y: -effEarH / 2 + R * 0.10,+ width: visHW, height: effEarH * 0.65))+ eCtx.fill(inner, with: .color(Color(hex: "#FCA5A5").opacity(0.70)))+ }+}++// MARK: - Beanie++private func drawBeaniesFront(ctx: inout GraphicsContext, H: MochiH, bodyPath: Path, simplified: Bool = false) {+ let s: CGFloat = 1.035, yEdge: CGFloat = 0.42, yCuff: CGFloat = 0.58+ let head = mochiOutfitPath(H.rx * s, H.ry * s)++ // shadow on head under the cuff+ var shadow = ctx+ shadow.clip(to: bodyPath)+ shadow.clip(to: mCapClip(H, y: yEdge - 0.12, s: 1))+ var shRect = Path()+ shRect.addRect(CGRect(x: -H.rx * 4, y: -H.ry * 4, width: H.rx * 8, height: H.ry * 8))+ shadow.fill(shRect, with: .color(Color(red: 30/255, green: 40/255, blue: 70/255, opacity: 0.10)))++ // knit body+ var knitCtx = ctx+ knitCtx.clip(to: mCapClip(H, y: yCuff, s: s))+ knitCtx.fill(head, with: .linearGradient(+ Gradient(stops: [+ .init(color: Color(hex: "#7DB6FF"), location: 0),+ .init(color: Color(hex: "#2F6FE0"), location: 1)+ ]),+ startPoint: CGPoint(x: H.rx * 0.5, y: -H.ry * 1.1),+ endPoint: CGPoint(x: -H.rx * 0.6, y: H.ry * 0.2)+ ))+ // vertical knit ribs (skip when simplified)+ if !simplified {+ var ribCtx = knitCtx+ ribCtx.clip(to: head)+ for k in -6...6 {+ let lon = CGFloat(k) * 0.24+ var pts: [P3] = []+ for i in 0...16 {+ let y = yCuff + (1.05 - yCuff) * CGFloat(i) / 16+ let q = mProj(H, mSurf(y, lon, s))+ if q.z > 0 { pts.append(q) }+ }+ guard pts.count >= 2 else { continue }+ var rp = Path()+ rp.move(to: CGPoint(x: pts[0].x, y: pts[0].y))+ for pt in pts.dropFirst() { rp.addLine(to: CGPoint(x: pt.x, y: pt.y)) }+ ribCtx.stroke(rp, with: .color(Color(red: 20/255, green: 50/255, blue: 140/255, opacity: 0.16)),+ style: StrokeStyle(lineWidth: H.R * 0.045, lineCap: .round))+ }+ }++ // cuff (folded band) — clip to [yEdge, yCuff] band using invert+ var cuffCtx = ctx+ cuffCtx.clip(to: mCapClip(H, y: yEdge, s: s * 1.04))+ cuffCtx.clip(to: mInvert(mCapClip(H, y: yCuff, s: s * 1.04), H: H), style: FillStyle(eoFill: true))+ let cuffHead = mochiOutfitPath(H.rx * s * 1.04, H.ry * s * 1.04)+ cuffCtx.fill(cuffHead, with: .linearGradient(+ Gradient(stops: [+ .init(color: Color(hex: "#3C7BEA"), location: 0),+ .init(color: Color(hex: "#2257C4"), location: 1)+ ]),+ startPoint: CGPoint(x: 0, y: -H.ry * 0.6),+ endPoint: CGPoint(x: 0, y: -H.ry * 0.2)+ ))+ var cuffRib = cuffCtx+ cuffRib.clip(to: cuffHead)+ for k in -14...14 {+ let lon = CGFloat(k) * 0.115+ let a = mProj(H, mSurf(yEdge, lon, s * 1.04))+ let b = mProj(H, mSurf(yCuff, lon, s * 1.04))+ if a.z < 0 { continue }+ var cp = Path()+ cp.move(to: CGPoint(x: a.x, y: a.y))+ cp.addLine(to: CGPoint(x: b.x, y: b.y))+ cuffRib.stroke(cp, with: .color(Color(red: 10/255, green: 30/255, blue: 100/255, opacity: 0.22)),+ style: StrokeStyle(lineWidth: H.R * 0.035, lineCap: .butt))+ }++ // top highlight+ var hiCtx = ctx+ hiCtx.clip(to: mCapClip(H, y: yCuff, s: s))+ hiCtx.clip(to: head)+ hiCtx.fill(head, with: .radialGradient(+ Gradient(stops: [+ .init(color: Color.white.opacity(0.35), location: 0),+ .init(color: .clear, location: 1)+ ]),+ center: CGPoint(x: H.rx * 0.3, y: -H.ry * 0.85),+ startRadius: 0, endRadius: H.R * 0.45+ ))++ // pompom on short spring+ let top = mProj(H, (0, 1.08 * s, 0))+ drawPompom(&ctx, x: top.x + H.physDx * H.rx * 0.25,+ y: top.y - H.R * 0.12 + H.physDy * H.ry * 0.15,+ r: H.R * 0.24)+}++// MARK: - Santa hat++private func drawSantaHatFront(ctx: inout GraphicsContext, H: MochiH, bodyPath: Path) {+ let s: CGFloat = 1.05, yEdge: CGFloat = 0.52+ let arc = mFrontArc(H, y: yEdge, s: s)+ guard !arc.isEmpty else { return }+ let L = arc.first!+ let Rt = arc.last!+ let crown = mProj(H, (0, 1.05, 0))+ // tip flops to right + spring lag+ let side: CGFloat = 1+ let tip = CGPoint(+ x: crown.x + side * H.rx * (0.95 + H.physDx * 0.35),+ y: crown.y + H.ry * (0.05 + H.physDy * 0.2)+ )+ let peak = CGPoint(+ x: crown.x + side * H.rx * 0.25,+ y: crown.y - H.ry * 0.62+ )+ var bag = Path()+ bag.move(to: CGPoint(x: L.x, y: L.y))+ bag.addCurve(+ to: CGPoint(x: peak.x, y: peak.y),+ control1: CGPoint(x: L.x - H.rx * 0.05, y: L.y - H.ry * 0.7),+ control2: CGPoint(x: peak.x - H.rx * 0.55, y: peak.y - H.ry * 0.05)+ )+ bag.addQuadCurve(+ to: CGPoint(x: tip.x, y: tip.y),+ control: CGPoint(x: tip.x - H.rx * 0.05, y: peak.y - H.ry * 0.02)+ )+ bag.addQuadCurve(+ to: CGPoint(x: peak.x + H.rx * 0.18, y: peak.y + H.ry * 0.32),+ control: CGPoint(x: tip.x - H.rx * 0.12, y: tip.y - H.ry * 0.22)+ )+ bag.addCurve(+ to: CGPoint(x: Rt.x, y: Rt.y),+ control1: CGPoint(x: Rt.x + H.rx * 0.05, y: peak.y + H.ry * 0.45),+ control2: CGPoint(x: Rt.x + H.rx * 0.08, y: Rt.y - H.ry * 0.35)+ )+ for i in stride(from: arc.count - 1, through: 0, by: -1) {+ bag.addLine(to: CGPoint(x: arc[i].x, y: arc[i].y))+ }+ bag.closeSubpath()++ // shadow on head+ var sCtx = ctx+ sCtx.clip(to: bodyPath)+ sCtx.clip(to: mCapClip(H, y: yEdge - 0.14, s: 1))+ var sRect = Path()+ sRect.addRect(CGRect(x: -H.rx * 4, y: -H.ry * 4, width: H.rx * 8, height: H.ry * 8))+ sCtx.fill(sRect, with: .color(Color(red: 120/255, green: 10/255, blue: 10/255, opacity: 0.10)))++ // bag fill+ ctx.fill(bag, with: .linearGradient(+ Gradient(stops: [+ .init(color: Color(hex: "#FF6B6B"), location: 0),+ .init(color: Color(hex: "#E53935"), location: 0.55),+ .init(color: Color(hex: "#B71C1C"), location: 1)+ ]),+ startPoint: CGPoint(x: -H.rx * 0.6, y: -H.ry * 1.6),+ endPoint: CGPoint(x: H.rx * 0.7, y: -H.ry * 0.3)+ ))++ // folds+ var fCtx = ctx+ fCtx.clip(to: bag)+ for (a, b, w): (CGFloat, CGFloat, CGFloat) in [(0.15, 0.55, 0.10), (0.45, 0.85, 0.08)] {+ var fold = Path()+ fold.move(to: CGPoint(+ x: peak.x - H.rx * 0.1 + (Rt.x - L.x) * a * 0.3,+ y: peak.y + H.ry * 0.15+ ))+ fold.addQuadCurve(+ to: CGPoint(x: tip.x - H.rx * (0.45 - b * 0.3), y: tip.y - H.ry * 0.12),+ control: CGPoint(x: peak.x + H.rx * 0.35, y: peak.y + H.ry * (0.05 + a * 0.3))+ )+ fCtx.stroke(fold, with: .color(Color(red: 90/255, green: 0, blue: 0, opacity: 0.20)),+ style: StrokeStyle(lineWidth: H.R * w, lineCap: .round))+ }+ fCtx.fill(bag, with: .radialGradient(+ Gradient(stops: [+ .init(color: Color.white.opacity(0.32), location: 0),+ .init(color: .clear, location: 1)+ ]),+ center: CGPoint(x: peak.x - H.rx * 0.25, y: peak.y + H.ry * 0.05),+ startRadius: 0, endRadius: H.R * 0.5+ ))++ // trim + pompom+ drawFuzzyBand(&ctx, arc: arc, thick: H.R * 0.3)+ drawPompom(&ctx, x: tip.x, y: tip.y + H.R * 0.04, r: H.R * 0.22)+}++// MARK: - Party hat++private func drawPartyHatFront(ctx: inout GraphicsContext, H: MochiH, bodyPath: Path, simplified: Bool = false) {+ let baseY: CGFloat = 0.82, baseR: CGFloat = 0.42+ let lean: CGFloat = -0.24 + H.physDx * 0.12+ let c = mProj(H, (0.16, baseY + 0.06, 0))+ // full ring for left/right extremes+ var ring: [P3] = []+ for i in 0...48 {+ let a = CGFloat(i) / 48 * .pi * 2+ ring.append(mProj(H, (0.16 + baseR * sin(a), baseY + 0.06, baseR * cos(a))))+ }+ let left = ring.min(by: { $0.x < $1.x })!+ let right = ring.max(by: { $0.x < $1.x })!+ let h = H.ry * 1.6+ let apex = CGPoint(x: c.x + sin(lean) * h, y: c.y - cos(lean) * h)+ let front = mFrontRun(ring)++ var cone = Path()+ cone.move(to: CGPoint(x: left.x, y: left.y))+ cone.addQuadCurve(+ to: CGPoint(x: apex.x - H.R * 0.05, y: apex.y + H.R * 0.06),+ control: CGPoint(x: (left.x + apex.x) / 2 - H.rx * 0.06, y: (left.y + apex.y) / 2)+ )+ cone.addQuadCurve(+ to: CGPoint(x: apex.x + H.R * 0.05, y: apex.y + H.R * 0.06),+ control: CGPoint(x: apex.x, y: apex.y - H.R * 0.03)+ )+ cone.addQuadCurve(+ to: CGPoint(x: right.x, y: right.y),+ control: CGPoint(x: (right.x + apex.x) / 2 + H.rx * 0.06, y: (right.y + apex.y) / 2)+ )+ for i in stride(from: front.count - 1, through: 0, by: -1) {+ cone.addLine(to: CGPoint(x: front[i].x, y: front[i].y))+ }+ cone.closeSubpath()++ ctx.fill(cone, with: .linearGradient(+ Gradient(stops: [+ .init(color: Color(hex: "#FF9BD0"), location: 0),+ .init(color: Color(hex: "#F15BAE"), location: 0.5),+ .init(color: Color(hex: "#C2187A"), location: 1)+ ]),+ startPoint: CGPoint(x: left.x, y: apex.y),+ endPoint: CGPoint(x: right.x, y: left.y)+ ))++ var dotCtx = ctx+ dotCtx.clip(to: cone)+ // polka dots (skip when simplified)+ if !simplified {+ let dots: [(CGFloat, CGFloat)] = [+ (0.25, -0.35), (0.3, 0.3), (0.55, -0.05), (0.72, 0.28),+ (0.8, -0.3), (0.45, 0.6), (0.48, -0.65)+ ]+ for (t, u) in dots {+ let bx = left.x + (right.x - left.x) * (0.5 + u * 0.5)+ let by = left.y + (right.y - left.y) * (0.5 + u * 0.5)+ let x = bx + (apex.x - bx) * (1 - t)+ let y = by + (apex.y - by) * (1 - t)+ let r = H.R * 0.075 * (0.6 + t * 0.5)+ var dot = Path()+ dot.addEllipse(in: CGRect(x: x - r, y: y - r * 0.9, width: r * 2, height: r * 0.9 * 2))+ dotCtx.fill(dot, with: .color(Color.white.opacity(0.92)))+ }+ }+ dotCtx.fill(cone, with: .linearGradient(+ Gradient(stops: [+ .init(color: Color.white.opacity(0.28), location: 0),+ .init(color: .clear, location: 0.35),+ .init(color: Color(red: 80/255, green: 0, blue: 40/255, opacity: 0.18), location: 1)+ ]),+ startPoint: CGPoint(x: left.x, y: 0),+ endPoint: CGPoint(x: right.x, y: 0)+ ))++ // rim at base+ if !front.isEmpty {+ var rim = Path()+ rim.move(to: CGPoint(x: front[0].x, y: front[0].y))+ for i in 1..<front.count { rim.addLine(to: CGPoint(x: front[i].x, y: front[i].y)) }+ ctx.stroke(rim, with: .color(Color(hex: "#FFD84D")),+ style: StrokeStyle(lineWidth: H.R * 0.07, lineCap: .round))+ }+ drawPompom(&ctx, x: apex.x, y: apex.y - H.R * 0.04, r: H.R * 0.16,+ base: Color(hex: "#FFE27A"), shade: Color(hex: "#F2B705"))+}++// MARK: - Crown++private func drawCrownPart(ctx: inout GraphicsContext, H: MochiH, side: CGFloat, simplified: Bool = false) {+ let s: CGFloat = 1.06, yb: CGFloat = 0.46, yt: CGFloat = 0.66+ let n = 8, spikeH: CGFloat = 0.42+ let N = 120+ var seg: [(lon: CGFloat, b: P3, t: P3, tt: P3, z: CGFloat, spike: CGFloat)] = []+ for i in 0...N {+ let lon = -.pi + CGFloat(i) / CGFloat(N) * 2 * .pi+ let b = mProj(H, mSurf(yb, lon, s))+ let t = mProj(H, mSurf(yt, lon, s))+ let phase = ((lon + .pi) / (2 * .pi)) * CGFloat(n)+ let f = phase - floor(phase)+ let spike = pow(max(0, 1 - abs(f - 0.5) * 2), 1.6)+ let topY = yt + spikeH * spike+ let sp = mSurf(yt, lon, s)+ let tt = mProj(H, (sp.0 * (1 - 0.08 * spike), topY, sp.2 * (1 - 0.08 * spike)))+ seg.append((lon: lon, b: b, t: t, tt: tt, z: b.z, spike: spike))+ }+ var keep = seg.filter { side > 0 ? $0.z >= 0 : $0.z < 0.02 }+ guard keep.count >= 2 else { return }+ keep.sort { $0.b.x < $1.b.x }++ var shape = Path()+ shape.move(to: CGPoint(x: keep[0].tt.x, y: keep[0].tt.y))+ for i in 1..<keep.count { shape.addLine(to: CGPoint(x: keep[i].tt.x, y: keep[i].tt.y)) }+ for i in stride(from: keep.count - 1, through: 0, by: -1) {+ shape.addLine(to: CGPoint(x: keep[i].b.x, y: keep[i].b.y))+ }+ shape.closeSubpath()++ let dark = side < 0+ ctx.fill(shape, with: .linearGradient(+ dark+ ? Gradient(stops: [.init(color: Color(hex: "#C98A12"), location: 0),+ .init(color: Color(hex: "#8A5A06"), location: 1)])+ : Gradient(stops: [.init(color: Color(hex: "#FFE58A"), location: 0),+ .init(color: Color(hex: "#FBBF24"), location: 0.5),+ .init(color: Color(hex: "#D08A0B"), location: 1)]),+ startPoint: CGPoint(x: 0, y: -H.ry * 1.05),+ endPoint: CGPoint(x: 0, y: -H.ry * 0.45)+ ))++ if !dark {+ // band highlight+ var hiCtx = ctx+ hiCtx.clip(to: shape)+ hiCtx.fill(shape, with: .linearGradient(+ Gradient(stops: [+ .init(color: Color(red: 120/255, green: 70/255, blue: 0, opacity: 0.25), location: 0),+ .init(color: Color.white.opacity(0.0), location: 0.45),+ .init(color: Color.white.opacity(0.35), location: 0.62),+ .init(color: Color(red: 120/255, green: 70/255, blue: 0, opacity: 0.25), location: 1)+ ]),+ startPoint: CGPoint(x: -H.rx, y: 0),+ endPoint: CGPoint(x: H.rx, y: 0)+ ))+ // gems + ball tips on front spikes (skip when simplified)+ if !simplified {+ let gems: [Color] = [Color(hex: "#EF4444"), Color(hex: "#3B82F6"),+ Color(hex: "#22C55E"), Color(hex: "#A855F7")]+ for k in 0..<n {+ let lon = -.pi + (CGFloat(k) + 0.5) / CGFloat(n) * 2 * .pi+ let sp = mSurf(yt, lon, s)+ let tipP = mProj(H, (sp.0 * 0.92, yt + spikeH, sp.2 * 0.92))+ let mid = mProj(H, mSurf((yb + yt) / 2, lon, s * 1.01))+ if mid.z <= 0.12 { continue }+ let r = H.R * 0.055+ var tip = Path()+ tip.addEllipse(in: CGRect(x: tipP.x - r, y: tipP.y - r * 0.5 - r, width: r * 2, height: r * 2))+ ctx.fill(tip, with: .radialGradient(+ Gradient(stops: [.init(color: Color(hex: "#FFF6CC"), location: 0),+ .init(color: Color(hex: "#E0A21A"), location: 1)]),+ center: CGPoint(x: tipP.x - r * 0.3, y: tipP.y - r),+ startRadius: 0, endRadius: r * 1.2+ ))+ let gr = H.R * 0.075+ var gem = Path()+ gem.addEllipse(in: CGRect(+ x: mid.x - gr * max(0.35, mid.z),+ y: mid.y - gr,+ width: gr * max(0.35, mid.z) * 2,+ height: gr * 2+ ))+ ctx.fill(gem, with: .color(gems[k % gems.count]))+ var glint = Path()+ glint.addEllipse(in: CGRect(+ x: mid.x - gr * 0.25 * mid.z - gr * 0.28,+ y: mid.y - gr * 0.35 - gr * 0.28,+ width: gr * 0.56, height: gr * 0.56+ ))+ ctx.fill(glint, with: .color(Color.white.opacity(0.75)))+ }+ }+ }+}++// MARK: - Witch hat++private func drawWitchHatBack(ctx: inout GraphicsContext, H: MochiH) {+ let pts = witchBrimPts(H)+ let back = pts.filter { $0.z < 0.05 }.sorted { $0.x < $1.x }+ guard !back.isEmpty else { return }+ var ell = Path()+ ell.move(to: CGPoint(x: pts[0].x, y: pts[0].y))+ for q in pts.dropFirst() { ell.addLine(to: CGPoint(x: q.x, y: q.y)) }+ ell.closeSubpath()+ ctx.fill(ell, with: .linearGradient(+ Gradient(stops: [+ .init(color: Color(hex: "#2A0A4F"), location: 0),+ .init(color: Color(hex: "#3B0F6B"), location: 1)+ ]),+ startPoint: CGPoint(x: 0, y: -H.ry * 1.0),+ endPoint: CGPoint(x: 0, y: -H.ry * 0.4)+ ))+}++private func witchBrimPts(_ H: MochiH) -> [P3] {+ let y: CGFloat = 0.70, rr: CGFloat = 1.42+ return (0...120).map { i -> P3 in+ let a = -.pi + CGFloat(i) / 120 * 2 * .pi+ let wob = 1 + 0.035 * sin(a * 3 + 0.6)+ let droop = -0.10 * pow(abs(sin(a)), 2)+ return mProj(H, (rr * wob * sin(a), y + droop, rr * wob * cos(a)))+ }+}++private func drawWitchHatFront(ctx: inout GraphicsContext, H: MochiH, bodyPath: Path) {+ let all = witchBrimPts(H)+ var brim = Path()+ brim.move(to: CGPoint(x: all[0].x, y: all[0].y))+ for q in all.dropFirst() { brim.addLine(to: CGPoint(x: q.x, y: q.y)) }+ brim.closeSubpath()+ let fr = all.filter { $0.z >= 0 }.sorted { $0.x < $1.x }++ // shadow on head+ var sCtx = ctx+ sCtx.clip(to: bodyPath)+ sCtx.clip(to: mCapClip(H, y: 0.50, s: 1))+ var sRect = Path()+ sRect.addRect(CGRect(x: -H.rx * 4, y: -H.ry * 4, width: H.rx * 8, height: H.ry * 8))+ sCtx.fill(sRect, with: .color(Color(red: 40/255, green: 0, blue: 70/255, opacity: 0.10)))++ // full brim front+ ctx.fill(brim, with: .linearGradient(+ Gradient(stops: [+ .init(color: Color(hex: "#5B21B6"), location: 0),+ .init(color: Color(hex: "#3B0764"), location: 1)+ ]),+ startPoint: CGPoint(x: 0, y: -H.ry * 0.9),+ endPoint: CGPoint(x: 0, y: -H.ry * 0.3)+ ))+ if !fr.isEmpty {+ var frLine = Path()+ frLine.move(to: CGPoint(x: fr[0].x, y: fr[0].y))+ for i in 1..<fr.count { frLine.addLine(to: CGPoint(x: fr[i].x, y: fr[i].y)) }+ ctx.stroke(frLine, with: .color(Color(red: 190/255, green: 150/255, blue: 1, opacity: 0.35)),+ style: StrokeStyle(lineWidth: H.R * 0.035, lineCap: .round))+ }++ // cone+ let baseR: CGFloat = 0.62, by: CGFloat = 0.74+ let bl = mProj(H, (-baseR, by, 0))+ let br = mProj(H, (baseR, by, 0))+ let c = mProj(H, (0, by, 0))+ let lean: CGFloat = 0.10 + H.physDx * 0.15+ let top = CGPoint(+ x: c.x + H.rx * 0.18 + sin(lean) * H.ry * 0.3,+ y: c.y - H.ry * 1.25+ )+ let tip = CGPoint(+ x: top.x + H.rx * (0.45 + H.physDx * 0.25),+ y: top.y + H.ry * (0.22 + H.physDy * 0.1)+ )+ // cap arc clipped to [bl.x-1, br.x+1]+ let capFront = mFrontArc(H, y: by, s: baseR / mRingR(by)).filter {+ $0.x >= bl.x - 1 && $0.x <= br.x + 1+ }++ var cone = Path()+ cone.move(to: CGPoint(x: bl.x, y: bl.y))+ cone.addCurve(+ to: CGPoint(x: top.x - H.rx * 0.02, y: top.y - H.ry * 0.02),+ control1: CGPoint(x: bl.x + H.rx * 0.12, y: bl.y - H.ry * 0.5),+ control2: CGPoint(x: top.x - H.rx * 0.28, y: top.y + H.ry * 0.25)+ )+ cone.addQuadCurve(+ to: CGPoint(x: tip.x, y: tip.y),+ control: CGPoint(x: top.x + H.rx * 0.25, y: top.y - H.ry * 0.08)+ )+ cone.addQuadCurve(+ to: CGPoint(x: top.x + H.rx * 0.14, y: top.y + H.ry * 0.22),+ control: CGPoint(x: top.x + H.rx * 0.22, y: top.y + H.ry * 0.08)+ )+ cone.addCurve(+ to: CGPoint(x: br.x, y: br.y),+ control1: CGPoint(x: br.x - H.rx * 0.18, y: c.y - H.ry * 0.45),+ control2: CGPoint(x: br.x - H.rx * 0.02, y: br.y - H.ry * 0.2)+ )+ for i in stride(from: capFront.count - 1, through: 0, by: -1) {+ cone.addLine(to: CGPoint(x: capFront[i].x, y: capFront[i].y))+ }+ cone.closeSubpath()++ ctx.fill(cone, with: .linearGradient(+ Gradient(stops: [+ .init(color: Color(hex: "#7C3AED"), location: 0),+ .init(color: Color(hex: "#4C1D95"), location: 0.55),+ .init(color: Color(hex: "#2E1065"), location: 1)+ ]),+ startPoint: CGPoint(x: bl.x, y: top.y),+ endPoint: CGPoint(x: br.x, y: bl.y)+ ))++ var coneCtx = ctx+ coneCtx.clip(to: cone)+ coneCtx.fill(cone, with: .linearGradient(+ Gradient(stops: [+ .init(color: Color.white.opacity(0.22), location: 0),+ .init(color: .clear, location: 0.4),+ .init(color: Color.black.opacity(0.15), location: 1)+ ]),+ startPoint: CGPoint(x: bl.x, y: 0),+ endPoint: CGPoint(x: br.x, y: 0)+ ))+ // crease+ var crease = Path()+ crease.move(to: CGPoint(x: top.x - H.rx * 0.05, y: top.y + H.ry * 0.05))+ crease.addQuadCurve(+ to: CGPoint(x: top.x + H.rx * 0.2, y: top.y + H.ry * 0.06),+ control: CGPoint(x: top.x + H.rx * 0.1, y: top.y + H.ry * 0.12)+ )+ coneCtx.stroke(crease, with: .color(Color(red: 20/255, green: 0, blue: 40/255, opacity: 0.35)),+ style: StrokeStyle(lineWidth: H.R * 0.05, lineCap: .round))++ // orange band+ let fc = mProj(H, (0, by, baseR))+ let lift = H.ry * 0.11+ var band = Path()+ band.move(to: CGPoint(x: bl.x - 2, y: bl.y - lift))+ band.addQuadCurve(+ to: CGPoint(x: br.x + 2, y: br.y - lift),+ control: CGPoint(x: fc.x, y: 2 * (fc.y - lift) - (bl.y + br.y) / 2)+ )+ coneCtx.stroke(band, with: .color(Color(hex: "#F97316")),+ style: StrokeStyle(lineWidth: H.ry * 0.17, lineCap: .butt))++ // buckle+ let bk0 = mProj(H, (0, by, baseR))+ let bk = CGPoint(x: bk0.x, y: bk0.y - H.ry * 0.11)+ let bw = H.R * 0.2, bh = H.R * 0.16+ var bkCtx = ctx+ bkCtx.translateBy(x: bk.x, y: bk.y)+ var buckle = Path()+ buckle.addRoundedRect(+ in: CGRect(x: -bw / 2, y: -bh / 2, width: bw, height: bh),+ cornerSize: CGSize(width: bh * 0.25, height: bh * 0.25)+ )+ bkCtx.fill(buckle, with: .color(Color(hex: "#FCD34D")))+ var hole = Path()+ hole.addRoundedRect(+ in: CGRect(x: -bw / 2 + bw * 0.24, y: -bh / 2 + bh * 0.28,+ width: bw * 0.52, height: bh * 0.44),+ cornerSize: CGSize(width: bh * 0.10, height: bh * 0.10)+ )+ bkCtx.fill(hole, with: .color(Color(hex: "#C2410C")))+}++// MARK: - Sunglasses++private func drawSunglassesFront(ctx: inout GraphicsContext, H: MochiH, bodyPath: Path) {+ let rollH = MochiH(R: H.R, yaw: H.yaw, pitch: H.pitch + H.roll, physDx: H.physDx, physDy: H.physDy)+ let eyes = mEyeFrames(rollH)+ let w = H.R * 0.62, h = H.R * 0.46++ var g = ctx+ g.clip(to: bodyPath)++ let le = eyes[0], re = eyes[1]+ if le.visible && re.visible {+ var bridge = Path()+ bridge.move(to: CGPoint(x: le.x + w / 2 * le.fx * 0.9, y: le.y - h * 0.18))+ bridge.addQuadCurve(+ to: CGPoint(x: re.x - w / 2 * re.fx * 0.9, y: re.y - h * 0.18),+ control: CGPoint(x: (le.x + re.x) / 2, y: (le.y + re.y) / 2 - h * 0.42)+ )+ g.stroke(bridge, with: .color(Color(hex: "#111317")),+ style: StrokeStyle(lineWidth: H.R * 0.07, lineCap: .round))+ }+ for e in eyes {+ guard e.visible else { continue }+ let ox = e.x + e.sd * w / 2 * e.fx+ var temple = Path()+ temple.move(to: CGPoint(x: ox, y: e.y - h * 0.2))+ temple.addLine(to: CGPoint(x: e.sd * H.rx * 1.05, y: e.y - h * 0.35))+ g.stroke(temple, with: .color(Color(hex: "#111317")),+ style: StrokeStyle(lineWidth: H.R * 0.06, lineCap: .round))+ }+ for e in eyes {+ guard e.visible else { continue }+ var lens = Path()+ lens.addRoundedRect(+ in: CGRect(x: e.x - w / 2, y: e.y - h * 0.5, width: w, height: h),+ cornerSize: CGSize(width: h * 0.42, height: h * 0.42)+ )+ // foreshorten lens via scale+ var lg = g+ lg.translateBy(x: e.x, y: e.y)+ lg.scaleBy(x: e.fx, y: e.fy)+ var lensLocal = Path()+ lensLocal.addRoundedRect(+ in: CGRect(x: -w / 2, y: -h / 2, width: w, height: h),+ cornerSize: CGSize(width: h * 0.42, height: h * 0.42)+ )+ lg.fill(lensLocal, with: .color(Color(red: 17/255, green: 19/255, blue: 23/255, opacity: 0.82)))+ lg.stroke(lensLocal, with: .color(Color(hex: "#0B0C0F")),+ style: StrokeStyle(lineWidth: H.R * 0.05))+ // glare+ var glare = Path()+ glare.move(to: CGPoint(x: -w * 0.28, y: -h * 0.05))+ glare.addLine(to: CGPoint(x: -w * 0.05, y: -h * 0.3))+ lg.stroke(glare, with: .color(Color.white.opacity(0.45)),+ style: StrokeStyle(lineWidth: H.R * 0.05, lineCap: .round))+ }+}++// MARK: - Round glasses++private func drawRoundGlassesFront(ctx: inout GraphicsContext, H: MochiH, bodyPath: Path) {+ let rollH = MochiH(R: H.R, yaw: H.yaw, pitch: H.pitch + H.roll, physDx: H.physDx, physDy: H.physDy)+ let eyes = mEyeFrames(rollH)+ let d = H.R * 0.56++ var g = ctx+ g.clip(to: bodyPath)++ let le = eyes[0], re = eyes[1]+ if le.visible && re.visible {+ var bridge = Path()+ bridge.move(to: CGPoint(x: le.x + d / 2 * le.fx, y: le.y - d * 0.08))+ bridge.addQuadCurve(+ to: CGPoint(x: re.x - d / 2 * re.fx, y: re.y - d * 0.08),+ control: CGPoint(x: (le.x + re.x) / 2, y: (le.y + re.y) / 2 - d * 0.3)+ )+ g.stroke(bridge, with: .color(Color(hex: "#8A4B12")),+ style: StrokeStyle(lineWidth: H.R * 0.055, lineCap: .round))+ }+ for e in eyes {+ guard e.visible else { continue }+ var temple = Path()+ temple.move(to: CGPoint(x: e.x + e.sd * d / 2 * e.fx, y: e.y - d * 0.1))+ temple.addLine(to: CGPoint(x: e.sd * H.rx * 1.05, y: e.y - d * 0.25))+ g.stroke(temple, with: .color(Color(hex: "#8A4B12")),+ style: StrokeStyle(lineWidth: H.R * 0.05, lineCap: .round))+ }+ for e in eyes {+ guard e.visible else { continue }+ var lg = g+ lg.translateBy(x: e.x, y: e.y)+ lg.scaleBy(x: e.fx, y: e.fy)+ // circle fill+ var circle = Path()+ circle.addEllipse(in: CGRect(x: -d / 2, y: -d / 2, width: d, height: d))+ lg.fill(circle, with: .color(Color(red: 190/255, green: 225/255, blue: 1, opacity: 0.18)))+ lg.stroke(circle, with: .color(Color(hex: "#9A5A1A")),+ style: StrokeStyle(lineWidth: H.R * 0.065, lineCap: .round))+ // highlight arc+ var arcPath = Path()+ arcPath.addArc(center: .zero, radius: d / 2 - H.R * 0.03,+ startAngle: .radians(.pi * 1.1), endAngle: .radians(.pi * 1.45), clockwise: false)+ lg.stroke(arcPath, with: .color(Color.white.opacity(0.55)),+ style: StrokeStyle(lineWidth: H.R * 0.03, lineCap: .round))+ }+}++// MARK: - Scarf++private func drawScarfFront(ctx: inout GraphicsContext, H: MochiH) {+ let s: CGFloat = 1.05, y0: CGFloat = -0.34, y1: CGFloat = -0.66+ let top = mFrontArcRoll(H, y: y0, s: s)+ let bot = mFrontArcRoll(H, y: y1, s: s)+ guard !top.isEmpty, !bot.isEmpty else { return }++ var band = Path()+ band.move(to: CGPoint(x: top[0].x, y: top[0].y))+ for q in top.dropFirst() { band.addLine(to: CGPoint(x: q.x, y: q.y)) }+ for i in stride(from: bot.count - 1, through: 0, by: -1) {+ band.addLine(to: CGPoint(x: bot[i].x, y: bot[i].y))+ }+ band.closeSubpath()++ var g = ctx+ g.clip(to: mochiOutfitPath(H.rx * s, H.ry * s))+ g.fill(band, with: .linearGradient(+ Gradient(stops: [+ .init(color: Color(hex: "#F87171"), location: 0),+ .init(color: Color(hex: "#B91C1C"), location: 1)+ ]),+ startPoint: CGPoint(x: 0, y: -H.ry * 0.2),+ endPoint: CGPoint(x: 0, y: H.ry * 0.7)+ ))+ var g2 = g+ g2.clip(to: band)+ // stripes along meridians+ for lon: CGFloat in [-1.0, -0.45, 0.1, 0.65, 1.2] {+ let a = mProj(H, mSurf(y0, lon, s))+ let b = mProj(H, mSurf(y1, lon, s))+ if a.z < 0 { continue }+ var stripe = Path()+ stripe.move(to: CGPoint(x: a.x, y: a.y - 4))+ stripe.addLine(to: CGPoint(x: b.x, y: b.y + 4))+ g2.stroke(stripe, with: .color(Color.white.opacity(0.85)),+ style: StrokeStyle(lineWidth: H.R * 0.09 * max(0.3, a.z), lineCap: .round))+ }+ g.fill(band, with: .linearGradient(+ Gradient(stops: [+ .init(color: Color.white.opacity(0.18), location: 0),+ .init(color: Color.black.opacity(0.10), location: 1)+ ]),+ startPoint: CGPoint(x: 0, y: -H.ry * 0.5),+ endPoint: CGPoint(x: 0, y: H.ry * 0.3)+ ))++ // hanging end+ let k = mProj(H, mSurf((y0 + y1) / 2, -0.55, s * 1.03))+ if k.z > 0 {+ let sw = H.physDx * H.rx * 0.12+ var end = Path()+ end.move(to: CGPoint(x: k.x - H.R * 0.16, y: k.y))+ end.addQuadCurve(+ to: CGPoint(x: k.x - H.R * 0.2 + sw * 1.4, y: k.y + H.ry * 0.62),+ control: CGPoint(x: k.x - H.R * 0.24 + sw, y: k.y + H.ry * 0.35)+ )+ end.addLine(to: CGPoint(x: k.x + H.R * 0.06 + sw * 1.4, y: k.y + H.ry * 0.60))+ end.addQuadCurve(+ to: CGPoint(x: k.x + H.R * 0.12, y: k.y),+ control: CGPoint(x: k.x + H.R * 0.02 + sw, y: k.y + H.ry * 0.3)+ )+ end.closeSubpath()+ ctx.fill(end, with: .linearGradient(+ Gradient(stops: [+ .init(color: Color(hex: "#EF4444"), location: 0),+ .init(color: Color(hex: "#B91C1C"), location: 1)+ ]),+ startPoint: CGPoint(x: 0, y: k.y),+ endPoint: CGPoint(x: 0, y: k.y + H.ry * 0.6)+ ))+ var eCtx = ctx+ eCtx.clip(to: end)+ // stripes in hanging end+ for t: CGFloat in [0.35, 0.7] {+ var stripe = Path()+ stripe.addRect(CGRect(+ x: k.x - H.R * 0.4 + sw,+ y: k.y + H.ry * 0.62 * t,+ width: H.R * 0.8, height: H.R * 0.07+ ))+ eCtx.fill(stripe, with: .color(Color.white.opacity(0.85)))+ }+ // fringe+ for i in 0..<4 {+ let fx = k.x - H.R * 0.17 + sw * 1.4 + CGFloat(i) * H.R * 0.075+ var fringe = Path()+ fringe.move(to: CGPoint(x: fx, y: k.y + H.ry * 0.6))+ fringe.addLine(to: CGPoint(x: fx, y: k.y + H.ry * 0.72))+ ctx.stroke(fringe, with: .color(Color(hex: "#DC2626")),+ style: StrokeStyle(lineWidth: H.R * 0.035, lineCap: .round))+ }+ // knot (rotated ellipse)+ var knotCtx = ctx+ knotCtx.translateBy(x: k.x, y: k.y)+ knotCtx.rotate(by: .radians(0.2))+ var knot = Path()+ knot.addEllipse(in: CGRect(x: -H.R * 0.17, y: -H.R * 0.14, width: H.R * 0.34, height: H.R * 0.28))+ knotCtx.fill(knot, with: .radialGradient(+ Gradient(stops: [+ .init(color: Color(hex: "#F87171"), location: 0),+ .init(color: Color(hex: "#B91C1C"), location: 1)+ ]),+ center: CGPoint(x: -H.R * 0.05, y: -H.R * 0.05),+ startRadius: 0, endRadius: H.R * 0.2+ ))+ }+}++// MARK: - Pumpkin++private func drawPumpkinFront(ctx: inout GraphicsContext, H: MochiH, bodyPath: Path, simplified: Bool = false) {+ // ribs only — body recolor is done in BotEngine.drawBody(pumpkinColors:)+ if !simplified {+ var g = ctx+ g.clip(to: bodyPath)+ for lon: CGFloat in [-1.15, -0.55, 0.0, 0.55, 1.15] {+ var pts: [P3] = []+ for i in 0...30 {+ let y = -0.98 + 1.96 * CGFloat(i) / 30+ let q = mProjRoll(H, mSurf(y, lon, 1))+ if q.z > 0 { pts.append(q) }+ }+ guard pts.count >= 2 else { continue }+ var rib = Path()+ rib.move(to: CGPoint(x: pts[0].x, y: pts[0].y))+ for pt in pts.dropFirst() { rib.addLine(to: CGPoint(x: pt.x, y: pt.y)) }+ let zz = pts[pts.count / 2].z+ g.stroke(rib, with: .color(Color(red: 150/255, green: 50/255, blue: 0, opacity: 0.22 * zz)),+ style: StrokeStyle(lineWidth: H.R * 0.12, lineCap: .round))+ // highlight offset stripe+ var hi = Path()+ hi.move(to: CGPoint(x: pts[0].x + H.R * 0.07, y: pts[0].y))+ for pt in pts.dropFirst() { hi.addLine(to: CGPoint(x: pt.x + H.R * 0.07, y: pt.y)) }+ g.stroke(hi, with: .color(Color(red: 1, green: 220/255, blue: 170/255, opacity: 0.18 * zz)),+ style: StrokeStyle(lineWidth: H.R * 0.04, lineCap: .round))+ }+ }++ let t = mProjRoll(H, (0.02, 1.0, 0))+ // stem+ var stem = Path()+ stem.move(to: CGPoint(x: t.x - H.R * 0.09, y: t.y + H.R * 0.04))+ stem.addQuadCurve(+ to: CGPoint(x: t.x + H.R * 0.08, y: t.y - H.R * 0.3),+ control: CGPoint(x: t.x - H.R * 0.08, y: t.y - H.R * 0.22)+ )+ stem.addLine(to: CGPoint(x: t.x + H.R * 0.13, y: t.y - H.R * 0.22))+ stem.addQuadCurve(+ to: CGPoint(x: t.x + H.R * 0.08, y: t.y + H.R * 0.04),+ control: CGPoint(x: t.x + H.R * 0.04, y: t.y - H.R * 0.15)+ )+ stem.closeSubpath()+ ctx.fill(stem, with: .linearGradient(+ Gradient(stops: [+ .init(color: Color(hex: "#65A30D"), location: 0),+ .init(color: Color(hex: "#3F6212"), location: 1)+ ]),+ startPoint: CGPoint(x: t.x - H.R * 0.1, y: 0),+ endPoint: CGPoint(x: t.x + H.R * 0.1, y: 0)+ ))++ // leaf+ var leafCtx = ctx+ leafCtx.translateBy(x: t.x - H.R * 0.06, y: t.y - H.R * 0.02)+ leafCtx.rotate(by: .radians(-0.5))+ var leaf = Path()+ leaf.move(to: .zero)+ leaf.addQuadCurve(+ to: CGPoint(x: -H.R * 0.38, y: -H.R * 0.02),+ control: CGPoint(x: -H.R * 0.18, y: -H.R * 0.2)+ )+ leaf.addQuadCurve(+ to: .zero,+ control: CGPoint(x: -H.R * 0.18, y: H.R * 0.1)+ )+ leafCtx.fill(leaf, with: .linearGradient(+ Gradient(stops: [+ .init(color: Color(hex: "#84CC16"), location: 0),+ .init(color: Color(hex: "#4D7C0F"), location: 1)+ ]),+ startPoint: CGPoint(x: 0, y: -H.R * 0.15),+ endPoint: CGPoint(x: -H.R * 0.3, y: 0)+ ))+ var vein = Path()+ vein.move(to: CGPoint(x: -H.R * 0.02, y: -H.R * 0.01))+ vein.addQuadCurve(+ to: CGPoint(x: -H.R * 0.32, y: -H.R * 0.03),+ control: CGPoint(x: -H.R * 0.18, y: -H.R * 0.08)+ )+ leafCtx.stroke(vein, with: .color(Color(red: 30/255, green: 60/255, blue: 0, opacity: 0.4)),+ style: StrokeStyle(lineWidth: H.R * 0.02, lineCap: .round))++ // tendril (skip when simplified)+ if !simplified {+ var tendril = Path()+ tendril.move(to: CGPoint(x: t.x + H.R * 0.1, y: t.y - H.R * 0.12))+ tendril.addCurve(+ to: CGPoint(x: t.x + H.R * 0.22, y: t.y - H.R * 0.06),+ control1: CGPoint(x: t.x + H.R * 0.3, y: t.y - H.R * 0.25),+ control2: CGPoint(x: t.x + H.R * 0.35, y: t.y - H.R * 0.02)+ )+ ctx.stroke(tendril, with: .color(Color(hex: "#4D7C0F")),+ style: StrokeStyle(lineWidth: H.R * 0.03, lineCap: .round))+ }+}++// MARK: - Bow++private func drawBowFront(ctx: inout GraphicsContext, H: MochiH, bodyPath: Path) {+ let a = mProjRoll(H, mSurf(0.86, 0.55, 1.02))+ guard a.z >= -0.2 else { return }+ let s = H.R * 0.26+ let sq = max(0.45, cos(0.55 + H.yaw))++ var g = ctx+ g.translateBy(x: a.x, y: a.y)+ g.rotate(by: .radians(0.35 + H.yaw * 0.3))+ g.scaleBy(x: sq, y: 1)++ for sdD: Double in [-1.0, 1.0] {+ let sd = CGFloat(sdD)+ var wing = Path()+ wing.move(to: .zero)+ wing.addCurve(+ to: CGPoint(x: sd * s * 1.15, y: 0),+ control1: CGPoint(x: sd * s * 0.6, y: -s * 0.85),+ control2: CGPoint(x: sd * s * 1.35, y: -s * 0.55)+ )+ wing.addCurve(+ to: .zero,+ control1: CGPoint(x: sd * s * 1.35, y: s * 0.55),+ control2: CGPoint(x: sd * s * 0.6, y: s * 0.85)+ )+ g.fill(wing, with: .linearGradient(+ Gradient(stops: [+ .init(color: Color(hex: "#FF8CC6"), location: 0),+ .init(color: Color(hex: "#DB2777"), location: 1)+ ]),+ startPoint: CGPoint(x: 0, y: -s),+ endPoint: CGPoint(x: 0, y: s)+ ))+ // crease+ var crease = Path()+ crease.move(to: CGPoint(x: sd * s * 0.25, y: -s * 0.05))+ crease.addQuadCurve(+ to: CGPoint(x: sd * s * 0.95, y: -s * 0.05),+ control: CGPoint(x: sd * s * 0.7, y: -s * 0.15)+ )+ g.stroke(crease, with: .color(Color(red: 140/255, green: 10/255, blue: 70/255, opacity: 0.35)),+ style: StrokeStyle(lineWidth: s * 0.08, lineCap: .round))+ }+ // centre knot+ var knot = Path()+ knot.addEllipse(in: CGRect(x: -s * 0.24, y: -s * 0.30, width: s * 0.48, height: s * 0.60))+ g.fill(knot, with: .radialGradient(+ Gradient(stops: [+ .init(color: Color(hex: "#FFB3D9"), location: 0),+ .init(color: Color(hex: "#C2185B"), location: 1)+ ]),+ center: CGPoint(x: -s * 0.06, y: -s * 0.1),+ startRadius: 0, endRadius: s * 0.35+ ))+}diff --git a/NotchBuddy/Sources/App/MochiWardrobe.swift b/NotchBuddy/Sources/App/MochiWardrobe.swiftnew file mode 100644index 00000000..98b930ea--- /dev/null+++ b/NotchBuddy/Sources/App/MochiWardrobe.swift@@ -0,0 +1,89 @@+import Foundation++enum Outfit: String, CaseIterable {+ case auto, none, partyHat, beanie, crown, sunglasses, roundGlasses,+ bow, scarf, witchHat, pumpkin, santaHat, bunnyEars++ var displayName: String {+ switch self {+ case .auto: return "Auto (seasons)"+ case .none: return "None"+ case .partyHat: return "Party hat"+ case .beanie: return "Beanie"+ case .crown: return "Crown"+ case .sunglasses: return "Sunglasses"+ case .roundGlasses: return "Round glasses"+ case .bow: return "Bow"+ case .scarf: return "Scarf"+ case .witchHat: return "Witch hat"+ case .pumpkin: return "Pumpkin"+ case .santaHat: return "Santa hat"+ case .bunnyEars: return "Bunny ears"+ }+ }++ // Returns the seasonal outfit for the given date (user's local calendar).+ // Priority: partyHat > santaHat > witchHat > bunnyEars > sunglasses > none+ static func seasonal(for date: Date, calendar: Calendar) -> Outfit {+ let day = calendar.component(.day, from: date)+ let month = calendar.component(.month, from: date)+ let year = calendar.component(.year, from: date)++ // Dec 31 – Jan 2 → party hat+ if (month == 12 && day == 31) || (month == 1 && day <= 2) { return .partyHat }++ // Dec 1–26 → santa hat+ if month == 12 && day <= 26 { return .santaHat }++ // Oct 1 – Nov 1 → witch hat+ if month == 10 || (month == 11 && day == 1) { return .witchHat }++ // Easter −2 / +1 → bunny ears (Meeus/Jones/Butcher algorithm)+ let (eMonth, eDay) = easterDate(year: year)+ let eComps = DateComponents(year: year, month: eMonth, day: eDay)+ if let easterDate = calendar.date(from: eComps) {+ let delta = calendar.dateComponents([.day], from: easterDate, to: date).day ?? 0+ if delta >= -2 && delta <= 1 { return .bunnyEars }+ }++ // Jun 21 – Aug 31 → sunglasses+ if (month == 6 && day >= 21) || month == 7 || month == 8 { return .sunglasses }++ return .none+ }++ // If selection == .auto → seasonal; otherwise selection itself.+ static func resolved(selection: Outfit, date: Date, calendar: Calendar) -> Outfit {+ selection == .auto ? seasonal(for: date, calendar: calendar) : selection+ }++ // UserDefaults key "mochiOutfit", default "auto", unknown value → .auto+ static var stored: Outfit {+ get {+ let raw = UserDefaults.standard.string(forKey: "mochiOutfit") ?? "auto"+ return Outfit(rawValue: raw) ?? .auto+ }+ set {+ UserDefaults.standard.set(newValue.rawValue, forKey: "mochiOutfit")+ }+ }+}++// Meeus/Jones/Butcher algorithm — returns (month, day) of Easter Sunday for the given year.+private func easterDate(year: Int) -> (Int, Int) {+ let a = year % 19+ let b = year / 100+ let c = year % 100+ let d = b / 4+ let e = b % 4+ let f = (b + 8) / 25+ let g = (b - f + 1) / 3+ let h = (19 * a + b - d - g + 15) % 30+ let i = c / 4+ let k = c % 4+ let l = (32 + 2 * e + 2 * i - h - k) % 7+ let m = (a + 11 * h + 22 * l) / 451+ let month = (h + l - 7 * m + 114) / 31+ let day = (h + l - 7 * m + 114) % 31 + 1+ return (month, day)+}diff --git a/README.md b/README.mdindex 2c9d5e7f..e37c3e77 100644--- a/README.md+++ b/README.md@@ -43,6 +43,7 @@ Meet **Mochi**: a soft little squircle with big eyes that pops out of your notch- 🪟 **Drag Mochi onto any window** — attach that window as context for Claude *(macOS)*.- 🔌 **Integrations** — Stripe payments, n8n workflows, GitHub (open PRs, reviews requested, CI status), Vercel deployments, Resend emails, Notion, Cal.com. Each one gets its own little colored Mochi.- 🎵 **Apple Music pill** *(macOS, GitHub build)* — add the Apple Music pill in Settings → Active pills to see what's playing and control playback from the notch; Mochi dances while it plays.+- 👗 **Dress Mochi up** — right-click him for the wardrobe. He also dresses up for the seasons on his own- 🎭 **A real character** — idle breathing, blinks, eyes on a sphere that follow your mouse, emotes, 28 handcrafted sounds, a greeting on launch.- 🫥 **Invisible when idle** — hides away when nothing is running, peeks out when you hover the notch (the top edge of the screen on Windows and Linux).- 🖥️ **Any Mac, notch or not** — on an iMac, a Mac mini, or a MacBook with its lid closed on an external display, Mochi sits in a small bar at the top of the screen.diff --git a/design/outfits/mochi-outfits-reference.png b/design/outfits/mochi-outfits-reference.pngnew file mode 100644index 00000000..9242e59eBinary files /dev/null and b/design/outfits/mochi-outfits-reference.png differdiff --git a/design/outfits/mochi-outfits.js b/design/outfits/mochi-outfits.jsnew file mode 100644index 00000000..bd32605a--- /dev/null+++ b/design/outfits/mochi-outfits.js@@ -0,0 +1,618 @@+// Mochi outfit reference renderer (Canvas 2D).+// Coordinates mirror BotEngine.draw(): origin at body centre, y down on screen,+// R = W*0.3, rx = 1.14R, ry = 0.88R. Head "3D" model: superellipsoid whose+// horizontal radius at height y (y up, -1..1) is r(y) = (1-|y|^2.7)^(1/2.7),+// so that its silhouette matches mochiPath at yaw = pitch = 0.++const EXP = 2.7;+// Accessories are seen slightly from above (and hats sit tipped forward): rings show as ellipses.+const VIEW_TILT = -0.30;+const ACC_PITCH = 0.4;+const EYE_W = 0.25, EYE_H = 0.27, EYE_SP = 0.37, EYE_P = -0.12;++function ringR(y) { const a = Math.min(1, Math.abs(y)); return Math.pow(1 - Math.pow(a, EXP), 1 / EXP); }++// rotate a head-local point (x right, y up, z toward viewer) by yaw then pitch+function rot(p, yaw, pitch) {+ let [x, y, z] = p;+ const cy = Math.cos(yaw), sy = Math.sin(yaw);+ let x1 = x * cy + z * sy, z1 = -x * sy + z * cy;+ const cp = Math.cos(pitch), sp = Math.sin(pitch);+ let y2 = y * cp + z1 * sp, z2 = -y * sp + z1 * cp;+ return [x1, y2, z2];+}+// head-local -> screen (body space). returns {x, y, z}+function proj(H, p) {+ // accessories follow the head pitch only partly, so hats never flip to a top-down view+ const r = rot(p, H.yaw, (H.view || 0) + H.pitch * ACC_PITCH);+ return { x: r[0] * H.rx, y: -r[1] * H.ry, z: r[2] };+}+// point on the head surface at height y, longitude lon (0 = facing viewer), scaled by s+function surf(y, lon, s = 1) { const r = ringR(y) * s; return [r * Math.sin(lon), y, r * Math.cos(lon)]; }++function mochiPath(rx, ry) {+ const p = new Path2D(); const n = 96, e = 2 / EXP;+ for (let i = 0; i <= n; i++) {+ const a = i / n * Math.PI * 2, ca = Math.cos(a), sa = Math.sin(a);+ const x = rx * Math.sign(ca) * Math.pow(Math.abs(ca), e);+ const y = ry * Math.sign(sa) * Math.pow(Math.abs(sa), e);+ i ? p.lineTo(x, y) : p.moveTo(x, y);+ }+ p.closePath(); return p;+}++function lin(ctx, x0, y0, x1, y1, stops) {+ const g = ctx.createLinearGradient(x0, y0, x1, y1);+ stops.forEach(([o, c]) => g.addColorStop(o, c)); return g;+}+function rad(ctx, x, y, r0, r1, stops) {+ const g = ctx.createRadialGradient(x, y, r0, x, y, r1);+ stops.forEach(([o, c]) => g.addColorStop(o, c)); return g;+}++// ---------- Body + eyes (faithful to BotEngine) ----------+function drawBody(ctx, H, colors) {+ const { rx, ry, R } = H; const path = mochiPath(rx, ry);+ const top = colors ? colors[0] : '#EDEDEF', bot = colors ? colors[1] : '#C4C5CA';+ ctx.fillStyle = lin(ctx, rx * 0.7, -ry * 0.85, -rx * 0.8, ry * 0.9, [[0, top], [1, bot]]);+ ctx.fill(path);+ ctx.fillStyle = rad(ctx, 0, 0, R * 0.15, R * 1.25, [[0, 'rgba(0,0,0,0)'], [0.6, 'rgba(0,0,0,0)'], [1, 'rgba(0,0,0,0.2)']]);+ ctx.fill(path);+ ctx.fillStyle = rad(ctx, rx * 0.34, -ry * 0.46, 0, R * 0.42, [[0, 'rgba(255,255,255,0.55)'], [1, 'rgba(255,255,255,0)']]);+ ctx.fill(path);+ return path;+}++// Same formula as drawEyes(): spherical addition, NOT the rotation used for accessories.+function eyeFrames(H) {+ const out = [];+ for (const sd of [-1, 1]) {+ const eyeYaw = sd * EYE_SP + H.yaw;+ let eyePitch = EYE_P + H.pitch;+ const cp = Math.cos(eyePitch);+ const visible = Math.cos(eyeYaw) * cp > 0.04;+ out.push({+ sd, visible,+ x: Math.sin(eyeYaw) * cp * H.rx,+ y: -Math.sin(eyePitch) * H.ry,+ fx: Math.max(0.18, Math.cos(eyeYaw)),+ fy: Math.max(0.18, cp),+ w: H.R * EYE_W, h: H.R * EYE_H,+ });+ }+ return out;+}+function drawEyes(ctx, H, path, alpha = 1) {+ ctx.save(); ctx.clip(path);+ for (const e of eyeFrames(H)) {+ if (!e.visible) continue;+ ctx.save(); ctx.translate(e.x, e.y); ctx.scale(e.fx, e.fy);+ const w = e.w, hh = e.h;+ ctx.fillStyle = `rgba(26,20,18,${alpha})`;+ roundRect(ctx, -w / 2, -hh / 2, w, hh, Math.min(w, hh) / 2); ctx.fill();+ ctx.restore();+ }+ ctx.restore();+}+function roundRect(ctx, x, y, w, h, r) {+ ctx.beginPath(); ctx.moveTo(x + r, y); ctx.arcTo(x + w, y, x + w, y + h, r); ctx.arcTo(x + w, y + h, x, y + h, r);+ ctx.arcTo(x, y + h, x, y, r); ctx.arcTo(x, y, x + w, y, r); ctx.closePath();+}++// ---------- helpers for "wrapped" items ----------+// Front arc of a ring (height y, scale s) projected, from left extreme to right extreme (z >= 0 side).+function ringPoints(H, y, s, n = 72) {+ const pts = [];+ for (let i = 0; i <= n; i++) { const lon = -Math.PI + i / n * 2 * Math.PI; pts.push({ lon, ...proj(H, surf(y, lon, s)) }); }+ return pts;+}+function frontArc(H, y, s) {+ // walk the ring, keep the contiguous z>=0 part ordered by screen x+ const pts = ringPoints(H, y, s, 120).filter(p => p.z >= -0.02);+ pts.sort((a, b) => a.x - b.x); return pts;+}+// region of the inflated head ABOVE the front arc of ring y (the part a cap covers)+function capClip(H, y, s, extraTop = 3) {+ const arc = frontArc(H, y, s);+ const p = new Path2D();+ p.moveTo(arc[0].x - H.rx, arc[0].y);+ for (const q of arc) p.lineTo(q.x, q.y);+ p.lineTo(arc[arc.length - 1].x + H.rx, arc[arc.length - 1].y);+ p.lineTo(H.rx * 2, -H.ry * extraTop); p.lineTo(-H.rx * 2, -H.ry * extraTop); p.closePath();+ return p;+}+// contiguous visible (z>=0) run of a closed ring, ordered left->right+function frontRun(ring) {+ const n = ring.length - 1; let start = -1;+ for (let i = 0; i < n; i++) if (ring[i].z >= 0 && ring[(i - 1 + n) % n].z < 0) { start = i; break; }+ if (start < 0) { // whole ring visible (seen from above): use its lower half+ const my = ring.reduce((s, q) => s + q.y, 0) / ring.length;+ return ring.filter(q => q.y >= my).sort((a, b) => a.x - b.x);+ }+ const out = []; for (let k = 0; k < n; k++) { const q = ring[(start + k) % n]; if (q.z < 0) break; out.push(q); }+ if (out.length > 1 && out[0].x > out[out.length - 1].x) out.reverse();+ return out;+}+function strokeArc(ctx, arc) { ctx.beginPath(); arc.forEach((q, i) => i ? ctx.lineTo(q.x, q.y) : ctx.moveTo(q.x, q.y)); }++// soft round "pompom" made of overlapping puffs+function pompom(ctx, x, y, r, base = '#FFFFFF', shade = '#D5D9E2') {+ ctx.save(); ctx.translate(x, y);+ // fluffy rim bumps+ const n = 11;+ for (let i = 0; i < n; i++) {+ const a = i / n * Math.PI * 2, br = r * (0.34 + 0.06 * Math.sin(i * 2.3));+ const bx = Math.cos(a) * r * 0.78, by = Math.sin(a) * r * 0.78;+ ctx.fillStyle = rad(ctx, bx - br * 0.4, by - br * 0.5, 0, br * 1.3, [[0, base], [1, shade]]);+ ctx.beginPath(); ctx.arc(bx, by, br, 0, Math.PI * 2); ctx.fill();+ }+ ctx.fillStyle = rad(ctx, -r * 0.3, -r * 0.35, 0, r * 1.05, [[0, base], [0.7, base], [1, shade]]);+ ctx.beginPath(); ctx.arc(0, 0, r * 0.86, 0, Math.PI * 2); ctx.fill();+ ctx.restore();+}+// fuzzy band along a polyline (santa trim)+function fuzzyBand(ctx, arc, thick, base = '#FFFFFF', shade = '#DADDE4') {+ ctx.save();+ ctx.lineJoin = 'round'; ctx.lineCap = 'round';+ strokeArc(ctx, arc); ctx.strokeStyle = shade; ctx.lineWidth = thick; ctx.stroke();+ strokeArc(ctx, arc); ctx.strokeStyle = base; ctx.lineWidth = thick * 0.78; ctx.stroke();+ // bumps along the edges+ const step = Math.max(2, Math.floor(arc.length / 16));+ for (let i = 0; i < arc.length; i += step) {+ const q = arc[i]; const r = thick * (0.32 + 0.1 * Math.sin(i * 1.7));+ ctx.fillStyle = rad(ctx, q.x - r * 0.3, q.y - thick * 0.35 - r * 0.3, 0, r * 1.2, [[0, base], [1, shade]]);+ ctx.beginPath(); ctx.arc(q.x, q.y - thick * 0.32, r, 0, Math.PI * 2); ctx.fill();+ }+ ctx.restore();+}+// quadratic bezier helpers for tubes+function qb(p0, p1, p2, t) { const u = 1 - t; return { x: u * u * p0.x + 2 * u * t * p1.x + t * t * p2.x, y: u * u * p0.y + 2 * u * t * p1.y + t * t * p2.y }; }+function qbd(p0, p1, p2, t) { const u = 1 - t; return { x: 2 * u * (p1.x - p0.x) + 2 * t * (p2.x - p1.x), y: 2 * u * (p1.y - p0.y) + 2 * t * (p2.y - p1.y) }; }++// ---------- OUTFITS ----------+// Each outfit has optional back(ctx,H) (before body) and front(ctx,H,path) (after body+eyes).+// H.phys = {dx, dy}: spring lag of floppy parts in head units (driven by yaw velocity + gravity in Swift).++const OUTFITS = {};++// --- Beanie: knitted cap that wraps the top of the head, ribbed cuff, bouncy pompom+OUTFITS.beanie = {+ front(ctx, H, path) {+ const s = 1.035, yEdge = 0.42, yCuff = 0.58;+ const head = mochiPath(H.rx * s, H.ry * s);+ // shadow on the head under the cuff+ ctx.save(); ctx.clip(path); ctx.clip(capClip(H, yEdge - 0.12, 1));+ ctx.fillStyle = 'rgba(30,40,70,0.10)'; ctx.fill(path); ctx.restore();+ // knit body+ ctx.save(); ctx.clip(capClip(H, yCuff, s));+ ctx.fillStyle = lin(ctx, H.rx * 0.5, -H.ry * 1.1, -H.rx * 0.6, H.ry * 0.2, [[0, '#7DB6FF'], [1, '#2F6FE0']]);+ ctx.fill(head);+ // vertical knit ribs following meridians+ ctx.clip(head);+ for (let k = -6; k <= 6; k++) {+ const lon = k * 0.24; const pts = [];+ for (let i = 0; i <= 16; i++) { const y = yCuff + (1.05 - yCuff) * i / 16; const q = proj(H, surf(y, lon, s)); if (q.z > 0) pts.push(q); }+ if (pts.length < 2) continue;+ ctx.beginPath(); pts.forEach((q, i) => i ? ctx.lineTo(q.x, q.y) : ctx.moveTo(q.x, q.y));+ ctx.strokeStyle = 'rgba(20,50,140,0.16)'; ctx.lineWidth = H.R * 0.045; ctx.stroke();+ }+ ctx.restore();+ // cuff (folded band)+ ctx.save(); ctx.clip(capClip(H, yEdge, s * 1.04)); ctx.clip(invert(capClip(H, yCuff, s * 1.04), H));+ const cuffHead = mochiPath(H.rx * s * 1.04, H.ry * s * 1.04);+ ctx.fillStyle = lin(ctx, 0, -H.ry * 0.6, 0, -H.ry * 0.2, [[0, '#3C7BEA'], [1, '#2257C4']]);+ ctx.fill(cuffHead);+ ctx.clip(cuffHead);+ for (let k = -14; k <= 14; k++) {+ const lon = k * 0.115; const a = proj(H, surf(yEdge, lon, s * 1.04)), b = proj(H, surf(yCuff, lon, s * 1.04));+ if (a.z < 0) continue;+ ctx.beginPath(); ctx.moveTo(a.x, a.y); ctx.lineTo(b.x, b.y); ctx.strokeStyle = 'rgba(10,30,100,0.22)'; ctx.lineWidth = H.R * 0.035; ctx.stroke();+ }+ ctx.restore();+ // top highlight+ ctx.save(); ctx.clip(capClip(H, yCuff, s)); ctx.clip(head);+ ctx.fillStyle = rad(ctx, H.rx * 0.3, -H.ry * 0.85, 0, H.R * 0.45, [[0, 'rgba(255,255,255,0.35)'], [1, 'rgba(255,255,255,0)']]);+ ctx.fill(head); ctx.restore();+ // pompom on a short spring+ const top = proj(H, [0, 1.08 * s, 0]);+ pompom(ctx, top.x + H.phys.dx * H.rx * 0.25, top.y - H.R * 0.12 + H.phys.dy * H.ry * 0.15, H.R * 0.24);+ }+};++// region complement helper (big rect minus path) using evenodd+function invert(p, H) {+ const q = new Path2D(); q.rect(-H.rx * 4, -H.ry * 4, H.rx * 8, H.ry * 8); q.addPath(p); q.__evenodd = true; return q;+}+// patch ctx.clip to honour evenodd paths+const _clip = CanvasRenderingContext2D.prototype.clip;+CanvasRenderingContext2D.prototype.clip = function (p, rule) { if (p && p.__evenodd) return _clip.call(this, p, 'evenodd'); return p ? _clip.call(this, p, rule) : _clip.call(this); };++// --- Santa hat: soft red bag that flops to the side, fuzzy trim, pompom at the tip+OUTFITS.santaHat = {+ front(ctx, H, path) {+ const s = 1.05, yEdge = 0.52;+ const arc = frontArc(H, yEdge, s);+ const L = arc[0], Rt = arc[arc.length - 1];+ const crown = proj(H, [0, 1.05, 0]);+ // tip: flops to the right and down, plus spring lag+ const side = 1;+ const tip = { x: crown.x + side * H.rx * (0.95 + H.phys.dx * 0.35), y: crown.y + H.ry * (0.05 + H.phys.dy * 0.2) };+ const peak = { x: crown.x + side * H.rx * 0.25, y: crown.y - H.ry * 0.62 };+ const bag = new Path2D();+ bag.moveTo(L.x, L.y);+ bag.bezierCurveTo(L.x - H.rx * 0.05, L.y - H.ry * 0.7, peak.x - H.rx * 0.55, peak.y - H.ry * 0.05, peak.x, peak.y);+ bag.quadraticCurveTo(tip.x - H.rx * 0.05, peak.y - H.ry * 0.02, tip.x, tip.y);+ bag.quadraticCurveTo(tip.x - H.rx * 0.12, tip.y - H.ry * 0.22, peak.x + H.rx * 0.18, peak.y + H.ry * 0.32);+ bag.bezierCurveTo(Rt.x + H.rx * 0.05, peak.y + H.ry * 0.45, Rt.x + H.rx * 0.08, Rt.y - H.ry * 0.35, Rt.x, Rt.y);+ for (let i = arc.length - 1; i >= 0; i--) bag.lineTo(arc[i].x, arc[i].y);+ bag.closePath();+ // shadow on head+ ctx.save(); ctx.clip(path); ctx.clip(capClip(H, yEdge - 0.14, 1)); ctx.fillStyle = 'rgba(120,10,10,0.10)'; ctx.fill(path); ctx.restore();+ ctx.fillStyle = lin(ctx, -H.rx * 0.6, -H.ry * 1.6, H.rx * 0.7, -H.ry * 0.3, [[0, '#FF6B6B'], [0.55, '#E53935'], [1, '#B71C1C']]);+ ctx.fill(bag);+ // folds: soft darker creases following the flop+ ctx.save(); ctx.clip(bag);+ ctx.lineCap = 'round';+ for (const [a, b, w] of [[0.15, 0.55, 0.10], [0.45, 0.85, 0.08]]) {+ ctx.beginPath();+ ctx.moveTo(peak.x - H.rx * 0.1 + (Rt.x - L.x) * a * 0.3, peak.y + H.ry * 0.15);+ ctx.quadraticCurveTo(peak.x + H.rx * 0.35, peak.y + H.ry * (0.05 + a * 0.3), tip.x - H.rx * (0.45 - b * 0.3), tip.y - H.ry * 0.12);+ ctx.strokeStyle = 'rgba(90,0,0,0.20)'; ctx.lineWidth = H.R * w; ctx.stroke();+ }+ ctx.fillStyle = rad(ctx, peak.x - H.rx * 0.25, peak.y + H.ry * 0.05, 0, H.R * 0.5, [[0, 'rgba(255,255,255,0.32)'], [1, 'rgba(255,255,255,0)']]);+ ctx.fill(bag);+ ctx.restore();+ // trim + pompom+ fuzzyBand(ctx, arc, H.R * 0.3);+ pompom(ctx, tip.x, tip.y + H.R * 0.04, H.R * 0.22);+ }+};++// --- Party hat: chubby cone with rounded tip, polka dots, pompom; sits tilted on the crown+OUTFITS.partyHat = {+ front(ctx, H, path) {+ const baseY = 0.82, baseR = 0.42, lean = -0.24 + H.phys.dx * 0.12;+ // base ring on the head (front arc), apex above, leaning+ const c = proj(H, [0.16, baseY + 0.06, 0]);+ const ring = []; for (let i = 0; i <= 48; i++) { const a = i / 48 * Math.PI * 2; ring.push(proj(H, [0.16 + baseR * Math.sin(a), baseY + 0.06, baseR * Math.cos(a)])); }+ let left = ring.reduce((m, q) => q.x < m.x ? q : m), right = ring.reduce((m, q) => q.x > m.x ? q : m);+ const h = H.ry * 1.6;+ const apex = { x: c.x + Math.sin(lean) * h, y: c.y - Math.cos(lean) * h };+ const front = frontRun(ring);+ const cone = new Path2D();+ cone.moveTo(left.x, left.y);+ cone.quadraticCurveTo((left.x + apex.x) / 2 - H.rx * 0.06, (left.y + apex.y) / 2, apex.x - H.R * 0.05, apex.y + H.R * 0.06);+ cone.quadraticCurveTo(apex.x, apex.y - H.R * 0.03, apex.x + H.R * 0.05, apex.y + H.R * 0.06);+ cone.quadraticCurveTo((right.x + apex.x) / 2 + H.rx * 0.06, (right.y + apex.y) / 2, right.x, right.y);+ for (let i = front.length - 1; i >= 0; i--) cone.lineTo(front[i].x, front[i].y);+ cone.closePath();+ ctx.fillStyle = lin(ctx, left.x, apex.y, right.x, left.y, [[0, '#FF9BD0'], [0.5, '#F15BAE'], [1, '#C2187A']]);+ ctx.fill(cone);+ ctx.save(); ctx.clip(cone);+ // polka dots placed along the cone+ const dots = [[0.25, -0.35], [0.3, 0.3], [0.55, -0.05], [0.72, 0.28], [0.8, -0.3], [0.45, 0.6], [0.48, -0.65]];+ for (const [t, u] of dots) {+ const bx = left.x + (right.x - left.x) * (0.5 + u * 0.5);+ const by = left.y + (right.y - left.y) * (0.5 + u * 0.5);+ const x = bx + (apex.x - bx) * (1 - t) * 0.0 + (apex.x - bx) * (1 - t);+ const y = by + (apex.y - by) * (1 - t);+ const r = H.R * 0.075 * (0.6 + t * 0.5);+ ctx.beginPath(); ctx.ellipse(x, y, r, r * 0.9, 0, 0, Math.PI * 2); ctx.fillStyle = 'rgba(255,255,255,0.92)'; ctx.fill();+ }+ ctx.fillStyle = lin(ctx, left.x, 0, right.x, 0, [[0, 'rgba(255,255,255,0.28)'], [0.35, 'rgba(255,255,255,0)'], [1, 'rgba(80,0,40,0.18)']]);+ ctx.fill(cone);+ ctx.restore();+ // rim at the base+ ctx.beginPath(); front.forEach((q, i) => i ? ctx.lineTo(q.x, q.y) : ctx.moveTo(q.x, q.y));+ ctx.strokeStyle = '#FFD84D'; ctx.lineWidth = H.R * 0.07; ctx.lineCap = 'round'; ctx.stroke();+ pompom(ctx, apex.x, apex.y - H.R * 0.04, H.R * 0.16, '#FFE27A', '#F2B705');+ }+};++// --- Crown: golden band AROUND the head, spikes all around (back ones behind the head)+function crownGeom(H) {+ const s = 1.06, yb = 0.46, yt = 0.66, n = 8;+ return { s, yb, yt, n, spikeH: 0.42 };+}+function crownPart(ctx, H, side) { // side: -1 back half, +1 front half+ const { s, yb, yt, n, spikeH } = crownGeom(H);+ const N = 120; const seg = [];+ for (let i = 0; i <= N; i++) {+ const lon = -Math.PI + i / N * 2 * Math.PI;+ const b = proj(H, surf(yb, lon, s)), t = proj(H, surf(yt, lon, s));+ const phase = ((lon + Math.PI) / (2 * Math.PI)) * n; const f = phase - Math.floor(phase);+ const spike = Math.pow(Math.max(0, 1 - Math.abs(f - 0.5) * 2), 1.6); // 0..1 peak at middle+ const topY = yt + spikeH * spike;+ const tt = proj(H, [surf(yt, lon, s)[0] * (1 - 0.08 * spike), topY, surf(yt, lon, s)[2] * (1 - 0.08 * spike)]);+ seg.push({ lon, b, t, tt, z: b.z, spike });+ }+ const keep = seg.filter(q => side > 0 ? q.z >= 0 : q.z < 0.02);+ if (keep.length < 2) return;+ keep.sort((a, b) => a.b.x - b.b.x);+ const shape = new Path2D();+ keep.forEach((q, i) => i ? shape.lineTo(q.tt.x, q.tt.y) : shape.moveTo(q.tt.x, q.tt.y));+ for (let i = keep.length - 1; i >= 0; i--) shape.lineTo(keep[i].b.x, keep[i].b.y);+ shape.closePath();+ const dark = side < 0;+ ctx.fillStyle = lin(ctx, 0, -H.ry * 1.05, 0, -H.ry * 0.45, dark ? [[0, '#C98A12'], [1, '#8A5A06']] : [[0, '#FFE58A'], [0.5, '#FBBF24'], [1, '#D08A0B']]);+ ctx.fill(shape);+ if (!dark) {+ // band highlight + gems + ball tips on front spikes+ ctx.save(); ctx.clip(shape);+ ctx.fillStyle = lin(ctx, -H.rx, 0, H.rx, 0, [[0, 'rgba(120,70,0,0.25)'], [0.45, 'rgba(255,255,255,0.0)'], [0.62, 'rgba(255,255,255,0.35)'], [1, 'rgba(120,70,0,0.25)']]);+ ctx.fill(shape); ctx.restore();+ const gems = ['#EF4444', '#3B82F6', '#22C55E', '#A855F7'];+ for (let k = 0; k < n; k++) {+ const lon = -Math.PI + (k + 0.5) / n * 2 * Math.PI;+ const sp = surf(yt, lon, s);+ const tipP = proj(H, [sp[0] * 0.92, yt + spikeH, sp[2] * 0.92]);+ const mid = proj(H, surf((yb + yt) / 2, lon, s * 1.01));+ if (mid.z <= 0.12) continue;+ const r = H.R * 0.055;+ ctx.beginPath(); ctx.arc(tipP.x, tipP.y - r * 0.5, r, 0, Math.PI * 2);+ ctx.fillStyle = rad(ctx, tipP.x - r * 0.3, tipP.y - r, 0, r * 1.2, [[0, '#FFF6CC'], [1, '#E0A21A']]); ctx.fill();+ const gr = H.R * 0.075;+ ctx.beginPath(); ctx.ellipse(mid.x, mid.y, gr * Math.max(0.35, mid.z), gr, 0, 0, Math.PI * 2);+ ctx.fillStyle = gems[k % gems.length]; ctx.fill();+ ctx.beginPath(); ctx.arc(mid.x - gr * 0.25 * mid.z, mid.y - gr * 0.35, gr * 0.28, 0, Math.PI * 2); ctx.fillStyle = 'rgba(255,255,255,0.75)'; ctx.fill();+ }+ }+}+OUTFITS.crown = {+ back(ctx, H) { crownPart(ctx, H, -1); },+ front(ctx, H, path) {+ ctx.save(); ctx.clip(path); ctx.clip(capClip(H, crownGeom(H).yb - 0.1, 1)); ctx.clip(invert(capClip(H, crownGeom(H).yb, 1), H));+ ctx.fillStyle = 'rgba(80,50,0,0.12)'; ctx.fill(path); ctx.restore();+ crownPart(ctx, H, 1);+ }+};++// --- Witch hat: wide floppy brim around the head, tall cone with a bent tip, orange band + gold buckle+function witchBrimPts(H) {+ const y = 0.70, rr = 1.42, pts = [];+ for (let i = 0; i <= 120; i++) {+ const a = -Math.PI + i / 120 * 2 * Math.PI;+ const wob = 1 + 0.035 * Math.sin(a * 3 + 0.6);+ const droop = -0.10 * Math.pow(Math.abs(Math.sin(a)), 2); // brim edges droop a little+ pts.push({ a, ...proj(H, [rr * wob * Math.sin(a), y + droop, rr * wob * Math.cos(a)]) });+ }+ return pts;+}+OUTFITS.witchHat = {+ back(ctx, H) {+ const pts = witchBrimPts(H).filter(p => p.z < 0.05).sort((a, b) => a.x - b.x);+ const ell = new Path2D(); witchBrimPts(H).forEach((q, i) => i ? ell.lineTo(q.x, q.y) : ell.moveTo(q.x, q.y)); ell.closePath();+ ctx.fillStyle = lin(ctx, 0, -H.ry * 1.0, 0, -H.ry * 0.4, [[0, '#2A0A4F'], [1, '#3B0F6B']]);+ ctx.fill(ell); // whole brim behind the head; front part is redrawn in front()+ },+ front(ctx, H, path) {+ const all = witchBrimPts(H);+ const brim = new Path2D(); all.forEach((q, i) => i ? brim.lineTo(q.x, q.y) : brim.moveTo(q.x, q.y)); brim.closePath();+ const fr = all.filter(p => p.z >= 0).sort((a, b) => a.x - b.x);+ // shadow of brim on head+ ctx.save(); ctx.clip(path); ctx.clip(capClip(H, 0.50, 1)); ctx.fillStyle = 'rgba(40,0,70,0.10)'; ctx.fill(path); ctx.restore();+ ctx.fillStyle = lin(ctx, 0, -H.ry * 0.9, 0, -H.ry * 0.3, [[0, '#5B21B6'], [1, '#3B0764']]);+ ctx.fill(brim);+ ctx.beginPath(); fr.forEach((q, i) => i ? ctx.lineTo(q.x, q.y) : ctx.moveTo(q.x, q.y));+ ctx.strokeStyle = 'rgba(190,150,255,0.35)'; ctx.lineWidth = H.R * 0.035; ctx.stroke();+ // cone: base ring r=0.62 at y=0.72, apex high, tip bends over+ const baseR = 0.62, by = 0.74;+ const bl = proj(H, [-baseR, by, 0]), br = proj(H, [baseR, by, 0]);+ const c = proj(H, [0, by, 0]);+ const lean = 0.10 + H.phys.dx * 0.15;+ const top = { x: c.x + H.rx * 0.18 + Math.sin(lean) * H.ry * 0.3, y: c.y - H.ry * 1.25 };+ const tip = { x: top.x + H.rx * (0.45 + H.phys.dx * 0.25), y: top.y + H.ry * (0.22 + H.phys.dy * 0.1) };+ const cone = new Path2D();+ cone.moveTo(bl.x, bl.y);+ cone.bezierCurveTo(bl.x + H.rx * 0.12, bl.y - H.ry * 0.5, top.x - H.rx * 0.28, top.y + H.ry * 0.25, top.x - H.rx * 0.02, top.y - H.ry * 0.02);+ cone.quadraticCurveTo(top.x + H.rx * 0.25, top.y - H.ry * 0.08, tip.x, tip.y);+ cone.quadraticCurveTo(top.x + H.rx * 0.22, top.y + H.ry * 0.08, top.x + H.rx * 0.14, top.y + H.ry * 0.22);+ cone.bezierCurveTo(br.x - H.rx * 0.18, c.y - H.ry * 0.45, br.x - H.rx * 0.02, br.y - H.ry * 0.2, br.x, br.y);+ const capFront = frontArc(H, by, baseR / ringR(by)).filter(q => q.x >= bl.x - 1 && q.x <= br.x + 1);+ for (let i = capFront.length - 1; i >= 0; i--) cone.lineTo(capFront[i].x, capFront[i].y + H.ry * 0.0);+ cone.closePath();+ ctx.fillStyle = lin(ctx, bl.x, top.y, br.x, bl.y, [[0, '#7C3AED'], [0.55, '#4C1D95'], [1, '#2E1065']]);+ ctx.fill(cone);+ ctx.save(); ctx.clip(cone);+ ctx.fillStyle = lin(ctx, bl.x, 0, br.x, 0, [[0, 'rgba(255,255,255,0.22)'], [0.4, 'rgba(255,255,255,0)'], [1, 'rgba(0,0,0,0.15)']]);+ ctx.fill(cone);+ // crease where the tip bends+ ctx.beginPath(); ctx.moveTo(top.x - H.rx * 0.05, top.y + H.ry * 0.05); ctx.quadraticCurveTo(top.x + H.rx * 0.1, top.y + H.ry * 0.12, top.x + H.rx * 0.2, top.y + H.ry * 0.06);+ ctx.strokeStyle = 'rgba(20,0,40,0.35)'; ctx.lineWidth = H.R * 0.05; ctx.lineCap = 'round'; ctx.stroke();+ // orange band: gentle curve across the cone just above its base+ const fc = proj(H, [0, by, baseR]);+ const lift = H.ry * 0.11;+ ctx.beginPath();+ ctx.moveTo(bl.x - 2, bl.y - lift);+ ctx.quadraticCurveTo(fc.x, 2 * (fc.y - lift) - (bl.y + br.y) / 2 + lift * 0.0, br.x + 2, br.y - lift);+ ctx.strokeStyle = '#F97316'; ctx.lineWidth = H.ry * 0.17; ctx.lineCap = 'butt'; ctx.stroke();+ ctx.restore();+ // buckle+ const bk0 = proj(H, [0, by, baseR]); const bk = { x: bk0.x, y: bk0.y - H.ry * 0.11 };+ const bw = H.R * 0.2, bh = H.R * 0.16;+ ctx.save(); ctx.translate(bk.x, bk.y - H.ry * 0.0);+ roundRect(ctx, -bw / 2, -bh / 2, bw, bh, bh * 0.25); ctx.fillStyle = '#FCD34D'; ctx.fill();+ roundRect(ctx, -bw / 2 + bw * 0.24, -bh / 2 + bh * 0.28, bw * 0.52, bh * 0.44, bh * 0.1); ctx.fillStyle = '#C2410C'; ctx.fill();+ ctx.restore();+ }+};++// --- Glasses pinned to the real eye positions+function lens(ctx, e, w, h, r) { ctx.save(); ctx.translate(e.x, e.y); ctx.scale(e.fx, e.fy); roundRect(ctx, -w / 2, -h / 2, w, h, r); ctx.restore(); }+OUTFITS.sunglasses = {+ frontAfterEyes: true,+ front(ctx, H, path) {+ const eyes = eyeFrames(H);+ const w = H.R * 0.62, h = H.R * 0.46;+ ctx.save(); ctx.clip(path);+ // bridge+ const [l, r] = eyes;+ if (l.visible && r.visible) {+ ctx.beginPath(); ctx.moveTo(l.x + w / 2 * l.fx * 0.9, l.y - h * 0.18); ctx.quadraticCurveTo((l.x + r.x) / 2, (l.y + r.y) / 2 - h * 0.42, r.x - w / 2 * r.fx * 0.9, r.y - h * 0.18);+ ctx.strokeStyle = '#111317'; ctx.lineWidth = H.R * 0.07; ctx.stroke();+ }+ // temples to the head edge+ for (const e of eyes) {+ if (!e.visible) continue;+ const ox = e.x + e.sd * w / 2 * e.fx;+ ctx.beginPath(); ctx.moveTo(ox, e.y - h * 0.2); ctx.lineTo(e.sd * H.rx * 1.05, e.y - h * 0.35);+ ctx.strokeStyle = '#111317'; ctx.lineWidth = H.R * 0.06; ctx.stroke();+ }+ for (const e of eyes) {+ if (!e.visible) continue;+ lens(ctx, e, w, h, h * 0.42); ctx.fillStyle = 'rgba(17,19,23,0.82)'; ctx.fill();+ ctx.lineWidth = H.R * 0.05; ctx.strokeStyle = '#0B0C0F'; ctx.stroke();+ ctx.save(); ctx.translate(e.x, e.y); ctx.scale(e.fx, e.fy);+ ctx.beginPath(); ctx.moveTo(-w * 0.28, -h * 0.05); ctx.lineTo(-w * 0.05, -h * 0.3);+ ctx.strokeStyle = 'rgba(255,255,255,0.45)'; ctx.lineWidth = H.R * 0.05; ctx.lineCap = 'round'; ctx.stroke();+ ctx.restore();+ }+ ctx.restore();+ }+};+OUTFITS.roundGlasses = {+ front(ctx, H, path) {+ const eyes = eyeFrames(H); const d = H.R * 0.56;+ ctx.save(); ctx.clip(path);+ const [l, r] = eyes;+ if (l.visible && r.visible) {+ ctx.beginPath(); ctx.moveTo(l.x + d / 2 * l.fx, l.y - d * 0.08); ctx.quadraticCurveTo((l.x + r.x) / 2, (l.y + r.y) / 2 - d * 0.3, r.x - d / 2 * r.fx, r.y - d * 0.08);+ ctx.strokeStyle = '#8A4B12'; ctx.lineWidth = H.R * 0.055; ctx.stroke();+ }+ for (const e of eyes) {+ if (!e.visible) continue;+ ctx.beginPath(); ctx.moveTo(e.x + e.sd * d / 2 * e.fx, e.y - d * 0.1); ctx.lineTo(e.sd * H.rx * 1.05, e.y - d * 0.25);+ ctx.strokeStyle = '#8A4B12'; ctx.lineWidth = H.R * 0.05; ctx.stroke();+ }+ for (const e of eyes) {+ if (!e.visible) continue;+ ctx.save(); ctx.translate(e.x, e.y); ctx.scale(e.fx, e.fy);+ ctx.beginPath(); ctx.arc(0, 0, d / 2, 0, Math.PI * 2);+ ctx.fillStyle = 'rgba(190,225,255,0.18)'; ctx.fill();+ ctx.lineWidth = H.R * 0.065; ctx.strokeStyle = '#9A5A1A'; ctx.stroke();+ ctx.beginPath(); ctx.arc(0, 0, d / 2 - H.R * 0.03, Math.PI * 1.1, Math.PI * 1.45);+ ctx.strokeStyle = 'rgba(255,255,255,0.55)'; ctx.lineWidth = H.R * 0.03; ctx.stroke();+ ctx.restore();+ }+ ctx.restore();+ }+};++// --- Scarf: knitted band wrapped low around the body, knot + hanging end+OUTFITS.scarf = {+ front(ctx, H, path) {+ const s = 1.05, y0 = -0.34, y1 = -0.66;+ const top = frontArc(H, y0, s), bot = frontArc(H, y1, s);+ const band = new Path2D();+ top.forEach((q, i) => i ? band.lineTo(q.x, q.y) : band.moveTo(q.x, q.y));+ for (let i = bot.length - 1; i >= 0; i--) band.lineTo(bot[i].x, bot[i].y);+ band.closePath();+ ctx.save(); ctx.clip(mochiPath(H.rx * s, H.ry * s));+ ctx.fillStyle = lin(ctx, 0, -H.ry * 0.2, 0, H.ry * 0.7, [[0, '#F87171'], [1, '#B91C1C']]); ctx.fill(band);+ ctx.clip(band);+ // stripes along meridians+ for (const lon of [-1.0, -0.45, 0.1, 0.65, 1.2]) {+ const a = proj(H, surf(y0, lon + H.yaw * 0, s)), b = proj(H, surf(y1, lon, s));+ if (a.z < 0) continue;+ ctx.beginPath(); ctx.moveTo(a.x, a.y - 4); ctx.lineTo(b.x, b.y + 4);+ ctx.strokeStyle = 'rgba(255,255,255,0.85)'; ctx.lineWidth = H.R * 0.09 * Math.max(0.3, a.z); ctx.stroke();+ }+ ctx.fillStyle = lin(ctx, 0, -H.ry * 0.5, 0, H.ry * 0.3, [[0, 'rgba(255,255,255,0.18)'], [1, 'rgba(0,0,0,0.1)']]); ctx.fill(band);+ ctx.restore();+ // hanging end from the knot at lon -0.55+ const k = proj(H, surf((y0 + y1) / 2, -0.55, s * 1.03));+ if (k.z > 0) {+ const sw = H.phys.dx * H.rx * 0.12;+ const end = new Path2D();+ end.moveTo(k.x - H.R * 0.16, k.y);+ end.quadraticCurveTo(k.x - H.R * 0.24 + sw, k.y + H.ry * 0.35, k.x - H.R * 0.2 + sw * 1.4, k.y + H.ry * 0.62);+ end.lineTo(k.x + H.R * 0.06 + sw * 1.4, k.y + H.ry * 0.6);+ end.quadraticCurveTo(k.x + H.R * 0.02 + sw, k.y + H.ry * 0.3, k.x + H.R * 0.12, k.y);+ end.closePath();+ ctx.fillStyle = lin(ctx, 0, k.y, 0, k.y + H.ry * 0.6, [[0, '#EF4444'], [1, '#B91C1C']]); ctx.fill(end);+ ctx.save(); ctx.clip(end);+ ctx.fillStyle = 'rgba(255,255,255,0.85)';+ for (const t of [0.35, 0.7]) ctx.fillRect(k.x - H.R * 0.4 + sw, k.y + H.ry * 0.62 * t, H.R * 0.8, H.R * 0.07);+ ctx.restore();+ // fringe+ for (let i = 0; i < 4; i++) {+ const fx = k.x - H.R * 0.17 + sw * 1.4 + i * H.R * 0.075;+ ctx.beginPath(); ctx.moveTo(fx, k.y + H.ry * 0.6); ctx.lineTo(fx, k.y + H.ry * 0.72);+ ctx.strokeStyle = '#DC2626'; ctx.lineWidth = H.R * 0.035; ctx.lineCap = 'round'; ctx.stroke();+ }+ // knot+ ctx.beginPath(); ctx.ellipse(k.x, k.y, H.R * 0.17, H.R * 0.14, 0.2, 0, Math.PI * 2);+ ctx.fillStyle = rad(ctx, k.x - H.R * 0.05, k.y - H.R * 0.05, 0, H.R * 0.2, [[0, '#F87171'], [1, '#B91C1C']]); ctx.fill();+ }+ }+};++// --- Pumpkin: body recolour + soft ribs following meridians + curly stem & leaf+OUTFITS.pumpkin = {+ bodyColors: ['#FFA94D', '#E8590C'],+ front(ctx, H, path) {+ ctx.save(); ctx.clip(path);+ for (const lon of [-1.15, -0.55, 0.0, 0.55, 1.15]) {+ const pts = [];+ for (let i = 0; i <= 30; i++) { const y = -0.98 + 1.96 * i / 30; const q = proj(H, surf(y, lon, 1)); if (q.z > 0) pts.push(q); }+ if (pts.length < 2) continue;+ ctx.beginPath(); pts.forEach((q, i) => i ? ctx.lineTo(q.x, q.y) : ctx.moveTo(q.x, q.y));+ const zz = pts[Math.floor(pts.length / 2)].z;+ ctx.strokeStyle = `rgba(150,50,0,${0.22 * zz})`; ctx.lineWidth = H.R * 0.12; ctx.lineCap = 'round'; ctx.stroke();+ ctx.strokeStyle = `rgba(255,220,170,${0.18 * zz})`; ctx.lineWidth = H.R * 0.04; ctx.save(); ctx.translate(H.R * 0.07, 0); ctx.stroke(); ctx.restore();+ }+ ctx.restore();+ const t = proj(H, [0.02, 1.0, 0]);+ // stem+ ctx.beginPath(); ctx.moveTo(t.x - H.R * 0.09, t.y + H.R * 0.04);+ ctx.quadraticCurveTo(t.x - H.R * 0.08, t.y - H.R * 0.22, t.x + H.R * 0.08, t.y - H.R * 0.3);+ ctx.lineTo(t.x + H.R * 0.13, t.y - H.R * 0.22);+ ctx.quadraticCurveTo(t.x + H.R * 0.04, t.y - H.R * 0.15, t.x + H.R * 0.08, t.y + H.R * 0.04); ctx.closePath();+ ctx.fillStyle = lin(ctx, t.x - H.R * 0.1, 0, t.x + H.R * 0.1, 0, [[0, '#65A30D'], [1, '#3F6212']]); ctx.fill();+ // leaf+ ctx.save(); ctx.translate(t.x - H.R * 0.06, t.y - H.R * 0.02); ctx.rotate(-0.5);+ ctx.beginPath(); ctx.moveTo(0, 0); ctx.quadraticCurveTo(-H.R * 0.18, -H.R * 0.2, -H.R * 0.38, -H.R * 0.02); ctx.quadraticCurveTo(-H.R * 0.18, H.R * 0.1, 0, 0);+ ctx.fillStyle = lin(ctx, 0, -H.R * 0.15, -H.R * 0.3, 0, [[0, '#84CC16'], [1, '#4D7C0F']]); ctx.fill();+ ctx.beginPath(); ctx.moveTo(-H.R * 0.02, -H.R * 0.01); ctx.quadraticCurveTo(-H.R * 0.18, -H.R * 0.08, -H.R * 0.32, -H.R * 0.03); ctx.strokeStyle = 'rgba(30,60,0,0.4)'; ctx.lineWidth = H.R * 0.02; ctx.stroke();+ ctx.restore();+ // curly tendril+ ctx.beginPath(); ctx.moveTo(t.x + H.R * 0.1, t.y - H.R * 0.12);+ ctx.bezierCurveTo(t.x + H.R * 0.3, t.y - H.R * 0.25, t.x + H.R * 0.35, t.y - H.R * 0.02, t.x + H.R * 0.22, t.y - H.R * 0.06);+ ctx.strokeStyle = '#4D7C0F'; ctx.lineWidth = H.R * 0.03; ctx.lineCap = 'round'; ctx.stroke();+ }+};++// --- Bow (kept, now anchored in 3D so it turns with the head)+OUTFITS.bow = {+ front(ctx, H, path) {+ const a = proj(H, surf(0.86, 0.55, 1.02));+ if (a.z < -0.2) return;+ const s = H.R * 0.26, sq = Math.max(0.45, Math.cos(0.55 + H.yaw));+ ctx.save(); ctx.translate(a.x, a.y); ctx.rotate(0.35 + H.yaw * 0.3); ctx.scale(sq, 1);+ for (const sd of [-1, 1]) {+ ctx.beginPath(); ctx.moveTo(0, 0);+ ctx.bezierCurveTo(sd * s * 0.6, -s * 0.85, sd * s * 1.35, -s * 0.55, sd * s * 1.15, 0);+ ctx.bezierCurveTo(sd * s * 1.35, s * 0.55, sd * s * 0.6, s * 0.85, 0, 0);+ ctx.fillStyle = lin(ctx, 0, -s, 0, s, [[0, '#FF8CC6'], [1, '#DB2777']]); ctx.fill();+ ctx.beginPath(); ctx.moveTo(sd * s * 0.25, -s * 0.05); ctx.quadraticCurveTo(sd * s * 0.7, -s * 0.15, sd * s * 0.95, -s * 0.05);+ ctx.strokeStyle = 'rgba(140,10,70,0.35)'; ctx.lineWidth = s * 0.08; ctx.lineCap = 'round'; ctx.stroke();+ }+ ctx.beginPath(); ctx.ellipse(0, 0, s * 0.24, s * 0.3, 0, 0, Math.PI * 2);+ ctx.fillStyle = rad(ctx, -s * 0.06, -s * 0.1, 0, s * 0.35, [[0, '#FFB3D9'], [1, '#C2185B']]); ctx.fill();+ ctx.restore();+ }+};++// ---------- composite draw ----------+function drawMochi(ctx, W, opts) {+ const R = W * (opts.scale || 1) * 0.3;+ const H = { R, rx: R * 1.14, ry: R * 0.88, view: VIEW_TILT, yaw: opts.yaw || 0, pitch: opts.pitch || 0, phys: opts.phys || { dx: 0, dy: 0 } };+ const o = opts.outfit ? OUTFITS[opts.outfit] : null;+ ctx.save(); ctx.translate(W / 2, W / 2 + R * 0.45);+ if (opts.tilt) ctx.rotate(opts.tilt);+ if (o && o.back) o.back(ctx, H);+ const path = drawBody(ctx, H, o && o.bodyColors);+ drawEyes(ctx, H, path);+ if (o && o.front) o.front(ctx, H, path);+ ctx.restore();+}diff --git a/design/outfits/sheet.html b/design/outfits/sheet.htmlnew file mode 100644index 00000000..ef3883dc--- /dev/null+++ b/design/outfits/sheet.html@@ -0,0 +1,31 @@+<!doctype html><html><body style="margin:0;background:#1b1c1f">+<div id="sheet" style="display:inline-block;background:#0B0C0E;padding:12px"></div>+<script src="mochi-outfits.js"></script>+<script>+const outfits = (new URLSearchParams(location.search).get('o')||'none,beanie,santaHat,partyHat,crown,witchHat,sunglasses,roundGlasses,scarf,pumpkin,bow').split(',');+const cols = [+ {label:'L', yaw:-0.5, pitch:0, phys:{dx:0.6,dy:0}},+ {label:'front', yaw:0, pitch:0, phys:{dx:0,dy:0}},+ {label:'R', yaw:0.5, pitch:0, phys:{dx:-0.6,dy:0}},+ {label:'up', yaw:0.15, pitch:0.4, phys:{dx:0,dy:0.4}},+ {label:'down', yaw:-0.2, pitch:-0.5, phys:{dx:0,dy:-0.4}},+ {label:'tilt', yaw:0.3, pitch:-0.25, tilt:0.12, phys:{dx:-0.3,dy:0}},+];+const S = document.getElementById('sheet');+const W = 190, small = 64;+for (const o of outfits) {+ const row = document.createElement('div'); row.style.cssText='display:flex;align-items:center;gap:6px;margin:4px 0';+ const lab = document.createElement('div'); lab.textContent=o; lab.style.cssText='width:90px;color:#ddd;font:12px -apple-system,Helvetica;text-align:right';+ row.appendChild(lab);+ for (const c of cols) {+ const cv = document.createElement('canvas'); cv.width=W*2; cv.height=W*2; cv.style.width=W+'px'; cv.style.height=W+'px'; cv.style.background='#15171b'; cv.style.borderRadius='10px';+ const ctx = cv.getContext('2d'); ctx.scale(2,2);+ drawMochi(ctx, W, {...c, scale:0.62, outfit: o==='none'?null:o});+ row.appendChild(cv);+ }+ const cv = document.createElement('canvas'); cv.width=small*2; cv.height=small*2; cv.style.width=small+'px'; cv.style.height=small+'px'; cv.style.background='#000';+ const ctx = cv.getContext('2d'); ctx.scale(2,2); drawMochi(ctx, small, {scale:0.62, outfit:o==='none'?null:o});+ row.appendChild(cv);+ S.appendChild(row);+}+</script></body></html>diff --git a/docs/SPEC.md b/docs/SPEC.mdindex e1dec489..d8077f50 100644--- a/docs/SPEC.md+++ b/docs/SPEC.md@@ -127,7 +127,7 @@ Remplace la carte principale quand `showingDetail && githubHasPulse`. En-tête :### Section Activity (`GitHubActivityDetailContent`)-Section `.activity` de `GitHubDetailView`. En-tête : chevron.left + « Activity » à gauche ; à droite (11 pt #8E939C) : « 1,234 past year · N repos » (clic → `github.com/<login>`). Au survol / clic sur un carré : texte remplacé par « Oct 3 · 12 contributions » (ou « 1 contribution », ou « No contributions »). Grille de contributions : colonnes = semaines (la plus ancienne à gauche, ~20 semaines à 8 pt avec espacement 2 pt), lignes = jours de la semaine (dimanche = ligne 0). Couleurs des niveaux : 0 = blanc 6 %, 1 = `#0E4429`, 2 = `#006D32`, 3 = `#26A641`, 4 = `#39D353`. Pas de ScrollView, `.clipped()`. `refreshActivityIfStale()` à l'apparition.+Section `.activity` de `GitHubDetailView`. En-tête : chevron.left + « Activity » à gauche ; à droite (11 pt #8E939C) : « 1,234 past year · N repos » (clic → `github.com/<login>`). Au survol / clic sur un carré : texte remplacé par « Oct 3 · 12 contributions » (ou « 1 contribution », ou « No contributions »). Grille de contributions : colonnes = semaines (la plus ancienne à gauche, carrés de 7 pt, espacement 1,5 pt, nombre de semaines calculé selon la largeur disponible, environ 23), lignes = jours de la semaine (dimanche = ligne 0). Couleurs des niveaux : 0 = blanc 6 %, 1 = `#0E4429`, 2 = `#006D32`, 3 = `#26A641`, 4 = `#39D353`. Pas de ScrollView, `.clipped()`. `refreshActivityIfStale()` à l'apparition.### Boutons- Pilule, 12,5 pt medium, fond blanc 9 % (survol 15 %), primaire : fond `#F5F6F8` texte `#0B0C0E`. Appui : échelle 0,94. Raccourcis affichés en petite pastille bordée (Y, N).@@ -238,6 +238,38 @@ Fenêtre Réglages (SwiftUI, simple), sections dans l'ordre d'affichage :- **Hotkey** : raccourci global pour ouvrir le notch.- **Startup** : lancer au démarrage (`SMAppService.mainApp`).+### Garde-robe (`WardrobeView`)++Accessible par clic droit sur la tête de Mochi (étendu ou compact). L'île s'étend sur `.wardrobe`.++**Mise en page** : Mochi à gauche (même position qu'overview, avec la tenue survolée en aperçu direct). À droite : en-tête « Wardrobe » 12 pt semibold + la tenue sélectionnée en 11 pt #8E939C. Si Auto : « Auto · Witch hat » (tenue de saison actuelle).++Grille de pastilles 30 pt, coins 7 pt, fond blanc 6 %, bord blanc 8 % (sélectionnée : 40 %). Chaque pastille affiche l'accessoire dessiné en Canvas statique. La pastille **Auto** porte un badge « AUTO » en 8 pt ; au survol, l'en-tête de droite affiche le nom de la tenue de saison (ou « None » si aucune). Survol : fond 10 % + aperçu sur Mochi. Clic → sélectionne, sauvegarde, son « pop », émote proud.++**Affichage de la tenue** : la tenue n'est visible sur le gros Mochi que quand `focusId == mainPillId` (ou `focusId == nil`), ou quand l'île n'est pas en mode expanded, ou quand la vue active est `.wardrobe`. Dans tous les autres cas (focus sur une autre tâche en expanded), Mochi porte `.none`.++**Transitions** : chaque accessoire dispose d'une valeur `presence` (0 → 1, animée en 350 ms `Ease.inOut`). À l'entrée, la position est interpolée avec `Ease.back` (légère surcourse). Chaque accessoire est dessiné dans un calque dédié (`GraphicsContext.drawLayer`) pour éviter les transparences parasites entre formes superposées ; opacité du calque = `min(1, presence × 2.5)`. Déplacements typiques à l'entrée : chapeaux descendent de 1,0 ry ; oreilles montent ; écharpe et nœud émergent de leur position de repos.++**Physique** : `physDx` et `physDy` (ressort ω₀ ≈ √60 rad/s, ζ ≈ 0,6) suivent la vélocité du yaw (décalage horizontal) et du bounce (décalage vertical). Impulsions supplémentaires : `physVy += 0,6` lors d'un écrasement (`squash`) ; force centrifuge `rollVel × 0,18` ajoutée à la cible de `physDx` pendant la roulade avec tenue.++**Roulade** : quand Mochi porte une tenue (`outfit != .none`, `outfitPresence > 0,05`), la roulade est **rigide** — tout Mochi (mains derrière, accessoires, corps, yeux, mains devant) est dessiné dans un contexte tourné de `roll` autour du centre du corps. Les accessoires utilisent une projection sans roll (`H.roll = 0`) et restent posés sur la tête ; ils co-tournent via le contexte. Particules et badge sont dessinés hors du contexte tourné. Quand aucune tenue n'est portée, la roulade originale s'applique (illusion sphérique par les yeux uniquement).++**Fermeture** : Échap, clic maison, ou clic droit sur Mochi à nouveau.++**Référence visuelle** : `design/outfits/` (`mochi-outfits.js`, `sheet.html`, `mochi-outfits-reference.png`). Outil de développement : `scripts/render-outfits.sh` (hors CI) — génère `/tmp/coucou-outfits.png`, `/tmp/coucou-roll.png`, `/tmp/coucou-transition.png`.++**Calendrier des saisons** (mode Auto) :+- 1 oct – 1 nov : Witch hat+- 1 déc – 26 déc : Santa hat+- 31 déc – 2 jan : Party hat+- Pâques −2 / +1 : Bunny ears+- 21 juin – 31 août : Sunglasses++**Identifiants stables** (UserDefaults key `mochiOutfit`) :+`auto`, `none`, `partyHat`, `beanie`, `crown`, `witchHat`, `santaHat`, `bunnyEars`, `bow`, `sunglasses`, `roundGlasses`, `scarf`, `pumpkin`++Les valeurs supprimées (`topHat`, `cap`, `heartsHeadband`, `strawHat`) sont migrées vers `auto` à la lecture.+## 11. JalonsChaque jalon se termine par build + capture + comparaison aux références + commit (voir CLAUDE.md).diff --git a/scripts/RenderOutfits.swift b/scripts/RenderOutfits.swiftnew file mode 100644index 00000000..3e1642cd--- /dev/null+++ b/scripts/RenderOutfits.swift@@ -0,0 +1,331 @@+// RenderOutfits.swift — standalone planche renderer for Mochi outfits+// Compile + run via: bash scripts/render-outfits.sh+// Output: /tmp/coucou-outfits.png++import Foundation+import SwiftUI+import AppKit++// MARK: - Stubs (substitutes for app-only types)++@MainActor+final class SoundEngine {+ static let shared = SoundEngine()+ var enabled: Bool = false+ func play(_ name: String) {}+}++extension Notification.Name {+ static let botDizzy = Notification.Name("notchBuddy.botDizzy")+ static let botGreet = Notification.Name("notchBuddy.botGreet")+ static let botBlink = Notification.Name("notchBuddy.botBlink")+ static let botSetTgEs = Notification.Name("notchBuddy.botSetTgEs")+ static let botGulp = Notification.Name("notchBuddy.botGulp")+ static let botMorphTo = Notification.Name("notchBuddy.botMorphTo")+ static let triggerEmote = Notification.Name("notchBuddy.triggerEmote")+ static let triggerSlap = Notification.Name("notchBuddy.triggerSlap")+ static let greetComplete = Notification.Name("notchBuddy.greetComplete")+ static let greetingHover = Notification.Name("notchBuddy.greetingHover")+ static let greetingInterrupt = Notification.Name("notchBuddy.greetingInterrupt")+ static let islandAction = Notification.Name("notchBuddy.islandAction")+ static let islandCollapse = Notification.Name("notchBuddy.islandCollapse")+ static let hookReveal = Notification.Name("notchBuddy.hookReveal")+ static let musicReveal = Notification.Name("notchBuddy.musicReveal")+ static let openFullSettings = Notification.Name("notchBuddy.openFullSettings")+}++extension Color {+ init(hex: String) {+ let h = hex.trimmingCharacters(in: CharacterSet(charactersIn: "#"))+ let val = UInt64(h, radix: 16) ?? 0+ let r = Double((val >> 16) & 0xFF) / 255+ let g = Double((val >> 8) & 0xFF) / 255+ let b = Double( val & 0xFF) / 255+ self.init(red: r, green: g, blue: b)+ }+}++// MARK: - Cell view — one outfit at one pose++struct MochiCell: View {+ let outfit: Outfit+ let yaw: CGFloat+ let pitch: CGFloat+ let tilt: CGFloat+ let phys: (dx: CGFloat, dy: CGFloat)+ let cellSize: CGFloat+ var roll: CGFloat = 0+ var presence: CGFloat = 1++ var body: some View {+ Canvas { context, sz in+ let W = sz.width, H = sz.height+ // scale=0.62, R = W * 0.62 * 0.3+ let R = W * 0.62 * 0.3+ let rx = R * 1.14+ let ry = R * 0.88+ let cx = W / 2+ let cy = H / 2 + R * 0.06+ let sx: CGFloat = 1, sy: CGFloat = 1+ let morph: CGFloat = 0++ let mH = MochiH(R: R, yaw: yaw, pitch: pitch, physDx: phys.dx, physDy: phys.dy, roll: roll)++ // 1. Behind-body outfit+ drawOutfitBehindStatic(+ context: context, outfit: outfit, H: mH,+ cx: cx, cy: cy, tilt: tilt, sx: sx, sy: sy,+ roll: roll, morph: morph, isMini: false, presence: presence+ )++ // 2. Body (replicate BotEngine.drawBody for idle / pumpkin state)+ var bCtx = context+ bCtx.translateBy(x: cx, y: cy)+ if tilt != 0 { bCtx.rotate(by: .radians(tilt)) }+ bCtx.scaleBy(x: sx, y: sy)+ let body = mochiOutfitPath(rx, ry)++ // Base gradient (pumpkin-aware)+ let pumpkin = outfit == .pumpkin+ let cTop: Color = pumpkin ? Color(hex: "#FFA94D") : Color(red: 0.929, green: 0.929, blue: 0.937)+ let cBot: Color = pumpkin ? Color(hex: "#E8590C") : Color(red: 0.769, green: 0.773, blue: 0.792)+ bCtx.fill(body, with: .linearGradient(+ Gradient(colors: [cTop, cBot]),+ startPoint: CGPoint(x: rx * 0.7, y: -ry * 0.85),+ endPoint: CGPoint(x: -rx * 0.8, y: ry * 0.9)+ ))+ // Shadow rim+ bCtx.fill(body, with: .radialGradient(+ Gradient(stops: [+ .init(color: .clear, location: 0.6),+ .init(color: Color.black.opacity(0.2), location: 1)+ ]),+ center: .zero, startRadius: R * 0.15, endRadius: R * 1.25+ ))+ // Top-left highlight+ bCtx.fill(body, with: .radialGradient(+ Gradient(stops: [+ .init(color: Color.white.opacity(0.55), location: 0),+ .init(color: .clear, location: 1)+ ]),+ center: CGPoint(x: rx * 0.34, y: -ry * 0.46),+ startRadius: 0, endRadius: R * 0.42+ ))++ // 3. Eyes (clipped to body)+ var eyeBase = bCtx+ eyeBase.clip(to: body)+ let ink = Color(red: 0.102, green: 0.082, blue: 0.071)+ for f in mEyeFrames(mH) {+ guard f.visible else { continue }+ var eCtx = eyeBase+ eCtx.translateBy(x: f.x, y: f.y)+ eCtx.scaleBy(x: f.fx, y: f.fy)+ let hh = max(f.h, f.w * 0.3)+ var pill = Path()+ pill.addRoundedRect(+ in: CGRect(x: -f.w / 2, y: -hh / 2, width: f.w, height: hh),+ cornerSize: CGSize(width: min(f.w / 2, hh / 2), height: min(f.w / 2, hh / 2))+ )+ eCtx.fill(pill, with: .color(ink))+ }++ // 4. Front outfit+ drawOutfitFrontStatic(+ context: context, outfit: outfit, H: mH,+ cx: cx, cy: cy, tilt: tilt, sx: sx, sy: sy,+ roll: roll, morph: morph, isMini: false, presence: presence+ )+ }+ .frame(width: cellSize, height: cellSize)+ }+}++// MARK: - Grid view++// Outfit order matching sheet.html+private let targetOutfits: [Outfit] = [+ .none, .beanie, .santaHat, .partyHat, .crown, .witchHat,+ .sunglasses, .roundGlasses, .scarf, .pumpkin, .bow,+]++private struct PoseSpec {+ let label: String+ let yaw: CGFloat+ let pitch: CGFloat+ let tilt: CGFloat+ let phys: (dx: CGFloat, dy: CGFloat)+ let size: CGFloat+}++// Columns matching sheet.html cols array + small pill-preview column (W=190, scale=0.62; small=64)+private let poses: [PoseSpec] = [+ PoseSpec(label: "L", yaw: -0.5, pitch: 0, tilt: 0, phys: (0.6, 0), size: 190),+ PoseSpec(label: "front", yaw: 0, pitch: 0, tilt: 0, phys: (0, 0), size: 190),+ PoseSpec(label: "R", yaw: 0.5, pitch: 0, tilt: 0, phys: (-0.6, 0), size: 190),+ PoseSpec(label: "up", yaw: 0.15, pitch: 0.4, tilt: 0, phys: (0, 0.4), size: 190),+ PoseSpec(label: "down", yaw: -0.2, pitch: -0.5, tilt: 0, phys: (0, -0.4), size: 190),+ PoseSpec(label: "tilt", yaw: 0.3, pitch: -0.25, tilt: 0.12, phys: (-0.3, 0), size: 190),+ PoseSpec(label: "mini", yaw: 0, pitch: 0, tilt: 0, phys: (0, 0), size: 64),+]++private let labelW: CGFloat = 90+private let gap: CGFloat = 6++struct OutfitGrid: View {+ var body: some View {+ VStack(alignment: .leading, spacing: gap) {+ // Column headers+ HStack(spacing: gap) {+ Spacer().frame(width: labelW)+ ForEach(poses.indices, id: \.self) { i in+ Text(poses[i].label)+ .font(.system(size: 9, design: .monospaced))+ .foregroundColor(.gray)+ .frame(width: poses[i].size, alignment: .center)+ }+ }+ // One row per outfit+ ForEach(targetOutfits.indices, id: \.self) { oi in+ let outfit = targetOutfits[oi]+ HStack(spacing: gap) {+ Text(outfit.rawValue)+ .font(.system(size: 10))+ .foregroundColor(.white)+ .frame(width: labelW, alignment: .trailing)+ ForEach(poses.indices, id: \.self) { pi in+ let p = poses[pi]+ MochiCell(outfit: outfit, yaw: p.yaw, pitch: p.pitch,+ tilt: p.tilt, phys: p.phys, cellSize: p.size)+ .background(pi == poses.count - 1+ ? Color.black+ : Color(red: 0.083, green: 0.090, blue: 0.106))+ .clipShape(RoundedRectangle(cornerRadius: pi == poses.count - 1 ? 0 : 8))+ }+ }+ }+ }+ .padding(12)+ .background(Color(red: 0.043, green: 0.047, blue: 0.055))+ }+}++// MARK: - Roll planche++private let rollOutfits: [Outfit] = [+ .none, .beanie, .santaHat, .witchHat, .crown,+ .sunglasses, .roundGlasses, .scarf, .bow, .pumpkin, .bunnyEars+]++private let rollValues: [CGFloat] = [0, CGFloat.pi/3, CGFloat.pi*2/3, CGFloat.pi, CGFloat.pi*4/3, CGFloat.pi*5/3]++struct RollGrid: View {+ var body: some View {+ VStack(alignment: .leading, spacing: gap) {+ // Column headers+ HStack(spacing: gap) {+ Spacer().frame(width: labelW)+ ForEach(rollValues.indices, id: \.self) { i in+ Text(String(format: "%.2fπ", rollValues[i] / .pi))+ .font(.system(size: 9, design: .monospaced))+ .foregroundColor(.gray)+ .frame(width: 120, alignment: .center)+ }+ }+ ForEach(rollOutfits.indices, id: \.self) { oi in+ let outfit = rollOutfits[oi]+ HStack(spacing: gap) {+ Text(outfit.rawValue)+ .font(.system(size: 10))+ .foregroundColor(.white)+ .frame(width: labelW, alignment: .trailing)+ ForEach(rollValues.indices, id: \.self) { ri in+ MochiCell(outfit: outfit, yaw: 0, pitch: 0, tilt: 0, phys: (0, 0),+ cellSize: 120, roll: rollValues[ri])+ .background(Color(red: 0.083, green: 0.090, blue: 0.106))+ .clipShape(RoundedRectangle(cornerRadius: 8))+ }+ }+ }+ }+ .padding(12)+ .background(Color(red: 0.043, green: 0.047, blue: 0.055))+ }+}++// MARK: - Transition planche++private let transitionOutfits: [Outfit] = [.witchHat, .santaHat, .bunnyEars, .scarf]+private let presenceValues: [CGFloat] = [0, 0.3, 0.6, 1]++struct TransitionGrid: View {+ var body: some View {+ VStack(alignment: .leading, spacing: gap) {+ // Column headers+ HStack(spacing: gap) {+ Spacer().frame(width: labelW)+ ForEach(presenceValues.indices, id: \.self) { i in+ Text(String(format: "p=%.1f", presenceValues[i]))+ .font(.system(size: 9, design: .monospaced))+ .foregroundColor(.gray)+ .frame(width: 120, alignment: .center)+ }+ }+ ForEach(transitionOutfits.indices, id: \.self) { oi in+ let outfit = transitionOutfits[oi]+ HStack(spacing: gap) {+ Text(outfit.rawValue)+ .font(.system(size: 10))+ .foregroundColor(.white)+ .frame(width: labelW, alignment: .trailing)+ ForEach(presenceValues.indices, id: \.self) { pi in+ MochiCell(outfit: outfit, yaw: 0, pitch: 0, tilt: 0, phys: (0, 0),+ cellSize: 120, presence: presenceValues[pi])+ .background(Color(red: 0.083, green: 0.090, blue: 0.106))+ .clipShape(RoundedRectangle(cornerRadius: 8))+ }+ }+ }+ }+ .padding(12)+ .background(Color(red: 0.043, green: 0.047, blue: 0.055))+ }+}++// MARK: - Helper to render and save a view++@MainActor+private func renderAndSave<V: View>(_ view: V, path: String) {+ let renderer = ImageRenderer(content: view)+ renderer.scale = 2.0+ guard let nsImage = renderer.nsImage else {+ print("Error: ImageRenderer returned nil for \(path)")+ return+ }+ guard let tiff = nsImage.tiffRepresentation,+ let rep = NSBitmapImageRep(data: tiff),+ let png = rep.representation(using: .png, properties: [:])+ else {+ print("Error: PNG conversion failed for \(path)")+ return+ }+ do {+ try png.write(to: URL(fileURLWithPath: path))+ print("✓ \(path) — \(Int(nsImage.size.width))×\(Int(nsImage.size.height)) @ 2×")+ } catch {+ print("Error writing \(path): \(error)")+ }+}++// MARK: - Entry point++@main+struct RenderOutfits {+ static func main() {+ MainActor.assumeIsolated {+ renderAndSave(OutfitGrid(), path: "/tmp/coucou-outfits.png")+ renderAndSave(RollGrid(), path: "/tmp/coucou-roll.png")+ renderAndSave(TransitionGrid(), path: "/tmp/coucou-transition.png")+ }+ }+}diff --git a/scripts/render-outfits.sh b/scripts/render-outfits.shnew file mode 100644index 00000000..73d38496--- /dev/null+++ b/scripts/render-outfits.sh@@ -0,0 +1,30 @@+#!/bin/bash+# render-outfits.sh — compile and run the Mochi outfit planche renderer+# NOT in CI. Run manually: bash scripts/render-outfits.sh+# Output: /tmp/coucou-outfits.png++set -e+cd "$(dirname "$0")/.."++SDK=$(xcrun --sdk macosx --show-sdk-path)++echo "Compiling renderer..."+swiftc \+ -parse-as-library \+ -sdk "$SDK" \+ -target arm64-apple-macosx15.0 \+ NotchBuddy/Sources/App/IslandScreenGeometry.swift \+ NotchBuddy/Sources/App/IslandTypes.swift \+ NotchBuddy/Sources/App/MochiWardrobe.swift \+ NotchBuddy/Sources/App/BotEngine.swift \+ NotchBuddy/Sources/App/MochiOutfitDrawing.swift \+ scripts/RenderOutfits.swift \+ -framework AppKit \+ -framework SwiftUI \+ -o /tmp/coucou-render-outfits \+ 2>&1++echo "Running renderer..."+/tmp/coucou-render-outfits+echo "Opening..."+open /tmp/coucou-outfits.pngdiff --git a/scripts/test-wardrobe.sh b/scripts/test-wardrobe.shnew file mode 100755index 00000000..d416186a--- /dev/null+++ b/scripts/test-wardrobe.sh@@ -0,0 +1,8 @@+#!/usr/bin/env bash+set -euo pipefail+cd "$(dirname "$0")/.."+TEST_DIR="$(mktemp -d "${TMPDIR:-/tmp}/coucou-wardrobe.XXXXXX")"+trap 'rm -rf "$TEST_DIR"' EXIT+swiftc NotchBuddy/Sources/App/MochiWardrobe.swift \+ tests/MochiWardrobeTests.swift -o "$TEST_DIR/wardrobe-tests"+"$TEST_DIR/wardrobe-tests"diff --git a/tests/MochiWardrobeTests.swift b/tests/MochiWardrobeTests.swiftnew file mode 100644index 00000000..2cdf5d7d--- /dev/null+++ b/tests/MochiWardrobeTests.swift@@ -0,0 +1,110 @@+import Foundation++@main+enum MochiWardrobeTests {++ static var failures = 0++ static func check(_ label: String, _ got: Bool) {+ if got { print(" ✓ \(label)") }+ else { print(" ✗ \(label)"); failures += 1 }+ }++ static func date(year: Int, month: Int, day: Int) -> Date {+ var c = DateComponents(); c.year = year; c.month = month; c.day = day+ return Calendar(identifier: .gregorian).date(from: c)!+ }++ static func seasonal(_ year: Int, _ month: Int, _ day: Int) -> Outfit {+ Outfit.seasonal(for: date(year: year, month: month, day: day),+ calendar: Calendar(identifier: .gregorian))+ }++ static func main() {+ print("Outfit.seasonal — witch hat (Oct 1 – Nov 1)")+ check("Sep 30 → none", seasonal(2026, 9, 30) == .none)+ check("Oct 1 → witchHat", seasonal(2026, 10, 1) == .witchHat)+ check("Oct 31 → witchHat", seasonal(2026, 10, 31) == .witchHat)+ check("Nov 1 → witchHat", seasonal(2026, 11, 1) == .witchHat)+ check("Nov 2 → none", seasonal(2026, 11, 2) == .none)++ print("Outfit.seasonal — santa hat (Dec 1–26)")+ check("Nov 30 → none", seasonal(2026, 11, 30) == .none)+ check("Dec 1 → santaHat", seasonal(2026, 12, 1) == .santaHat)+ check("Dec 26 → santaHat", seasonal(2026, 12, 26) == .santaHat)+ check("Dec 27 → none", seasonal(2026, 12, 27) == .none)++ print("Outfit.seasonal — party hat (Dec 31 – Jan 2)")+ check("Dec 30 → none", seasonal(2026, 12, 30) == .none)+ check("Dec 31 → partyHat", seasonal(2026, 12, 31) == .partyHat)+ check("Jan 1 → partyHat", seasonal(2027, 1, 1) == .partyHat)+ check("Jan 2 → partyHat", seasonal(2027, 1, 2) == .partyHat)+ check("Jan 3 → none", seasonal(2027, 1, 3) == .none)++ print("Outfit.seasonal — Feb 13–16 → none (heartsHeadband removed)")+ check("Feb 12 → none", seasonal(2026, 2, 12) == .none)+ check("Feb 13 → none", seasonal(2026, 2, 13) == .none)+ check("Feb 15 → none", seasonal(2026, 2, 15) == .none)+ check("Feb 16 → none", seasonal(2026, 2, 16) == .none)++ print("Outfit.seasonal — bunny ears (Easter ±)")+ // Easter 2026 = April 5+ check("Apr 3 2026 → bunnyEars", seasonal(2026, 4, 3) == .bunnyEars) // -2+ check("Apr 4 2026 → bunnyEars", seasonal(2026, 4, 4) == .bunnyEars) // -1+ check("Apr 5 2026 → bunnyEars", seasonal(2026, 4, 5) == .bunnyEars) // 0+ check("Apr 6 2026 → bunnyEars", seasonal(2026, 4, 6) == .bunnyEars) // +1+ check("Apr 7 2026 → none", seasonal(2026, 4, 7) == .none) // +2+ check("Apr 2 2026 → none", seasonal(2026, 4, 2) == .none) // -3+ // Easter 2027 = March 28+ check("Mar 26 2027 → bunnyEars", seasonal(2027, 3, 26) == .bunnyEars)+ check("Mar 29 2027 → bunnyEars", seasonal(2027, 3, 29) == .bunnyEars)+ check("Mar 30 2027 → none", seasonal(2027, 3, 30) == .none)+ // Easter 2028 = April 16+ check("Apr 14 2028 → bunnyEars", seasonal(2028, 4, 14) == .bunnyEars)+ check("Apr 17 2028 → bunnyEars", seasonal(2028, 4, 17) == .bunnyEars)+ check("Apr 18 2028 → none", seasonal(2028, 4, 18) == .none)++ print("Outfit.seasonal — sunglasses (Jun 21 – Aug 31)")+ check("Jun 20 → none", seasonal(2026, 6, 20) == .none)+ check("Jun 21 → sunglasses", seasonal(2026, 6, 21) == .sunglasses)+ check("Aug 31 → sunglasses", seasonal(2026, 8, 31) == .sunglasses)+ check("Sep 1 → none", seasonal(2026, 9, 1) == .none)++ print("Outfit.resolved")+ let d = date(year: 2026, month: 10, day: 15)+ let cal = Calendar(identifier: .gregorian)+ check("auto → seasonal", Outfit.resolved(selection: .auto, date: d, calendar: cal) == .witchHat)+ check("none → none", Outfit.resolved(selection: .none, date: d, calendar: cal) == .none)+ check("beanie → beanie", Outfit.resolved(selection: .beanie, date: d, calendar: cal) == .beanie)++ print("Outfit.rawValue stability")+ check("auto rawValue", Outfit.auto.rawValue == "auto")+ check("none rawValue", Outfit.none.rawValue == "none")+ check("partyHat rawValue", Outfit.partyHat.rawValue == "partyHat")+ check("beanie rawValue", Outfit.beanie.rawValue == "beanie")+ check("crown rawValue", Outfit.crown.rawValue == "crown")+ check("sunglasses rawValue", Outfit.sunglasses.rawValue == "sunglasses")+ check("roundGlasses rawValue", Outfit.roundGlasses.rawValue == "roundGlasses")+ check("bow rawValue", Outfit.bow.rawValue == "bow")+ check("scarf rawValue", Outfit.scarf.rawValue == "scarf")+ check("witchHat rawValue", Outfit.witchHat.rawValue == "witchHat")+ check("pumpkin rawValue", Outfit.pumpkin.rawValue == "pumpkin")+ check("santaHat rawValue", Outfit.santaHat.rawValue == "santaHat")+ check("bunnyEars rawValue", Outfit.bunnyEars.rawValue == "bunnyEars")++ print("Outfit.stored — removed rawValues → auto")+ for removed in ["topHat", "cap", "heartsHeadband", "strawHat"] {+ UserDefaults.standard.set(removed, forKey: "mochiOutfit")+ check("'\(removed)' stored → .auto", Outfit.stored == .auto)+ }++ print("Outfit.stored unknown → auto")+ UserDefaults.standard.set("totallyUnknown", forKey: "mochiOutfit")+ check("unknown → .auto", Outfit.stored == .auto)+ UserDefaults.standard.removeObject(forKey: "mochiOutfit")+ check("missing → .auto", Outfit.stored == .auto)++ if failures == 0 { print("\nAll tests passed.") }+ else { print("\n\(failures) test(s) FAILED."); exit(1) }+ }+}