Files
zhangxiang a57826f710 docs(brand): 品牌全案手册与落库证据入库(判据、门禁、负例都在场)
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 个文本/矢量件。
2026-10-16 19:23:28 +08:00

324 lines
18 KiB
Python
Raw Permalink 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.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
物(第二十八刀)· 按"一笔画得完 + 一条直边 + 一个负形"重画
两条新判据(从 Apple / Patagonia / Shell / Lacoste / WWF 反推,
且与本项目已有律自洽):
J1 外廓一笔画得完,且必须有至少一条直边。
Patagonia 用地平线封、Shell 用底边封、秦权用平底封。
⇒ "闭合"是靠直线封出来的,不是靠描边 —— 这就是躲开
「光滑凸卵形判死」的机制。
J2 内部只允许一个负形,且 ≥2px@16。
Apple 一口咬痕、Lacoste 张开的口、WWF 的眼圈,都只有一个。
⇒ 第二条负形一出现就退回数码管/文件图标那一族。
泰卦六爻有三根阴爻各带一个断口 = 三个负形,注定失败。
我用复杂度阶梯去救它,方向从一开始就错了。
J3 识别靠"不可迁移特征",不靠细节数量。
删掉的一律是说明性细节(纹理、关节、高光、刻度),
保留的一律是"换个形状就不再是这个物"的那一处。
J4 语汇走肖形印/画像石/木刻版画(一刀一块面),
不走写实剪影,也不走插画。
三个活口(撞车排查后剩下的):
O1 秦权/秤砣 —— 度量族。顶钮的孔 = 唯一负形 = 不可迁移特征。
撞车:未查到知名品牌。
O2 斗样 —— 结构族。唯一活口,代价是读成建筑业。
O3 符/节 —— 信物族。两半一缝 = 一个负形;合符为信,
与"印=一纸为凭"同族,把"致远"从交通工具换成信物。
"""
import importlib.util
import math
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
n5 = load("n5", os.path.join(HERE, "n5-refine.py"))
RED = "#C41E3A"
WHITE = "#FFFFFF"
PAPER = "#F7F4EF"
VB = 256.0
# ---------------------------------------------------------------- 手工控制点
# 全部用 C(三次贝塞尔)一笔画完,端点钝收,不用一条独立的描边。
# 坐标是我在 256 方格里肉眼定的,不是公式算的 —— 这一刀换的就是这个。
def quan():
"""秦权/秤砣:平底(J1 的直边)、凹弧收肩、顶上一枚钮,
钮上一个圆孔 —— 全标志唯一的负形(J2),也是不可迁移特征(J3)。
没有孔它就是一块石头;有了孔它就是权衡。"""
body = ("M 62 202 " # 左下(平底起)
"C 58 168 74 132 96 108 " # 左腹外鼓后收
"C 108 95 112 86 112 76 " # 收肩
"L 100 76 " # 钮左足(直边)
"C 96 76 94 73 94 68 "
"C 94 55 106 44 128 44 " # 钮顶弧
"C 150 44 162 55 162 68 "
"C 162 73 160 76 156 76 "
"L 144 76 " # 右肩回身
"C 144 86 148 95 160 108 "
"C 182 132 198 168 194 202 " # 右腹
"Z")
eye = ("M 128 52 "
"C 137 52 143 58 143 65 "
"C 143 72 137 78 128 78 "
"C 119 78 113 72 113 65 "
"C 113 58 119 52 128 52 Z")
return ('<path fill-rule="evenodd" d="%s %s"/>' % (body, eye))
def dougong():
"""斗栱两层出挑:从下往上一笔画完的阶梯外廓,平底。
唯一负形 = 栌斗口那道开口(不画第二道缝)。
代价:会被读成建筑业/文旅。"""
d = ("M 44 208 L 212 208 L 212 186 L 176 186 " # 底 + 第一层挑
"L 176 160 L 214 160 L 214 138 L 152 138 " # 第二层挑(出)
"L 152 116 L 186 116 L 186 94 L 70 94 L 70 116 "
"L 104 116 L 104 138 L 42 138 L 42 160 "
"L 80 160 L 80 186 L 44 186 Z")
mouth = "M 106 160 L 150 160 L 150 186 L 106 186 Z"
return '<path fill-rule="evenodd" d="%s %s"/>' % (d, mouth)
def fu():
"""符/节:左右两半,中间一道缝 = 唯一负形。
合符为信 = 验证与授权;把"致远"从交通工具换成信物。
外廓不是卵形:有平底、有斜肩、有齿。"""
left = ("M 46 52 L 116 52 L 116 92 L 104 92 L 104 116 "
"L 116 116 L 116 204 L 46 204 Z")
right = ("M 140 52 L 210 52 L 210 204 L 140 204 L 140 116 "
"L 152 116 L 152 92 L 140 92 Z")
return '<path d="%s"/><path d="%s"/>' % (left, right)
CANDS = [
("O1", "秦权 · 秤砣", quan,
"度量族。平底是 J1 要的那条直边;钮孔是唯一的负形,也是 J3 说的"
"不可迁移特征 —— 没有它是一块石头,有它是权衡。"
"语义:定标准、有权衡、分量压得住,全是高管语言,不越界到某个行业。"
"落在落款位读作镇纸/重器,与毛笔字同属文房世界。"),
("O2", "斗栱", dougong,
"结构族唯一活口。可指认度最高,但中国建筑学会会徽就是斗拱+模数立方体,"
"且它会把公司读成建筑业/文旅而非咨询。层叠台阶天然过剪影律。"),
("O3", "符 · 节", fu,
"信物族。持节出使、合符为信 —— 两半一缝,缝是唯一负形。"
"与你们已有的「印=一纸为凭」同族。风险:「符」冷读易滑向符箓/护身符。"),
]
CSS = """
*{box-sizing:border-box}body{margin:0;background:#F7F4EF;color:#4F4A42;
font:17px/1.9 "Songti SC","Noto Serif SC",Georgia,serif;-webkit-font-smoothing:antialiased}
.wrap{max-width:1120px;margin:0 auto;padding:46px 32px 96px}
.ey{font:12px/1.4 "PingFang SC",Inter,sans-serif;letter-spacing:.16em;text-transform:uppercase;color:#8A8377}
h1{font-size:50px;line-height:1.14;color:#26221E;margin:12px 0 14px;font-weight:600}
h1 em{font-style:normal;color:#C41E3A}
h2{font-size:24px;color:#26221E;margin:56px 0 6px;font-weight:600}
h2 .no{color:#C41E3A;margin-right:10px}
p{max-width:74ch;margin:9px 0}
.lede{font-size:19px;color:#26221E;max-width:72ch}
.j{border-left:2px solid #C41E3A;padding:2px 0 2px 16px;margin:12px 0;color:#26221E;max-width:80ch}
.j b{color:#C41E3A}
.card{background:#fff;border:1px solid #E2DDD3;padding:20px 22px;margin:0 0 14px}
.hd{display:flex;justify-content:space-between;align-items:baseline;gap:16px;margin-bottom:14px}
.nm{font-weight:650;color:#26221E;font-size:17px;font-family:"PingFang SC",Inter,sans-serif}
.cx{font:12px/1 "PingFang SC",Inter,sans-serif;color:#8A8377;font-variant-numeric:tabular-nums}
.row{display:flex;gap:22px;align-items:flex-end;flex-wrap:wrap}
.cell{text-align:center}
.lab{font:11.5px/1.5 "PingFang SC",Inter,sans-serif;color:#8A8377;margin-top:8px}
.tl{display:inline-flex;align-items:center;justify-content:center;border-radius:22.5%;
overflow:hidden;box-shadow:0 0 0 1px #DDD6CB}
.why{font-size:14.5px;color:#55504a;margin:12px 0 0;max-width:86ch}
table{border-collapse:collapse;width:100%;margin:14px 0;font:14px/1.6 "PingFang SC",Inter,sans-serif}
th,td{padding:10px 12px;border-bottom:1px solid #C3BDB1;text-align:left}
th{font-size:11px;letter-spacing:.11em;text-transform:uppercase;color:#8A8377;font-weight:500}
td.n{text-align:right;font-variant-numeric:tabular-nums;white-space:nowrap}
.pass{color:#0f7b3b;font-weight:600}.fail{color:#C41E3A;font-weight:600}
.lock{background:#fff;border:1px solid #E2DDD3;padding:26px 30px;margin:14px 0}
pre{font:9.5px/1.15 ui-monospace,Menlo,monospace;margin:0;text-align:left}
footer{margin-top:56px;padding-top:16px;border-top:1px solid #C3BDB1;
font:12.5px/1.7 "PingFang SC",Inter,sans-serif;color:#8A8377}
"""
JS = r"""<script>
const WHT=[255,255,255],REDc=[196,30,58],INKc=[38,34,30];
function D(a,b){return Math.hypot(a[0]-b[0],a[1]-b[1],a[2]-b[2]);}
function isRed(p,a){return a>=40&&D(p,WHT)>=110&&D(p,REDc)<D(p,INKc);}
function ras(el,size){return new Promise(r=>{
const s=new XMLSerializer().serializeToString(el);
const im=new Image(),cv=document.createElement('canvas');cv.width=size;cv.height=size;
const x=cv.getContext('2d');x.fillStyle='#fff';x.fillRect(0,0,size,size);
im.onload=()=>{x.drawImage(im,0,0,size,size);r(x.getImageData(0,0,size,size));};
im.onerror=()=>r(null);im.src='data:image/svg+xml;charset=utf-8,'+encodeURIComponent(s);});}
function ink(im){const d=im.data;let n=0;for(let i=0;i<d.length;i+=4){
if(isRed([d[i],d[i+1],d[i+2]],d[i+3]))n++;}return 100*n/(d.length/4);}
function runs(im,px,vert){const d=im.data;let best=Infinity;
for(let a=0;a<px;a++){let c=0;
for(let b=0;b<px;b++){const i=((vert?b:a)*px+(vert?a:b))*4;
if(isRed([d[i],d[i+1],d[i+2]],d[i+3]))c++;else{if(c)best=Math.min(best,c);c=0;}}
if(c)best=Math.min(best,c);}
return best===Infinity?0:best;}
function holes(im,px){ /* 数封闭负形:先从画布边框泛洪白,剩下没被漫到的白区
再按连通域标记 —— 一个连通域 = 一个负形。
上一版直接数白像素个数,泰卦会报成几百而不是 3。 */
const d=im.data,seen=new Uint8Array(px*px),st=[];
const isW=i=>d[i+3]<40||D([d[i],d[i+1],d[i+2]],WHT)<110;
for(let k=0;k<px;k++){st.push(k,px*(px-1)+k,k*px,px*k+px-1);}
while(st.length){const p=st.pop();if(seen[p])continue;seen[p]=1;
const x=p%px,y=(p/px)|0;
[[1,0],[-1,0],[0,1],[0,-1]].forEach(([dx,dy])=>{const nx=x+dx,ny=y+dy;
if(nx>=0&&ny>=0&&nx<px&&ny<px){const q=ny*px+nx;if(!seen[q]&&isW(q*4))st.push(q);}});}
let n=0,sizes=[];
for(let i=0;i<px*px;i++){
if(seen[i]||!isW(i*4))continue;
n++;let sz=0;const q2=[i];seen[i]=1;
while(q2.length){const p=q2.pop();sz++;
const x=p%px,y=(p/px)|0;
[[1,0],[-1,0],[0,1],[0,-1]].forEach(([dx,dy])=>{const nx=x+dx,ny=y+dy;
if(nx>=0&&ny>=0&&nx<px&&ny<px){const r=ny*px+nx;
if(!seen[r]&&isW(r*4)){seen[r]=1;q2.push(r);}}});}
if(sz>=2)sizes.push(sz); // 1~2 像素的抗锯齿碎点不算一个负形
}
return sizes.length;}
function grid(im,px){const d=im.data,g=[];for(let y=0;y<px;y++){let s='';
for(let x=0;x<px;x++){const i=(y*px+x)*4,a=d[i+3],p=[d[i],d[i+1],d[i+2]];
s+=(isRed(p,a)?'#':'.');}g.push(s);}return g;}
(async()=>{
const out={};
for(const el of document.querySelectorAll('svg[data-k]')){
const i16=await ras(el,16),i512=await ras(el,512);
if(!i16) continue;
out[el.dataset.k]={ink16:ink(i16),ink512:ink(i512),
hMin:runs(i16,16,false),vMin:runs(i16,16,true),holes:holes(i16,16),g:grid(i16,16)};
}
document.querySelectorAll('[data-cell]').forEach(td=>{
const c=td.dataset.cell,at=c.lastIndexOf('@');
const k=c.slice(0,at),f=c.slice(at+1),o=out[k];if(!o)return;
if(f==='ink')td.textContent=o.ink512.toFixed(1)+'%';
else if(f==='hmin'){td.textContent=o.hMin+'px';td.className=o.hMin>=2?'pass':'fail';}
else if(f==='vmin'){td.textContent=o.vMin+'px';td.className=o.vMin>=2?'pass':'fail';}
else if(f==='holes'){td.textContent=o.holes;td.className=o.holes<=1?'pass':'fail';}
else if(f==='drift'){const d=Math.abs(o.ink512-o.ink16);td.textContent=d.toFixed(1)+'pt';
td.className=d<6?'pass':'fail';}
});
document.querySelectorAll('[data-g]').forEach(p=>{const o=out[p.dataset.g];
if(o)p.textContent=o.g.join(String.fromCharCode(10));});
window.__ob=out;
})();
</script>
"""
def svg(inner, px, key=None, col=RED):
k = ' data-k="%s"' % key if key else ""
return ('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 %g %g" '
'width="%d" height="%d" style="width:%dpx;height:%dpx;display:block"%s>'
'<g fill="%s">%s</g></svg>' % (VB, VB, px, px, px, px, k, col, inner))
def build():
H = ['<!DOCTYPE html><html lang="zh-CN"><head><meta charset="utf-8">'
'<meta name="viewport" content="width=device-width,initial-scale=1">'
'<title>物 · 第二十八刀</title><style>' + CSS + '</style></head><body><div class="wrap">']
H.append('<div class="ey">Cut 28 · 2026-10-14 · 改画一个「物」 · repo 零改动</div>')
H.append('<h1>物:<em>一笔画得完,一条直边,一个负形</em></h1>')
H.append('<p class="lede">你贴的那批日式极简,配方是<b>一个有机剪影 + 一个双关</b>;'
'而我 27 刀全是参数生成的等距几何,一个双关都没有。'
'这一刀换成肉眼定的贝塞尔控制点,并且先立三条可判的规矩。</p>')
H.append('<h2><span class="no">1</span>三条判据(从 Apple/Patagonia/Shell/Lacoste/WWF 反推)</h2>')
for t in [
"<b>J1 外廓一笔画得完,且至少有一条直边。</b>Patagonia 用地平线封、Shell 用底边封、"
"秦权用平底封。⇒「闭合」是靠直线封出来的,不是靠描边 —— 这正是躲开"
"「光滑凸卵形判死」的机制。",
"<b>J2 内部只允许一个负形。</b>Apple 一口咬痕、Lacoste 张开的口、WWF 的眼圈,都只有一个。"
"⇒ 第二条负形一出现就退回数码管/文件图标那一族。<b>泰卦六爻有三根阴爻各带一个断口 "
"= 三个负形,注定失败</b>;我上一刀拿复杂度阶梯去救它,方向从一开始就错了。",
"<b>J3 识别靠不可迁移特征,不靠细节数量。</b>删掉的一律是说明性细节(纹理、关节、高光、刻度),"
"保留的一律是「换个形状就不再是这个物」的那一处。所有端点钝收,出锋只留在大尺寸版。",
"<b>J4 语汇走肖形印/画像石/木刻版画</b>(一刀一块面),不走写实剪影,也不走插画。"
"模数几何像图标、插画性像贴纸 —— 两头我都被否过。",
]:
H.append('<div class="j">%s</div>' % t)
H.append('<h2><span class="no">2</span>三个活口</h2>')
H.append('<p>撞车排查后剩下的三条:度量族(秦权/秤砣)、结构族(斗栱)、信物族(符/节)。'
'拱顶石、榫卯、窗、圭表、灯、阶梯全部出局,理由见页末。</p>')
for key, nm, fn, why in CANDS:
body = fn()
H.append('<div class="card"><div class="hd"><span class="nm">%s %s</span>'
'<span class="cx">负形 <span data-cell="%s@holes">…</span> 个 · '
'墨率 <span data-cell="%s@ink">…</span></span></div><div class="row">'
% (key, nm, key, key))
for px in (200, 96, 48, 32, 16):
H.append('<div class="cell"><span class="tl" style="background:#fff">%s</span>'
'<div class="lab">%dpx</div></div>' % (svg(body, px, "%s@%d" % (key, px)), px))
H.append('<div class="cell"><span class="tl" style="background:#141210">%s</span>'
'<div class="lab">暖墨底反白</div></div>'
% svg(body, 96, None, WHITE))
H.append('</div><p class="why">%s</p></div>' % why)
H.append('<h2><span class="no">3</span>落款位</h2>')
H.append('<p>硬钝块落在「遠」的右下,读作镇纸/重器 —— 与毛笔字同属文房世界,'
'这是度量族相对结构族最大的优势。</p>')
for key, nm, fn, why in CANDS:
h = 45.4 * 0.40
k = h / VB
H.append('<div class="lock"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 480 120" '
'width="480" height="120" style="width:480px;height:120px">%s'
'<g transform="translate(%g,%g) scale(%g) translate(%g,%g)"><g fill="%s">%s</g></g>'
'</svg><div style="font:12px/1.6 Inter,sans-serif;color:#8A8377;margin-top:8px">'
'%s · 块高 = 字标块高 0.40 倍</div></div>'
% (n5.wordmark_fixed(), 306.3 + 4, 66.3 - h + 2, k, -VB / 2, -VB / 2, RED, fn(), nm))
H.append('<h2><span class="no">4</span>实测</h2>')
H.append('<table><thead><tr><th>候选</th><th class="n">封闭负形数<br>(J2 须 ≤1)</th>'
'<th class="n">横向最细@16</th><th class="n">竖向最细@16</th>'
'<th class="n">墨率@512</th><th class="n">漂移</th></tr></thead><tbody>')
for key, nm, fn, why in CANDS:
H.append('<tr><td><b>%s %s</b></td>'
'<td class="n" data-cell="%s@16@holes">…</td>'
'<td class="n" data-cell="%s@16@hmin">…</td>'
'<td class="n" data-cell="%s@16@vmin">…</td>'
'<td class="n" data-cell="%s@16@ink">…</td>'
'<td class="n" data-cell="%s@16@drift">…</td></tr>'
% (key, nm, key, key, key, key, key))
H.append('</tbody></table>')
H.append('<p>负形个数是<b>泛洪算出来的</b>:从画布边框往里漫白,没被漫到的白区才算封闭负形。'
'不读我写的路径个数 —— 上一刀的教训是读常量的门禁会假绿。</p>')
H.append('<h3>16×16 栅格</h3><div class="row">')
for key, nm, fn, why in CANDS:
H.append('<div class="cell"><pre data-g="%s@16">…</pre><div class="lab">%s %s</div></div>'
% (key, key, nm))
H.append('</div>')
H.append('<footer>生成器 <code>object.py</code> · 控制点为肉眼定,非公式生成 · '
'出局候选与撞车依据:拱顶石(麦当劳「金拱门」/Keystone Strategy 旧金山技术咨询/'
'科石 KeyStone 上海/华夏基石 本土头部管理咨询)、榫卯(dovetail.com 用研 SaaS + 已注册商标)、'
'窗(微软;且漏窗之「漏」对 IT 甲方是负词)、圭表日晷(投影须用线违实心律;'
'圆盘+放射=时钟家族)、灯(Google Lighthouse)、阶梯(金字塔=传销话术)· '
'repo 零改动</footer>')
H.append(JS)
H.append('</div></body></html>')
return "".join(H)
if __name__ == "__main__":
html = build()
out = os.path.join(HERE, "object.html")
with open(out, "w", encoding="utf-8") as f:
f.write(html)
os.makedirs(os.path.join(HERE, "assets-object"), exist_ok=True)
for key, nm, fn, why in CANDS:
with open(os.path.join(HERE, "assets-object", key + ".svg"), "w", encoding="utf-8") as fh:
fh.write('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 %g %g">'
'<g fill="%s">%s</g></svg>' % (VB, VB, RED, fn()))
print("object.html %s B / %d 候选" % (format(len(html.encode("utf-8")), ","), len(CANDS)))