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)
This commit is contained in:
+31
-12
@@ -13,6 +13,24 @@ const HGB_PosterGenerator = (function () {
|
||||
{ id: 'minimal', name: '极简', bg: '#ffffff', primary: '#111827', accent: '#4f46e5' }
|
||||
];
|
||||
|
||||
/**
|
||||
* 字体层级预设(白名单):AI 只能从中选择,保证标题/副标题的字号比与字重组合可控。
|
||||
* 字重限制在 400 / 700 / 800 —— 渲染器只内嵌 Noto Sans SC Regular(400) 与 Bold(700-900),
|
||||
* 超出范围的权重会被浏览器合成,视觉不可控。
|
||||
*/
|
||||
const TYPE_SCALES = [
|
||||
{ id: 'impact', name: '强冲击', titleWeight: 800, subWeight: 400, titleRatio: 0.075, subRatio: 0.38, note: '促销/活动主视觉,超大粗标题压场' },
|
||||
{ id: 'editorial', name: '编辑感', titleWeight: 700, subWeight: 400, titleRatio: 0.062, subRatio: 0.44, note: '文化/品牌叙事,标题收敛、副标题更可读' },
|
||||
{ id: 'steady', name: '稳健均衡', titleWeight: 700, subWeight: 700, titleRatio: 0.068, subRatio: 0.40, note: '政务/金融等信息型海报,标题副标题同粗同稳' },
|
||||
{ id: 'quiet', name: '克制留白', titleWeight: 400, subWeight: 400, titleRatio: 0.052, subRatio: 0.46, note: '高端/极简,细标题+大留白,靠空间而非字重建立层级' }
|
||||
];
|
||||
|
||||
const DEFAULT_SCALE = 'impact';
|
||||
|
||||
function scaleOf(id) {
|
||||
return TYPE_SCALES.find(s => s.id === id) || TYPE_SCALES[0];
|
||||
}
|
||||
|
||||
function uid(p) { return p + '_' + Date.now().toString(36) + Math.random().toString(36).slice(2, 6); }
|
||||
|
||||
function rect(id, x, y, w, h, fill) { return { id, type: 'rect', x, y, w, h, fill }; }
|
||||
@@ -28,9 +46,9 @@ const HGB_PosterGenerator = (function () {
|
||||
const cw = spec.w, ch = spec.h, els = [];
|
||||
els.push(rect(uid('bg'), 0, 0, cw, ch, o.palette.bg));
|
||||
els.push(circle(uid('dot'), cw / 2, ch * 0.30, ch * 0.12, o.palette.accent));
|
||||
const fs = Math.round(cw * 0.075);
|
||||
els.push(text(uid('title'), o.title, cw / 2, ch * 0.50, fs, 800, o.palette.primary, 'middle'));
|
||||
if (o.sub) els.push(text(uid('sub'), o.sub, cw / 2, ch * 0.56, Math.round(fs * 0.38), 400, o.palette.primary, 'middle'));
|
||||
const fs = Math.round(cw * o.scale.titleRatio);
|
||||
els.push(text(uid('title'), o.title, cw / 2, ch * 0.50, fs, o.scale.titleWeight, o.palette.primary, 'middle'));
|
||||
if (o.sub) els.push(text(uid('sub'), o.sub, cw / 2, ch * 0.56, Math.round(fs * o.scale.subRatio), o.scale.subWeight, o.palette.primary, 'middle'));
|
||||
els.push(rect(uid('bar'), cw / 2 - cw * 0.12, ch * 0.62, cw * 0.24, 8, o.palette.accent));
|
||||
return els;
|
||||
}
|
||||
@@ -42,9 +60,9 @@ const HGB_PosterGenerator = (function () {
|
||||
els.push(rect(uid('bg'), 0, 0, cw, ch, o.palette.bg));
|
||||
els.push(rect(uid('side'), 0, 0, cw * 0.06, ch, o.palette.accent));
|
||||
const mx = cw * 0.13;
|
||||
const fs = Math.round(cw * 0.08);
|
||||
els.push(text(uid('title'), o.title, mx, ch * 0.44, fs, 800, o.palette.primary, 'start'));
|
||||
if (o.sub) els.push(text(uid('sub'), o.sub, mx, ch * 0.52, Math.round(fs * 0.36), 400, o.palette.primary, 'start'));
|
||||
const fs = Math.round(cw * o.scale.titleRatio);
|
||||
els.push(text(uid('title'), o.title, mx, ch * 0.44, fs, o.scale.titleWeight, o.palette.primary, 'start'));
|
||||
if (o.sub) els.push(text(uid('sub'), o.sub, mx, ch * 0.52, Math.round(fs * o.scale.subRatio), o.scale.subWeight, o.palette.primary, 'start'));
|
||||
els.push(rect(uid('bar'), mx, ch * 0.58, cw * 0.18, 8, o.palette.accent));
|
||||
return els;
|
||||
}
|
||||
@@ -55,9 +73,9 @@ const HGB_PosterGenerator = (function () {
|
||||
const cw = spec.w, ch = spec.h, els = [];
|
||||
els.push(rect(uid('bg'), 0, 0, cw, ch, o.palette.bg));
|
||||
els.push(rect(uid('band'), 0, ch * 0.18, cw, ch * 0.16, o.palette.accent));
|
||||
const fs = Math.round(cw * 0.07);
|
||||
els.push(text(uid('title'), o.title, cw / 2, ch * 0.26, fs, 800, o.palette.bg, 'middle'));
|
||||
if (o.sub) els.push(text(uid('sub'), o.sub, cw / 2, ch * 0.55, Math.round(fs * 0.42), 400, o.palette.primary, 'middle'));
|
||||
const fs = Math.round(cw * o.scale.titleRatio);
|
||||
els.push(text(uid('title'), o.title, cw / 2, ch * 0.26, fs, o.scale.titleWeight, o.palette.bg, 'middle'));
|
||||
if (o.sub) els.push(text(uid('sub'), o.sub, cw / 2, ch * 0.55, Math.round(fs * o.scale.subRatio), o.scale.subWeight, o.palette.primary, 'middle'));
|
||||
return els;
|
||||
}
|
||||
}
|
||||
@@ -67,13 +85,14 @@ const HGB_PosterGenerator = (function () {
|
||||
function generate(spec, decision) {
|
||||
const palette = PALETTES.find(p => p.id === decision.paletteId) || PALETTES[0];
|
||||
const layout = LAYOUTS.find(l => l.id === decision.layoutId) || LAYOUTS[0];
|
||||
const o = { palette, title: decision.title || '海报标题', sub: decision.sub || '' };
|
||||
const scale = scaleOf(decision.typeScaleId);
|
||||
const o = { palette, scale, title: decision.title || '海报标题', sub: decision.sub || '' };
|
||||
return layout.build(spec, o);
|
||||
}
|
||||
|
||||
function defaultDecision(title, sub) {
|
||||
return { paletteId: 'indigo', layoutId: 'centered', title: title || '海报标题', sub: sub || '' };
|
||||
return { paletteId: 'indigo', layoutId: 'centered', typeScaleId: DEFAULT_SCALE, title: title || '海报标题', sub: sub || '' };
|
||||
}
|
||||
|
||||
return { PALETTES, LAYOUTS, generate, defaultDecision };
|
||||
return { PALETTES, LAYOUTS, TYPE_SCALES, scaleOf, generate, defaultDecision };
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user