AgentSkillsCN

orb

【做什么】构建动画 SwiftUI 圆球——模仿 Siri 风格的网格渐变、粒子球,以及 AI 助手可视化界面。 【如何】运用 7 种合成技术(网格渐变、Canvas 粒子、Metal 着色器、图层旋转、角形辉光、色调偏移、动画遮罩),结合代码模式与性能规范。 【何时】适用于构建或修改动画圆球 UI、语音聊天可视化界面、AI 思维指示器、Siri 风格的辉光效果、粒子特效,或 Kingly Clawd 头像时使用。 【为什么】动画圆球需要精准的图层叠加、60fps 的性能预算、无障碍合规性,以及跨平台(iOS/macOS)的一致性。这项技能凝聚了久经考验的实战经验与模式。 触发条件:“圆球”、“Siri 动画”、“网格渐变”、“语音可视化”、“粒子球”、“辉光效果”、“动画渐变”、“MeshGradient”、“Canvas 动画”、“TimelineView”、“OCMiniOrb”、“Clawd 圆球”、“Kaaba”、“钻石圆球”、“涟漪效果”、“音频反应”

SKILL.md
--- frontmatter
name: orb
description: |
  [WHAT] Build animated SwiftUI orbs — Siri-style mesh gradients, particle spheres, and AI assistant visualizers.
  [HOW] 7 compositing techniques (MeshGradient, Canvas particles, Metal shaders, layer rotation, angular glow, hue-shift, animated masks) with code patterns and performance rules.
  [WHEN] Use when building or modifying animated orb UIs, voice chat visualizers, AI thinking indicators, Siri-style glows, particle effects, or the Kingly Clawd avatar.
  [WHY] Animated orbs require precise layering, 60fps budgets, accessibility compliance, and cross-platform (iOS/macOS) consistency. This skill encodes battle-tested patterns.

  Triggers: "orb", "siri animation", "mesh gradient", "voice visualizer", "particle sphere", "glow effect", "animated gradient", "MeshGradient", "Canvas animation", "TimelineView", "OCMiniOrb", "Clawd orb", "kaaba", "diamond orb", "ripple effect", "audio reactive"
triggers:
  - orb animation
  - siri clone
  - mesh gradient
  - voice visualizer
  - particle sphere
  - glow shadow
  - animated orb
  - canvas particle
  - metal shader ripple
  - audio reactive UI

Orb — Animated SwiftUI Visualizer Skill

Decision Tree

code
What are you building?
|
|-- Modify existing OCMiniOrb?
|   |-- Add/change state? -> See: Existing Implementation
|   |-- Tune layers? -> See: references/existing-impl.md
|   \-- Add audio reactivity? -> Bind audioLevel to scaleEffect
|
|-- New orb variant?
|   |-- Siri iOS 18 style (edge glow)? -> T1: MeshGradient + T2: AnimatedRectangle mask
|   |-- Classic Siri (layered rotation)? -> T3: Layer rotation with Figma assets
|   |-- Particle sphere (Jarvis)? -> T6: 3D particle system in Canvas
|   |-- Kaaba/Diamond? -> See: references/variants.md
|   \-- Glow button shadow? -> T7: Angular gradient + blur
|
|-- Performance issue?
|   |-- Dropped frames? -> Check: fractal conditional removal, Canvas vs SwiftUI shapes
|   |-- High CPU idle? -> Ensure TimelineView pauses when not visible
|   \-- Memory growth? -> Check particle pool / recycle bin pattern
|
\-- Accessibility?
    \-- .accessibilityReduceMotion -> guard !reduceMotion else { return }

Quick Reference: 7 Techniques

#TechniqueAPIBest ForRef
T1MeshGradientMeshGradient(width:height:points:colors:)Siri iOS 18 edge glowreferences/techniques.md#t1
T2AnimatedRectangleCustom Shape + animatableDataBreathing border maskreferences/techniques.md#t2
T3Layer RotationZStack + .rotationEffect + .hueRotationClassic Siri iconreferences/techniques.md#t3
T4Hue-Shift GradientTimelineView + shiftHue()Color cycling backgroundsreferences/techniques.md#t4
T5Metal RippleShaderLibrary.Ripple + .layerEffectTap/activation ripplereferences/techniques.md#t5
T63D Particle SphereCanvas + sphere projection mathJarvis orb, particle cloudsreferences/techniques.md#t6
T7Angular GlowAngularGradient + .blurButton glow shadowsreferences/techniques.md#t7

Existing Implementation (OCMiniOrb)

Path: packages/uikit/Sources/OCDesignKit/Components/OCMiniOrb.swift Storybook: apps/storybook/Sources/Shared/MiniOrbPage.swift Spec: docs/ux/orb/mini-clawd-spec.md

6-layer stack in ZStack:

LayerWhatHow
1. Ambient GlowRadialGradient + .blur(size*0.25)Opacity pulse 0.2-0.35, 2s
2. Base OrbRadialGradient circleBreathe 0.98-1.02, 3s; audio in speaking
3. FractalCanvas + TimelineView(1/30fps)6 Fibonacci rings, conditional on state
4. GlassRadialGradient + .ultraThinMaterialStatic 0.85x
5. Smoke4 orbiting blobs in Canvas3-6s rotation per blob
6. Eyes2 white circlesDim to 0.4 in thinking

States: OrbDisplayState.idle, .thinking, .speaking, .listening Colors: OCColors.voiceOrb{State}Start/End, .voiceHighlight, .voiceParticle

Performance Rules (NON-NEGOTIABLE)

  1. Canvas over shapes — Use Canvas for particle systems (single draw call per layer)
  2. Conditional hierarchy — Remove fractal/smoke from view tree when idle: if state == .thinking { ... }
  3. 30fps capTimelineView(.animation(minimumInterval: 1.0 / 30.0))
  4. Reduce motion@Environment(\.accessibilityReduceMotion) guards ALL animation starts
  5. Pool particles — Recycle bin pattern (linked list, not array append/remove)
  6. No SpriteKit — Pure SwiftUI + Canvas + optional Metal
  7. Target — 60fps at 48pt on iPhone 12 / M1 Mac

Compositing Recipe: New Orb

swift
// Minimal orb skeleton
struct MyOrb: View {
    let state: OrbDisplayState
    var size: CGFloat = 48
    @Environment(\.accessibilityReduceMotion) private var reduceMotion

    var body: some View {
        ZStack {
            // 1. Glow (always)
            Circle().fill(RadialGradient(...)).blur(radius: size * 0.25)
            // 2. Base (always)
            Circle().fill(RadialGradient(...)).scaleEffect(breatheScale)
            // 3. Active layers (conditional)
            if state != .idle {
                activeLayer(size)  // Canvas-based
            }
            // 4. Glass (always)
            Circle().fill(...).background(.ultraThinMaterial.opacity(0.15))
            // 5. Highlights (always)
            eyeDots(size)
        }
        .frame(width: size * 1.3, height: size * 1.3)
        .accessibilityLabel("Assistant \(state.label)")
    }
}

Key Helper: sinInRange

swift
func sinInRange(_ range: ClosedRange<Float>, offset: Float, timeScale: Float, t: Float) -> Float {
    let amplitude = (range.upperBound - range.lowerBound) / 2
    let midPoint = (range.upperBound + range.lowerBound) / 2
    return midPoint + amplitude * sin(timeScale * t + offset)
}

Used by MeshGradient (T1) and AnimatedRectangle (T2) for organic motion.

References

FileContent
references/techniques.mdFull code for all 7 techniques with copy-paste patterns
references/existing-impl.mdOCMiniOrb layer-by-layer analysis, modification guide
references/variants.mdKaaba/Diamond, particle sphere, mesh orb variant specs

External Sources

Related Skills

  • pencil — Visual design prompts and character art for orb avatars (concept → prompt)
  • swiftui-animation — General SwiftUI animation patterns (broader scope)
  • swiftui-performance-audit — Runtime perf diagnostics (when orb causes frame drops)

Technique Map

  • 6-layer ZStack compositing — Ambient glow, base orb, fractal (conditional), glass, smoke, eyes; because layering order determines visual hierarchy and performance.
  • Canvas over shapes for particles — Single draw call per layer; because SwiftUI shapes = many draw calls; Canvas = one.
  • Conditional hierarchy — Remove fractal/smoke when idle; because redundant layers drain GPU when not visible.
  • 30fps cap for TimelineView — minimumInterval: 1.0/30.0; because 60fps for decorative layers wastes budget.
  • Reduce motion guard — @Environment(.accessibilityReduceMotion) on ALL animation; because accessibility compliance is non-negotiable.
  • sinInRange helper — Organic motion for MeshGradient and AnimatedRectangle; because procedural variation feels more natural than linear.
  • Pool particles — Recycle bin pattern, not array append/remove; because mid-frame allocation causes frame drops.

Technique Notes

7 techniques: T1 MeshGradient, T2 AnimatedRectangle, T3 layer rotation, T4 hue-shift, T5 Metal ripple, T6 particle sphere, T7 angular glow. OCMiniOrb path: OCDesignKit/Components/OCMiniOrb.swift. Target: 60fps at 48pt on iPhone 12.


Prompt Architect Overlay

Role Definition: Animated SwiftUI orb builder. Siri-style mesh gradients, particle spheres, AI assistant visualizers. Encodes 7 compositing techniques with performance rules and accessibility compliance.

Input Contract: Accepts orb variant (Siri iOS 18, classic Siri, particle sphere, Kaaba/Diamond), modification target (existing OCMiniOrb or new), or performance issue. State (idle/thinking/speaking/listening) if modifying existing.

Output Contract: Layer-by-layer compositing recipe, technique references, performance rules checklist. SwiftUI code snippets. Accessibility labels. References to techniques.md, existing-impl.md, variants.md.

Edge Cases & Fallbacks: If frame drops→check conditional hierarchy, Canvas vs shapes, particle count. If modify OCMiniOrb→reference existing-impl.md. If audio reactive→bind audioLevel to scaleEffect. If Metal needed→orb skill T5; metal-shaders for MSL.