itwanger/vibe-science / skills/one-minute-remotion
one-minute-remotion
VerifiedVibeScience:把小学、初中、高中的数理化生知识点或 AI 概念做成1至2分钟中文科普视频,覆盖写稿、自选音色配音、连续动画、手机端字幕和MP4。文字稿保存到one-minute/,超时保留全文。“下一步”只推进一个阶段,配音完成后停下供试听。用于知识点短视频、一分钟或两分钟科普、课堂概念短片、写或润色one-minute目录稿件,或明确调用one-minute-remotion;普通长视频不属于本技能范围。
assets/huashu/diagram.js
View on GitHub// 图解与形变 DG:点列、逐笔描出(draw-on)、揭开遮罩、手绘抖动线、manim 式 Transform / Write、白板笔画时间线+跟随的笔、
// 神经网络(神经元/连线/信号闪过)、Indicate / Circumscribe / 大括号、3b1b 色板。
// 约定:点列 pts = [[x,y],...];cum = DG.cum(pts) 是累计弧长;「画到 d」都按弧长算。确定性:随机全走种子。
(() => {
let W = 1920, H = 1080; U.onStage((w, h) => { W = w; H = h; }); // 画布尺寸跟 U.setStage 走(默认 1920×1080)
const { clamp, lerp, rng } = U;
const DG = window.DG = {};
// ---------- 点列 ----------
DG.cum = pts => { const L = [0]; for (let i = 1; i < pts.length; i++) L.push(L[i - 1] + Math.hypot(pts[i][0] - pts[i - 1][0], pts[i][1] - pts[i - 1][1])); return L; };
DG.len = pts => { const L = DG.cum(pts); return L[L.length - 1]; };
// 折线上弧长 d 处的点
DG.pointAt = (pts, cum, d) => {
if (d <= 0) return pts[0]; const n = pts.length; if (d >= cum[n - 1]) return pts[n - 1];
let lo = 0, hi = n - 1; while (hi - lo > 1) { const m = (lo + hi) >> 1; if (cum[m] < d) lo = m; else hi = m; }
const q = (d - cum[lo]) / (cum[hi] - cum[lo] || 1); return [lerp(pts[lo][0], pts[hi][0], q), lerp(pts[lo][1], pts[hi][1], q)];
};
// 逐笔描出:画折线的前 d 长度(用当前 strokeStyle/lineWidth),返回笔尖位置。白板、红笔圈、红线连接都用它。
DG.drawPartial = (c, pts, cum, d) => {
const n = pts.length; if (d <= 0 || n < 2) return pts[0];
c.beginPath(); c.moveTo(pts[0][0], pts[0][1]);
let i = 1; for (; i < n && cum[i] <= d; i++) c.lineTo(pts[i][0], pts[i][1]);
let tip = pts[n - 1];
if (i < n) { tip = DG.pointAt(pts, cum, d); c.lineTo(tip[0], tip[1]); }
c.stroke(); return tip;
};
// 变换点列:平移 (dx,dy)、缩放 s
DG.xform = (pts, dx, dy, s = 1) => pts.map(([x, y]) => [dx + x * s, dy + y * s]);
// 椭圆弧点列(a0→a1)
DG.arcPts = (cx, cy, rx, ry, a0, a1, n = 24) => { const o = []; for (let i = 0; i <= n; i++) { const a = a0 + (a1 - a0) * i / n; o.push([cx + Math.cos(a) * rx, cy + Math.sin(a) * ry]); } return o; };
// 手画的圈:从 a0 起转 turns 圈(>1 首尾略交叉,像真的用笔圈)
DG.ellipsePts = (cx, cy, rx, ry, a0 = -Math.PI / 2, turns = 1.08, n = 64) => DG.arcPts(cx, cy, rx, ry, a0, a0 + turns * Math.PI * 2, n);
// 手绘抖动:Catmull-Rom 加密后按种子加低频抖动(静态,不沸腾——白板上的线画完就不动)
DG.hand = (pts, { per = 8, amp = 1.6, seed = 1, freq = 0.035 } = {}) => {
const d = KIT.densify(pts, per), r = rng(seed), ph = r() * 100;
return KIT.resample(d, 3).map(([x, y], i) => [x + PAINT.noise(i * freq + ph, 3.1) * amp * 2, y + PAINT.noise(i * freq + ph, 7.7) * amp * 2]);
};
// 揭开遮罩:沿折线前 d 长度,每段做成同向绕行的方条(方头延长 w/2),合成一条 Path2D 用来 clip。
// VideoScribe 的「Reveal」画法:之字形笔触从上往下揭开一张画;也用于逐字书写。同向绕行保证 nonzero 下重叠处不抵消。
DG.revealMask = (pts, cum, d, w) => {
const p = new Path2D(), h = w / 2;
for (let i = 1; i < pts.length && cum[i - 1] < d; i++) {
const a = pts[i - 1], b0 = pts[i], L = cum[i] - cum[i - 1]; if (L <= 0) continue;
const q = Math.min(1, (d - cum[i - 1]) / L), b = [a[0] + (b0[0] - a[0]) * q, a[1] + (b0[1] - a[1]) * q];
const ux = (b0[0] - a[0]) / L, uy = (b0[1] - a[1]) / L, nx = -uy * h, ny = ux * h;
const A = [a[0] - ux * h, a[1] - uy * h], B = [b[0] + ux * h, b[1] + uy * h];
p.moveTo(A[0] + nx, A[1] + ny); p.lineTo(B[0] + nx, B[1] + ny); p.lineTo(B[0] - nx, B[1] - ny); p.lineTo(A[0] - nx, A[1] - ny); p.closePath();
}
return p;
};
// 之字形揭开路径:在框 (x,y,w,h) 里从上往下 rows 行来回
DG.zigzag = (x, y, w, h, rows) => { const o = []; for (let r = 0; r <= rows; r++) { const yy = y + h * r / rows; o.push(r % 2 ? [x + w, yy] : [x, yy]); } return o; };
// ---------- manim Transform:两边点数相同、起点对齐(都从左上方向起、顺时针)才能逐点插值 ----------
DG.rectPts = (cx, cy, w, h, n = 64) => {
const per = 2 * (w + h), out = [];
for (let i = 0; i < n; i++) {
let d = i / n * per; let x, y;
if (d < w) { x = cx - w / 2 + d; y = cy - h / 2; }
else if ((d -= w) < h) { x = cx + w / 2; y = cy - h / 2 + d; }
else if ((d -= h) < w) { x = cx + w / 2 - d; y = cy + h / 2; }
else { d -= w; x = cx - w / 2; y = cy + h / 2 - d; }
out.push([x, y]);
}
return out;
};
DG.circlePts = (cx, cy, r, n = 64) => { const out = []; for (let i = 0; i < n; i++) { const a = -3 * Math.PI / 4 + i / n * 2 * Math.PI; out.push([cx + Math.cos(a) * r, cy + Math.sin(a) * r]); } return out; };
DG.morph = (A, B, p) => A.map((a, i) => [lerp(a[0], B[i][0], p), lerp(a[1], B[i][1], p)]);
DG.shape = (c, pts, { fill, stroke, lw = 2 } = {}) => {
c.beginPath(); pts.forEach((q, i) => i ? c.lineTo(q[0], q[1]) : c.moveTo(q[0], q[1])); c.closePath();
if (fill) { c.fillStyle = fill; c.fill(); }
if (stroke && lw > 0) { c.strokeStyle = stroke; c.lineWidth = lw; c.lineJoin = 'round'; c.stroke(); }
};
// ---------- 颜色(接受 '#hex' 或 [r,g,b]) ----------
DG.arr = h => Array.isArray(h) ? h : PAINT.hex(h);
DG.mixA = (h1, h2, t) => { const a = DG.arr(h1), b = DG.arr(h2); return [lerp(a[0], b[0], t), lerp(a[1], b[1], t), lerp(a[2], b[2], t)]; };
DG.rgba = (h, a = 1) => { const v = DG.arr(h); return `rgba(${v[0] | 0},${v[1] | 0},${v[2] | 0},${a})`; };
DG.mix = (h1, h2, t) => DG.rgba(DG.mixA(h1, h2, t));
// 3b1b 色板。Grant 的 custom_config 在 ffmpeg 导出时 saturation=1.5,照 manim 原色值直接用会发灰,所以 DG.MANIM 是饱和后的。
DG.MANIM_RAW = { BLUE_C: '#58C4DD', BLUE_D: '#29ABCA', BLUE_E: '#1C758A', TEAL_C: '#5CD0B3', GREEN_C: '#83C167', YELLOW: '#FFFF00', GOLD_C: '#F0AC5F',
RED_C: '#FC6255', MAROON_C: '#C55F73', PURPLE_C: '#9A72AC', GREY_A: '#DDDDDD', GREY_B: '#BBBBBB', GREY_C: '#888888', GREY_D: '#444444', GREY_E: '#222222', WHITE: '#FFFFFF', BLACK: '#000000' };
DG.saturate = (hex, s = 1.5) => { // CSS/SVG saturate 矩阵
const [r, g, b] = PAINT.hex(hex);
const R = (0.213 + 0.787 * s) * r + (0.715 - 0.715 * s) * g + (0.072 - 0.072 * s) * b;
const G = (0.213 - 0.213 * s) * r + (0.715 + 0.285 * s) * g + (0.072 - 0.072 * s) * b;
const B = (0.213 - 0.213 * s) * r + (0.715 - 0.715 * s) * g + (0.072 + 0.928 * s) * b;
const f = v => Math.round(clamp(v, 0, 255)).toString(16).padStart(2, '0');
return '#' + f(R) + f(G) + f(B);
};
DG.MANIM = {}; for (const k in DG.MANIM_RAW) DG.MANIM[k] = DG.saturate(DG.MANIM_RAW[k]);
DG.U = H / 8; // manim:画面高 8 个单位 → 1 单位 = 135px(1080p)
// ---------- Write 与公式(CMU = LaTeX Computer Modern;中文用思源宋) ----------
DG.FONT = { rm: 'CMU-rm', it: 'CMU-it', zh: 'NotoSerifSC' };
const famOf = tk => tk.zh ? DG.FONT.zh : tk.it ? DG.FONT.it : DG.FONT.rm;
// tokens: [{s, it, zh, col, sub, sup, size, gap}];返回每个 token 的 {x,w,sz}(相对起点)
DG.layout = (c, tokens, size) => {
let x = 0; return tokens.map(tk => {
const sz = (tk.size || 1) * size; c.font = `${sz}px "${famOf(tk)}"`;
const w = c.measureText(tk.s).width; let sw = 0;
if (tk.sub || tk.sup) { c.font = `${sz * 0.62}px "${DG.FONT.rm}"`; sw = c.measureText(tk.sub || tk.sup).width + sz * 0.04; }
const r = { x, w: w + sw, sz }; x += w + sw + (tk.gap != null ? tk.gap : sz * 0.06); return r;
});
};
// manim Write:每个 token 先沿轮廓描边(lineDash 推进),后半程填色、描边淡掉;token 间 lag = min(4/(n+1), 0.2)(3b1b creation.py)。
// 尊重外层 globalAlpha(FadeOut 时整条公式一起淡)。返回每个 token 的屏幕 {x,w}。
DG.math = (c, tokens, x, y, size, { p = 1, align = 'center', col = '#fff', lag } = {}) => {
const L = DG.layout(c, tokens, size), total = L.length ? L[L.length - 1].x + L[L.length - 1].w : 0;
const x0 = align === 'center' ? x - total / 2 : align === 'right' ? x - total : x;
const n = tokens.length, r = lag != null ? lag : Math.min(4 / (n + 1), 0.2);
const A0 = c.globalAlpha;
c.save(); c.textBaseline = 'alphabetic'; c.textAlign = 'left';
tokens.forEach((tk, i) => {
const q = MO.lagged(i, n, clamp(p), r); if (q <= 0) return;
const sz = L[i].sz, fx = x0 + L[i].x, colr = tk.col || col;
const draw = (txt, xx, yy, f, mode) => { c.font = f; mode === 's' ? c.strokeText(txt, xx, yy) : c.fillText(txt, xx, yy); };
const main = `${sz}px "${famOf(tk)}"`, small = `${sz * 0.62}px "${DG.FONT.rm}"`;
c.font = main; const mw = c.measureText(tk.s).width;
const parts = [[tk.s, fx, y, main]]; if (tk.sub) parts.push([tk.sub, fx + mw + sz * 0.02, y + sz * 0.22, small]); if (tk.sup) parts.push([tk.sup, fx + mw + sz * 0.02, y - sz * 0.42, small]);
const qs = MO.doubleSmooth(q);
if (qs < 1) { c.strokeStyle = colr; c.lineWidth = Math.max(1.2, sz * 0.025); c.setLineDash([sz * 5 * clamp(qs * 2), 1e5]); c.globalAlpha = A0 * (1 - clamp((qs - 0.6) / 0.4)); parts.forEach(pt => draw(pt[0], pt[1], pt[2], pt[3], 's')); c.setLineDash([]); }
const fa = clamp((qs - 0.4) / 0.6); if (fa > 0) { c.globalAlpha = A0 * fa; c.fillStyle = colr; parts.forEach(pt => draw(pt[0], pt[1], pt[2], pt[3], 'f')); }
c.globalAlpha = A0;
});
c.restore();
return L.map(l => ({ x: x0 + l.x, w: l.w }));
};
// 纯文本的 Write(中文标题也走这个:非 ASCII 字自动用 DG.FONT.zh)
DG.write = (c, text, x, y, size, p, opt = {}) => DG.math(c, [...text].map(ch => ({ s: ch, zh: /[^\x00-\x7f]/.test(ch) || opt.zh, gap: 0 })), x, y, size, { ...opt, p });
// ---------- 神经网络 ----------
// 神经元:描边白 2px,填充不透明度 = 激活值(3b1b nn/part1.py 原做法)
DG.neuron = (c, x, y, r, a, { stroke = '#fff', fill = '#fff', lw = 2, sa = 1 } = {}) => {
c.save(); c.beginPath(); c.arc(x, y, r, 0, Math.PI * 2);
if (a > 0) { c.globalAlpha = clamp(a); c.fillStyle = fill; c.fill(); }
c.globalAlpha = sa; c.strokeStyle = stroke; c.lineWidth = lw; c.stroke(); c.restore();
};
// 圆周到圆周的连线端点
DG.edgeEnds = (ax, ay, ar, bx, by, br) => { const dx = bx - ax, dy = by - ay, d = Math.hypot(dx, dy) || 1; return [ax + dx / d * ar, ay + dy / d * ar, bx - dx / d * br, by - dy / d * br]; };
// 连线:正权重蓝、负权重红;线宽 = minW + maxW·|w|³(nn/part2.py:3·(|w|/max)³);p = 画到哪(ShowCreation)
DG.edge = (c, e, w, p = 1, { maxW = 3.2, minW = 0.6, pos = DG.MANIM.BLUE_C, neg = DG.MANIM.RED_C, alpha = 0.85, from = 0 } = {}) => {
if (p <= from) return;
const [x1, y1, x2, y2] = e;
c.save(); c.strokeStyle = w >= 0 ? pos : neg; c.globalAlpha = alpha; c.lineWidth = minW + maxW * Math.pow(Math.min(1, Math.abs(w)), 3);
c.beginPath(); c.moveTo(lerp(x1, x2, from), lerp(y1, y2, from)); c.lineTo(lerp(x1, x2, p), lerp(y1, y2, p)); c.stroke(); c.restore();
};
// ShowPassingFlash(time_width=2.0):信号沿线闪过,返回可见段 [lo, hi](0..1)
DG.flash = (alpha, tw = 2) => { const up = lerp(0, 1 + tw, alpha); return [clamp(up - tw), clamp(up)]; };
// ---------- 提示 ----------
DG.indicate = p => ({ s: 1 + 0.2 * MO.thereAndBack(clamp(p)), k: MO.thereAndBack(clamp(p)) }); // 放大 1.2、染黄(k)、回来
// Circumscribe:矩形框沿周长画出再收走(time_width 0.3 的近似)
DG.circumscribe = (c, x, y, w, h, p, { col = DG.MANIM.YELLOW, lw = 4, tw = 0.3 } = {}) => {
if (p <= 0 || p >= 1) return; const pts = DG.rectPts(x + w / 2, y + h / 2, w, h, 160);
const hi = clamp(lerp(0, 1 + tw, p)), lo = clamp(hi - tw - (1 - p) * 0.7);
c.save(); c.strokeStyle = col; c.lineWidth = lw; c.beginPath();
const i0 = Math.floor(lo * 160), i1 = Math.floor(hi * 160); for (let i = i0; i <= Math.min(160, i1); i++) { const q = pts[i % 160]; i === i0 ? c.moveTo(q[0], q[1]) : c.lineTo(q[0], q[1]); } c.stroke(); c.restore();
};
// 大括号(竖直,开口朝右),从中间向两端长出
DG.brace = (c, x, y0, y1, { col = '#fff', lw = 3, depth = 22, p = 1 } = {}) => {
if (p <= 0) return; const ym = (y0 + y1) / 2;
c.save(); c.strokeStyle = col; c.lineWidth = lw; c.lineCap = 'round'; c.globalAlpha = clamp(p * 1.5);
const k = MO.smooth(p), a0 = lerp(ym, y0, k), a1 = lerp(ym, y1, k);
c.beginPath(); c.moveTo(x, a0); c.quadraticCurveTo(x - depth * 0.5, a0, x - depth * 0.5, a0 + Math.min(40, (ym - a0) * 0.3));
c.lineTo(x - depth * 0.5, ym - Math.min(40, (ym - a0) * 0.3)); c.quadraticCurveTo(x - depth * 0.5, ym, x - depth, ym);
c.quadraticCurveTo(x - depth * 0.5, ym, x - depth * 0.5, ym + Math.min(40, (a1 - ym) * 0.3));
c.lineTo(x - depth * 0.5, a1 - Math.min(40, (a1 - ym) * 0.3)); c.quadraticCurveTo(x - depth * 0.5, a1, x, a1); c.stroke(); c.restore();
};
// ---------- 白板:笔画时间线 + 一支跟着画的笔 ----------
// 按顺序往板上加笔画,每笔时长 = 长度 / 笔速,自动排成时间线;画的时候笔尖永远在最新那一笔的前沿,两笔之间沿弧线滑过去,笔从不离开画面。
// const B = DG.board({ ink, lw, speed, font }); B.at(0.12); B.line(pts); B.text('猫?', x, y, 150, {rate: 7.5}); B.pop('×1000万张', x, y, 74); ...
// 每帧:const { tip, col } = B.draw(g, ft)(在世界坐标里画,调用方先套相机);const [sx, sy] = B.penAt(ft, cam, tip);DG.pen(c, sx, sy, col || B.penColor(ft))。
// 自定义笔画 B.push({ kind:'custom', t0, t1, col, draw(g, q, ft) → 笔尖|null, start() → 世界点, end() → 世界点, handed:true })。
// 速度口径(RSA 实测):正文写字 ≈16 字/秒、标题 ≈7.5 字/秒;强调色关键词不带手、整词弹出(后期合成)。
DG.board = ({ ink = '#0A0503', lw = 6.5, speed = 2600, font = '"LXGWWenKai-500"' } = {}) => {
const B = { S: [], cur: 0, ink, lw, speed, font };
B.at = t => { B.cur = t; return B; };
B.push = s => { B.S.push(s); return s; };
B.line = (raw, { w = lw, col = ink, speed: sp = speed, seed = B.S.length + 1, amp = 1.4, smooth = true, min = 0.04, gap = 0.02 } = {}) => {
const pts = smooth ? DG.hand(raw, { amp, seed, per: 8 }) : raw, cum = DG.cum(pts), len = cum[cum.length - 1];
const d = Math.max(min, len / sp); B.S.push({ kind: 'line', pts, cum, len, w, col, t0: B.cur, t1: B.cur + d }); B.cur += d + gap;
};
// 一笔直线(不抖、固定时长,比如网络连线),不推进太多时间
B.segment = (a, b, { w = 3, col = ink, dur = 0.06, gap = 0.012 } = {}) => {
const L = Math.hypot(b[0] - a[0], b[1] - a[1]); B.S.push({ kind: 'line', pts: [a, b], cum: [0, L], len: L, w, col, t0: B.cur, t1: B.cur + dur }); B.cur += gap;
};
// 手写字:rate 字/秒
B.text = (str, x, y, size, { col = ink, rate = 16, align = 'left', dur } = {}) => {
const d = dur || [...str].length / rate; B.S.push({ kind: 'text', str, x, y, size, col, align, t0: B.cur, t1: B.cur + d }); B.cur += d + 0.03;
};
// 强调词:不带手、0.3s 放大回落整词弹出
B.pop = (str, x, y, size, { col = ink, align = 'center', dur = 0.3 } = {}) => { B.S.push({ kind: 'pop', str, x, y, size, col, align, t0: B.cur, t1: B.cur + dur }); B.cur += 0.12; };
// 铺色(淡入,不推进时间)
B.fill = (path, col, dur = 0.18) => { B.S.push({ kind: 'fill', path, col, t0: B.cur, t1: B.cur + dur }); };
const drawOne = (g, s, ft) => {
if (ft < s.t0) return null;
const q = clamp((ft - s.t0) / (s.t1 - s.t0));
if (s.kind === 'custom') return s.draw(g, q, ft);
if (s.kind === 'fill') { g.save(); g.globalAlpha = q; g.fillStyle = s.col; g.fill(s.path); g.restore(); return null; }
if (s.kind === 'line') { g.strokeStyle = s.col; g.lineWidth = s.w; return DG.drawPartial(g, s.pts, s.cum, s.len * MO.sineInOut(q)); }
if (s.kind === 'pop') {
g.save(); g.font = `${s.size}px ${B.font}`; g.fillStyle = s.col; g.textBaseline = 'alphabetic'; g.textAlign = s.align;
const e = MO.backOut(q, 2.2); g.globalAlpha = clamp(q * 4); g.translate(s.x, s.y - s.size * 0.35); g.scale(e, e); g.fillText(s.str, 0, s.size * 0.35); g.restore(); return null;
}
if (s.kind === 'text') {
// 逐字写:笔尖在字框里 3 行之字形来回,遮罩跟着笔尖揭开这个字(Reveal 画法用在单字上)
g.save(); g.font = `${s.size}px ${B.font}`; g.fillStyle = s.col; g.textBaseline = 'alphabetic';
const chars = [...s.str], ws = chars.map(ch => g.measureText(ch).width), w = ws.reduce((a, b) => a + b, 0), x0 = s.align === 'center' ? s.x - w / 2 : s.x;
const n = chars.length, k = Math.min(n, q * n), done = Math.floor(k);
let x = x0, tip = null;
chars.forEach((ch, i) => {
if (i < done) g.fillText(ch, x, s.y);
else if (i === done && k < n) {
const zz = DG.zigzag(x - 2, s.y - s.size * 0.95, ws[i] + 4, s.size * 1.15, 3), cum = DG.cum(zz), d = cum[cum.length - 1] * (k - done);
g.save(); g.clip(DG.revealMask(zz, cum, d, s.size * 0.62)); g.fillText(ch, x, s.y); g.restore(); tip = DG.pointAt(zz, cum, d);
}
x += ws[i];
});
g.restore(); return tip || [x0 + w, s.y - s.size * 0.35];
}
return null;
};
// 画全部笔画(世界坐标)。返回正在画的那一笔的笔尖与墨色(没有在画的 → tip=null)
B.draw = (g, ft) => {
g.lineJoin = 'round'; g.lineCap = 'round';
let tip = null, col = null;
for (const s of B.S) { const p = drawOne(g, s, ft); if (p && ft < s.t1) { tip = p; col = s.col; } }
return { tip, col };
};
const handed = () => B.S.filter(s => s.kind !== 'pop' && s.kind !== 'fill' && (s.kind !== 'custom' || s.handed !== false));
const tw = s => s.size * [...s.str].length * 0.9;
const endPt = s => s.kind === 'custom' ? s.end() : s.kind === 'line' ? s.pts[s.pts.length - 1] : [s.align === 'center' ? s.x + tw(s) / 2 : s.x + tw(s), s.y - s.size * 0.3];
const startPt = s => s.kind === 'custom' ? s.start() : s.kind === 'line' ? s.pts[0] : [s.align === 'center' ? s.x - tw(s) / 2 : s.x, s.y - s.size * 0.3];
// 笔在屏幕上的位置:在画 → 笔尖;两笔之间 → 从上一笔终点沿弧线滑到下一笔起点;开场 → 从右下入画
B.penAt = (ft, cam, tip) => {
if (tip) return CAM.toScreen(cam, tip[0], tip[1]);
let prev = null, next = null;
for (const s of handed()) { if (s.t1 <= ft) prev = s; else if (s.t0 > ft && !next) next = s; }
if (prev && next) {
const q = MO.sineInOut((ft - prev.t1) / (next.t0 - prev.t1)), a = CAM.toScreen(cam, ...endPt(prev)), b = CAM.toScreen(cam, ...startPt(next));
return [lerp(a[0], b[0], q), lerp(a[1], b[1], q) - Math.sin(q * Math.PI) * Math.min(80, 20 + Math.hypot(b[0] - a[0], b[1] - a[1]) * 0.15)];
}
if (next) { const b = CAM.toScreen(cam, ...startPt(next)), q = MO.cubicOut(clamp(ft / next.t0)); return [lerp(W * 0.62, b[0], q), lerp(H * 0.7, b[1], q)]; }
return CAM.toScreen(cam, ...endPt(prev));
};
// 空档里笔的颜色 = 下一笔的墨色(没有下一笔就用上一笔)
B.penColor = ft => { const hs = handed(), nx = hs.find(s => s.t0 > ft), pv = [...hs].reverse().find(s => s.t1 <= ft); return (nx || pv || { col: ink }).col; };
return B;
};
// 一支马克笔(屏幕空间,笔尖在 (x,y),笔身朝右上)。笔尾帽 = 墨色;有高光和投影,浮在板上。用笔引导视线。
DG.pen = (c, x, y, col, tilt = 0) => {
c.save(); c.translate(x, y); c.rotate(-0.72 + tilt);
c.fillStyle = 'rgba(0,0,0,.12)'; c.beginPath(); c.roundRect(30, 14, 250, 34, 16); c.fill();
c.fillStyle = col; c.beginPath(); c.moveTo(0, 0); c.lineTo(26, -8); c.lineTo(26, 8); c.closePath(); c.fill();
c.fillStyle = '#e8e8e4'; c.beginPath(); c.roundRect(24, -12, 26, 24, 4); c.fill();
c.fillStyle = '#26262a'; c.beginPath(); c.roundRect(48, -17, 190, 34, 12); c.fill();
c.fillStyle = col; c.beginPath(); c.roundRect(212, -18, 46, 36, 10); c.fill();
c.fillStyle = 'rgba(255,255,255,.22)'; c.beginPath(); c.roundRect(60, -12, 140, 7, 4); c.fill();
c.restore();
};
})();
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |