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 个文本/矢量件。
301 lines
15 KiB
Python
301 lines
15 KiB
Python
#!/usr/bin/env python3
|
||
# -*- coding: utf-8 -*-
|
||
"""
|
||
一相圆 · 第三十七刀:把 T2b 收敛成母版
|
||
|
||
甲方已裁定(2026-10-14):
|
||
① 环上 NOVALON **绕两次**(复环)—— 因为实测 7 个字母填不满一圈;
|
||
② 圆心「睿新致遠」**穿出缺口**(款出)—— 照参照图那个机关,环闭而款出。
|
||
|
||
这一刀只解三个还没定的数,别的都不动:
|
||
dx 款出多少。太小读不出"出",太大全幅右坠。
|
||
char_col 书法用墨还是朱砂。墨=环是印、字是款;朱=通体一印。
|
||
opening 开口 110° 是否合适(同时试 80° 与 140°)。
|
||
|
||
新增一个直接可读的判据:**出环量** = 字行右缘到该方位基线圆的距离。
|
||
正 = 确实穿到了基线圆之外(款出成立);负 = 还含在环里。
|
||
另沿用 cut 35/36 的两道闸:离环(不许撞环带)、越界(不许顶破画布)。
|
||
"""
|
||
import importlib.util
|
||
import json
|
||
import math
|
||
import os
|
||
|
||
HERE = os.path.dirname(os.path.abspath(__file__))
|
||
sp = importlib.util.spec_from_file_location("r2", os.path.join(HERE, "ring2.py"))
|
||
r2 = importlib.util.module_from_spec(sp)
|
||
sp.loader.exec_module(r2)
|
||
|
||
RED, INK, WHITE = r2.RED, r2.INK, r2.WHITE
|
||
CX, CY, S, OUT = r2.CX, r2.CY, r2.S, r2.OUT
|
||
|
||
BASE = dict(text="NOVALONNOVALON", opening=110.0, gap_at=90.0,
|
||
rho=0.44, kappa=0.88, stroke=0.24)
|
||
|
||
CELLS = [
|
||
("F1 款出 0.18·Rb", dict(dx=0.18), "墨",
|
||
"只挪一点。量出来若出环量为负,就说明它其实还没出去 —— 那是白挪。"),
|
||
("F2 款出 0.30·Rb", dict(dx=0.30), "墨",
|
||
"cut 36 的 T2b 就是这个位置,甲方选中的那一版。"),
|
||
("F3 款出 0.42·Rb", dict(dx=0.42), "墨",
|
||
"再往外。看全幅是否开始右坠、右端是否顶到画布。"),
|
||
("F4 朱砂款", dict(dx=0.30), "朱",
|
||
"环与款同为朱砂 —— 通体一枚印,不再有「环是印、字是款」的分工。"),
|
||
("F5 开口 80°", dict(dx=0.30, opening=80.0), "墨",
|
||
"缺口收窄。款要出去,就得从更窄的口出去,挤不挤得下要量。"),
|
||
("F6 开口 140°", dict(dx=0.30, opening=140.0), "墨",
|
||
"缺口放宽。一相圆的「缺一」说得最重,但环也就不像环了。"),
|
||
]
|
||
|
||
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:1200px;margin:0 auto;padding:46px 32px 100px}
|
||
code{font:14px/1.5 ui-monospace,Menlo,monospace;background:#EFEAE1;padding:1px 5px}
|
||
.ey{font:12px/1.4 "PingFang SC",Inter,sans-serif;letter-spacing:.18em;
|
||
text-transform:uppercase;color:#8A8377}
|
||
h1{font-size:50px;line-height:1.16;color:#26221E;margin:12px 0 16px;font-weight:600}
|
||
h1 em{font-style:normal;color:#C41E3A}
|
||
h2{font-size:25px;color:#26221E;margin:58px 0 8px;font-weight:600}
|
||
h2 .no{color:#C41E3A;margin-right:10px}
|
||
p{max-width:84ch;margin:10px 0}
|
||
.lede{font-size:19px;color:#26221E;max-width:78ch}
|
||
.j{border-left:2px solid #C41E3A;padding:3px 0 3px 18px;margin:14px 0;color:#26221E;max-width:90ch}
|
||
.card{background:#fff;border:1px solid #EFEAE1;padding:22px 24px;margin:0 0 16px}
|
||
.hd{display:flex;justify-content:space-between;align-items:baseline;gap:16px;
|
||
flex-wrap:wrap;margin-bottom:16px}
|
||
.nm{font-weight:650;color:#26221E;font-size:16px;font-family:"PingFang SC",Inter,sans-serif}
|
||
.cx{font:12px/1.5 "PingFang SC",Inter,sans-serif;color:#8A8377;font-variant-numeric:tabular-nums}
|
||
.row{display:flex;gap:22px;align-items:flex-start;flex-wrap:wrap}
|
||
.cell{text-align:center}
|
||
.lab{font:11.5px/1.5 "PingFang SC",Inter,sans-serif;color:#8A8377;margin-top:7px}
|
||
.tl{display:inline-flex;align-items:center;justify-content:center;
|
||
border-radius:22.5%;overflow:hidden;box-shadow:0 0 0 1px #EFEAE1}
|
||
.why{font-size:14.5px;color:#4F4A42;margin:16px 0 0;max-width:94ch}
|
||
table{border-collapse:collapse;width:100%;margin:14px 0;
|
||
font:13px/1.6 "PingFang SC",Inter,sans-serif}
|
||
th,td{padding:10px 11px;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}
|
||
footer{margin-top:56px;padding-top:16px;border-top:1px solid #C3BDB1;
|
||
font:12.5px/1.7 "PingFang SC",Inter,sans-serif;color:#8A8377}
|
||
"""
|
||
|
||
|
||
def geom(dxfrac, **kw):
|
||
L = dict(kw)
|
||
items, lay = r2.layout(**L)
|
||
dx = dxfrac * lay["Rb0"]
|
||
cen, g = r2.center(lay, dx=dx)
|
||
# 出环量:字行右缘到「该方位基线圆」的距离
|
||
xr, yr = g_x1(lay, dx, g["csize"]), CY
|
||
th = math.degrees(math.atan2(xr - CX, -(yr - CY)))
|
||
rb = lay["rb_of"](th)
|
||
past = math.hypot(xr - CX, yr - CY) - rb
|
||
return items, lay, cen, dx, g, past
|
||
|
||
|
||
def g_x1(lay, dx, csize):
|
||
total = 4 * csize + 3 * csize * 0.10
|
||
return CX + dx - total / 2.0 + total
|
||
|
||
|
||
def build():
|
||
P = ['<!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">']
|
||
P.append('<div class="ey">Cut 37 · 2026-10-14 · 甲方已裁:复环 + 款出 · repo 零改动</div>')
|
||
P.append('<h1>母版收敛:<em>款出多少、用墨还是用朱</em></h1>')
|
||
P.append('<p class="lede">复环(NOVALON 绕两次)与款出缺口已经定了。这一刀只收三个数:'
|
||
'款出位移 dx、书法颜色、开口角度。判据加一条硬的 —— <b>出环量</b>:'
|
||
'字行右缘到该方位基线圆的距离,正数才叫真的出去了。</p>')
|
||
|
||
rows = []
|
||
for nm, kw, ccol, why in CELLS:
|
||
p = dict(BASE)
|
||
p.update({k: v for k, v in kw.items() if k != "dx"})
|
||
dxfrac = kw.get("dx", 0.30)
|
||
items, lay, cen, dx, g, past = geom(dxfrac, **p)
|
||
col = RED if ccol == "朱" else INK
|
||
ring = r2.ring_svg(items)
|
||
body = ring + cen.replace(INK, col) if col != INK else ring + cen
|
||
key = nm.split()[0]
|
||
wht = r2.ring_svg(items) + cen.replace(INK, WHITE)
|
||
rows.append((nm, body, lay, g, key, dx, past, ccol, why, items))
|
||
|
||
P.append('<div class="card"><div class="hd"><span class="nm">%s</span>'
|
||
'<span class="cx">dx=%g · 圆心字高 %g · 离环 %g · 出环 %+.1f · '
|
||
'右缘 %g(画布 %g)</span></div><div class="row">'
|
||
% (nm, round(dx, 1), round(g["csize"], 1), round(g["clear"], 1),
|
||
past, round(g_x1(lay, dx, g["csize"]), 1), S))
|
||
P.append('<div class="cell">%s<div class="lab">300px</div></div>'
|
||
% r2.svg(body, 300, "%s@300" % key))
|
||
P.append('<div class="cell">%s<div class="lab">140px</div></div>'
|
||
% r2.svg(body, 140, "%s@140" % key))
|
||
P.append('<div class="cell"><span class="tl" style="background:#141210">%s</span>'
|
||
'<div class="lab">暖墨底反白</div></div>' % r2.svg(wht, 160))
|
||
P.append('<div class="cell"><span class="tl" style="background:#C41E3A">%s</span>'
|
||
'<div class="lab">朱砂底·白环</div></div>'
|
||
% r2.svg(r2.ring_svg(items) + cen.replace(INK, WHITE), 160))
|
||
P.append('<div class="cell"><span class="tl" style="background:#fff">%s</span>'
|
||
'<div class="lab">40px 实测源</div></div>'
|
||
% r2.svg(body, 40, "%s@40" % key))
|
||
P.append('</div><p class="why">%s</p></div>' % why)
|
||
|
||
P.append('<h2><span class="no">1</span>判据</h2>')
|
||
P.append('<table><thead><tr><th>候选</th><th class="n">dx</th><th class="n">圆心字高</th>'
|
||
'<th class="n">离环(≥6)</th><th class="n">出环量(>0)</th>'
|
||
'<th class="n">右缘余量</th><th class="n">带填充率</th>'
|
||
'<th class="n">最细@40</th></tr></thead><tbody>')
|
||
for nm, body, lay, g, key, dx, past, ccol, why, items in rows:
|
||
margin = S - g_x1(lay, dx, g["csize"])
|
||
P.append('<tr><td><b>%s</b></td><td class="n">%g</td><td class="n">%g</td>'
|
||
'<td class="n %s">%g</td><td class="n %s">%+.1f</td>'
|
||
'<td class="n %s">%g</td>'
|
||
'<td class="n" data-cell="%s@512@band">…</td>'
|
||
'<td class="n" data-cell="%s@40@min">…</td></tr>'
|
||
% (nm, round(dx, 1), round(g["csize"], 1),
|
||
"pass" if g["clear"] >= 6 else "fail", round(g["clear"], 1),
|
||
"pass" if past > 0 else "fail", past,
|
||
"pass" if margin >= 6 else "fail", round(margin, 1),
|
||
key, key))
|
||
P.append('</tbody></table>')
|
||
P.append('<p><b>出环量</b> = 字行右缘到该方位基线圆的距离。它是"款出"这条裁定有没有'
|
||
'真正落地的唯一硬指标 —— dx 挪了但出环量为负,就是白挪。'
|
||
'<b>右缘余量</b> = 画布边到字行右缘,小于 6 就是顶破了。'
|
||
'<b>带填充率</b>沿用 cut 36 那支射线采样器(几何对照实测 99.6%,通过)。</p>')
|
||
P.append('<p id="ctrl">仪器对照:计算中…</p>')
|
||
|
||
P.append('<footer>生成器 <code>final.py</code>(复用 <code>ring2.py</code> 螺旋解算与两道闸)· '
|
||
'环上字母沿用 <code>novalon.py</code> 构造几何,只改模块全局笔宽 T · '
|
||
'圆心四字取自 <code>public/logo.svg</code> 字标组真迹路径,只缩放不改动 · '
|
||
'repo 零改动</footer>')
|
||
|
||
BAND = {}
|
||
|
||
def prof(L):
|
||
a0, span = L["a0"], L["span"]
|
||
o = []
|
||
for d in range(360):
|
||
rel = (d - a0) % 360.0
|
||
if rel <= span:
|
||
f = rel / span
|
||
rb = L["Rb0"] + (L["Rb1"] - L["Rb0"]) * f
|
||
ch = L["ch0"] + (L["ch1"] - L["ch0"]) * f
|
||
o.append([1, round(rb, 2), round(rb + ch, 2)])
|
||
else:
|
||
o.append([0, 0.0, 0.0])
|
||
return o
|
||
|
||
for nm, body, lay, g, key, dx, past, ccol, why, items in rows:
|
||
BAND[key] = prof(lay)
|
||
# 离屏 512 样张:只放环。圆心在基线圆以内,不进环带,所以不影响带填充率口径。
|
||
P.append('<div style="position:absolute;left:-9999px;top:0">%s</div>'
|
||
% r2.svg(r2.ring_svg(items), 512, "%s@512" % key))
|
||
|
||
P.append('<script>var BAND=' + json.dumps(BAND) + ';</script>')
|
||
P.append(r"""<script>
|
||
const WHT=[255,255,255];
|
||
function D(a,b){return Math.hypot(a[0]-b[0],a[1]-b[1],a[2]-b[2]);}
|
||
function isAny(p,a){return a>=40&&D(p,WHT)>=110;}
|
||
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 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(isAny([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 bandFill(gd,P){
|
||
const d=gd.data,N=512,cx=220,cy=220,k=N/440;
|
||
let sw=0,sf=0;
|
||
for(let a=0;a<360;a++){const e=P[a]; if(!e[0])continue;
|
||
const rb=e[1],ro=e[2]; if(!(ro>rb))continue;
|
||
const t=a*Math.PI/180, sx=Math.sin(t), sy=-Math.cos(t);
|
||
let dark=0,tot=0;
|
||
for(let r=rb;r<=ro;r+=0.5){
|
||
const px=(cx+sx*r)*k, py=(cy+sy*r)*k;
|
||
if(px<0||py<0||px>=N||py>=N)continue;
|
||
const i=(Math.floor(py)*N+Math.floor(px))*4;
|
||
tot++; if(isAny([d[i],d[i+1],d[i+2]],d[i+3]))dark++;
|
||
}
|
||
if(!tot)continue;
|
||
const w=ro*ro-rb*rb; sw+=w; sf+=w*(dark/tot);
|
||
}
|
||
return sw?100*sf/sw:0;
|
||
}
|
||
function rasSrc(src,size){return new Promise(r=>{const im=new Image();
|
||
const 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(src);});}
|
||
(async()=>{
|
||
const out={};
|
||
for(const el of document.querySelectorAll('svg[data-k]')){
|
||
const n=+el.dataset.k.split('@')[1];
|
||
const iS=await ras(el,n); if(!iS)continue;
|
||
const rec={hMin:runs(iS,n,false),vMin:runs(iS,n,true)};
|
||
if(n===512)rec.band=bandFill(iS,BAND[el.dataset.k.split('@')[0]]);
|
||
out[el.dataset.k]=rec;
|
||
}
|
||
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==='band')td.textContent=(o.band===undefined?'—':o.band.toFixed(1)+'%');
|
||
else if(f==='min'){const m=Math.min(o.hMin,o.vMin);td.textContent=m.toFixed(2)+'px';
|
||
td.className=m>=2?'pass':'fail';}
|
||
});
|
||
/* 几何对照:按同一份 prof 画一枚实心环带,应≈100%。
|
||
全白/满墨那一对验不出圆心与缩放 —— _bandfill.py 就是被这点骗过的。 */
|
||
{
|
||
const P=BAND[Object.keys(BAND)[1]];
|
||
let outer=[],inner=[];
|
||
for(let a=0;a<360;a++){const q=P[a]; if(!q[0])continue;
|
||
const t=a*Math.PI/180;
|
||
outer.push((220+Math.sin(t)*q[2]).toFixed(2)+' '+(220-Math.cos(t)*q[2]).toFixed(2));
|
||
inner.push((220+Math.sin(t)*q[1]).toFixed(2)+' '+(220-Math.cos(t)*q[1]).toFixed(2));}
|
||
const dd='M '+outer.join(' L ')+' Z M '+inner.reverse().join(' L ')+' Z';
|
||
const src='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 440 440" '+
|
||
'width="512" height="512" style="width:512px;height:512px;display:block">'+
|
||
'<path d="'+dd+'" fill="#C41E3A" fill-rule="evenodd"/></svg>';
|
||
const gd=await rasSrc(src,512);
|
||
const t2=document.createElement('canvas');t2.width=512;t2.height=512;
|
||
const tc=t2.getContext('2d');
|
||
const blank=tc.getImageData(0,0,512,512);
|
||
const full=tc.createImageData(512,512);
|
||
for(let i=0;i<full.data.length;i+=4){full.data[i]=196;full.data[i+1]=30;
|
||
full.data[i+2]=58;full.data[i+3]=255;}
|
||
const neg=bandFill(blank,P), pos=bandFill(full,P), geo=gd?bandFill(gd,P):-1;
|
||
const ok=(neg<0.05&&pos>99.95&&geo>99);
|
||
document.getElementById('ctrl').innerHTML=
|
||
'仪器对照(同一套采样代码):负·全白 = '+neg.toFixed(1)+'% 应 0.0 · '
|
||
+'正·满墨 = '+pos.toFixed(1)+'% 应 100.0 · 几何·实心环带 = '
|
||
+geo.toFixed(1)+'% 应≈100 —— <b class="'+(ok?'pass':'fail')+'">'
|
||
+(ok?'三条全过,本页带填充率可用':'有一条不过,本页带填充率作废')+'</b>';
|
||
}
|
||
const unres=[...document.querySelectorAll('[data-cell]')].filter(e=>e.textContent==='…').length;
|
||
window.__f={out:out,unresolved:unres};
|
||
})();
|
||
</script>""")
|
||
P.append('</div></body></html>')
|
||
return "".join(P)
|
||
|
||
|
||
if __name__ == "__main__":
|
||
html = build()
|
||
with open(os.path.join(HERE, "final.html"), "w", encoding="utf-8") as f:
|
||
f.write(html)
|
||
for nm, kw, ccol, why in CELLS:
|
||
p = dict(BASE)
|
||
p.update({k: v for k, v in kw.items() if k != "dx"})
|
||
items, lay, cen, dx, g, past = geom(kw.get("dx", 0.30), **p)
|
||
print("%-4s dx=%5.1f 圆心=%5.1f 离环=%5.1f 出环=%+6.1f 款=%s"
|
||
% (nm.split()[0], dx, g["csize"], g["clear"], past, ccol))
|
||
print("final.html %s B" % format(len(html.encode("utf-8")), ","))
|