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 个文本/矢量件。
297 lines
16 KiB
Python
297 lines
16 KiB
Python
#!/usr/bin/env python3
|
||
# -*- coding: utf-8 -*-
|
||
"""
|
||
权 · 矢量化(第二十九刀)
|
||
|
||
上一刀的形研究(生成器出草图)第一次给出了可用的轮廓。
|
||
但它有三处不能直接要,这三处正是设计工作本身:
|
||
|
||
删 肩腹交界那两个小凹缺 —— J3 说的"说明性细节",16px 必糊。
|
||
破 完全对称 —— 研究第五变量:零记忆点。
|
||
破法不靠加形状,靠**把左肩一刀切平**:右肩是磨圆的耳,左肩是凿出的平面。
|
||
这一下同时满足 J4(肖形印/木刻版画语汇:一刀一块面)与不对称。
|
||
收 通用圆角 → 刀刻感:底边拉直、两底角只留极小圆, flank 的凹弧加深。
|
||
|
||
J1 外廓一笔画得完 + 至少一条直边 → 平底
|
||
J2 只允许一个封闭负形 → 钮上的孔
|
||
J3 不可迁移特征 → 那个孔(没有它是一块石头)
|
||
"""
|
||
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
|
||
|
||
|
||
n5 = load("n5", os.path.join(HERE, "n5-refine.py"))
|
||
RED = "#C41E3A"
|
||
WHITE = "#FFFFFF"
|
||
PAPER = "#F7F4EF"
|
||
VB = 256.0
|
||
|
||
# ---------------------------------------------------------------- 轮廓
|
||
# 一笔画完(一个 subpath),平底,全钝。左肩切平 = 唯一的偏差。
|
||
BODY = (
|
||
"M 60 196 "
|
||
"C 60 202 63 205 69 205 " # 左下:极小圆,不是通用大圆角
|
||
"L 187 205 " # ← J1 的直边(平底)
|
||
"C 193 205 196 202 196 196 " # 右下
|
||
"C 196 166 189 140 177 121 " # 右腹:凹弧上收
|
||
"C 187 119 194 112 194 102 " # 右耳出
|
||
"C 194 90 184 83 172 83 " # 右耳顶
|
||
"C 165 83 159 86 156 91 " # 入颈
|
||
"C 155 78 153 66 153 60 "
|
||
"C 153 44 143 34 128 34 " # 钮顶
|
||
"C 113 34 103 44 103 60 "
|
||
"C 103 66 101 78 100 91 "
|
||
"C 97 88 93 86 88 86 " # ← 左肩:一刀切平(唯一的偏差)
|
||
"L 70 86 " # 凿出的平面,不是圆耳
|
||
"L 70 116 "
|
||
"C 70 119 72 121 76 121 " # 平面回落接左腹
|
||
"C 66 140 60 166 60 196 "
|
||
"Z"
|
||
)
|
||
# 唯一的封闭负形:钮孔。尺寸 30×28 单位 = 16px 下约 1.9×1.75px,
|
||
# 所以简标档要放大它,主标档保持这个比例。
|
||
EYE = ("M 128 48 C 136 48 142 54 142 62 C 142 70 136 76 128 76 "
|
||
"C 120 76 114 70 114 62 C 114 54 120 48 128 48 Z")
|
||
|
||
QUAN = '<path fill-rule="evenodd" d="%s %s"/>' % (BODY, EYE)
|
||
|
||
# 简标档:≤32px。删掉不对称偏差与极小圆角,钮孔放大到 4px,
|
||
# 因为 16px 下 1.75px 的孔会被抗锯齿填掉 —— 那时它读成实心块。
|
||
QUAN_SIMPLE = (
|
||
'<path fill-rule="evenodd" d="'
|
||
"M 62 200 L 194 200 L 194 150 "
|
||
"C 194 128 186 112 174 100 L 174 84 L 82 84 L 82 100 "
|
||
"C 70 112 62 128 62 150 Z "
|
||
"M 128 44 C 141 44 150 53 150 66 C 150 79 141 88 128 88 "
|
||
"C 115 88 106 79 106 66 C 106 53 115 44 128 44 Z"
|
||
'"/>'
|
||
)
|
||
|
||
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:76ch;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}
|
||
.card{background:#fff;border:1px solid #E2DDD3;padding:22px 24px;margin:14px 0}
|
||
.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}
|
||
.tl svg{display:block}
|
||
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 comps(im,px,red){const d=im.data,seen=new Uint8Array(px*px);
|
||
const test=i=>red?isRed([d[i],d[i+1],d[i+2]],d[i+3]):(d[i+3]<40||D([d[i],d[i+1],d[i+2]],WHT)<110);
|
||
let n=0,sizes=[];
|
||
for(let p=0;p<px*px;p++){if(seen[p]||!test(p*4))continue;n++;let sz=0;const st=[p];seen[p]=1;
|
||
while(st.length){const q=st.pop();sz++;const x=q%px,y=(q/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]&&test(r*4)){seen[r]=1;st.push(r);}}});}
|
||
if(sz>=2)sizes.push(sz);}
|
||
return sizes;}
|
||
function holes(im,px){ /* 封闭负形 = 边框泛洪后仍未被漫到的白区连通域。
|
||
⚠ 上一版把计数交给 comps(),而 comps() 自建 seen、把外围背景也数成一个
|
||
连通域 —— 于是实心矩形报 1 个负形(应为 0)。必须复用边框的 seen。 */
|
||
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;
|
||
for(let p=0;p<px*px;p++){
|
||
if(seen[p]||!isW(p*4))continue;
|
||
n++;const q2=[p];seen[p]=1;let sz=0;
|
||
while(q2.length){const r=q2.pop();sz++;const x=r%px,y=(r/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 s2=ny*px+nx;
|
||
if(!seen[s2]&&isW(s2*4)){seen[s2]=1;q2.push(s2);}}});}
|
||
if(sz<2)n-=1; // 单像素抗锯齿噪点不算一个负形
|
||
}
|
||
return n;}
|
||
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),blocks:comps(i16,16,true).length,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==='blocks'){td.textContent=o.blocks;}
|
||
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.__q=out;
|
||
})();
|
||
</script>
|
||
"""
|
||
|
||
|
||
def svg(inner, px, key=None, col=RED, vb=VB):
|
||
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 29 · 2026-10-14 · 度量族 · 秦权/秤砣 · repo 零改动</div>')
|
||
H.append('<h1>权:<em>平底、一孔、左肩一刀切平</em></h1>')
|
||
H.append('<p class="lede">形来自上一刀的生成式形研究(那是草图,不是交付物)。'
|
||
'这一刀做我早该做的三件事:<b>删掉说明性细节、破掉对称、把通用圆角改成刀刻</b>。</p>')
|
||
|
||
H.append('<h2><span class="no">1</span>主标档</h2>')
|
||
H.append('<div class="card"><div class="row">')
|
||
for px in (220, 120, 64, 40, 32, 16):
|
||
H.append('<div class="cell"><span class="tl" style="background:#fff">%s</span>'
|
||
'<div class="lab">%dpx</div></div>' % (svg(QUAN, px, "M@%d" % px), px))
|
||
H.append('<div class="cell"><span class="tl" style="background:#141210">%s</span>'
|
||
'<div class="lab">暖墨底反白</div></div>' % svg(QUAN, 120, None, WHITE))
|
||
H.append('</div><p>左肩那一刀平面是唯一的偏差:右耳磨圆、左肩凿平,'
|
||
'读起来像刻出来的而不是画出来的(J4 肖形印/木刻版画语汇)。'
|
||
'底边是整条标志唯一的直线,靠它把外廓"封"住 —— 不是靠描边。</p></div>')
|
||
|
||
H2_ = ['<h2><span class="no">2</span>简标档(≤32px)</h2>',
|
||
'<div class="card"><div class="row">']
|
||
for px in (64, 32, 24, 16):
|
||
H2_.append('<div class="cell"><span class="tl" style="background:#fff">%s</span>'
|
||
'<div class="lab">%dpx</div></div>' % (svg(QUAN_SIMPLE, px, "S@%d" % px), px))
|
||
H2_.append('<div class="cell"><span class="tl" style="background:#C41E3A">%s</span>'
|
||
'<div class="lab">朱砂底反白</div></div>' % svg(QUAN_SIMPLE, 64, None, WHITE))
|
||
H2_.append('</div><p>主标的钮孔是 30 单位,16px 下只有 1.9px,会被抗锯齿填成实心。'
|
||
'简标档把孔放大到 44 单位(16px 下 2.75px),同时删掉左肩偏差与全部小圆角——'
|
||
'<b>小版本从系统内部长出来,不是把主版本压糊</b>(American Express 另出 '
|
||
'「AM EX」是同一个做法)。</p></div>')
|
||
H.append("".join(H2_))
|
||
|
||
H.append('<h2><span class="no">3</span>落款位</h2>')
|
||
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">'
|
||
'主标 · 块高 = 字标块高 0.40 倍,落「遠」右下,读作镇纸/重器</div></div>'
|
||
% (n5.wordmark_fixed(), 306.3 + 4, 66.3 - h + 2, k, -VB / 2, -VB / 2, RED, QUAN))
|
||
|
||
H.append('<h2><span class="no">4</span>度量(这次同时数封闭负形与分离块数)</h2>')
|
||
H.append('<p>上一刀的教训:我把两种病混成一种了。泰卦死于<b>碎片化</b>(9 个分离块),'
|
||
'不是死于封闭负形(实测 0 个)。所以两个都量,并且<b>加正负对照</b>:'
|
||
'泰卦必须报 9 块 / 0 负形,实心矩形必须报 1 块 / 0 负形。</p>')
|
||
H.append('<table><thead><tr><th>档</th><th class="n">分离块数</th>'
|
||
'<th class="n">封闭负形<br>(须 ≤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, label in (("M@16", "权 · 主标档@16"), ("S@16", "权 · 简标档@16"),
|
||
("T@16", "正对照:泰卦 R1@16"), ("K@16", "负对照:实心矩形@16")):
|
||
H.append('<tr><td><b>%s</b></td><td class="n" data-cell="%s@blocks">…</td>'
|
||
'<td class="n" data-cell="%s@holes">…</td>'
|
||
'<td class="n" data-cell="%s@hmin">…</td>'
|
||
'<td class="n" data-cell="%s@vmin">…</td>'
|
||
'<td class="n" data-cell="%s@ink">…</td>'
|
||
'<td class="n" data-cell="%s@drift">…</td></tr>'
|
||
% (label, key, key, key, key, key, key))
|
||
H.append('</tbody></table>')
|
||
# 对照样本也要挂上 data-k
|
||
tai = ('<g fill="%s">' % RED + "".join(
|
||
['<rect x="30" y="32" width="196" height="21"/>',
|
||
'<rect x="30" y="66" width="196" height="21"/>',
|
||
'<rect x="30" y="100" width="196" height="21"/>',
|
||
'<rect x="30" y="134" width="87" height="21"/><rect x="139" y="134" width="87" height="21"/>',
|
||
'<rect x="30" y="168" width="87" height="21"/><rect x="139" y="168" width="87" height="21"/>',
|
||
'<rect x="30" y="202" width="87" height="21"/><rect x="139" y="202" width="87" height="21"/>'])
|
||
+ '</g>')
|
||
solid = '<g fill="%s"><rect x="40" y="40" width="176" height="176"/></g>' % RED
|
||
H.append('<div style="position:absolute;width:0;height:0;overflow:hidden">'
|
||
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" width="16" height="16" '
|
||
'style="width:16px;height:16px" data-k="T@16">%s</svg>'
|
||
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" width="16" height="16" '
|
||
'style="width:16px;height:16px" data-k="K@16">%s</svg></div>' % (tai, solid))
|
||
|
||
H.append('<h3>16×16 栅格</h3><div class="row">')
|
||
for key, label in (("M@16", "主标档"), ("S@16", "简标档"), ("T@16", "正对照 泰卦")):
|
||
H.append('<div class="cell"><pre data-g="%s">…</pre><div class="lab">%s</div></div>'
|
||
% (key, label))
|
||
H.append('</div>')
|
||
|
||
H.append('<footer>生成器 <code>quan.py</code> · 轮廓为单个 subpath、平底、全钝收 · '
|
||
'形研究来源:上一刀 ImageGen 草图(<code>vibe_images/form-study-quan_*.png</code>,'
|
||
'AI 生成、带水印,<b>不作为交付物</b>,仅取其轮廓关系后由我矢量化重画)· '
|
||
'块数与负形数均为连通域实测,含正负对照 · repo 零改动</footer>')
|
||
H.append(JS)
|
||
H.append('</div></body></html>')
|
||
return "".join(H)
|
||
|
||
|
||
if __name__ == "__main__":
|
||
html = build()
|
||
out = os.path.join(HERE, "quan.html")
|
||
with open(out, "w", encoding="utf-8") as f:
|
||
f.write(html)
|
||
os.makedirs(os.path.join(HERE, "assets-quan"), exist_ok=True)
|
||
for nm, body in (("primary", QUAN), ("simple", QUAN_SIMPLE)):
|
||
with open(os.path.join(HERE, "assets-quan", "quan-%s.svg" % nm), "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, body))
|
||
print("quan.html %s B / 2 档矢量已出" % format(len(html.encode("utf-8")), ","))
|