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 个文本/矢量件。
287 lines
14 KiB
Python
287 lines
14 KiB
Python
#!/usr/bin/env python3
|
||
# -*- coding: utf-8 -*-
|
||
"""
|
||
N5 竹简 · 第二轮优化:换优化轴,不再调参数
|
||
|
||
第一轮(n5-opt.py)动的是参数:缝宽、绳区、结、双绳、斜切。结论是缝 11 + 实体绳。
|
||
本轮动的是四个不同层面,每个都对应第一轮没解决的一类问题:
|
||
|
||
Q1 剪影兜底(结构层)
|
||
问题:缝 11 让四片在 16px 存活,但这是"调出来的",换渲染器/换 DPI 仍可能塌。
|
||
做法:简片之间挖白色竖缝,但**竖缝不到顶底**——整枚仍是一整块连通的方。
|
||
收益:小尺寸下缝隙自然消失时,退化成"一枚实心朱方"而不是"一坨模糊"。
|
||
负形同时是「川」:4 片红之间恰是 3 道白竖=川,暗合「致远」的行旅。
|
||
|
||
Q2 绳咬合字标(系统层)
|
||
问题:符号与字标现在是并排放的两个物体。
|
||
做法:让编绳向右延伸,成为 NOVALON 所坐的那条线。
|
||
收益:lockup 从"图形 + 文字"变成一个有承重关系的整体。
|
||
|
||
Q3 笔意收边(气质层)
|
||
问题:直角矩形简片配毛笔字,几何与手写仍是两套语言(第一轮被否的根因)。
|
||
做法:简片做极轻的收分(上窄下宽),模拟竹材与运笔的呼吸。
|
||
|
||
Q4 墨量平衡(量测层)
|
||
问题:没人验证过符号的"视觉重量"和书法块是否相当。
|
||
做法:实测两者墨量密度(有色像素 ÷ 包围盒),把简片宽调到同一档。
|
||
"""
|
||
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"))
|
||
opt = load("opt", os.path.join(HERE, "n5-opt.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 slip_taper(x, y, w, h, taper=0.10):
|
||
"""收分:以 w 为中线宽,上边 w*(1-t/2)、下边 w*(1+t/2)。"""
|
||
wt, wb = w * (1 - taper / 2), w * (1 + taper / 2)
|
||
return ('<path d="M %g %g L %g %g L %g %g L %g %g Z" fill="%s"/>'
|
||
% (x + (w - wt) / 2, y, x + (w + wt) / 2, y, x + (w + wb) / 2, y + h,
|
||
x + (w - wb) / 2, y + h, RED))
|
||
|
||
|
||
# ---------------- Q1 剪影兜底:竖缝不到顶底,整枚连通 ----------------
|
||
def q1(n=4, slit=6, inset=7, cord=6, overhang=8, taper=0.0):
|
||
bw = (ENV_W - (n - 1) * slit) / n
|
||
x0 = ENV_X
|
||
top_h = (BCY - cord / 2) - BT
|
||
bot_y = BCY + cord / 2
|
||
bot_h = BB - bot_y
|
||
out = []
|
||
for i in range(n):
|
||
x = x0 + i * (bw + slit)
|
||
for y, h in ((BT, top_h), (bot_y, bot_h)):
|
||
out.append(slip_taper(x, y, bw, h, taper) if taper else rc(x, y, bw, h))
|
||
# 竖缝:不画(靠片间留白);但把顶底各留一条同色桥,使整枚连通
|
||
bridge = inset
|
||
for i in range(n - 1):
|
||
sx = x0 + (i + 1) * bw + i * slit
|
||
out.append(rc(sx, BT, slit, bridge)) # 顶部短桥
|
||
out.append(rc(sx, BB - bridge, slit, bridge)) # 底部短桥
|
||
cx0, cx1 = x0 - overhang, x0 + n * bw + (n - 1) * slit + overhang
|
||
out.append(rc(cx0, BCY - cord / 2, cx1 - cx0, cord)) # 实体绳,外露两端
|
||
return "".join(out)
|
||
|
||
|
||
# ---------------- Q2 绳咬合字标 ----------------
|
||
def q2():
|
||
base = q1()
|
||
# 绳向右延伸到字标下方,成为 NOVALON 的承托线(字标 ink 左界 114.22,NOVALON 底 105)
|
||
return base + rc(ENV_X - 8, BCY - 3, 300, 6)
|
||
|
||
|
||
# ---------------- Q3 笔意收分 ----------------
|
||
def q3():
|
||
return q1(taper=0.14)
|
||
|
||
|
||
# ---------------- Q4 墨量平衡:三档片宽对比 ----------------
|
||
Q4 = [("疏(现状 缝11)", dict(n=4, gap=11, rope=17, cord=6, overhang=8)),
|
||
("中(缝 13)", dict(n=4, gap=13, rope=17, cord=6, overhang=8)),
|
||
("密(缝 9)", dict(n=4, gap=9, rope=17, cord=6, overhang=8))]
|
||
|
||
VARIANTS = [
|
||
dict(id="Q1", nm="剪影兜底", body=lambda: q1(),
|
||
axis="结构层",
|
||
idea="四片之间留竖缝,但竖缝不到顶底——顶底各一道同色短桥,使整枚是一整块连通方。",
|
||
why="小尺寸下缝隙必然消失,那时它退化成「一枚实心朱方」而不是「一坨模糊」——"
|
||
"稳健性由结构保证,不再靠调缝宽赌渲染器。负形顺带是「川」(3 道白竖),暗合致远。",
|
||
risk="顶底短桥会让大尺寸下的「片」感稍弱,边缘不如分离式干净。"),
|
||
dict(id="Q2", nm="绳咬合字标", body=lambda: q2(),
|
||
axis="系统层",
|
||
idea="编绳向右延伸,成为 NOVALON 所坐的那条承重线。",
|
||
why="把「图形 + 文字」两个并置物体,变成一个有结构关系的整体;"
|
||
"也是全站 hairline 语言与标识的第一次同源。",
|
||
risk="延伸线在深色底上会与字标争注意力;且线一长,16px 下只剩一条横线,符号身份丢失。"),
|
||
dict(id="Q3", nm="笔意收分", body=lambda: q3(),
|
||
axis="气质层",
|
||
idea="简片上窄下宽 14%,模拟竹材剖面与运笔的呼吸。",
|
||
why="第一轮被否的根因是「几何方块配毛笔字」两套语言;收分是成本最低的调和手段,"
|
||
"不动结构只改轮廓性格。",
|
||
risk="14% 收分在 16px 下约 0.4px,几乎无感;它是为大尺寸场景服务的。"),
|
||
dict(id="Q4", nm="墨量平衡", body=lambda: opt.slips(**Q4[1][1]),
|
||
axis="量测层",
|
||
idea="实测符号墨量密度与书法块密度,把缝宽调到两者同档(下表三档对比)。",
|
||
why="视觉重量匹配是「耐看」的物理基础,此前只凭眼睛判断。",
|
||
risk="密度相等不等于重量相等——书法笔画有飞白与粗细变化,均值会掩盖局部失衡。"),
|
||
]
|
||
|
||
|
||
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 262px;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}
|
||
.axis{display:inline-block;font-size:10.5px;letter-spacing:.1em;color:var(--muted);
|
||
border:1px solid var(--hair);padding:2px 8px;margin-left:6px;vertical-align:2px}
|
||
"""
|
||
|
||
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 stats(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,inked=0,minx=W,maxx=0,miny=H,maxy=0;
|
||
const isRed=p=>D(p,RED)<D(p,INK);
|
||
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 ink=a>=40&&D(p,WHITE)>=110;
|
||
// 行程只数红:用于评估符号的"片"是否分开
|
||
const r=ink&&isRed(p);
|
||
if(r&&!on){n++;on=true;}else if(!r)on=false;
|
||
if(ink){inked++;if(x<minx)minx=x;if(x>maxx)maxx=x;if(y<miny)miny=y;if(y>maxy)maxy=y;}}
|
||
if(n>best)best=n;}
|
||
const bbox=(maxx-minx+1)*(maxy-miny+1)||1;
|
||
return {runs:best, density:inked/bbox};
|
||
}
|
||
(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 stats(el,S);
|
||
out[k].dense=await stats(el,512); // 密度统一在 512 量,避免大小元素尺度不可比
|
||
}
|
||
document.querySelectorAll('[data-r]').forEach(td=>{
|
||
const [k,S]=td.getAttribute('data-r').split('@');
|
||
const o=out[k]&&out[k][S]; if(o) td.textContent=o.runs;});
|
||
document.querySelectorAll('[data-d]').forEach(td=>{
|
||
const o=out[td.getAttribute('data-d')];
|
||
if(o&&o.dense) td.textContent=(o.dense.density*100).toFixed(1)+'%';});
|
||
window.__opt2=out;
|
||
})();
|
||
</script>
|
||
"""
|
||
|
||
|
||
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 round 2 · 2026-10-13</div>')
|
||
w('<h1>N5 第二轮优化:<em>换轴,不再调参数</em></h1>')
|
||
w('<p class="lede">第一轮动的是缝宽、绳粗、结、双绳——都是参数。这一轮动四个不同层面:'
|
||
'结构(让稳健性由构造保证而非调参赌渲染器)、系统(让绳与字标发生承重关系)、'
|
||
'气质(让几何方块带上笔意)、量测(第一次实测符号与书法块的墨量密度)。</p></header>')
|
||
|
||
for v in VARIANTS:
|
||
body = v["body"]()
|
||
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<span class="axis">%s</span></h3>'
|
||
% (v["id"], v["nm"], v["axis"]))
|
||
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"><b>代价</b>:%s</div>' % v["risk"])
|
||
w('<div class="small" style="margin-top:8px">实测红色行程段数:'
|
||
'<b data-r="%s@16">…</b> @16px · <b data-r="%s@24">…</b> @24px · '
|
||
'<b data-r="%s@32">…</b> @32px | 墨量密度 <b data-d="%s">…</b></div>'
|
||
% (v["id"], v["id"], v["id"], v["id"]))
|
||
w('</div></div>')
|
||
|
||
w('<section class="band"><h2 class="band">墨量密度对照(实测)</h2>')
|
||
w('<p>密度=有色像素 ÷ 该元素 ink 包围盒面积(64px 栅格)。'
|
||
'符号与书法块密度接近时,两者在视觉上"一样重";差得多就会一方压过另一方。</p>')
|
||
w('<table><thead><tr><th>元素</th><th>墨量密度</th><th>说明</th></tr></thead><tbody>')
|
||
w('<tr><td>书法「睿新致遠」块</td><td class="n" data-d="cal">…</td>'
|
||
'<td>基准——它是整幅标识的视觉重心</td></tr>')
|
||
for vid in ("Q1", "Q2", "Q3", "Q4"):
|
||
w('<tr><td>%s</td><td class="n" data-d="%s">…</td><td>见上面对应小节</td></tr>'
|
||
% (vid, vid))
|
||
w('<tr><td>第一轮 O7(缝 11 + 绳 + 结)</td><td class="n" data-d="O7">…</td>'
|
||
'<td>作为对照基线</td></tr>')
|
||
w('</tbody></table>')
|
||
w('<div class="note"><b>怎么读这张表:</b>若符号密度明显高于书法块,说明符号偏「重」、'
|
||
'会跟毛笔字抢注意力;明显低于则符号「压不住」,显得可有可无。'
|
||
'Q1 因为多了顶底短桥(把缝补成连通方),密度会比分离式高——'
|
||
'这是它为稳健性付的视觉代价,需看数值决定是否收窄桥长。</div>')
|
||
w('</section>')
|
||
|
||
w('<div style="position:absolute;width:0;height:0;overflow:hidden" aria-hidden="true">')
|
||
# 待测:书法块本体(取 n5 的已居中字标)
|
||
w('<svg xmlns="http://www.w3.org/2000/svg" viewBox="100 0 380 120" width="380" height="120" '
|
||
'data-src="cal">%s</svg>' % n5.wordmark_fixed(INK))
|
||
for v in VARIANTS:
|
||
w('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 108 120" width="108" height="120" '
|
||
'data-src="%s">%s</svg>' % (v["id"], v["body"]()))
|
||
w('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 108 120" width="108" height="120" '
|
||
'data-src="O7">%s</svg>' % opt.slips(n=4, gap=11, rope=17, cord=6, overhang=8, knot=True))
|
||
w('</div>')
|
||
w(JS)
|
||
w('<footer>生成器 <code>n5-opt2.py</code> · 复用 <code>n5-refine.py</code> 居中字标与 '
|
||
'<code>n5-opt.py</code> 参数化简片 · 段数与密度均页内实测</footer>')
|
||
w('</div></body></html>')
|
||
return "".join(P)
|
||
|
||
|
||
def main():
|
||
path = os.path.join(HERE, "n5-opt2.html")
|
||
with open(path, "w", encoding="utf-8") as f:
|
||
f.write(build())
|
||
print("n5-opt2.html %s B" % f"{os.path.getsize(path):,}")
|
||
|
||
|
||
if __name__ == "__main__":
|
||
main()
|