reverse-engineer-animation
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseReverse Engineer Animation
逆向工程动画
Measure motion that already exists in a recording, then reproduce it. This is the forensic
counterpart to the skill (which prescribes how motion should be designed).
ui-animation测量录制视频中已有的运动效果,然后进行重现。这是技能的逆向分析对应技能(技能规定了运动效果应该如何设计)。
ui-animationui-animationReference files
参考文件
| File | Read when |
|---|---|
| references/measurement-guide.md | Deciding what to measure, eye vs script, reading |
| references/curve-fitting.md | Reading |
| references/code-output.md | Emitting code for CSS, Motion/Framer Motion, SwiftUI, React Native, or UIKit |
| references/choreography.md | Multi-element / multi-phase motion: staggers, blur-before-move, per-edge settling |
| 文件 | 阅读时机 |
|---|---|
| references/measurement-guide.md | 决定测量内容、人工目测 vs 脚本分析、读取 |
| references/curve-fitting.md | 读取 |
| references/code-output.md | 生成CSS、Motion/Framer Motion、SwiftUI、React Native或UIKit代码 |
| references/choreography.md | 多元素/多阶段运动:交错动画、移动前模糊、逐边缘稳定 |
Dependencies
依赖项
- — frame extraction (
ffmpeg). Required for step 1.brew install ffmpeg - Python: — tracking + curve fitting (steps 4).
pip install opencv-python numpy scipy
Extraction degrades gracefully: with only ffmpeg you can still extract frames and reason
visually. Tracking and fitting need the Python packages.
- — 帧提取(执行
ffmpeg安装)。步骤1必需。brew install ffmpeg - Python: — 运动跟踪 + 曲线拟合(步骤4)。
pip install opencv-python numpy scipy
提取功能具备降级兼容性:仅安装ffmpeg时,仍可提取帧并进行视觉分析。跟踪与拟合功能需要上述Python包。
Workflow
工作流程
Copy and track this checklist:
text
Reverse-engineer progress:
- [ ] Step 1: Extract frames + contact sheet
- [ ] Step 2: Vision pass — identify element, effects, phases
- [ ] Step 3: Decide precision (eye-only vs scripted)
- [ ] Step 4: Track motion and fit curves (if escalating)
- [ ] Step 5: Annotate choreography (delays, asymmetry)
- [ ] Step 6: Emit code for the target(s)
- [ ] Step 7: Validate against the recording复制并跟踪以下检查清单:
text
Reverse-engineer progress:
- [ ] Step 1: Extract frames + contact sheet
- [ ] Step 2: Vision pass — identify element, effects, phases
- [ ] Step 3: Decide precision (eye-only vs scripted)
- [ ] Step 4: Track motion and fit curves (if escalating)
- [ ] Step 5: Annotate choreography (delays, asymmetry)
- [ ] Step 6: Emit code for the target(s)
- [ ] Step 7: Validate against the recordingStep 1: Extract frames
步骤1:提取帧
Run (add for very
slow clips). On a multi-second recording, trim to just the transition with
— extracting the whole clip floods the contact sheet
and dilutes tracking. Open the generated first — it shows the whole
window at once.
python3 scripts/extract_frames.py <video> <outdir>--fps N--start SECONDS --duration SECONDScontact_sheet.png执行 (针对极慢片段可添加参数)。对于时长较长的录制视频,使用参数仅裁剪过渡部分——提取整个视频会导致联系表内容过多,降低跟踪效率。先打开生成的文件,它会一次性展示整个窗口的帧内容。
python3 scripts/extract_frames.py <video> <outdir>--fps N--start SECONDS --duration SECONDScontact_sheet.pngStep 2: Vision pass
步骤2:视觉分析
View the contact sheet and name, in order:
- The element(s) that move.
- Every effect present — translate, scale (often anisotropic), opacity, blur, corner
radius, shadow, color. Use the property checklist in .
references/measurement-guide.md - The phases — e.g. backdrop blurs in, element tucks under the notch, over-stretches, then settles per-edge. Note which property leads and which lags.
查看联系表,并按顺序确认:
- 运动的元素。
- 所有存在的效果——平移、缩放(通常为各向异性)、透明度、模糊、圆角、阴影、颜色。可参考中的属性检查清单。
references/measurement-guide.md - 动画阶段——例如背景模糊出现、元素隐藏至缺口下方、过度拉伸、然后逐边缘稳定。记录哪些属性先启动,哪些滞后。
Step 3: Decide precision
步骤3:确定精度等级
- Simple fade or linear slide → read timing off the contact sheet and skip to step 5.
- Elastic, springy, or multi-property motion → escalate to step 4. Eyeballing a spring is unreliable.
- 简单淡入淡出或线性滑动 → 从联系表读取时间,直接跳至步骤5。
- 弹性、弹簧效果或多属性运动 → 升级至步骤4。目测弹簧效果的误差较大。
Step 4: Track and fit
步骤4:跟踪与拟合
Run → . Pass
to isolate one element when several move (one bbox per element). Then run
→ spring params, cubic-bezier, and a
fit error per property. Read to interpret the numbers and
pick the model. High error on both models means multi-phase motion — split the timeline
and fit each segment.
python3 scripts/track_motion.py <outdir>metrics.json--bbox X,Y,W,Hpython3 scripts/fit_curves.py <outdir>/metrics.jsonreferences/curve-fitting.md执行 → 生成。当多个元素运动时,传递参数以隔离单个元素(每个元素对应一个bbox)。然后执行 → 生成弹簧参数、三次贝塞尔曲线,以及每个属性的拟合误差。阅读以解读数值并选择模型。两种模型均出现高误差意味着存在多阶段运动——拆分时间轴并分别拟合每个片段。
python3 scripts/track_motion.py <outdir>metrics.json--bbox X,Y,W,Hpython3 scripts/fit_curves.py <outdir>/metrics.jsonreferences/curve-fitting.mdStep 5: Annotate choreography
步骤5:标注动画编排逻辑
Load . Build the timing-offset table (when each property starts
and settles) — those lead/lag gaps and the over-stretch carry more of the feel than any
single curve.
references/choreography.md打开。构建时间偏移表(每个属性的启动与稳定时间)——这些领先/滞后间隔以及过度拉伸效果对动画质感的影响,比单一曲线更大。
references/choreography.mdStep 6: Emit code
步骤6:生成代码
Substitute the fitted parameters into the templates in for the
requested target. Keep movement on /. Emit two transitions when
open and close differ. Produce the consolidated handoff motion spec (timing table +
curves + snippet) from so the result can be implemented without
the video.
references/code-output.mdtransformopacityreferences/code-output.md将拟合参数代入中对应目标平台的模板。仅在/属性上实现运动效果。当展开与收起动画不同时,生成两组过渡代码。根据生成整合的移交运动规范(时间表 + 曲线 + 代码片段),以便无需原视频即可实现该动画。
references/code-output.mdtransformopacityreferences/code-output.mdStep 7: Validate
步骤7:验证
See Validation below.
参见下方验证部分。
Asymmetric open/close
非对称展开/收起动画
Open and close are almost never mirror images — open tends to be slower and springier,
close faster and flatter. Measure each direction separately (record or trim two clips
and run the pipeline on each). Report two curves; never reuse the open curve reversed.
展开与收起动画几乎不会是镜像效果——展开通常更慢、弹簧感更强,收起则更快、更平缓。分别测量两个方向(录制或裁剪两个片段,并对每个片段运行流程)。输出两组曲线;切勿直接复用反向的展开曲线。
Anti-patterns
反模式
- Fitting one global curve to multi-phase motion — split into phases and compose keyframes.
- Tracking only position and ignoring blur/opacity — those usually lead the move and are where the polish lives.
- Assuming symmetric open/close — measure both directions.
- Reporting spring params without checking the fit error — a bad fit gives confident-looking but wrong numbers.
- Emitting code that animates layout props (,
width,height,top) — reproduce the motion onleft/transform(defer toopacityrules).ui-animation - Re-reading a script to reconstruct its logic instead of running it — the scripts are the canonical, deterministic path.
- 用单一全局曲线拟合多阶段运动——拆分为多个阶段并组合关键帧。
- 仅跟踪位置而忽略模糊/透明度——这些效果通常先于位置移动,是动画精致感的关键。
- 假设展开与收起动画对称——需测量两个方向。
- 未检查拟合误差就报告弹簧参数——拟合效果差会产生看似可信但错误的数值。
- 生成动画布局属性(、
width、height、top)的代码——应在left/transform上重现运动效果(遵循opacity规则)。ui-animation - 重新阅读脚本以重构逻辑而非直接运行脚本——脚本是标准化、确定性的执行路径。
Validation
验证
- Re-derive: play the emitted animation, screen-record it, run it back through
, and compare contact sheets side-by-side with the original.
extract_frames.py - Slow to 0.1x in DevTools to confirm phase order (lead/lag) and the over-stretch survive.
- Confirm the emitted code only animates ,
transform, andopacity.filter - Sanity-check fitted spring /
overshootagainst what you saw — a clear bounce must not fit as a flat ease.zeta
- 重新推导:播放生成的动画,录制屏幕,将其重新传入,并将联系表与原视频的联系表并排对比。
extract_frames.py - 在DevTools中将速度调至0.1x,确认阶段顺序(领先/滞后)和过度拉伸效果得以保留。
- 确认生成的代码仅对、
transform和opacity属性执行动画。filter - 对照视觉效果 sanity-check 拟合的弹簧/
overshoot参数——明显的弹跳效果不能拟合为平缓的缓动曲线。zeta
Related skills
相关技能
- — turn the extracted spec into production-grade, interruptible motion and apply its easing defaults and anti-pattern rules.
ui-animation
- ——将提取的规范转换为生产级、可中断的运动效果,并应用其缓动默认值与反模式规则。
ui-animation