# animated-sketch-diagram

Adopt this skill: https://proskills.md/skills/other/iflytek-ifly-skills-skills-animated-sketch-diagram

Page: https://proskills.md/skills/other/iflytek-ifly-skills-skills-animated-sketch-diagram
This document is the public skill bundle for that page. It contains SKILL.md and every helper file the catalog carries. No login is required.

## File: skills/animated-sketch-diagram/SKILL.md
size: 8386
sha: 8a1fa4587a4e5ddba4b9803d0e1046ca056b3e9c
upstream: https://github.com/iflytek/ifly-skills/blob/main/skills/animated-sketch-diagram/SKILL.md

````text
---
name: animated-sketch-diagram
description: 生成"黑墨手绘涂鸦"风格的动画架构图/流程图：米色纸面、针管笔墨线、极淡水洗色块、简笔涂鸦图标、序号章、连线上的流动圆点动画、图标微动效。产出单文件自包含动画 HTML（SVG+CSS），可一键导出无缝循环 GIF。当用户想画架构图、流程图、信息图、技术示意图、对比图、pipeline/workflow 可视化，或提到"手绘风""涂鸦风""动图""animated diagram""GIF 架构图"时使用；即使用户没明说要动画，做技术概念科普配图时也应优先考虑本 skill。
metadata: {
  "homepage": "https://github.com/OLDyade/animated-sketch-diagram",
  "openclaw": "{\"emoji\": \"✏️\", \"dimensions\": [\"手绘动画架构图\", \"图表可视化\"], \"user_instructions\": [\"帮我画一张架构图动图\", \"画一张手绘风流程图\", \"把这个概念画成动画示意图\"], \"requires\": {\"bins\": [\"node\", \"ffmpeg\"]}}"
}
---

# Animated Sketch Diagram（手绘涂鸦风动画信息图）

产出一张像资深工程师在牛皮笔记本上手绘的系统图：米色纸面、黑墨抖动描边、
极淡水洗色块、简笔涂鸦图标（小人/文档/纸箱/月亮）、序号章、✦ 点缀，
连线上有小圆点沿路径流动、图标带微动效，整体 3s 无缝循环。

**产物**：一个自包含 HTML 文件（内联 SVG + CSS 动画 + base64 字体，双击即可播放）；
需要 GIF 时用 `scripts/render-gif.mjs` 逐帧录制。

## 工作流

### 1. 先规划内容，再动笔

**版式跟着内容的天然形状走，不要反过来。** 先判断主题本身长什么样，再选版式原型：

| 内容的天然形状 | 版式原型 |
|---|---|
| N 个并列的类别/方案/阶段，各自内部有流程 | 横向色带 band（左侧标签栏 + 右侧流程画布） |
| 自上而下的分层架构（前端→服务→存储） | 纵向层叠：全宽色层堆叠，跨层竖直连线 |
| 一个核心与多个卫星（hub-and-spoke） | 径向：中心 mascot 大圆 + 环绕节点 + 放射连线 |
| 两三个东西逐维度对比 | 并排色柱/矩阵，同一行是同一维度 |
| 单一主流程 | 不用色带，一条蛇形/折线主轴铺满画布 |
| 时间演进 | 横向时间轴 + 上下交错的事件卡 |

原型可以混搭（如 band 内部径向）。所有原型共用同一套元件：

- **区块（region）**：一级分区的圆角水洗色块，左上序号章 + 顶部居中标题；相邻区块换色。
- **内卡（node）**：纸白小卡片 = 简笔涂鸦图标 + 手写标签，一个区块内 3~6 个为宜；
  "文档/列表"用折角纸 + 三两行短横线速记，"一叠"用偏移副本。
- **连线（edge)**：微弯曲线箭头，线上可挂小字标签。**拓扑跟内容走**：分支、汇聚、
  往返、回环、跨区块长弧、环形轨道都是一等公民，不要把图默认摆成单向流水线——
  内容里有循环/转向，图上就要画出来并让圆点沿它转。实线/虚线只表达"确定/弱、
  数据面/控制面"这类强弱语义，不是"主流程/回环"的分工。
- **点缀件**：虚线引用框（放命令/示例）、简笔小人、✦ 火花、中央手写口号。

**规划的最后一步是编排流动**：动画不是装饰，是把主题里"什么在流动"讲出来。
先用一句话回答——这张图里流动的是什么（数据？请求？记忆？任务？），
它从哪来、经过谁、在哪分叉、在哪转圈、最后到哪去——再把这条"流动脚本"
落成路径：该分支就分支、该汇聚就汇聚、该循环就让圆点沿弧转回去。
主题本身是环（飞轮、迭代、生命周期）→ 图的动线就该是环；
主题是发散/收敛（一发多、多合一）→ 动线就该扇形展开/合拢。
看成品时"流动的形状"应该能复述出主题的结构，全图只有一排同向箭头
通常说明流动没规划，不是主题真的这么直。

内容永远来自用户的主题。不要照搬任何示例里的文字、节点名或结构；
示例里的"三条横带"只是原型之一，不是本 skill 的固定输出形状。

### 2. 反问图标来源（交互场景必做）

动笔前用 AskUserQuestion 问一次图标怎么来（用户此前已表态或本次已指定的不重复问）：

1. **生图模型生成**（质感最像真手绘）——选这个就先做工具发现：当前环境有生图
   skill/MCP/工具就直接用；没有就请用户提供生图 API。生成时统一约束提示词：
   黑墨简笔涂鸦、单一线宽、纸色/透明底、无阴影；产物转 data URI 用 `<image>` 内嵌，
   尺寸对齐 token，不引外部 URL。
2. **自己设计 SVG 简笔图标**（默认推荐，零依赖）——按 recipes §4 的涂鸦配方就地画。
3. **网上搜现成素材**——找 CC0/开源手绘图标（如 tabler、handdrawn 系列），
   下载 SVG 后统一改成 ink 色和 2px 线宽再内嵌，风格必须归一。

无头/非交互/子代理场景不要卡在提问上：直接用方案 2。

### 3. 读风格系统

读 `references/style-guide.md` —— 调色板、字体、描边、圆角、间距、动画节奏的全部 token。
风格的辨识度来自 token 的组合，务必按 token 来，不要自由发挥配色。

### 4. 读代码配方，组装 HTML

读 `references/svg-recipes.md` —— 面板、节点、箭头、流动圆点、图标微动效、标题高亮
的可复制 SVG/CSS 模式。按配方组装出**一个** HTML 文件。

关键约束（导出 GIF 依赖这些）：

- 只用 **CSS 动画**（`@keyframes` + `offset-path`），不用 SMIL `<animate>`，
  不用 JS 驱动动画 —— 录制脚本靠 `document.getAnimations()` 逐帧定格。
- 所有 `animation-duration` 必须能整除全局循环时长 `--loop`（默认 3000ms），
  且 `infinite` 循环，这样 GIF 首尾无缝。
- 字体用 base64 内联（命令见 recipes），保证文件自包含、离线可开。

### 5. 导出 GIF

**GIF 是主要交付物**（HTML 只是源），写完 HTML 就导：

```bash
cd ~/.claude/skills/animated-sketch-diagram/scripts
npm install          # 仅第一次
node render-gif.mjs /path/to/diagram.html /path/to/diagram.gif
```

脚本自动找本机 Chrome/Chromium，逐帧截图后 ffmpeg 合成（需要 ffmpeg）。
参数：`--fps 25 --loop 3000 --scale 2`——**scale 保持 2**，1x 的 GIF 文字发糊。

### 6. 自检-修正循环（必做，产完不算完）

审查对象是**导出的 GIF**，不是 HTML：从 GIF 里抽 2~3 个间隔帧
（`ffmpeg -i x.gif -vf "select='not(mod(n,25))'" -vsync 0 f%d.png`），
用 Read 看图，逐项过：

- **清晰度**：文字边缘干净可读，没有糊化/噪点（糊 = scale 忘了 2 或被后期缩放）
- **排版**：内容撑满区块（两侧无大白边）、区块高度贴内容、眯眼看墨色分布均匀无"成片空白"
- **动画**：对比两帧，圆点位移明显（速度感）、微动效在动；播放确认循环无接缝、
  流动"一眼可见"而不是要凑近找
- **流动编排**：流动的形状能复述主题结构（有分叉/汇聚/回环的主题，动线也有），
  不是一排同向平行线
- **风格**：手绘抖动生效、箭头贴节点边缘、文字无溢出、中文字体正确
- **内容**：节点/连线/标签与规划一一对应，无错别字

**发现任何一项不合格：改 → 重渲 → 重看，直到全过。** 至少完整跑一轮这个循环才能交付；
交付时把 GIF 和 HTML 一起给出，并注明尺寸/帧数/文件大小。

## 质量红线

- 构图要"密"：区块尺寸贴内容，每个区块必须有一叠纸/小人/回环/标注框等非线性元素，
  连线挂标签——细则见 style-guide.md 的"构图密度"。一排等宽盒子加箭头 = 不合格。
- 区块之间 24px+，节点间 36px+；密不等于挤。
- 全图基本单色墨：彩色只出现在水洗底色和流动圆点上，文字图标一律 ink。
- 一个区块一种水洗色；相邻区块换色。
- 手写体只用于图内文字；代码/命令片段用等宽字体放引用框里。
- 动画是点缀不是主角，但必须"一眼可见"：圆点小（r≈4.5）而速度要跟上
  （80~150px/s，见 style-guide 动画节奏），微动效幅度小。
````

## File: skills/animated-sketch-diagram/assets/fonts-cn/README.md
size: 500
sha: 82825c1073ca0640e26fb647c439d6c66ce89d98
upstream: https://github.com/iflytek/ifly-skills/blob/main/skills/animated-sketch-diagram/assets/fonts-cn/README.md

````text
# CJK font (downloaded on demand)

`LXGWWenKaiScreen.ttf` (~24 MB, SIL OFL 1.1) is not committed here to keep the
repository light. Download it once before rendering diagrams with Chinese/CJK
labels:

```bash
curl -L -o LXGWWenKaiScreen.ttf \
  https://github.com/OLDyade/animated-sketch-diagram/raw/main/assets/fonts-cn/LXGWWenKaiScreen.ttf
```

The build step subsets it to only the characters actually used (a few dozen KB
inlined into the output HTML). Latin-only diagrams do not need this file.
````

## File: skills/animated-sketch-diagram/README.md
size: 1738
sha: be88507a730efb7a734df37d3f37e8554082a5ef
upstream: https://github.com/iflytek/ifly-skills/blob/main/skills/animated-sketch-diagram/README.md

````text
# Animated Sketch Diagram

Generates hand-drawn "ink on beige paper" animated architecture and flow
diagrams as a single self-contained HTML (pure SVG + CSS, zero JS runtime),
with flowing dots that trace the system's real topology — branches, merges,
feedback loops. A bundled headless-Chrome renderer exports pixel-perfect,
seamlessly-looping GIFs.

![demo](https://github.com/OLDyade/animated-sketch-diagram/raw/main/examples/agent-loop.gif)

More demos (all unretouched exports):
[examples gallery](https://github.com/OLDyade/animated-sketch-diagram/tree/main/examples).

## Highlights

- **Motion that narrates.** The animation retells the architecture instead of decorating it.
- **One file, zero runtime.** `@keyframes` + `offset-path`; double-click to play, works offline.
- **Seamless-loop GIF export.** All durations divide one global loop; frames are stepped deterministically.
- **Token design system.** Fixed palette / stroke / rhythm — consistent output, not style roulette.
- **Self-check loop.** Renders, reads frames back, fixes, re-renders before delivering.
- **CJK-ready.** OFL LXGW WenKai Screen, auto-subsetted (see `assets/fonts-cn/README.md`).

## Usage

Ask the agent, in any project:

> Draw me an animated sketch diagram of how a RAG pipeline works.

GIF export (once: `npm ci` inside `scripts/`; needs Node.js, Chrome/Chromium, ffmpeg):

```bash
node scripts/render-gif.mjs diagram.html diagram.gif --fps 25 --loop 3000 --scale 2
```

## Credits & Licenses

Skill code MIT (upstream: [OLDyade/animated-sketch-diagram](https://github.com/OLDyade/animated-sketch-diagram)).
Bundled fonts (Kalam, Patrick Hand, Caveat, Excalifont, LXGW WenKai Screen) are
SIL OFL 1.1; [rough.js](https://roughjs.com/) is MIT.
````

## File: skills/animated-sketch-diagram/scripts/package-lock.json
size: 671
sha: 9777ac4a782637eba980b08be2422add72db47b8
upstream: https://github.com/iflytek/ifly-skills/blob/main/skills/animated-sketch-diagram/scripts/package-lock.json

```text
{
  "name": "animated-sketch-diagram-scripts",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "animated-sketch-diagram-scripts",
      "dependencies": {
        "playwright-core": "^1.49.0"
      }
    },
    "node_modules/playwright-core": {
      "version": "1.61.1",
      "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.61.1.tgz",
      "integrity": "sha512-h7Qlt6m4REp25qvIdvbDtVmD4LqVXfpRxhORv9L0jzETM05p4fuPJ3dKyuSXQxDSbXnmS79HAgi9589lGSpLkg==",
      "license": "Apache-2.0",
      "bin": {
        "playwright-core": "cli.js"
      },
      "engines": {
        "node": ">=18"
      }
    }
  }
}
```

## File: skills/animated-sketch-diagram/scripts/package.json
size: 145
sha: be3faff11404634168195b0439e38f7837d63a9b
upstream: https://github.com/iflytek/ifly-skills/blob/main/skills/animated-sketch-diagram/scripts/package.json

```text
{
  "name": "animated-sketch-diagram-scripts",
  "private": true,
  "type": "module",
  "dependencies": {
    "playwright-core": "^1.49.0"
  }
}
```

## File: skills/animated-sketch-diagram/scripts/render-gif.mjs
size: 3072
sha: f0f887e7159b1879501c305fa3eeb98b75bf8add
upstream: https://github.com/iflytek/ifly-skills/blob/main/skills/animated-sketch-diagram/scripts/render-gif.mjs

```text
#!/usr/bin/env node
// 逐帧定格 CSS 动画并合成无缝循环 GIF
// 用法: node render-gif.mjs input.html output.gif [--fps 25] [--loop 3000] [--scale 2]
import { chromium } from 'playwright-core';
import { existsSync, mkdtempSync, rmSync } from 'node:fs';
import { execFileSync } from 'node:child_process';
import { tmpdir } from 'node:os';
import { resolve, join } from 'node:path';
import { globSync } from 'node:fs';

const args = process.argv.slice(2);
const [input, output] = args;
if (!input || !output) {
  console.error('用法: node render-gif.mjs input.html output.gif [--fps 25] [--loop 3000] [--scale 2]');
  process.exit(1);
}
const opt = (name, dflt) => {
  const i = args.indexOf('--' + name);
  return i > -1 ? Number(args[i + 1]) : dflt;
};
const fps = opt('fps', 25);
const loop = opt('loop', 3000); // ms，须与 HTML 里 --loop 一致
const scale = opt('scale', 2); // 默认 2x 截图：1x 的 GIF 文字发糊

function findChrome() {
  const candidates = [
    process.env.CHROME_PATH,
    '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
    '/Applications/Chromium.app/Contents/MacOS/Chromium',
    '/usr/bin/google-chrome',
    '/usr/bin/chromium-browser',
    ...globSync(join(process.env.HOME || '', 'Library/Caches/ms-playwright/chromium-*/chrome-mac*/Chromium.app/Contents/MacOS/Chromium')),
  ].filter(Boolean);
  const hit = candidates.find(p => existsSync(p));
  if (!hit) throw new Error('找不到 Chrome/Chromium，请设置 CHROME_PATH 环境变量');
  return hit;
}

const frames = Math.round((loop / 1000) * fps);
const dir = mkdtempSync(join(tmpdir(), 'sketch-gif-'));
const browser = await chromium.launch({ executablePath: findChrome() });
try {
  const page = await browser.newPage({ deviceScaleFactor: scale });
  await page.goto('file://' + resolve(input));
  await page.evaluate(() => document.fonts.ready);
  const { w, h } = await page.evaluate(() => {
    const el = document.querySelector('.canvas') || document.body;
    const r = el.getBoundingClientRect();
    return { w: Math.ceil(r.width), h: Math.ceil(r.height) };
  });
  await page.setViewportSize({ width: w, height: h });
  // 暂停所有动画，逐帧 seek。GIF 无缝循环靠"所有时长整除 loop"
  await page.evaluate(() => document.getAnimations().forEach(a => a.pause()));
  for (let i = 0; i < frames; i++) {
    const t = (i / fps) * 1000;
    await page.evaluate(t => document.getAnimations().forEach(a => { a.currentTime = t; }), t);
    await page.screenshot({ path: join(dir, `f${String(i).padStart(3, '0')}.png`) });
    process.stdout.write(`\r帧 ${i + 1}/${frames}`);
  }
  console.log('\nffmpeg 合成中…');
  execFileSync('ffmpeg', [
    '-v', 'error', '-y', '-framerate', String(fps), '-i', join(dir, 'f%03d.png'),
    '-vf', 'split[a][b];[a]palettegen=stats_mode=diff[p];[b][p]paletteuse=dither=sierra2_4a',
    '-loop', '0', resolve(output),
  ], { stdio: 'inherit' });
  console.log('完成 →', resolve(output));
} finally {
  await browser.close();
  rmSync(dir, { recursive: true, force: true });
}
```

## File: skills/animated-sketch-diagram/references/style-guide.md
size: 8751
sha: 9dc451f59026a1f6c1e6c97b17370fe0f6354121
upstream: https://github.com/iflytek/ifly-skills/blob/main/skills/animated-sketch-diagram/references/style-guide.md

```text
# 风格系统（Design Tokens）

美学定位：**黑墨手绘涂鸦 + 米色纸面 + 极淡水洗色块**——像资深工程师在牛皮笔记本上
用针管笔画的系统图，再用水彩淡淡罩了几块底色。风格辨识度 = 这些 token 的严格组合。

## 画布

| Token | 值 | 说明 |
|---|---|---|
| 纸面底色 paper | `#f8f5e8` | 温暖米色，绝不用纯白 |
| 画布宽度 | `1200px` | 高度随内容 |
| 墨线色 ink | `#212020` | 所有描边和文字，近黑微暖；绝不用纯黑 `#000` |
| 弱文字 | ink @ 65% opacity | 副标题、注释 |
| 纸纹 | feTurbulence 极淡颗粒（recipes §0） | 可选，加了更像纸 |

## 区块水洗色板

"区块"指版式的一级分区（横向 band、纵向层、径向扇区、对比柱都算）。
每个区块罩一种水洗色，相邻区块不同色；同一图 3~5 种即可，顺序随意但要错开冷暖。

| 色名 | 区块底 wash | 更深一档（内部强调条/横幅） | 流动圆点 dot |
|---|---|---|---|
| 鼠尾草绿 sage | `#f0f1e0` | `#e8ebd5` | `#5f7a4a` |
| 黄油黄 butter | `#f9f3d1` | `#f4ecc0` | `#b8912a` |
| 蜜桃粉 peach | `#f8e9d9` | `#f3ddc8` | `#bf7350` |
| 薰衣草紫 lavender | `#e9e1ea` | `#ded2e0` | `#7d6a99` |
| 雾蓝 mist | `#eef2f4` | `#e2e9ee` | `#5b7d94` |

牛皮纸棕 `#e9dac1`（描边同 ink）留给"容器"类比喻：纸箱、横幅、档案盒。

- 内卡（区块里的小卡片/文档/白纸）一律纸白 `#faf7eb`，不用水洗色。
- 水洗色只出现在区块底和少量强调条上；图的主体观感是"墨线 + 纸色"。

## 点缀（少量、手写感的灵魂）

- **序号章**：ink 实心圆 Ø30，内写 paper 色手写数字，贴在区块左上角。
- **火花 ✦ / 小星 ☆**：4 角星小路径，散布在大标题、口号、关键区块旁，每图 3~6 个。
- **简笔小人**：圆头 + 弧线身体的涂鸦小人，放在"人/agent 做事"的语义位置，一图 1~3 个。
- **中央口号**：一句手写短语放版面天然留白处，两侧各一个 ✦。
- 没有彩色 mascot、没有荧光笔高亮、没有底部色条——焦点靠 ✦ 和口号，全图基本单色墨。

## 字体

| 角色 | 字体栈 | 用在哪 |
|---|---|---|
| 标题体 `--font-title` | `'Comic Sans MS','Kalam','LXGW WenKai Screen','Kaiti SC',cursive` **700** | 大标题、中央口号、区块标题、节点内关键词 |
| 正文体 `--font-body` | `'Comic Sans MS','PatrickHand','LXGW WenKai Screen','Kaiti SC',cursive` **400** | 注释、内卡标签、连线文字、副标 |

- **Comic Sans MS** 是 macOS/Windows 系统字体，按名引用、不捆绑（也不可捆绑，商业字体）。
  拉丁字符全部落在它上面：标题/节点标题用 Bold，注释/连线文字用 Regular。
- **汉字**落到捆绑的 **LXGW WenKai Screen（霞鹜文楷，OFL）**——原始 TTF 在
  `assets/fonts-cn/`（25MB，永不整包内联），注入脚本自动提取 HTML 里用到的汉字
  子集化成几十 KB woff2 再内联（见 recipes §0；需 `fonttools`+`brotli`，
  缺就 `pip3 install --user --break-system-packages fonttools brotli`）。兜底 Kaiti SC。
- 捆绑的 Kalam/PatrickHand/Caveat/Excalifont（assets/fonts/）作无 Comic Sans 环境的
  后备，也是想换味时的备选菜单。
- 代码/命令用 `ui-monospace, Menlo, monospace`。**所有文字一律 ink 色**。

### 字号阶梯

| 层级 | 字体/字号 | 备注 |
|---|---|---|
| 大标题 | title / 58~64px bold | 抖动下划线收尾，旁边一颗 ✦ |
| 中央口号 | title / 28~32px bold | 两侧 ✦ |
| 区块标题 | title / 24~25px bold | 区块顶部**居中** |
| 区块副标 | body / 14~15px @65% | 跟在标题下方居中（可省） |
| 内卡标签 | body / 15~16px | 卡内图标下方或右侧 |
| 连线标签 | body / 13~14px | Comic Sans 偏宽，标签词要短 |

## 形状与描边（比常规更糙）

| 元素 | 规格 |
|---|---|
| 区块面板 | 圆角 18px，ink **2.2px**，roughness 1.8；fill 水洗色 |
| 区块头部 | 左上序号章 + 顶部居中标题；标题下可画一条抖动细分隔线（1.4px） |
| 内卡 | 圆角 8px，ink 1.7px，fill `#faf7eb`；"一叠纸"= 背后垫 1~2 张偏移 (+4,+4) 的同款卡 |
| 文档卡 | 右上角画折角（两条短线三角），比圆角矩形更像"纸" |
| 图标 | 纯 ink 单色简笔涂鸦，2px 线宽：小人/文档/文件夹/纸箱/放大镜/笔记本电脑/月亮/齿轮/勾叉 |
| 主流程箭头 | ink **2.0px**，**微弯曲线**（浅 Q 弧，不要笔直）+ 末端实心小三角 |
| 大回环箭头 | ink 2.2px 长弧线绕版面外侧走，气势要足；虚线弧留给弱关联（1.6px，`7 6`） |
| 引用/命令框 | 圆角 8px，ink 1.4px 虚线 `4 4`，fill 纸白 |

**手绘抖动是硬要求**：所有静态几何形状加 `data-rough`（本风格 roughness 取 1.6~2.2，
比默认糙），由捆绑的 rough.js/sketchify.js 加载时替换。参与 CSS 动画的元素除外（见 recipes）。

## 版面

版式原型由内容决定（见 SKILL.md 第 1 步原型表），以下通用：

- 大标题放角部（右上或左上），签名式，带下划线扫尾；不占整行。
- 区块之间间距 24px+；区块内边距 20px；节点间距 ≥ 36px。
- 区块标签 = 序号章（有流程顺序时）+ 居中标题；序号让读者自己找到阅读顺序，
  所以跨区块的连线可以少画几根，版面更透气。
- 主轴方向（横排左→右等）只是**默认阅读方向**，不是流动的枷锁：分支、汇聚、
  往返、跨区块回环、环形轨道按内容需要自由画，回环弧走主轴上下/外侧的空档；
  内容整体成环时，用一根绕版面外侧的大弧箭头点题并让圆点沿它跑。
  实线/虚线表达"确定/弱"的语义强弱：迭代循环是核心流程 → 实线；偶发降级/弱关联 → 虚线。
- 版面天然空隙放中央口号 + ✦，不要硬填满。

## 构图密度与排版

排版由**内容量**驱动，先数清楚要画多少东西（节点数、附件数、标注数），再倒推几何：

- **横向撑满**：一行节点要铺满区块可用宽度——首节点贴左内边距、末节点贴右内边距、
  间隙均分（间隙宽 = (可用宽 − Σ节点宽) / 间隙数）。不要把内容挤在中间留两侧大白边；
  间隙大恰好给箭头和线上标签留了呼吸空间。
- **纵向贴内容**：区块高度 = 头部（标题+副标 ~70px）+ 主轴行 + 附件行（标注框/回环弧下探深度）
  + 内边距，逐项加出来；不要先定高度再填内容。整图高度同理 = 各区块自然高度之和。
- 附件（标注框、小人、一叠纸）优先塞进主轴上下的空档，它们是"补白"手段：
  哪里空补哪里，而不是固定挂在某个位置。
- 每个区块至少一个**非线性元素**：一叠纸 / 简笔小人 / 纸箱横幅 / 标注框 / 回环弧。
  只有"一排盒子加箭头"的区块是不合格的。
- 内卡里"图标 + 三两行短横线"就能表达"列表/文档内容"，多用这种速记涂鸦。
- 连线尽量挂小标签（做什么/传什么）。
- 完稿判断：眯眼看整图，墨色应该均匀分布；哪块区域一眼看过去是"一片空"，
  就说明那里要么该缩小、要么缺一个附件。

## 动画节奏

| Token | 值 |
|---|---|
| 全局循环 `--loop` | 默认 `3000ms`，所有动画时长 ∈ {loop, loop/2, loop/3, loop/4}，全部 infinite（GIF 无缝的充分条件）。**整体嫌快/慢时直接调这个值（2400~3600ms），所有动画等比缩放**，别逐个改时长 |
| 圆点速度 | **按像素速度定时长，不是固定一圈一个 loop**：目标 **80~150px/s**。估算路径长度 L，取 duration = loop/k 中最接近 L/110s 的档。短线（<150px）至少 loop/3，长弧用 loop 或 loop/2。一圈 3s 爬 50px 的点是死的。 |
| 圆点形态 | r=4.5，fill 区块 dot 色 + paper 色 2.5px halo；再叠一个 `scale` 呼吸（loop/4，1→1.35）让它"活"；多条线负延迟错开 |
| 圆点放哪 | **任何有"流动"语义的路径都放**：主流程、回环、分支、跨区块长弧、环形轨道——尤其回环，圆点沿弧转回去才有"循环起来"的感觉；不放的只有纯标注连线（标注框的引出虚线）。整图流动应有"有去有回/有转向"的层次，全是同向平行线 = 不合格 |
| 微动效 | 每图 2~4 处：齿轮/月亮微转、勾描画、光标闪、✦ 脉冲缩放 |
| 缓动 | 圆点位移 `linear`；呼吸和微动效 `ease-in-out` |

判断标准：盯着成品 GIF 看 2 秒，应该能立刻感到"东西在流动"；如果要凑近找才看见点在动，速度或密度不够。
```

## File: skills/animated-sketch-diagram/references/svg-recipes.md
size: 13558
sha: b2479051845692d1cea037f236d9930093cb50fd
upstream: https://github.com/iflytek/ifly-skills/blob/main/skills/animated-sketch-diagram/references/svg-recipes.md

````text
# SVG/CSS 代码配方

组装规则：一个 HTML 文件，`<body>` 里一个 `.canvas` 容器，内联一个 `<svg viewBox="0 0 1200 H">`。
所有坐标手工布局，token 值见 style-guide.md。下面的坐标、文字都是**占位示意**，按你的内容重算。

**手绘感的来源**：所有静态几何形状加 `data-rough`（本风格默认 `data-roughness="1.8"`），
加载时由捆绑的 rough.js + sketchify.js 自动替换成抖动描边的手绘版本。
你只管写干净的 `<rect>/<path>/<circle>`，不要自己模拟抖动。
例外：**参与 CSS 动画的元素**（流动圆点、旋转齿轮、描画对勾等）**不加** `data-rough`
（rough 替换的是静态视觉副本，动画类挂在原元素上会看不见）。

## 0. 文件骨架 + 资产内联 + 纸纹

HTML 里写三个占位符：`__FONTFACES__`（在 `<style>` 内）、`__ROUGH_JS__`、`__SKETCHIFY_JS__`，
写完后用脚本一次性注入（别手工粘贴几十 KB 字符串）：

```bash
python3 - <<'EOF'
import base64, pathlib, re
skill = pathlib.Path.home() / '.claude/skills/animated-sketch-diagram'
p = pathlib.Path('diagram.html')
html = p.read_text()
faces = ''
# 拉丁手写后备字体（无 Comic Sans 环境用），全量内联
for f in sorted((skill/'assets/fonts').glob('*.woff2')):
    fam, w = f.stem.rsplit('-', 1)
    b64 = base64.b64encode(f.read_bytes()).decode()
    faces += ("@font-face{font-family:'%s';font-weight:%s;"
              "src:url(data:font/woff2;base64,%s) format('woff2');}\n" % (fam, w, b64))
# 汉字：LXGW WenKai Screen 按用到的字符子集化（几十 KB），永不整包内联
chars = ''.join(sorted(set(re.findall(r'[^\x00-\x7f]', html))))
if chars:
    import tempfile
    from fontTools import subset  # pip3 install --user --break-system-packages fonttools brotli
    out = tempfile.mktemp(suffix='.woff2')
    subset.main([str(skill/'assets/fonts-cn/LXGWWenKaiScreen.ttf'),
                 '--text=%s' % chars, '--flavor=woff2', '--output-file=%s' % out])
    b64 = base64.b64encode(open(out, 'rb').read()).decode()
    faces += ("@font-face{font-family:'LXGW WenKai Screen';"
              "src:url(data:font/woff2;base64,%s) format('woff2');}\n" % b64)
html = html.replace('__FONTFACES__', faces)
html = html.replace('__ROUGH_JS__', (skill/'assets/vendor/rough.js').read_text())
html = html.replace('__SKETCHIFY_JS__', (skill/'assets/vendor/sketchify.js').read_text())
p.write_text(html)
EOF
```

```html
<meta charset="utf-8">
<style>
__FONTFACES__
:root { --loop: 3000ms; --ink: #212020; --paper: #f8f5e8;
        --font-title: 'Comic Sans MS','Kalam','LXGW WenKai Screen','Kaiti SC',cursive;
        --font-body: 'Comic Sans MS','PatrickHand','LXGW WenKai Screen','Kaiti SC',cursive; }
body { margin: 0; background: var(--paper); }
.canvas { width: 1200px; margin: 0 auto; }
svg { display: block; }  /* 不加会有 ~5px 行内基线空隙被录进 GIF */
svg text { font-family: var(--font-body); fill: var(--ink); }
.t-title { font-family: var(--font-title); font-weight: 700; }
.t-strong { font-family: var(--font-title); font-weight: 700; }
.mono { font-family: ui-monospace, Menlo, monospace; }
</style>
<div class="canvas">
  <svg viewBox="0 0 1200 900" width="1200" height="900">
    <!-- 纸纹（可选，放最底层）：极淡颗粒。alpha 行系数 0.06，调大更糙 -->
    <filter id="grain">
      <feTurbulence type="fractalNoise" baseFrequency="0.9" numOctaves="2"/>
      <feColorMatrix type="matrix" values="0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0.06 0.06 0.06 0 0"/>
    </filter>
    <rect width="1200" height="900" fill="var(--paper)"/>
    <rect width="1200" height="900" filter="url(#grain)"/>
    <!-- 内容 -->
  </svg>
</div>
<!-- body 末尾 -->
<script>__ROUGH_JS__</script>
<script>__SKETCHIFY_JS__</script>
<script>sketchify()</script>
```

## 1. 大标题（签名式）+ 下划线扫尾 + ✦

```html
<text class="t-title" x="880" y="80" font-size="62">MyTitle</text>
<!-- 抖动下划线：从标题下方扫过，末端上翘 -->
<path data-rough data-roughness="2.2" d="M878 96 Q1030 106 1180 92" fill="none"
      stroke="var(--ink)" stroke-width="3"/>
<!-- 4 角星 ✦（可挂 .pulse 微动效） -->
<path d="M1186 118 l3.5 8.5 8.5 3.5 -8.5 3.5 -3.5 8.5 -3.5 -8.5 -8.5 -3.5 8.5 -3.5 z" fill="var(--ink)"/>
```

中央口号放版面天然空隙：

```html
<text class="t-title" x="600" y="360" font-size="30" text-anchor="middle">Every run becomes a better next start</text>
<!-- 两侧各一颗 ✦，同上 path，缩放/平移 -->
```

## 2. 区块面板：序号章 + 居中标题（以横向区块为例）

这是"横向区块"的写法；纵向层/径向/对比柱等原型用同样的 token 照此类推。

```html
<g class="region region-sage">
  <rect data-rough data-roughness="1.8" x="240" y="250" width="360" height="170" rx="18"
        fill="#f0f1e0" stroke="var(--ink)" stroke-width="2.2"/>
  <!-- 序号章：ink 实心圆 + paper 数字 -->
  <circle data-rough cx="272" cy="278" r="15" fill="var(--ink)" stroke="none"/>
  <!-- 数字必须用 style= 内联（CSS 的 svg text{fill:ink} 会覆盖 fill 属性，黑圆上黑字 = 看不见） -->
  <text x="272" y="286" font-size="20" font-weight="bold" style="fill:var(--paper)" text-anchor="middle">2</text>
  <!-- 居中标题 + 分隔线（分隔线可省） -->
  <text class="t-strong" x="435" y="286" font-size="25" text-anchor="middle">Memory Extraction</text>
  <path data-rough d="M258 300 H582" fill="none" stroke="var(--ink)" stroke-width="1.4"/>
</g>
```

## 3. 内卡：纸白卡片、一叠纸、折角文档

```html
<!-- 普通内卡：图标 + 标签 -->
<rect data-rough x="260" y="316" width="150" height="34" rx="8"
      fill="#faf7eb" stroke="var(--ink)" stroke-width="1.7"/>
<text x="300" y="338" font-size="15">User Messages</text>

<!-- 一叠纸：背后垫 1~2 张偏移副本（先画后面的） -->
<rect data-rough x="496" y="308" width="86" height="98" rx="6" fill="#faf7eb" stroke="var(--ink)" stroke-width="1.5"/>
<rect data-rough x="490" y="303" width="86" height="98" rx="6" fill="#faf7eb" stroke="var(--ink)" stroke-width="1.5"/>
<rect data-rough x="484" y="298" width="86" height="98" rx="6" fill="#faf7eb" stroke="var(--ink)" stroke-width="1.7"/>

<!-- 折角文档：右上角折角 + 内部三两行短横线（"速记涂鸦"表达内容） -->
<path data-rough d="M484 298 h66 l20 20 v78 h-86 z" fill="#faf7eb" stroke="var(--ink)" stroke-width="1.7"/>
<path d="M550 298 v20 h20" fill="none" stroke="var(--ink)" stroke-width="1.7"/>
<line x1="496" y1="340" x2="556" y2="340" stroke="var(--ink)" stroke-width="1.6"/>
<line x1="496" y1="352" x2="548" y2="352" stroke="var(--ink)" stroke-width="1.6"/>
<line x1="496" y1="364" x2="552" y2="364" stroke="var(--ink)" stroke-width="1.6"/>
```

## 4. 简笔涂鸦图标（纯 ink 单色，2px）

就地用几条 `line/circle/path` 画，不引图标库。常用速记：

```html
<!-- 小人（圆头 + 弧身），"人/agent 在做事" -->
<circle data-rough cx="400" cy="330" r="11" fill="#faf7eb" stroke="var(--ink)" stroke-width="2"/>
<path data-rough d="M384 372 q16 -22 32 0 z" fill="#faf7eb" stroke="var(--ink)" stroke-width="2"/>
<!-- 放大镜（塞在小人手边表示在检索） -->
<circle cx="424" cy="352" r="7" fill="none" stroke="var(--ink)" stroke-width="2"/>
<line x1="429" y1="358" x2="437" y2="366" stroke="var(--ink)" stroke-width="2.4" stroke-linecap="round"/>

<!-- 文件夹 -->
<path data-rough d="M700 340 h16 l5 6 h23 v26 h-44 z" fill="#faf7eb" stroke="var(--ink)" stroke-width="1.8"/>
<!-- 纸箱（牛皮纸棕 fill） -->
<path data-rough d="M760 350 l30 -8 30 8 v24 l-30 8 -30 -8 z" fill="#e9dac1" stroke="var(--ink)" stroke-width="1.8"/>
<line x1="790" y1="342" x2="790" y2="374" stroke="var(--ink)" stroke-width="1.4"/>
<!-- 月亮（Dream/夜间任务；可挂 .spin 微转） -->
<path d="M900 330 a12 12 0 1 0 10 18 a9 9 0 0 1 -10 -18 z" fill="var(--ink)"/>
<!-- 齿轮 = 圆 + 4 短齿；勾 = 折线；叉 = 两斜线；笔记本电脑 = 梯形 + 屏幕矩形 -->
```

## 5. 连线：微弯箭头 / 大回环 / 虚线弱关联

`<defs>` 里放一个箭头 marker（ink 实心小三角）：

```html
<defs>
  <marker id="arr" viewBox="0 0 10 8" refX="9" refY="4"
          markerWidth="8" markerHeight="6.5" orient="auto-start-reverse">
    <path d="M0 0 L10 4 L0 8 Z" fill="var(--ink)"/>
  </marker>
</defs>

<!-- 主流程：浅弧，不要笔直（手绘图没有直线） -->
<path data-rough id="e1" d="M410 333 Q447 328 486 334" fill="none" stroke="var(--ink)"
      stroke-width="2.0" marker-end="url(#arr)"/>
<text x="448" y="320" font-size="14" text-anchor="middle">线上标签</text>

<!-- 大回环：绕版面外侧的长弧，收尾点题（如 "Better Next Run"），圆点沿它跑 -->
<path data-rough data-roughness="2" d="M300 760 C120 700 100 260 300 120" fill="none"
      stroke="var(--ink)" stroke-width="2.2" marker-end="url(#arr)"/>

<!-- 核心迭代回环：实线弧（循环是主流程时不要用虚线弱化它） -->
<path data-rough d="M900 420 Q760 500 620 430" fill="none" stroke="var(--ink)"
      stroke-width="2.0" marker-end="url(#arr)"/>

<!-- 偶发降级/弱关联：才用虚线弧 -->
<path data-rough d="M900 300 Q780 350 660 310 " fill="none" stroke="var(--ink)"
      stroke-width="1.6" stroke-dasharray="7 6" marker-end="url(#arr)"/>

<!-- 分支：一出二（同一起点两条弧，各自带箭头、标签、圆点） -->
<path data-rough d="M420 330 Q470 300 520 292" fill="none" stroke="var(--ink)" stroke-width="2.0" marker-end="url(#arr)"/>
<path data-rough d="M420 336 Q470 366 520 374" fill="none" stroke="var(--ink)" stroke-width="2.0" marker-end="url(#arr)"/>
<!-- 汇聚：二入一 = 两条弧指向同一节点边缘的不同锚点，反向同理 -->

<!-- 环形轨道：节点绕环排布时，一条闭合椭圆弧当"传送带"，多个圆点错开在上面转 -->
<path data-rough id="orbit" d="M600 470 a170 90 0 1 0 0.1 0" fill="none"
      stroke="var(--ink)" stroke-width="2.2"/>
```

- 箭头指到目标边缘外 2px，别扎进卡片里。
- **流动拓扑跟内容走**：分支、汇聚、往返、跨区块长弧、环形轨道都是常规手段。
  一张图的连线如果全是同向平行线，先怀疑是拓扑画错了，不是内容真的这么单调。

## 6. 流动圆点（动画的灵魂）

圆点是独立 `<circle>`，用 CSS `offset-path` 沿**同一条 `d` 字符串**跑；
黑墨线上必须带 paper 色 halo 才看得清：

```html
<!-- --t 按路径长度选档：目标速度 80~150px/s（短线 loop/3≈1000ms，中长线 loop/2，长弧 loop） -->
<circle class="dot" r="4.5" fill="#5f7a4a" stroke="var(--paper)" stroke-width="2.5"
        style="offset-path: path('M410 333 Q447 328 486 334'); --t: calc(var(--loop) / 3)"/>
```

```css
.dot { offset-rotate: 0deg; transform-box: fill-box; transform-origin: center;
       animation: travel var(--t, var(--loop)) linear infinite,
                  breathe calc(var(--loop) / 4) ease-in-out infinite; }
@keyframes travel { from { offset-distance: 0%; } to { offset-distance: 100%; } }
@keyframes breathe { 50% { transform: scale(1.35); } }  /* 呼吸让点"活"起来 */
/* 多条线负延迟错开（用显式类，别用 nth-of-type，多区块下计数会乱） */
.d2 { animation-delay: calc(var(--loop) / -3); }
.d3 { animation-delay: calc(var(--loop) * -2 / 3); }
```

- **时长必须仍是 loop 的整数分之一**（loop/2、loop/3、loop/4），否则 GIF 循环有接缝；
  在这个约束里选最接近目标速度的档。一圈 3s 爬一条 50px 短线的点是死的。
- 圆点颜色 = 所在区块的 dot token（style-guide 色板）。
- **凡有"流动"语义的路径都放圆点**：主流程、回环（沿弧转回去才有"循环起来"的感觉）、
  分支两臂、跨区块长弧、环形轨道（放 2~3 个错开）。不放的只有标注框的引出虚线。
- 返回方向的流动不用重写路径：同一条 `d` 加 `animation-direction: reverse` 即可
  （如双向同步的去/回两个点）。
- `offset-path` 的 `d` 必须和连线的 `d` 逐字符一致，改线时同步改。

## 7. 图标微动效（挑 2~4 处）

```css
.spin { transform-box: fill-box; transform-origin: center;
        animation: spin var(--loop) linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.tick { stroke-dasharray: 26; animation: draw var(--loop) ease-in-out infinite; }
@keyframes draw { 0%{stroke-dashoffset:26} 40%,70%{stroke-dashoffset:0} 100%{stroke-dashoffset:-26} }

.blink { animation: blink calc(var(--loop) / 4) steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ✦ 呼吸脉冲 */
.pulse { transform-box: fill-box; transform-origin: center;
         animation: pulse calc(var(--loop) / 2) ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.25) rotate(10deg); } }
```

只用 `transform/opacity/stroke-dashoffset`，时长限定 loop 的整数分之一（无缝循环）。

## 8. 引用/命令框

```html
<rect data-rough x="330" y="430" width="640" height="40" rx="8" fill="#faf7eb"
      stroke="var(--ink)" stroke-width="1.4" stroke-dasharray="4 4"/>
<text class="mono" x="650" y="456" font-size="16" text-anchor="middle">$ command --example</text>
```

## 9. 自检渲染（写完必做）

有显示环境 `open diagram.html`；无头环境用 scripts/ 里装好的 playwright-core
截 PNG 后用 Read 看图。动画正确性以浏览器实际播放为准，不要只靠读代码。
````

## File: skills/animated-sketch-diagram/assets/fonts/Caveat-400.woff2
size: 48836
sha: fb050a64b1c6182851ef6fdecdaa29d637952cda
upstream: https://github.com/iflytek/ifly-skills/blob/main/skills/animated-sketch-diagram/assets/fonts/Caveat-400.woff2

Content is not inlined in the catalog. Read the upstream file: https://github.com/iflytek/ifly-skills/blob/main/skills/animated-sketch-diagram/assets/fonts/Caveat-400.woff2

## File: skills/animated-sketch-diagram/assets/fonts/Caveat-700.woff2
size: 51020
sha: e8b6ac7118ebb5976372916a7ab1bf1eb1a464d2
upstream: https://github.com/iflytek/ifly-skills/blob/main/skills/animated-sketch-diagram/assets/fonts/Caveat-700.woff2

Content is not inlined in the catalog. Read the upstream file: https://github.com/iflytek/ifly-skills/blob/main/skills/animated-sketch-diagram/assets/fonts/Caveat-700.woff2

## File: skills/animated-sketch-diagram/assets/fonts/Excalifont-400.woff2
size: 24956
sha: 98b9616a39025e37dcaacb5bce5a7791666bf38b
upstream: https://github.com/iflytek/ifly-skills/blob/main/skills/animated-sketch-diagram/assets/fonts/Excalifont-400.woff2

Content is not inlined in the catalog. Read the upstream file: https://github.com/iflytek/ifly-skills/blob/main/skills/animated-sketch-diagram/assets/fonts/Excalifont-400.woff2

## File: skills/animated-sketch-diagram/assets/fonts/Kalam-400.woff2
size: 22336
sha: e1ca03945415052a8c753064f27af2c2341df1b6
upstream: https://github.com/iflytek/ifly-skills/blob/main/skills/animated-sketch-diagram/assets/fonts/Kalam-400.woff2

Content is not inlined in the catalog. Read the upstream file: https://github.com/iflytek/ifly-skills/blob/main/skills/animated-sketch-diagram/assets/fonts/Kalam-400.woff2

## File: skills/animated-sketch-diagram/assets/fonts/Kalam-700.woff2
size: 22144
sha: 0a6bd556a497783e70b3a0dc941bc81133c63842
upstream: https://github.com/iflytek/ifly-skills/blob/main/skills/animated-sketch-diagram/assets/fonts/Kalam-700.woff2

Content is not inlined in the catalog. Read the upstream file: https://github.com/iflytek/ifly-skills/blob/main/skills/animated-sketch-diagram/assets/fonts/Kalam-700.woff2

## File: skills/animated-sketch-diagram/assets/fonts/PatrickHand-400.woff2
size: 23944
sha: e80b54b43638b7eca06658defe672ac887030713
upstream: https://github.com/iflytek/ifly-skills/blob/main/skills/animated-sketch-diagram/assets/fonts/PatrickHand-400.woff2

Content is not inlined in the catalog. Read the upstream file: https://github.com/iflytek/ifly-skills/blob/main/skills/animated-sketch-diagram/assets/fonts/PatrickHand-400.woff2

## File: skills/animated-sketch-diagram/_meta.json
size: 143
sha: 7352d4916332ec4441bdba00fdb0d64f7f467f61
upstream: https://github.com/iflytek/ifly-skills/blob/main/skills/animated-sketch-diagram/_meta.json

```text
{
  "ownerId": "kn7ap5fct403gcj6xgy1aspf9181wg6c",
  "slug": "animated-sketch-diagram",
  "version": "1.0.0",
  "publishedAt": 1784167271539
}
```
