# 第 37 章示例 · 动画 弹簧的可测试进度(`Spring.value`)、隐式与显式动画、相位枚举、进度条与弹簧曲线截图、`matchedGeometryEffect` 的命名空间约束。 ## 运行 swift run Ch37Demo # 命令行演示 + 输出快照 swift run Ch37App # 打开可交互窗口(展开卡片、进度条) ## 验证 swift test # 14 个测试 ./run.sh # build + test + 快照比对 ## 截图 SHOTS_DIR=shots swift run Ch37Demo # 写出 shots/animation-board.png `swift test` 的截图测试会生成四张(已存在则跳过): | 文件 | 场景 | | --- | --- | | `shots/animation-board.png` | 弹簧曲线/进度/相位(720×540) | | `shots/animation-expand.png` | 展开卡片关键帧(640×约 180) | | `shots/animation-progress.png` | 进度条 60%(640×约 70) | | `shots/animation-spring.png` | 弹簧曲线(640×220) | ## 结构 | 文件 | 对应小节 | 说明 | | --- | --- | --- | | `Sources/Ch37Kit/Animation.swift` | 37.1–37.4 | `SpringProbe` / `Phase` / `ExpandingCard` / 曲线 | | `Sources/Ch37Demo/App.swift` | 37.2 / 37.5 | 数值输出与截图 | ## 已知限制 动画的视觉效果依赖真实运行循环,`ImageRenderer` 只截取某一帧;弹簧数值由 `Spring` 的纯函数验证,视图动画需要在 App 里手测。