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 个文本/矢量件。
311 lines
16 KiB
Python
311 lines
16 KiB
Python
#!/usr/bin/env python3
|
||
# -*- coding: utf-8 -*-
|
||
"""
|
||
E1 一相圆 · 精修
|
||
|
||
诊断(当前 beauty.py 的 E1 为什么只到"很好"):
|
||
① 宽度线性递减 w = w0 + (w1-w0)*t —— 真笔不是线性:落笔压重、中段提速变细、
|
||
收笔出锋。线性渐变看着像"渐变描边",不像手写的。
|
||
② 两端平切 —— 起笔可以是钝的(笔落地),但收笔必须是尖尾(提笔离纸)。
|
||
③ 完美正圆 —— 手写圆一定有轻微椭圆性与圆心漂移;"不圆"正是这个符号的全部理由。
|
||
|
||
精修策略:中心线用 r(θ) = R·(1 + e·cos2(θ-φ)) 做轻微偏圆,
|
||
宽度用控制点插值的笔势曲线(落笔→最粗→匀速收细→尖尾),
|
||
开口方位让**尖尾指向字标**(阅读方向),而不是随便开。
|
||
|
||
三档各只动一个变量,便于指认:
|
||
F1 只修笔势(① + ②)
|
||
F2 笔势 + 不圆(① + ② + ③)
|
||
F3 笔势 + 不圆 + 轻重配比(再调 R/均宽,使墨量向书法块的 18.2% 靠)
|
||
"""
|
||
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
|
||
|
||
|
||
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
|
||
CX = ENV_X + ENV_W / 2
|
||
|
||
# 笔势曲线:t → 宽度系数(0..1)。落笔钝、约 15% 处最粗、之后匀收、末端出尖。
|
||
BRUSH = [(0.00, 0.42), (0.05, 0.92), (0.15, 1.00), (0.40, 0.90),
|
||
(0.65, 0.68), (0.86, 0.36), (0.97, 0.12), (1.00, 0.035)]
|
||
# 对照:线性渐变(当前 E1 的做法)
|
||
LINEAR = [(0.0, 1.0), (1.0, 0.26)]
|
||
|
||
|
||
def interp(prof, t):
|
||
for (a, va), (b, vb) in zip(prof, prof[1:]):
|
||
if a <= t <= b:
|
||
k = 0 if b == a else (t - a) / (b - a)
|
||
return va + (vb - va) * k
|
||
return prof[-1][1]
|
||
|
||
|
||
def enso(R=37.0, theta0=10.0, sweep=320.0, W=17.5, ecc=0.0, ephi=20.0,
|
||
prof=BRUSH, steps=160, cx=None, cy=None):
|
||
"""笔势环:中心线可偏心、宽度沿弧按笔势曲线变化、收笔成尖尾。"""
|
||
cx = CX if cx is None else cx
|
||
cy = BCY if cy is None else cy
|
||
a0, span = math.radians(theta0), math.radians(sweep)
|
||
ph = math.radians(ephi)
|
||
outer, inner = [], []
|
||
for i in range(steps + 1):
|
||
t = i / steps
|
||
ang = a0 + span * t
|
||
hw = W * interp(prof, t) / 2.0
|
||
r = R * (1 + ecc * math.cos(2 * (ang - ph)))
|
||
ca, sa = math.cos(ang), math.sin(ang)
|
||
outer.append((cx + (r + hw) * ca, cy + (r + hw) * sa))
|
||
inner.append((cx + (r - hw) * ca, cy + (r - hw) * sa))
|
||
pts = outer + list(reversed(inner))
|
||
d = "M " + " L ".join("%g %g" % p for p in pts) + " Z"
|
||
return '<path d="%s" fill="%s"/>' % (d, RED)
|
||
|
||
|
||
GRADES = [
|
||
dict(id="F1", nm="只修笔势", kw=dict(prof=BRUSH, ecc=0.0),
|
||
note="宽度换成落笔→最粗→匀收→尖尾的曲线,收笔成尖。圆仍是规尺圆。"),
|
||
dict(id="F2", nm="笔势 + 不圆", kw=dict(prof=BRUSH, ecc=0.028, ephi=24.0),
|
||
note="再加 2.8% 的轻微偏圆与圆心漂移。这是「手写」与「画出来的圆」的分界。"),
|
||
dict(id="F3", nm="笔势 + 不圆 + 配比", kw=dict(prof=BRUSH, ecc=0.028, ephi=24.0, R=39.5, W=15.0),
|
||
note="半径略增、均宽略减,把墨量往书法块(18.2%)方向拉,减轻「红圈压住毛笔字」的感觉。"),
|
||
]
|
||
|
||
# 开口方位:让尖尾指向字标(右侧阅读方向)
|
||
ANGLES = [
|
||
("尾朝右上(指向字标)", dict(theta0=10.0, sweep=320.0)),
|
||
("尾朝正上", dict(theta0=30.0, sweep=330.0)),
|
||
("尾朝右下", dict(theta0=-60.0, sweep=320.0)),
|
||
("开口更大(300°)", dict(theta0=14.0, sweep=300.0)),
|
||
]
|
||
|
||
# 对照:当前 beauty.py 的 E1(线性宽度 + 平切端)
|
||
CURRENT = dict(prof=LINEAR, ecc=0.0, theta0=-58.0, sweep=322.0, W=15.5)
|
||
|
||
|
||
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 + """
|
||
.be{display:grid;grid-template-columns:1fr 252px;border-bottom:1px solid var(--hair)}
|
||
.be>div:first-child{border-right:1px solid var(--hair);padding:18px 22px}
|
||
.be .big{background:#fff;border:1px solid var(--hair);padding:14px 16px;display:flex;
|
||
align-items:center;justify-content:center;min-height:112px}
|
||
.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 4px}
|
||
h3 .id{color:var(--red);font-size:11px;letter-spacing:.12em;margin-right:7px}
|
||
.strip{display:grid;grid-template-columns:repeat(4,1fr);border:1px solid var(--hair)}
|
||
.strip>div{padding:14px 10px;text-align:center;border-left:1px solid var(--hair)}
|
||
.strip>div:first-child{border-left:0}
|
||
.strip .lab{font-size:11px;color:var(--muted);margin-top:8px;font-family:'PingFang SC',serif}
|
||
"""
|
||
|
||
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 dens(el,size){
|
||
const im=await raster(el,size); if(!im) return null;
|
||
const d=im.data,W=im.width,H=im.height;
|
||
let inked=0,minx=W,maxx=0,miny=H,maxy=0;
|
||
for(let y=0;y<H;y++)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]];
|
||
if(a>=40&&D(p,WHITE)>=110){inked++;if(x<minx)minx=x;if(x>maxx)maxx=x;if(y<miny)miny=y;if(y>maxy)maxy=y;}}
|
||
return inked/(((maxx-minx+1)*(maxy-miny+1))||1);
|
||
}
|
||
(async()=>{
|
||
const out={};
|
||
for(const el of document.querySelectorAll('svg[data-src]')){
|
||
const k=el.getAttribute('data-src');
|
||
out[k]={d128:await dens(el,128), d512:await dens(el,512)};
|
||
}
|
||
document.querySelectorAll('[data-d]').forEach(td=>{
|
||
const o=out[td.getAttribute('data-d')]; if(o) td.textContent=(o.d512*100).toFixed(1)+'%';});
|
||
window.__enso=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>E1 一相圆 · 精修三档 · 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">Ensō refinement · 2026-10-13 · 评审稿(repo 零改动)</div>')
|
||
w('<h1>E1 一相圆 · <em>精修三档,每档只动一个变量</em></h1>')
|
||
w('<p class="lede">当前 E1 有三处机械感:宽度线性递减(真笔是曲线)、两端平切(收笔该出锋)、'
|
||
'完美正圆(手写圆不圆,那正是它的理由)。本轮按这三处逐个修,'
|
||
'并让尖尾指向字标——开口不是随便开。</p></header>')
|
||
|
||
# 对照基准
|
||
w('<section class="band"><h2 class="band">对照基准</h2>')
|
||
for label, kw, note in [
|
||
("当前 E1(线性宽 + 平切 + 正圆)", CURRENT, "本轮要超过的对象"),
|
||
("已定稿 N5 竹简", None, "另一条路线,作为最终裁决的参照"),
|
||
]:
|
||
body = enso(**kw) if kw else n5.V1
|
||
w('<div class="be"><div><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 (32, 16):
|
||
w('<div class="u">%s<span>%dpx</span></div>' % (mark_only(body, px), px))
|
||
w('</div></div><div class="meta"><h3>%s</h3>' % label)
|
||
w('<div class="small" style="margin:6px 0">%s</div>' % note)
|
||
w('<div class="small">墨量 <b data-d="%s">…</b></div>'
|
||
% ("cur" if kw else "n5"))
|
||
w('</div></div>')
|
||
w('<div style="display:none">'
|
||
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 108 120" data-src="cur">%s</svg>'
|
||
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 108 120" data-src="n5">%s</svg>'
|
||
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="100 0 380 120" data-src="cal">%s</svg>'
|
||
'</div>' % (enso(**CURRENT), n5.V1, n5.wordmark_fixed(INK)))
|
||
w('<p class="small">书法块墨量 <b data-d="cal">…</b> ——这是符号想贴近的基准;'
|
||
'符号是实心块、书法是笔画,差数倍是正常的,目标不是相等而是不抢。</p>')
|
||
w('</section>')
|
||
|
||
# 三档
|
||
w('<section class="band"><h2 class="band">精修三档</h2>')
|
||
for g in GRADES:
|
||
body = enso(**g["kw"])
|
||
w('<div class="be"><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 (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>' % (g["id"], g["nm"]))
|
||
w('<div class="small" style="margin:6px 0">%s</div>' % g["note"])
|
||
w('<div class="small">墨量 <b data-d="%s">…</b></div>' % g["id"])
|
||
w('</div></div>')
|
||
w('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 108 120" '
|
||
'style="position:absolute;width:0;height:0" data-src="%s">%s</svg>' % (g["id"], body))
|
||
w('</section>')
|
||
|
||
# 开口方位
|
||
w('<section class="band"><h2 class="band">开口方位(在 F2 上试四种)</h2>')
|
||
w('<p>开口位置决定尖尾指向哪里。让尖尾朝右上,视线会顺着它落到「睿新致遠」上;'
|
||
'朝正上则更端庄但失去引导;朝右下会指向 NOVALON 之下,容易显得下坠。</p>')
|
||
w('<div class="strip">')
|
||
for i, (lab, kw) in enumerate(ANGLES):
|
||
body = enso(prof=BRUSH, ecc=0.028, ephi=24.0, **kw)
|
||
w('<div>%s<div class="lab">%s</div></div>' % (mark_only(body, 62), lab))
|
||
w('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 108 120" '
|
||
'style="position:absolute;width:0;height:0" data-src="a%d">%s</svg>' % (i, body))
|
||
w('</div>')
|
||
w('</section>')
|
||
|
||
# 开口时钟:八方位一次看全,直接判定哪一档最不像字母
|
||
w('<section class="band"><h2 class="band">开口时钟 · 八方位</h2>')
|
||
w('<p>刚才那四格暴露了一个我没预料到的问题:<b>开口居中在右侧时,整枚被读成字母 C</b>——'
|
||
'因为 C 的缺口就在右边。圆相的缺口应该在"笔提起来"的地方,而不是在字母该开口的地方。'
|
||
'这里把开口中心按八个方位摆一遍(笔势曲线不变,始终是落笔钝重、绕一圈后收成尖尾)。</p>')
|
||
w('<div class="strip" style="grid-template-columns:repeat(4,1fr)">')
|
||
names = {0:"右(=C 危险区)", 45:"右下", 90:"正下", 135:"左下",
|
||
180:"正左", 225:"左上", 270:"正上(笔提起)", 315:"右上"}
|
||
for i, gc in enumerate((0, 45, 90, 135, 180, 225, 270, 315)):
|
||
sweep = 320.0
|
||
end = gc + (360.0 - sweep) / 2.0
|
||
start = end - sweep
|
||
body = enso(prof=BRUSH, ecc=0.028, ephi=24.0, theta0=start, sweep=sweep)
|
||
w('<div>%s<div class="lab">%s° %s</div></div>' % (mark_only(body, 56), gc, names[gc]))
|
||
w('</div>')
|
||
w('<p class="small">读法:0°=缺口在右(最像 C,避开);90°=缺口在下(最像"未闭合的环",'
|
||
'但重心下坠);270°=缺口在上(禅圆最常见的提笔位,端庄且不成字母);'
|
||
'45°/135° 是折中。</p>')
|
||
w('</section>')
|
||
|
||
w('<section class="band"><h2 class="band">我的判断</h2>')
|
||
w('<p>三档里 <b>F2</b> 是质变点——2.8% 的偏圆与圆心漂移,是"画出来的圆"和'
|
||
'"手写的圆"的分界,人眼对圆的完美度极其敏感,对 3% 的偏差同样敏感。'
|
||
'F1 只修笔势,仍然会被看成"一个渐变粗的圈"。'
|
||
'F3 减宽增径,墨量更低但笔势的厚重感也跟着削掉一半——'
|
||
'圆相这东西,太细就从"一笔"变成"一根线",反而回到我们第一轮被否的 hairline 问题。</p>')
|
||
w('<div class="note"><b>建议:F2 + 开口 270°(正上),次选 225°(左上)。</b>时钟实测:0° 读成 C、180° 读成反 C、90° 重心下坠,只有上半弧读作「笔提起」。'
|
||
'我上一条推荐的是「尖尾朝右上」,那正好落在 0° 附近的 C 字形危险区,'
|
||
'看了开口时钟才发现问题——撤回。'
|
||
'若你更在意符号不抢字标,再退到 F3 的配比。'
|
||
'但要说清楚:这三档仍是程序生成的,只是把"机械感"的三个来源去掉了。'
|
||
'真正的最后 5%——飞白、边缘的轻微不平、起笔那一下的顿挫——需要手工描,'
|
||
'或者接受它作为一枚"取圆相之意"的几何符号而非一幅圆相作品。</div>')
|
||
w('</section>')
|
||
|
||
w(JS)
|
||
w('<footer>生成器 <code>enso-refine.py</code> · 复用 <code>n5-refine.py</code> 的已居中字标 · '
|
||
'笔势曲线为 8 控制点插值,中心线为 r=R(1+e·cos2(θ-φ))</footer>')
|
||
w('</div></body></html>')
|
||
return "".join(P)
|
||
|
||
|
||
def export():
|
||
d = os.path.join(HERE, "assets-enso")
|
||
os.makedirs(d, exist_ok=True)
|
||
for g in GRADES:
|
||
body = enso(**g["kw"])
|
||
for kind, color in (("logo", INK), ("logo-white", WHITE)):
|
||
open(os.path.join(d, "%s-%s.svg" % (g["id"], kind)), "w", encoding="utf-8").write(
|
||
'<?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, n5.wordmark_fixed(color)))
|
||
open(os.path.join(d, "%s-mark.svg" % g["id"]), "w", encoding="utf-8").write(
|
||
'<?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)
|
||
print("assets-enso/ →", len(os.listdir(d)), "个文件")
|
||
|
||
|
||
def main():
|
||
path = os.path.join(HERE, "enso-refine.html")
|
||
with open(path, "w", encoding="utf-8") as f:
|
||
f.write(build())
|
||
print("enso-refine.html %s B" % f"{os.path.getsize(path):,}")
|
||
export()
|
||
|
||
|
||
if __name__ == "__main__":
|
||
main()
|