Files
drawlogo/js/sticker-skills/skills.js
T
sgp beb10e170b feat: 检索词表 + 表情技能 + 海报字重编排 三向增强
- 中文语义词表 425 → 619 条(+194),新增行业细分/商业指标/技术工程/合规风控/节日节气/生活服务等 17 组场景词;对 11.8 万图标名语料复核覆盖率 99.0%

- 表情技能 12 → 20(motion 11→13 新增循环接缝/多元素错峰;emotion 1→7 新增强度匹配/场景克制/覆盖度/可读性/调性一致/情绪跳变)

- 共享技能 54 → 55:新增头像向技能 avatar-safe-zone(圆/方裁切安全区),映射到方案评审步骤

- 海报字体层级:新增 TYPE_SCALES 四档白名单(impact/editorial/steady/quiet),AI 决策 JSON 增加 typeScaleId,渲染层按预设输出 400/700/800 与字号比;非法值回退默认

- 修复 audit-emojis.html 技能数量断言过期(12→20);emoji-smoke 62/62 通过,audit-emojis 27 通过 0 失败

- 版本联动 20261108e(cn-tags / skills core+layout / sticker skills / poster-generator+ai)
2026-11-08 10:45:28 +08:00

508 lines
29 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* 画个标 · 表情技能(20 个:motion 13 / emotion 7)
* 全部为纯函数:run(args) 返回 {ok/tip/...},test() 可自跑。
* 用于表情生成后的评审/优化建议(动态节奏/物理/循环/体积/平台/情绪)。
* 来源标注「自研」或公开设计原则。
*/
HGB_StickerSkills.register([
/* ---------- motion 动画节奏 ---------- */
{
id: 'motion-timing', name: '节奏合理性', category: 'motion', emoji: '⏱',
scene: '评估动画时长与帧率是否合理(过短看不清、过长拖沓、帧率过低卡顿)',
summary: '按动画类型建议合适时长与帧率:表情通常 0.8-2s,弹跳/闪烁宜短促,漂浮/旋转可稍长。',
params: { duration: '时长秒(默认 1.2)', fps: '帧率(默认 12)', type: '动画类型 id' },
source: '自研(动态表情通用规范)',
run(args) {
const d = Number(args.duration) || 1.2;
const fps = Number(args.fps) || 12;
const type = args.type || 'bounce';
const fastTypes = ['bounce', 'wiggle', 'fade'];
const ideal = fastTypes.includes(type) ? 1.0 : 1.5;
const fpsOk = fps >= 8;
const durOk = Math.abs(d - ideal) <= 0.6;
const tips = [];
if (!fpsOk) tips.push('帧率过低(<8fps)会卡顿,建议 12fps');
if (!durOk) tips.push(d < ideal - 0.6 ? '时长过短,动作看不清,建议 ' + ideal + 's' : '时长偏长,动作拖沓,建议 ' + ideal + 's');
return {
ok: fpsOk && durOk,
fps, duration: d, idealDuration: ideal,
tip: tips.length ? tips.join(';') : '节奏合理(' + d + 's × ' + fps + 'fps)'
};
},
test() { return this.run({ duration: 1.2, fps: 12, type: 'bounce' }); }
},
{
id: 'bounce-physics', name: '弹跳物理', category: 'motion', emoji: '🏀',
scene: '检查弹跳动画的落点与压缩是否符合物理直觉',
summary: '弹跳应在上升段减速、下落段加速,触底时有轻微压缩(squash)并回弹,幅度不溢出画面。',
params: { amplitude: '强度倍率(0.3-2)', elH: '元素高度 px' },
source: '自研(弹跳 12 原则)',
run(args) {
const amp = Number(args.amplitude) || 1;
const elH = Number(args.elH) || 80;
const jump = elH * 0.5 * amp;
const overflows = jump > elH * 0.9;
return {
ok: amp <= 1.2 && !overflows,
jumpHeight: Math.round(jump),
tip: overflows ? '弹跳幅度过大,位移可能超出表情画面,建议 amplitude ≤ 1.2' : (amp <= 1.2 ? '弹跳物理合理(高度 ≈ 元素高的 ' + Math.round(50 * amp) + '%)' : '幅度偏大,建议 0.8-1.2 之间')
};
},
test() { return this.run({ amplitude: 1, elH: 80 }); }
},
{
id: 'loop-seamless', name: '循环无缝', category: 'motion', emoji: '🔁',
scene: '检查动画首尾帧是否平滑衔接(循环无跳变)',
summary: '正弦/余弦类动画天然无缝;线性动画(旋转/位移动画)需确认首尾状态一致。',
params: { type: '动画类型 id' },
source: '自研(循环动画原则)',
run(args) {
const t = args.type || 'bounce';
const seamless = ['pulse', 'wiggle', 'float', 'fade', 'spin', 'twirl'].includes(t);
return {
ok: seamless,
tip: seamless ? '该类型使用正弦/整周期驱动,首尾自然衔接' : '该类型首尾状态可能跳变,建议确认结束帧与起始帧一致或使用整周期时长'
};
},
test() { return this.run({ type: 'pulse' }); }
},
{
id: 'motion-simplicity', name: '动画克制性', category: 'motion', emoji: '🧘',
scene: '检查表情动画是否过于花哨(多种动画叠加/幅度过大)',
summary: '单个表情建议只做一种主动画(或主+极轻微辅助),幅度适中,避免炫技影响识别。',
params: { animCount: '同时叠加的动画层数(默认 1)', amplitude: '强度倍率(默认 1)' },
source: '自研(动态设计克制原则)',
run(args) {
const n = Number(args.animCount) || 1;
const amp = Number(args.amplitude) || 1;
const ok = n <= 1 && amp <= 1.4;
return {
ok,
tip: ok ? '动画克制,主次分明' : (n > 1 ? '同时叠加 ' + n + ' 层动画,建议只保留主动画' : '幅度过大,建议降低到 1.4 以内')
};
},
test() { return this.run({ animCount: 1, amplitude: 1 }); }
},
/* ---------- emotion 情绪传达 ---------- */
{
id: 'emotion-fit', name: '情绪传达', category: 'motion', emoji: '😄',
scene: '检查动画类型与表情主题情绪是否匹配(开心/生气/惊讶/难过/兴奋/平静/鼓励/警示等)',
summary: '开心→弹跳/摇摆;生气→抖动;惊讶→心跳/脉冲;难过→漂浮;兴奋→弹跳旋转;平静→呼吸;鼓励→漂浮;警示→闪烁。',
params: { keyword: '主题/场景关键词(中文)', type: '动画类型 id' },
source: '自研(情绪-动作映射,与 emotion-params 生成决策同源)',
run(args) {
const kw = String(args.keyword || '');
const type = args.type || 'bounce';
const map = [
{ re: /开心|欢乐|庆祝|成功|胜利|点赞/, types: ['bounce', 'wiggle', 'spin'], hint: '弹跳/摇摆/旋转' },
{ re: /生气|愤怒|暴躁/, types: ['shake'], hint: '高频抖动' },
{ re: /惊讶|震惊|惊喜|哇/, types: ['heartbeat', 'pulse'], hint: '心跳脉冲' },
{ re: /难过|伤心|失落/, types: ['float'], hint: '低落漂浮' },
{ re: /兴奋|激动|high/, types: ['hopspin', 'bounce'], hint: '弹跳旋转' },
{ re: /平静|舒缓|放松/, types: ['breath', 'float'], hint: '柔和呼吸' },
{ re: /鼓励|加油|支持|打气/, types: ['float'], hint: '上下浮动' },
{ re: /警示|提醒|注意|重要/, types: ['fade', 'pulse'], hint: '闪烁/脉冲' }
];
const hit = kw ? map.find(m => m.re.test(kw)) : null;
if (!hit) return { ok: true, tip: '未识别情绪关键词,保持默认动画即可' };
const ok = hit.types.includes(type);
return { ok, tip: ok ? '动画与「' + kw + '」情绪匹配' : '「' + kw + '」更建议使用 ' + hit.hint + ' 表达' };
},
test() { return this.run({ keyword: '庆祝', type: 'bounce' }); }
},
/* ---------- style 风格匹配 ---------- */
{
id: 'motion-style-match', name: '动画与风格匹配', category: 'motion', emoji: '🎭',
scene: '检查动画风格与视觉风格是否统一(拟物→弹性动画,极简→克制位移)',
summary: '圆润/拟物风格适合弹性夸张动画;极简/几何风格适合小幅线性动画;像素风格适合定格跳帧。',
params: { styleId: '风格 id', type: '动画类型 id' },
source: '自研(风格-动画匹配)',
run(args) {
const sid = args.styleId || '';
const type = args.type || 'bounce';
const linear = ['minimal', 'swiss', 'flat'].some(k => sid.includes(k));
const pixel = sid.includes('pixel');
const playful = ['neon', 'cartoon', 'vibrant', 'fun'].some(k => sid.includes(k));
let tip = '动画与风格匹配';
let ok = true;
if (linear && ['wiggle', 'spin'].includes(type)) { ok = false; tip = '极简/几何风格建议克制位移(小幅漂浮/脉冲),摇摆旋转偏花哨'; }
if (pixel && ['float', 'wiggle'].includes(type)) { ok = false; tip = '像素风格建议定格跳帧动画,平滑漂浮/摇摆不协调'; }
if (playful && ['fade'].includes(type)) { ok = false; tip = '活泼风格建议弹性动画(弹跳/摇摆),闪烁过于安静'; }
return { ok, tip };
},
test() { return this.run({ styleId: 'minimal', type: 'bounce' }); }
},
/* ---------- export 导出工程 ---------- */
{
id: 'gif-volume', name: 'GIF 体积控制', category: 'motion', emoji: '📦',
scene: '评估导出 GIF 体积是否在平台限制内(微信动图建议 <500KB)',
summary: '体积 ≈ 尺寸² × 帧数 × 色彩复杂度;超限时建议降尺寸/降帧率/减少帧数。',
params: { size: '边长 px(默认 240)', fps: '帧率(默认 12)', duration: '时长秒(默认 1.2)' },
source: '自研(GIF 工程经验)',
run(args) {
const size = Number(args.size) || 240;
const fps = Number(args.fps) || 12;
const d = Number(args.duration) || 1.2;
const frames = Math.round(fps * d);
const estKb = Math.round(size * size * frames * 0.035 / 1024);
const ok = estKb <= 500;
const tips = [];
if (estKb > 500) {
if (size > 240) tips.push('降到 240px');
if (fps > 10) tips.push('帧率降到 8-10fps');
if (d > 1.2) tips.push('时长缩到 1.2s');
}
return { ok, estimatedKb: estKb, tip: ok ? '预计体积约 ' + estKb + 'KB,平台内合规' : '预计体积约 ' + estKb + 'KB 超限,建议:' + (tips.join('、') || '减少色彩数') };
},
test() { return this.run({ size: 240, fps: 12, duration: 1.2 }); }
},
{
id: 'platform-spec', name: '平台尺寸规范', category: 'motion', emoji: '📱',
scene: '按目标平台校验表情尺寸/格式合规性(微信/QQ/Telegram)',
summary: '微信动图 240px、QQ 表情 320px、Telegram 贴纸 512px;超限会压缩失真。',
params: { platform: '平台 id(wechat/qq/telegram/other)', size: '边长 px' },
source: '自研(平台规范)',
run(args) {
const spec = {
wechat: { size: 240, note: '微信动图/自定义表情 240' },
qq: { size: 320, note: 'QQ 表情 320' },
telegram: { size: 512, note: 'Telegram 贴纸 512' }
};
const p = spec[args.platform];
if (!p) return { ok: true, tip: '自定义尺寸 ' + (args.size || '?') + 'px 可直接使用' };
const size = Number(args.size) || 0;
const ok = size === p.size;
return { ok, tip: ok ? '符合' + p.note + '规格' : '建议导出为 ' + p.size + 'px(' + p.note + '),当前 ' + size + 'px 会被平台压缩' };
},
test() { return this.run({ platform: 'wechat', size: 240 }); }
},
/* ---------- emotion 情绪驱动(gen:情绪 → 动画决策) ---------- */
{
id: 'emotion-params', name: '情绪-动画映射', category: 'emotion', emoji: '😊',
scene: '根据目标情绪给出动画类型与参数建议(开心/生气/惊讶/难过/兴奋/平静)',
summary: '情绪决定动效语言:开心→轻快弹跳、生气→高频抖动、惊讶→心跳脉冲、难过→低落漂浮、兴奋→弹跳旋转、平静→柔和呼吸。',
params: { mood: '情绪词(happy/angry/surprised/sad/excited/calm)', type: '当前动画类型(可选)' },
source: '自研(情绪-动效语言映射)',
run(args) {
const map = {
happy: { type: 'bounce', speed: 1.2, amplitude: 1, note: '开心:轻快弹跳,节奏明快' },
angry: { type: 'shake', speed: 1.4, amplitude: 1.2, note: '生气:高频抖动,幅度略大' },
surprised: { type: 'heartbeat', speed: 1.2, amplitude: 1.1, note: '惊讶:心跳脉冲,节奏感强' },
sad: { type: 'float', speed: 0.8, amplitude: 0.8, note: '难过:低落漂浮,慢而轻' },
excited: { type: 'hopspin', speed: 1.3, amplitude: 1.1, note: '兴奋:弹跳旋转,活力四射' },
calm: { type: 'breath', speed: 0.9, amplitude: 0.8, note: '平静:柔和呼吸,舒缓' }
};
const m = map[String(args.mood || 'happy').toLowerCase()];
if (!m) return { ok: false, tip: '未识别情绪,可用:' + Object.keys(map).join('/') };
const matched = !args.type || args.type === m.type;
return Object.assign({ ok: matched, mood: m.type, tip: matched ? '推荐「' + m.note + '」' : '当前 ' + args.type + ' 与情绪不符,建议改用 ' + m.type + '(' + m.note + ')' }, m);
},
test() { return this.run({ mood: 'happy' }); }
},
/* ---------- motion 分层与幅度评审 ---------- */
{
id: 'layer-harmony', name: '分层动画协调', category: 'motion', emoji: '🎼',
scene: '检查分层动画(元素错峰)是否协调,不被打乱节奏',
summary: '分层错峰应在 0-0.5 周期内:主导元素同拍或先动,辅助元素错峰跟随;超过 0.5 会"各动各的"。',
params: { layered: '是否分层', layerSpread: '错峰比例 0-0.6', elementCount: '元素数' },
source: '自研(分层动画编排)',
run(args) {
const layered = !!args.layered;
const spread = Number(args.layerSpread) || 0;
const n = Number(args.elementCount) || 1;
if (!layered || n <= 1) return { ok: true, tip: '单拍动画,无需协调' };
const ok = spread >= 0 && spread <= 0.5;
return { ok, tip: ok ? '错峰 ' + spread + ' 周期,分层协调有层次' : '错峰比例超 0.5 会各动各的,建议 0.2-0.4' };
},
test() { return this.run({ layered: true, layerSpread: 0.3, elementCount: 3 }); }
},
{
id: 'motion-range', name: '幅度不溢出', category: 'motion', emoji: '📐',
scene: '检查动画位移/缩放是否超出表情画布(边缘被裁切)',
summary: '位移与缩放总和应在画布内:弹跳高度 ≤ 元素高 50%,缩放 ≤ 1.35,抖动位移 ≤ 8px。',
params: { type: '动画类型', amplitude: '强度倍率', elH: '元素高 px', size: '画布边长 px' },
source: '自研(画布安全域)',
run(args) {
const amp = Number(args.amplitude) || 1;
const elH = Number(args.elH) || 80;
const size = Number(args.size) || 240;
const t = args.type || 'bounce';
let maxShift = 0, maxScale = 1;
if (t === 'bounce' || t === 'hopspin') maxShift = elH * 0.5 * amp;
else if (t === 'shake') maxShift = 5 * amp;
else if (t === 'pulse') maxScale = 1 + 0.18 * amp;
else if (t === 'heartbeat') maxScale = 1 + 0.22 * amp;
else if (t === 'breath') maxScale = 1 + 0.09 * amp;
const margin = (size - elH) / 2;
const ok = maxShift <= margin + elH * 0.1 && maxScale <= 1.5;
return { ok, maxShift: Math.round(maxShift * 10) / 10, maxScale,
tip: ok ? '位移 ' + Math.round(maxShift) + 'px / 缩放 ' + Math.round(maxScale * 100) + '%,画布内安全' : '动画幅度可能溢出画布,建议降低 amplitude 或扩大安全边距' };
},
test() { return this.run({ type: 'bounce', amplitude: 1, elH: 80, size: 240 }); }
},
{
id: 'motion-ease', name: '缓动曲线', category: 'motion', emoji: '📈',
scene: '检查动画是否平滑缓动(无生硬突变)',
summary: '正弦/余弦类平滑;弹跳应有减速段;线性匀速位移显得生硬。',
params: { type: '动画类型 id' },
source: '自研(缓动 12 原则)',
run(args) {
const t = args.type || 'bounce';
const smooth = ['pulse', 'float', 'fade', 'breath', 'heartbeat', 'twirl', 'wiggle'].includes(t);
const eased = ['bounce', 'hopspin'].includes(t);
return { ok: smooth || eased, tip: (smooth ? '正弦驱动,平滑自然' : eased ? '含减速/压缩段,物理自然' : '线性驱动,建议叠加缓动曲线') + '(' + t + ')' };
},
test() { return this.run({ type: 'bounce' }); }
},
/* ---------- 第二批 motion(动效质量深化,2026-11-08) ---------- */
{
id: 'motion-loop-seam', name: '循环接缝', category: 'motion', emoji: '🔁',
scene: '检查循环类动画(漂浮/呼吸/脉冲/旋转)首尾帧是否闭合,避免导出 GIF 时出现跳帧',
summary: '周期动画必须满足 f(0) ≈ f(1):正弦驱动天然闭合;含位移累加或线性旋转的动画需确认整周期回到原点。',
params: { type: '动画类型 id', cycles: '整周期内的往返次数(默认 1)', amplitude: '强度倍率' },
source: '自研(循环动画连续性)',
run(args) {
const t = args.type || 'float';
const cycles = Number(args.cycles) || 1;
const amp = Number(args.amplitude) || 1;
const periodic = ['float', 'breath', 'pulse', 'heartbeat', 'wiggle', 'bounce', 'hopspin'];
const smoothLoop = ['float', 'breath', 'pulse', 'heartbeat'];
const spinning = ['spin', 'twirl'];
const continuous = spinning.includes(t);
const closed = periodic.includes(t) || continuous;
const intCycles = Math.abs(cycles - Math.round(cycles)) < 1e-6;
const ok = closed && intCycles;
const tips = [];
if (!closed) tips.push('该动画不保证首尾闭合,建议改用正弦驱动或补首尾过渡帧');
if (!intCycles) tips.push('往返次数需为整数(当前 ' + cycles + '),否则末帧与首帧错位');
if (smoothLoop.includes(t) && amp > 1.4) tips.push('幅度过大时接缝更明显,建议 amplitude ≤ 1.4');
return {
ok, type: t, cycles, amplitude: amp,
tip: tips.length ? tips.join(';') : '首尾帧闭合,循环无跳帧(' + t + ' × ' + cycles + ' 周期)'
};
},
test() {
return { ok: this.run({ type: 'float', cycles: 2, amplitude: 1 }).ok, bad: this.run({ type: 'float', cycles: 1.5 }).ok };
}
},
{
id: 'motion-multi-element', name: '多元素错峰', category: 'motion', emoji: '🎚',
scene: '表情由主图 + 装饰(星星/汗滴/符号)组成时,检查各元素是否错峰,避免整组同相抖动',
summary: 'N 个元素应按周期均匀分配相位延迟(delay = period / N),主图领先、装饰跟随 0.1-0.25 个周期。',
params: { elements: '元素数量', duration: '周期秒(默认 1.2)', leadRatio: '主图领先比例(默认 0.08)' },
source: '自研(分层动画错峰)',
run(args) {
const n = Math.max(1, Number(args.elements) || 3);
const d = Number(args.duration) || 1.2;
const lead = Number(args.leadRatio) || 0.08;
const step = n > 1 ? (0.85 - lead) / (n - 1) : 0;
const delays = [];
for (let i = 0; i < n; i++) delays.push(Math.round((-lead - step * i) * d * 1000) / 1000);
const samePhase = n > 1 && step * d < 0.02;
const maxDelay = Math.abs(delays[delays.length - 1] || 0);
const ok = !samePhase && maxDelay < d;
return {
ok, count: n, period: d, delays,
tip: ok
? n + ' 个元素按 ' + (step * d).toFixed(2) + 's 间隔错峰,最长延迟 ' + maxDelay.toFixed(2) + 's 在周期内'
: '元素同相或延迟超出周期,建议减小元素数或缩短延迟步长'
};
},
test() {
return { ok: this.run({ elements: 3, duration: 1.2 }).ok, single: this.run({ elements: 1 }).ok };
}
},
/* ---------- emotion 情绪传达(第二批,2026-11-08) ---------- */
{
id: 'emotion-intensity', name: '情绪强度匹配', category: 'emotion', emoji: '🌡',
scene: '评估动画幅度/节奏是否与情绪强度一致(微笑用轻浮动,狂喜才用夸张弹跳)',
summary: '强度 1-5 与动效幅度映射:1-2 用呼吸/淡入,3 用脉冲/浮动,4-5 才用弹跳/心跳/抖动。',
params: { intensity: '情绪强度 1-5(默认 3)', amplitude: '动效幅度倍率(默认 1)', type: '动画类型 id' },
source: '自研(情绪-动效映射)',
run(args) {
const intensity = Math.min(5, Math.max(1, Number(args.intensity) || 3));
const amp = Number(args.amplitude) || 1;
const t = args.type || 'pulse';
const strong = ['bounce', 'heartbeat', 'shake', 'hopspin', 'spin'];
const gentle = ['breath', 'fade', 'float', 'pulse', 'twirl', 'wiggle'];
const isStrong = strong.includes(t);
const expectedStrong = intensity >= 4;
const match = isStrong === expectedStrong;
const ampOk = intensity >= 4 ? amp >= 0.9 : amp <= 1.2;
const tips = [];
if (!match) tips.push(expectedStrong ? '强度 ' + intensity + ' 建议用更有力的动效(弹跳/心跳/抖动)' : '强度 ' + intensity + ' 用强动效会显得夸张,建议改呼吸/浮动/脉冲');
if (!ampOk) tips.push(intensity >= 4 ? '幅度偏小(' + amp + '),可提到 1.0+' : '幅度偏大(' + amp + '),建议 ≤ 1.2');
return {
ok: match && ampOk, intensity, amplitude: amp, type: t,
suggestTypes: expectedStrong ? strong : gentle,
tip: tips.length ? tips.join(';') : '情绪强度与动效力度匹配(强度 ' + intensity + ' × ' + t + ')'
};
},
test() {
return { ok: this.run({ intensity: 5, amplitude: 1.1, type: 'bounce' }).ok, gentle: this.run({ intensity: 1, amplitude: 0.8, type: 'breath' }).ok };
}
},
{
id: 'emotion-context', name: '场景克制度', category: 'emotion', emoji: '🏷',
scene: '同一情绪在不同使用场景(聊天/弹幕/工作群/亲密关系)需要不同表达强度',
summary: '工作场景避免强烈负向与夸张动效;弹幕需高辨识度短动效;亲密场景可夸张;聊天居中即可。',
params: { scene: '场景(chat/bullet/work/intimate,默认 chat)', emotion: '情绪 id(如 joy/anger/sad/wow/love)', amplitude: '动效幅度(默认 1)' },
source: '自研(场景化表情规范)',
run(args) {
const scene = args.scene || 'chat';
const emotion = args.emotion || 'joy';
const amp = Number(args.amplitude) || 1;
const cap = { chat: 1.3, bullet: 1.4, work: 0.9, intimate: 1.6 }[scene];
const negative = ['anger', 'sad', 'disgust', 'cry'].includes(emotion);
const strongNegInWork = scene === 'work' && negative && amp > 0.8;
const bulletSlow = scene === 'bullet' && amp < 0.9;
const ok = amp <= (cap || 1.3) && !strongNegInWork && !bulletSlow;
const tips = [];
if (amp > (cap || 1.3)) tips.push(scene + ' 场景建议幅度 ≤ ' + cap);
if (strongNegInWork) tips.push('工作场景的负向情绪建议收敛到 0.8 以下或改用中性表达');
if (bulletSlow) tips.push('弹幕场景需要更强视觉冲击,幅度建议 ≥ 0.9');
return {
ok, scene, emotion, amplitude: amp, cap: cap || 1.3,
tip: tips.length ? tips.join(';') : scene + ' 场景下 ' + emotion + ' 的表达强度合适'
};
},
test() {
return { ok: this.run({ scene: 'chat', emotion: 'joy', amplitude: 1.1 }).ok, work: this.run({ scene: 'work', emotion: 'anger', amplitude: 0.6 }).ok };
}
},
{
id: 'emotion-coverage', name: '情绪覆盖度', category: 'emotion', emoji: '🎭',
scene: '检查一套表情包的情绪分布是否失衡(全是开心 / 缺中性 / 负向过多)',
summary: '健康的一组表情建议:正向 50%-70%、中性 15%-30%、负向 10%-25%,且必含至少 1 个中性锚点。',
params: { emotions: '情绪 id 数组或 {joy:4, neutral:1} 计数对象' },
source: '自研(表情包情绪配比)',
run(args) {
const src = args.emotions;
const counts = {};
if (Array.isArray(src)) for (const e of src) counts[e] = (counts[e] || 0) + 1;
else if (src && typeof src === 'object') Object.assign(counts, src);
const total = Object.values(counts).reduce((a, b) => a + b, 0);
if (!total) return { ok: false, tip: '请提供至少一个情绪(数组或计数对象)' };
const group = e => ['joy', 'love', 'wow', 'excited', 'happy', 'laugh'].includes(e) ? 'pos'
: ['neutral', 'calm', 'think', 'hmm'].includes(e) ? 'neu' : 'neg';
let pos = 0, neu = 0, neg = 0;
for (const [e, n] of Object.entries(counts)) {
const g = group(e);
if (g === 'pos') pos += n; else if (g === 'neu') neu += n; else neg += n;
}
const r = { pos: pos / total, neu: neu / total, neg: neg / total };
const tips = [];
if (r.neu < 0.15) tips.push('缺中性锚点(当前 ' + Math.round(r.neu * 100) + '%),建议补 15%-30%');
if (r.pos > 0.8) tips.push('正向占比过高(' + Math.round(r.pos * 100) + '%),情绪层次单一');
if (r.neg > 0.3) tips.push('负向占比过高(' + Math.round(r.neg * 100) + '%),正式场景易误用');
return {
ok: tips.length === 0, total,
ratio: { pos: Math.round(r.pos * 100), neu: Math.round(r.neu * 100), neg: Math.round(r.neg * 100) },
tip: tips.length ? tips.join(';') : '情绪分布均衡(正 ' + Math.round(r.pos * 100) + '% / 中 ' + Math.round(r.neu * 100) + '% / 负 ' + Math.round(r.neg * 100) + '%)'
};
},
test() {
return { balanced: this.run({ emotions: { joy: 6, neutral: 2, sad: 2 } }).ok, unbalanced: this.run({ emotions: { joy: 9, wow: 1 } }).ok };
}
},
{
id: 'emotion-clarity', name: '情绪可读性', category: 'emotion', emoji: '👁',
scene: '小尺寸(48-96px)下表情是否一眼可辨,装饰过多会削弱情绪识别',
summary: '主体占画面 ≥ 60%、装饰元素 ≤ 2 个、避免细碎线条;小尺寸优先强化眼神与嘴形这类情绪特征。',
params: { size: '展示尺寸 px(默认 64)', subjectRatio: '主体占比 0-1(默认 0.7)', decorations: '装饰元素数(默认 1)', fineLines: '细碎线条数(默认 0)' },
source: '自研(小尺寸可读性)',
run(args) {
const size = Number(args.size) || 64;
const ratio = Number(args.subjectRatio) || 0.7;
const deco = Number(args.decorations) || 0;
const fine = Number(args.fineLines) || 0;
const small = size <= 96;
const tips = [];
if (ratio < 0.6) tips.push('主体占比 ' + Math.round(ratio * 100) + '% 偏小,建议 ≥60%');
if (deco > 2) tips.push('装饰 ' + deco + ' 个过多,小尺寸建议 ≤2');
if (small && fine > 0) tips.push('小尺寸下 ' + fine + ' 条细碎线条会糊,建议简化');
return {
ok: tips.length === 0, size, subjectRatio: ratio, decorations: deco,
tip: tips.length ? tips.join(';') : size + 'px 下主体清晰、装饰克制,情绪一眼可辨'
};
},
test() {
return { ok: this.run({ size: 64, subjectRatio: 0.72, decorations: 1 }).ok, noisy: this.run({ size: 64, subjectRatio: 0.5, decorations: 3 }).ok };
}
},
{
id: 'emotion-brand-fit', name: '角色调性一致性', category: 'emotion', emoji: '🧭',
scene: '角色/IP/品牌有固定调性时,检查表情情绪是否越界(严谨品牌不适合夸张搞怪)',
summary: '调性决定可用情绪集:friendly 全开、calm 去狂喜狂怒、sharp 弱化软萌、formal 仅中性+轻正向。',
params: { tone: '调性(friendly/calm/sharp/formal,默认 friendly)', emotion: '情绪 id', amplitude: '动效幅度(默认 1)' },
source: '自研(品牌调性-情绪白名单)',
run(args) {
const tone = args.tone || 'friendly';
const emotion = args.emotion || 'joy';
const amp = Number(args.amplitude) || 1;
const allow = {
friendly: ['joy', 'love', 'wow', 'sad', 'anger', 'neutral', 'laugh', 'think'],
calm: ['joy', 'neutral', 'think', 'calm', 'sad'],
sharp: ['anger', 'wow', 'joy', 'neutral', 'think'],
formal: ['neutral', 'joy', 'think']
}[tone] || ['joy', 'neutral'];
const inSet = allow.includes(emotion);
const ampCap = { friendly: 1.6, calm: 0.9, sharp: 1.3, formal: 0.7 }[tone] || 1.2;
const ampOk = amp <= ampCap;
const tips = [];
if (!inSet) tips.push(tone + ' 调性不建议使用 ' + emotion + ',可用:' + allow.join('/'));
if (!ampOk) tips.push(tone + ' 调性幅度建议 ≤ ' + ampCap + '(当前 ' + amp + ')');
return {
ok: inSet && ampOk, tone, emotion, amplitude: amp, allowed: allow,
tip: tips.length ? tips.join(';') : emotion + ' 符合 ' + tone + ' 调性,幅度 ' + amp + ' 在安全区'
};
},
test() {
return { ok: this.run({ tone: 'calm', emotion: 'joy', amplitude: 0.8 }).ok, bad: this.run({ tone: 'formal', emotion: 'anger', amplitude: 1.2 }).ok };
}
},
{
id: 'emotion-transition', name: '情绪跳变', category: 'emotion', emoji: '↔️',
scene: '一组表情按顺序播放或成套使用时,相邻情绪强度落差过大会显得突兀',
summary: '相邻情绪强度差建议 ≤2;强负向与强正向之间应有中性过渡项。',
params: { sequence: '情绪 id 数组(按使用顺序)' },
source: '自研(情绪序列过渡)',
run(args) {
const seq = Array.isArray(args.sequence) ? args.sequence : [];
if (seq.length < 2) return { ok: true, tip: '少于 2 个情绪,无需检查过渡' };
const level = { neutral: 1, calm: 1, think: 2, hmm: 2, joy: 3, love: 4, laugh: 4, wow: 4, sad: 3, cry: 4, anger: 5, excited: 5 };
const jump = [];
for (let i = 1; i < seq.length; i++) {
const a = level[seq[i - 1]] || 3, b = level[seq[i]] || 3;
if (Math.abs(a - b) >= 3) jump.push(seq[i - 1] + '→' + seq[i] + '(差' + Math.abs(a - b) + ')');
}
return {
ok: jump.length === 0, length: seq.length, jumps: jump,
tip: jump.length ? '情绪跳变过大:' + jump.join('、') + ',建议中间插入中性/轻度情绪过渡' : '情绪过渡平滑(' + seq.length + ' 个)'
};
},
test() {
return { smooth: this.run({ sequence: ['joy', 'wow', 'neutral'] }).ok, jump: this.run({ sequence: ['anger', 'calm', 'joy'] }).ok };
}
}
]);