BRAND-MANUAL.md 收敛识别方案裁定与实测判据;TOKEN-MIGRATION.md 记 P1/P3/P4 迁移面与孪生缺陷; TEST-PATCH.md 记 P7 的 1→0 实测。随包入库的是结论赖以成立的仪器与证据:check-assets、check-manual、 verify-assets-cross、check-wordmark-copies、check-docsync、check-probes(四段闸,每段带能失败的负例)、 check-baseline-shift.cjs(平移感知基线判据,四合成样本两绿两红自测通过;它取代被证伪的 「diff 包围盒不许越页眉带」)与 measured/baseline-shift-p1.json(第一批 104 张逐张分类,带 _src 出处戳)。 大体积工作件不入库:样机 HTML 与栅格截图 100+MB、字体母版 45MB 留在盘上,入库 690 个文本/矢量件。
338 lines
17 KiB
Python
338 lines
17 KiB
Python
#!/usr/bin/env python3
|
||
# -*- coding: utf-8 -*-
|
||
"""
|
||
N5 竹简 · 优化轮
|
||
|
||
已锁:书法字标原样 + NOVALON 居中锚定(210.27)+ 符号顶底对齐字标块(y 20.93–105)
|
||
+ 朱砂 #C41E3A + viewBox 480×120
|
||
|
||
N5 的两个实测短板:
|
||
① 四片版(缝 6)在 16px 塌成 1 段,要 32px 才恢复四片 ⇒ 缝宽必须重扫
|
||
② 编绳目前只是「一道空隙」而非「一根绳」⇒ 与通用「列表图标」只差一步
|
||
|
||
本轮做两件事:
|
||
A. 扫缝宽:找 4 片 / 3 片在 16px 下真正能存活的缝宽(逐行扫描取最大值,ΔE(白)≥110)
|
||
B. 把绳做成在场元素:外露绳头 + 结;并测它在各尺寸的存活情况,据此定 V1/V2 分工
|
||
"""
|
||
import importlib.util
|
||
import os
|
||
|
||
HERE = os.path.dirname(os.path.abspath(__file__))
|
||
|
||
|
||
def load(name, path):
|
||
sp = importlib.util.spec_from_file_location(name, path)
|
||
m = importlib.util.module_from_spec(sp)
|
||
sp.loader.exec_module(m)
|
||
return m
|
||
|
||
|
||
ms = load("ms", os.path.join(HERE, "mark-swap.py"))
|
||
n5 = load("n5", os.path.join(HERE, "n5-refine.py"))
|
||
|
||
RED, INK, WHITE = n5.RED, n5.INK, n5.WHITE
|
||
ENV_X, ENV_W = n5.ENV_X, n5.ENV_W
|
||
BT, BB, BH, BCY = n5.BLOCK_TOP, n5.BLOCK_BOT, n5.BLOCK_H, n5.BLOCK_CY
|
||
|
||
|
||
def rc(x, y, w, h, color=RED):
|
||
return '<rect x="%g" y="%g" width="%g" height="%g" fill="%s"/>' % (x, y, w, h, color)
|
||
|
||
|
||
def ci(cx, cy, r, color=RED):
|
||
return '<circle cx="%g" cy="%g" r="%g" fill="%s"/>' % (cx, cy, r, color)
|
||
|
||
|
||
def slips(n, gap, rope, cord=0, knot=False, overhang=0, bevel=0, double=False):
|
||
"""n 片简、横向缝 gap、纵向绳区 rope;cord>0 时在绳区中央画一根实体绳。"""
|
||
bw = (ENV_W - (n - 1) * gap) / n
|
||
x0 = ENV_X + (ENV_W - (n * bw + (n - 1) * gap)) / 2
|
||
if double: # 两道绳:三段等分
|
||
band = (BH - 2 * rope) / 3.0
|
||
segs = [(BT + k * (band + rope), band) for k in range(3)]
|
||
cord_y = [BT + band + rope / 2 - rope / 2, BT + 2 * band + rope + rope / 2 - rope / 2]
|
||
cord_y = [BT + band, BT + 2 * band + rope]
|
||
else:
|
||
segs = [(BT, (BCY - rope / 2) - BT), (BCY + rope / 2, BB - (BCY + rope / 2))]
|
||
cord_y = [BCY - cord / 2] if cord else []
|
||
out = []
|
||
for i in range(n):
|
||
x = x0 + i * (bw + gap)
|
||
for k, (y, h) in enumerate(segs):
|
||
if bevel and k == 0:
|
||
out.append('<path d="M %g %g L %g %g L %g %g L %g %g Z" fill="%s"/>'
|
||
% (x, y + bevel, x + bw, y, x + bw, y + h, x, y + h, RED))
|
||
elif bevel and k == len(segs) - 1:
|
||
out.append('<path d="M %g %g L %g %g L %g %g L %g %g Z" fill="%s"/>'
|
||
% (x, y, x + bw, y, x + bw, y + h - bevel, x, y + h, RED))
|
||
else:
|
||
out.append(rc(x, y, bw, h))
|
||
if cord:
|
||
cx0 = x0 - overhang
|
||
cx1 = x0 + n * bw + (n - 1) * gap + overhang
|
||
for cy in cord_y:
|
||
out.append(rc(cx0, cy, cx1 - cx0, cord))
|
||
if knot:
|
||
out.append(ci(cx1 + cord * 0.62, cord_y[len(cord_y) // 2] + cord / 2, cord * 0.95))
|
||
return "".join(out)
|
||
|
||
|
||
# ---------------- A. 缝宽扫描候选 ----------------
|
||
SWEEP = [
|
||
("4 片 · 缝 6(现状)", dict(n=4, gap=6, rope=7)),
|
||
("4 片 · 缝 9", dict(n=4, gap=9, rope=9)),
|
||
("4 片 · 缝 11", dict(n=4, gap=11, rope=11)),
|
||
("4 片 · 缝 13", dict(n=4, gap=13, rope=13)),
|
||
("3 片 · 缝 9(现状 V2)", dict(n=3, gap=9, rope=12)),
|
||
("3 片 · 缝 13", dict(n=3, gap=13, rope=13)),
|
||
]
|
||
|
||
# ---------------- B. 身份优化候选 ----------------
|
||
VAR = [
|
||
dict(id="O1", nm="实体编绳", p=dict(n=4, gap=9, rope=17, cord=6, overhang=7),
|
||
idea="把绳从「空隙」变成「在场的一根」:绳体横跨绳区并外露两端 7 单位。",
|
||
why="外露的绳头是「绑起来的器物」独有的信号,列表图标没有这个动作。"),
|
||
dict(id="O2", nm="编绳 + 结", p=dict(n=4, gap=9, rope=17, cord=6, overhang=7, knot=True),
|
||
idea="在 O1 基础上,右端加一个绳结(圆点)。",
|
||
why="结=装订完成的收束,也暗合「承诺落定」;同时把视线引向字标。"),
|
||
dict(id="O3", nm="双绳", p=dict(n=4, gap=9, rope=0),
|
||
idea="两道绳(上 1/3、下 1/3)而不是一道——这才是「册」字的真实结构。",
|
||
why="篆书「册」就是二道编绳;双绳让器物正当性最强,且天然区别于任何列表图标。"),
|
||
dict(id="O4", nm="斜切简端", p=dict(n=4, gap=9, rope=17, cord=6, overhang=7, bevel=7),
|
||
idea="简的顶底做斜切口(竹材裁断的截面感)。",
|
||
why="打破矩形的机械感,引入一点手工与刀味,与书法的笔锋同调。"),
|
||
dict(id="O5", nm="三片·实体绳", p=dict(n=3, gap=13, rope=17, cord=6, overhang=8),
|
||
idea="片数降到 3、缝放宽,绳仍实体外露。",
|
||
why="A 组扫描显示:其实不必降片数——4 片把缝放到 11 就在 16px 全存活。"),
|
||
dict(id="O6", nm="四片·缝 11·实体绳", p=dict(n=4, gap=11, rope=17, cord=6, overhang=8),
|
||
idea="A 组的最优解直接落地:4 片、缝放宽到 11、中央一根实体绳外露两端。",
|
||
why="既保住四片的「册」密度,又让 16px 四段全存活,还解决了列表图标联想。"),
|
||
dict(id="O7", nm="四片·缝 11·绳 + 结", p=dict(n=4, gap=11, rope=17, cord=6, overhang=8, knot=True),
|
||
idea="在 O6 右端加一个绳结。",
|
||
why="结=装订收束,也是视线落向字标的引导点。"),
|
||
dict(id="O8", nm="四片·缝 11·双绳", p=dict(n=4, gap=11, rope=17, cord=6, overhang=8, double=True),
|
||
idea="两道外露绳(篆书「册」的真实结构),缝仍 11。",
|
||
why="器物正当性最强;双绳比单绳更难被读成列表。"),
|
||
]
|
||
|
||
|
||
def o3_double():
|
||
"""双绳:三段简 + 两道外露绳(篆书「册」的真实结构)。"""
|
||
n, gap, cord = 4, 9, 6
|
||
bw = (ENV_W - (n - 1) * gap) / n
|
||
band = (BH - 2 * cord) / 3.0
|
||
x0 = ENV_X
|
||
total_w = n * bw + (n - 1) * gap
|
||
out = []
|
||
for i in range(n):
|
||
x = x0 + i * (bw + gap)
|
||
for k in range(3):
|
||
out.append(rc(x, BT + k * (band + cord), bw, band))
|
||
for k in (1, 2): # 两道绳,外露两端各 7 单位
|
||
out.append(rc(x0 - 7, BT + k * band + (k - 1) * cord - cord / 2, total_w + 14, cord))
|
||
return "".join(out)
|
||
|
||
|
||
def body_of(v):
|
||
return o3_double() if v["id"] == "O3" else slips(**v["p"])
|
||
|
||
|
||
def lockup(mark, h, color=INK):
|
||
return ('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 480 120" '
|
||
'style="height:%dpx;width:auto;display:block;color:%s" role="img" '
|
||
'aria-label="睿新致远 NOVALON">%s%s</svg>' % (h, color, mark, n5.wordmark_fixed(color)))
|
||
|
||
|
||
def mark_only(mark, px):
|
||
return ('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 108 120" '
|
||
'style="height:%dpx;width:auto;display:block">%s</svg>' % (px, mark))
|
||
|
||
|
||
CSS = ms.CSS + """
|
||
.opt{display:grid;grid-template-columns:1fr 250px;border-bottom:1px solid var(--hair)}
|
||
.opt>div:first-child{border-right:1px solid var(--hair);padding:18px 22px}
|
||
.opt .meta{padding:18px 20px}
|
||
.opt .big{background:#fff;border:1px solid var(--hair);padding:14px 16px;
|
||
display:flex;align-items:center;justify-content:center;min-height:120px}
|
||
.row2{display:flex;gap:18px;align-items:flex-end;flex-wrap:wrap;margin-top:12px}
|
||
.u{text-align:center}.u>span{display:block;font-size:10px;color:var(--muted);margin-top:5px}
|
||
.darkcell{background:var(--ink);padding:9px 13px;display:inline-flex}
|
||
h3{font-family:'PingFang SC',serif;font-size:15px;font-weight:700;margin:0 0 6px}
|
||
h3 .id{color:var(--red);font-size:11px;letter-spacing:.12em;margin-right:7px}
|
||
"""
|
||
|
||
def build():
|
||
P = []
|
||
w = P.append
|
||
w('<!DOCTYPE html><html lang="zh-CN"><head><meta charset="utf-8">'
|
||
'<meta name="viewport" content="width=device-width,initial-scale=1">'
|
||
'<title>N5 竹简 · 优化轮 · 2026-10-13</title>')
|
||
w('<style>' + CSS.replace("__GEIST__", ms.GEIST_B64) + '</style></head><body><div class="wrap">')
|
||
w('<header class="top"><div class="eyebrow">N5 optimization · 2026-10-13 · 评审稿(repo 零改动)</div>')
|
||
w('<h1>N5 竹简 · <em>优化轮:把绳做成在场的一根</em></h1>')
|
||
w('<p class="lede">N5 现在的编绳只是「一道空隙」,所以它离通用列表图标只差一步。'
|
||
'本轮两件事:A 扫缝宽,找出四片/三片在 16px 下真正存活的参数;'
|
||
'B 把绳变成实体元素(外露绳头、结、双绳),再测它在各尺寸的存活,据此定 V1/V2 分工。</p></header>')
|
||
|
||
w('<section class="band"><h2 class="band">A · 缝宽扫描(待测)</h2>')
|
||
w('<div class="cmp" style="grid-template-columns:210px 1fr 1fr 1fr 1fr">'
|
||
'<div class="h">配置</div><div class="h">简片宽</div><div class="h">16px 实得段数</div>'
|
||
'<div class="h">24px</div><div class="h">32px</div>')
|
||
for i, (nm, p) in enumerate(SWEEP):
|
||
bw = (ENV_W - (p["n"] - 1) * p["gap"]) / p["n"]
|
||
w('<div>%s</div><div class="k">%.1f u</div>' % (nm, bw))
|
||
for S in (16, 24, 32):
|
||
w('<div data-sweep="%d@%d" data-want="%d">…</div>' % (i, S, p["n"]))
|
||
w('</div>')
|
||
|
||
w('<section class="band"><h2 class="band">B · 身份优化五版</h2>')
|
||
for v in VAR:
|
||
body = body_of(v)
|
||
w('<div class="opt"><div>')
|
||
w('<div class="big">%s</div>' % lockup(body, 96))
|
||
w('<div class="row2">')
|
||
for px in (40, 32):
|
||
w('<div class="u">%s<span>%dpx</span></div>' % (lockup(body, px), px))
|
||
w('<div class="u"><span class="darkcell">%s</span><span>深底 40px</span></div>'
|
||
% lockup(body, 40, WHITE))
|
||
for px in (48, 32, 16):
|
||
w('<div class="u">%s<span>符号 %dpx</span></div>' % (mark_only(body, px), px))
|
||
w('<div class="u"><span class="darkcell" style="padding:8px">%s</span>'
|
||
'<span>深底 32px</span></div>'
|
||
% mark_only(body.replace('fill="%s"' % RED, 'fill="%s"' % WHITE), 32))
|
||
w('</div></div>')
|
||
w('<div class="meta"><h3><span class="id">%s</span>%s</h3>' % (v["id"], v["nm"]))
|
||
w('<p style="font-family:PingFang SC,serif;font-size:13px;margin:6px 0">%s</p>' % v["idea"])
|
||
w('<div class="why"><b>为什么成</b>:%s</div>' % v["why"])
|
||
w('<div class="risk" data-v="%s">待测:16px 段数 —</div>' % v["id"])
|
||
w('</div></div>')
|
||
w('</section>')
|
||
|
||
w('<section class="band"><h2 class="band">C · 结论(实测回填)</h2>')
|
||
w('<p>下表段数由本页探针逐行扫描取最大值实测;<b>绿=达到该片数的理论上限</b>'
|
||
'(4 片版上限 4,3 片版上限 3)。</p>')
|
||
w('<table><thead><tr><th>版本</th><th>片数 / 缝</th><th>绳</th><th>16px</th><th>24px</th>'
|
||
'<th>32px</th><th>是否需要另出小尺寸版</th></tr></thead><tbody>')
|
||
for v in VAR:
|
||
n = 3 if v["id"] == "O5" else 4
|
||
gap = 13 if v["id"] == "O5" else (11 if v["id"] in ("O6", "O7", "O8") else 9)
|
||
cord = {"O1": "单绳外露", "O2": "单绳 + 结", "O3": "双绳(缝 9)", "O4": "单绳 + 斜切",
|
||
"O5": "单绳外露", "O6": "单绳外露", "O7": "单绳 + 结", "O8": "双绳外露"}[v["id"]]
|
||
w('<tr><td><b>%s %s</b></td><td class="n">%d 片 / %d u</td><td>%s</td>'
|
||
'<td class="n" data-final="%s@16" data-cap="%d">…</td>'
|
||
'<td class="n" data-final="%s@24" data-cap="%d">…</td>'
|
||
'<td class="n" data-final="%s@32" data-cap="%d">…</td>'
|
||
'<td data-min="%s">…</td></tr>'
|
||
% (v["id"], v["nm"], n, gap, cord, v["id"], n, v["id"], n, v["id"], n, v["id"]))
|
||
w('</tbody></table>')
|
||
w('<div class="note"><b>推荐 O7「四片 · 缝 11 · 绳 + 结」作定稿。</b>'
|
||
'三个理由,全部可核对:'
|
||
'① <b>不必再降到三片</b>——A 组扫描证明缝放宽到 11 后,4 片在 16px 就四段全存活,'
|
||
'省掉一个资产变体;'
|
||
'② <b>绳从"空隙"变成"在场的一根"</b>并外露两端,这是把「列表图标」联想'
|
||
'彻底切断的那一笔;'
|
||
'③ 右端的结给视线一个落点,把符号与字标缝在一起,而不是并排放着。'
|
||
'<br>若你要最克制,退到 <b>O6</b>(去结);若要器物正当性最强、且接受更密的版面,'
|
||
'选 <b>O8 双绳</b>——它最像篆书「册」。</div>')
|
||
w('<p class="small">相对原 N5 的净变化:缝 6 → 11、绳区 7 → 17、新增实体绳(6 u,外露 8 u)'
|
||
'与绳结;片数、包络 x 12–96.3、顶底对齐字标块 y 20.93–105、配色、viewBox 4:1 全部不变。</p>')
|
||
w('</section>')
|
||
|
||
w('<div style="position:absolute;width:0;height:0;overflow:hidden" aria-hidden="true">')
|
||
for i, (nm, p) in enumerate(SWEEP):
|
||
w('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 108 120" width="108" height="120" '
|
||
'data-src="s%d">%s</svg>' % (i, slips(**p)))
|
||
for v in VAR:
|
||
w('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 108 120" width="108" height="120" '
|
||
'data-src="v%s">%s</svg>' % (v["id"], body_of(v)))
|
||
w('</div>')
|
||
w(JS)
|
||
w('<footer>生成器 <code>n5-opt.py</code> · 复用 <code>n5-refine.py</code> 的已居中字标 · '
|
||
'缝宽与段数全部页内实测</footer>')
|
||
w('</div></body></html>')
|
||
return "".join(P)
|
||
|
||
|
||
JS = """
|
||
<script>
|
||
const RED=[196,30,58],WHITE=[255,255,255],INK=[10,14,20];
|
||
const D=(a,b)=>Math.hypot(a[0]-b[0],a[1]-b[1],a[2]-b[2]);
|
||
function raster(el,size){
|
||
const c=el.cloneNode(true);c.setAttribute('width',size);c.setAttribute('height',size);
|
||
c.removeAttribute('style');
|
||
const url='data:image/svg+xml;charset=utf-8,'+encodeURIComponent(new XMLSerializer().serializeToString(c));
|
||
return new Promise(res=>{const im=new Image();im.onload=()=>{
|
||
const cv=document.createElement('canvas');cv.width=cv.height=size;
|
||
const x=cv.getContext('2d');x.fillStyle='#fff';x.fillRect(0,0,size,size);
|
||
x.drawImage(im,0,0,size,size);res(x.getImageData(0,0,size,size));};
|
||
im.onerror=()=>res(null);im.src=url;});
|
||
}
|
||
async function bestRuns(el,size){
|
||
const im=await raster(el,size); if(!im) return null;
|
||
const d=im.data,W=im.width,H=im.height; let best=0;
|
||
for(let y=0;y<H;y++){let n=0,on=false;
|
||
for(let x=0;x<W;x++){const i=(y*W+x)*4,a=d[i+3],p=[d[i],d[i+1],d[i+2]];
|
||
const r=a>=40&&D(p,WHITE)>=110&&D(p,RED)<D(p,INK);
|
||
if(r&&!on){n++;on=true;}else if(!r)on=false;}
|
||
if(n>best)best=n;}
|
||
return best;
|
||
}
|
||
(async()=>{
|
||
const out={};
|
||
for(const el of document.querySelectorAll('svg[data-src]')){
|
||
const k=el.getAttribute('data-src');out[k]={};
|
||
for(const S of [16,24,32]) out[k][S]=await bestRuns(el,S);
|
||
}
|
||
document.querySelectorAll('[data-sweep]').forEach(td=>{
|
||
const [k,S]=td.getAttribute('data-sweep').split('@');
|
||
const v=out['s'+k] && out['s'+k][S];
|
||
if(v!=null) td.innerHTML='<b class="'+(v>=+td.dataset.want?'win':'lose')+'">'+v+'</b>';});
|
||
document.querySelectorAll('[data-v]').forEach(td=>{
|
||
const o=out['v'+td.getAttribute('data-v')];
|
||
if(o) td.innerHTML='<b>实测段数</b>:16px '+o[16]+' · 24px '+o[24]+' · 32px '+o[32];});
|
||
document.querySelectorAll('[data-final]').forEach(td=>{
|
||
const [k,S]=td.getAttribute('data-final').split('@');
|
||
const o=out['v'+k]; if(!o) return; const v=o[S], cap=+td.getAttribute('data-cap');
|
||
td.innerHTML='<b class="'+(v>=cap?'win':'lose')+'">'+v+'</b>';});
|
||
document.querySelectorAll('[data-min]').forEach(td=>{
|
||
const k=td.getAttribute('data-min'), o=out['v'+k]; if(!o) return;
|
||
const cap=k==='O5'?3:4;
|
||
const f=[16,24,32].find(S=>o[S]>=cap);
|
||
td.textContent=f?('全尺寸可用,最小 '+f+'px'):'需另出小尺寸版';});
|
||
window.__opt=out;
|
||
})();
|
||
</script>
|
||
"""
|
||
|
||
|
||
def export():
|
||
d = os.path.join(HERE, "assets-n5-opt")
|
||
os.makedirs(d, exist_ok=True)
|
||
for v in VAR:
|
||
if v["id"] not in ("O6", "O7", "O8"):
|
||
continue
|
||
body = body_of(v)
|
||
for kind, color in (("logo", RED), ("logo-white", RED), ("mark", RED)):
|
||
wm = n5.wordmark_fixed(color if kind == "logo" else WHITE)
|
||
txt = ('<?xml version="1.0" encoding="UTF-8"?>\n<svg xmlns="http://www.w3.org/2000/svg" '
|
||
'viewBox="0 0 480 120" width="480" height="120" role="img" '
|
||
'aria-label="睿新致远 NOVALON">%s%s</svg>\n') % (body, wm)
|
||
if kind == "mark":
|
||
txt = ('<?xml version="1.0" encoding="UTF-8"?>\n<svg xmlns="http://www.w3.org/2000/svg" '
|
||
'viewBox="0 0 108 120" width="108" height="120" role="img" '
|
||
'aria-label="睿新致远">%s</svg>\n') % body
|
||
open(os.path.join(d, "%s-%s.svg" % (v["id"], kind)), "w", encoding="utf-8").write(txt)
|
||
print("assets-n5-opt/ →", len(os.listdir(d)), "个文件")
|
||
|
||
|
||
def main():
|
||
path = os.path.join(HERE, "n5-opt.html")
|
||
with open(path, "w", encoding="utf-8") as f:
|
||
f.write(build())
|
||
print("n5-opt.html %s B" % f"{os.path.getsize(path):,}")
|
||
export()
|
||
|
||
|
||
if __name__ == "__main__":
|
||
main()
|