fisheye-motion
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseFisheye Motion(鱼眼畸变 + 摩尔纹 + 暗角)
Fisheye Motion (Fisheye Distortion + Moiré + Vignette)
把一张图片(或视频)做成「用手机拍屏幕」的质感:以聚焦点为中心的桶形鱼眼畸变、
跟随画面弯曲的扫描线与固定屏幕扫描线干涉出的摩尔纹、四周暗角;
并可输出「推镜聚焦到目标区域 + 黄色标注块从左滑入」的 Remotion 视频。
Turn an image (or video) into the feel of “photographing a screen with a phone”: barrel fisheye distortion centered on the focus point, scanlines that follow the curvature of the image interfering with fixed screen scanlines to create moiré, and vignetting around the edges. It can also output a Remotion video featuring a “push-in focus onto a target area + yellow annotation block sliding in from the left.”
工作流程
Workflow
本 skill 不内置代码,所有实现都在独立仓库里。第一步永远是 clone 项目:
bash
git clone https://github.com/vibe-motion/fisheye-motion.git
cd fisheye-motion仓库结构:
- 根目录:Vite + React 交互测试应用(拖图、点击/拖动移动聚焦、导出 PNG)
- :与框架无关的 WebGL 渲染器(核心,全部效果的 shader 在这里)
src/lib/FisheyeRenderer.js - :React 组件封装
src/lib/FisheyeView.jsx - :Remotion 项目,输出聚焦推镜 + 标注滑入的视频
vibe-motion-app/
然后根据用户需求走两条路之一。
This skill does not include code; all implementations reside in a standalone repository. The first step is always to clone the project:
bash
git clone https://github.com/vibe-motion/fisheye-motion.git
cd fisheye-motionRepository structure:
- Root directory: Vite + React interactive test app (drag an image, click/drag to reposition the focus, export PNG)
- : framework-agnostic WebGL renderer (the core; all effect shaders are here)
src/lib/FisheyeRenderer.js - : React component wrapper
src/lib/FisheyeView.jsx - : Remotion project that outputs focus push-in + annotation slide-in videos
vibe-motion-app/
Then follow one of two paths depending on the requirements.
路线 A:静态效果 / 交互预览(Vite 应用)
Path A: Static Effects / Interactive Preview (Vite App)
bash
npm install
npm run dev- 默认加载 ;把用户的图放进
public/test.jpg或直接拖入页面。public/ - 点击/拖动画面改变聚焦(畸变中心);「导出 PNG」保存当前效果帧。
- 要在自己的 React 项目里复用,直接拷 两个文件,用法见仓库 README。
src/lib/
bash
npm install
npm run dev- Loads by default; place the user's image in
public/test.jpgor drag it directly onto the page.public/ - Click/drag the image to change the focus (distortion center); “Export PNG” saves the current effect frame.
- To reuse it in your own React project, copy the two files in directly; see the repository README for usage.
src/lib/
路线 B:视频输出(Remotion 项目)
Path B: Video Output (Remotion Project)
bash
cd vibe-motion-app
pnpm install # postinstall 自动准备 headless 浏览器
pnpm run dev # Remotion Studio 预览- 把用户的源图放到 下。
vibe-motion-app/public/ - 改 :
motion/config.js- :public 下的文件名
imageSrc - /
videoWidth:按源图等比取偶数尺寸videoHeight - →
focusFrom:聚焦推镜起止点(0..1 源图坐标,y 向下)focusTo - :标注块位置
rect(0..1 源图坐标)、颜色、混合模式{ x, y, w, h } - 时间轴:(推镜段)、
focusStartSec/focusEndSec(标注滑入段)、maskStartSec/maskEndSecdurationSeconds
- 渲染:
bash
undefinedbash
cd vibe-motion-app
pnpm install # postinstall 自动准备 headless 浏览器
pnpm run dev # Remotion Studio 预览- Place the user's source image under .
vibe-motion-app/public/ - Modify :
motion/config.js- : filename under
imageSrcpublic - /
videoWidth: even dimensions proportional to the source image's aspect ratiovideoHeight - →
focusFrom: starting and ending points of the focus push-in (0..1 source-image coordinates, with y pointing downward)focusTo - : annotation block position
rect(0..1 source-image coordinates), color, and blend mode{ x, y, w, h } - Timeline: (push-in segment),
focusStartSec/focusEndSec(annotation slide-in segment), andmaskStartSec/maskEndSecdurationSeconds
- Render:
bash
undefined透明 ProRes 4444 mov(默认)
透明 ProRes 4444 mov(默认)
pnpm run remotion:render
pnpm run remotion:render
H.264 mp4
H.264 mp4
REMOTION_OUTPUT=out/fisheye.mp4 REMOTION_CODEC=h264 REMOTION_PIXEL_FORMAT=yuv420p pnpm run remotion:render
4. 需要 GIF 预览时用 ffmpeg 转:
```bash
ffmpeg -i out/fisheye.mp4 -vf "fps=15,scale=540:-1:flags=lanczos,palettegen" /tmp/p.png
ffmpeg -i out/fisheye.mp4 -i /tmp/p.png -lavfi "fps=15,scale=540:-1:flags=lanczos[x];[x][1:v]paletteuse=dither=bayer:bayer_scale=4" out/fisheye.gifREMOTION_OUTPUT=out/fisheye.mp4 REMOTION_CODEC=h264 REMOTION_PIXEL_FORMAT=yuv420p pnpm run remotion:render
4. When a GIF preview is needed, convert it with ffmpeg:
```bash
ffmpeg -i out/fisheye.mp4 -vf "fps=15,scale=540:-1:flags=lanczos,palettegen" /tmp/p.png
ffmpeg -i out/fisheye.mp4 -i /tmp/p.png -lavfi "fps=15,scale=540:-1:flags=lanczos[x];[x][1:v]paletteuse=dither=bayer:bayer_scale=4" out/fisheye.gif定位目标区域(rect / focusTo)
Locating the Target Area (rect / focusTo)
用户通常会说「聚焦到 XX 文字/按钮上」。定位方法:
- 用多模态视觉读源图,估计目标区域的 0..1 归一化坐标(y 向下)。
- 取该区域中心;
focusTo框住目标,稍留 padding。rect - 渲染一帧检查(Studio 里拖时间轴,或 配合单帧渲染), 不准就微调坐标重来。畸变会弯曲画面,最终以渲染结果为准。
REMOTION_OUTPUT=out/check.png
Users will typically say “focus on the XX text/button.” To locate it:
- Use multimodal vision to inspect the source image and estimate the target area's normalized coordinates (0..1, with y pointing downward).
- Set to the center of that area; use
focusToto enclose the target, leaving a little padding.rect - Render a frame for inspection (drag the timeline in Studio, or use with single-frame rendering). If it is inaccurate, adjust the coordinates and try again. Distortion bends the image, so the final rendered result is authoritative.
REMOTION_OUTPUT=out/check.png
参数速查
Parameter Quick Reference
| 参数 | 默认 | 说明 |
|---|---|---|
| 1.6 | 畸变强度,0 = 无畸变, |
| 2 | 中心缩放(配合聚焦推镜) |
| | 摩尔纹强度/频率/角度 |
| | 暗角 |
| | 深色底图白字用 |
| Parameter | Default | Description |
|---|---|---|
| 1.6 | Distortion strength; 0 = no distortion, |
| 2 | Center zoom (used with the focus push-in) |
| | Moiré intensity/frequency/angle |
| | Vignette |
| | Use |
注意事项
Notes
- Remotion 并行/乱序渲染帧,动画量必须每帧独立计算——已由 保证, 改动画逻辑时保持这一约束,不要引入跨帧状态。
motion/timeline.js - 场景用 WebGL shader,headless 渲染需要 ,渲染脚本已默认设置。
--gl angle - 视觉效果非必要不跑自动化验证,渲染后目测(或发关键帧给用户确认)。
- Remotion renders frames in parallel and out of order, so animation values must be calculated independently for every frame. This is already guaranteed by ; preserve this constraint when changing the animation logic and do not introduce cross-frame state.
motion/timeline.js - Scenes use a WebGL shader, and headless rendering requires . The rendering script sets this by default.
--gl angle - For visual effects, avoid running automated validation unless necessary. Visually inspect the result after rendering, or send keyframes to the user for confirmation.
效果示例
Example
聚焦推镜到「浙大」二字并滑入黄色标注():
<img src="assets/fisheye-demo.gif" alt="fisheye focus demo" width="480" />assets/fisheye-demo.gifFocus push-in onto the “Zhejiang University” text and slide in a yellow annotation ():
<img src="assets/fisheye-demo.gif" alt="fisheye focus demo" width="480" />assets/fisheye-demo.gif