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

397 lines
20 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 -*-
"""
NOVALON 环 · 一相圆(第三十四刀 · 重写)
甲方三次澄清后锁定的形:
参照图里那个「字母沿圆环排布」的环形 **就是** 一相圆;
环上的英文换成 NOVALON,圆心原 "Design Institute Inc." 的位置
换成书法体「睿新致遠」真迹。
cut 32 画崩的两层原因,第二层是这一版才找到的:
一) 坐标原点搞错。novalon.py 的 GLYPH 局部 y=0 是字顶、y=H=100 是基线,
我按「原点在基线」去摆,字母从半径 R 插进 R-100、穿过圆心互撞。
⇒ 这一版把基线钉在 Rb 上,字头朝外长到 Rb+ch。
二) 参数化错了。上一版「半径由字母正好填满弧长解出」,于是
ch/Rb = radians(360-开口)·H / (Σ字宽 + (n-1)·字距)。
NOVALON 七字母 Σ字宽=588、字距 22 —— 实测出来 ch/Rb = 0.68~0.87,
即字母高度是半径的七到九成:那不是环,是七芒星。
参照图之所以是环,是因为它的文本长得多(一整句话绕圆),
7 个字母绕 300° 弧,在「半径=外径-字高」下字距必须被拉开。
⇒ 这一版反过来:**外径钉死填满画布,字距由弧长解出**,
并把「字高/字距」和「开口弧/字距」两个比值当设计参数公开量出来。
第三个真正的选择是开口方位:开口在下方(gap_at=180)时
字母从左下起、越过正上方、落到右下 —— 就是参照图那种拱顶排法,
每一字的倾斜都朝外、近顶处正直,NOVALON 能顺读。
开口在右(gap_at=90)时底部那两字必然倒立。这一刀把两种方位都排出来对照。
"""
import importlib.util
import json
import math
import os
import re
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
nv = load("nv", os.path.join(HERE, "novalon.py"))
CH = json.load(open(os.path.join(HERE, "_wm-chars.json"), encoding="utf-8"))["chars"]
RED = "#C41E3A"
INK = "#26221E"
WHITE = "#FFFFFF"
DEEP = "#141210"
S = 440.0
CX = CY = S / 2.0
MARGIN = 10.0
OUT = S / 2.0 - MARGIN # 210 —— 环的外缘,固定填满画布
H = nv.H # 100
SW = None # Σ字宽,下面按 text 现算
BOX = []
for _c in CH:
_v = [float(x) for x in re.findall(r"-?\d+\.?\d*", _c["d"])]
_xs, _ys = _v[0::2], _v[1::2]
BOX.append(((min(_xs) + max(_xs)) / 2.0, (min(_ys) + max(_ys)) / 2.0,
max(_xs) - min(_xs), max(_ys) - min(_ys)))
def char_svg(i, cx, cy, size, col=INK):
bcx, bcy, bw, bh = BOX[i]
k = size / max(bw, bh)
return ('<g transform="translate(%g,%g) scale(%g) translate(%g,%g)">'
'<path d="%s" fill="%s"/></g>' % (cx, cy, k, -bcx, -bcy, CH[i]["d"], col))
def widths(text):
ws = []
for c in text:
d, w = nv.GLYPH[c](0.0, H)
ws.append((c, d, w))
return ws
def solve(ch, opening, text="NOVALON"):
"""核心几何:外缘固定,字距由弧长解出。返回 (Rb, gap, arc, open_arc)。"""
if ch <= 0 or ch >= OUT:
raise AssertionError("字高 %g 不在 (0, %g)" % (ch, OUT))
Rb = OUT - ch # 基线半径
if Rb <= 0:
raise AssertionError("基线半径非正")
arc = math.radians(360.0 - opening) * Rb # 文字可用弧长
ink = (ch / H) * sum(w for _, _, w in widths(text))
gap = (arc - ink) / (len(text) - 1)
if gap <= 0:
raise AssertionError("字高 %g 在开口 %g° 下放不下 —— 弧长 %g < 字宽合计 %g"
% (ch, opening, arc, ink))
return Rb, gap, arc, math.radians(opening) * Rb
def ring(ch=52.0, opening=100.0, gap_at=180.0, col=RED, text="NOVALON", dots=False):
gl = widths(text)
Rb, gap, arc, open_arc = solve(ch, opening, text)
k = ch / H
a0 = gap_at + opening / 2.0
out = []
s = 0.0
for i, (c, d, w) in enumerate(gl):
sc = k * w
ang = a0 + math.degrees((s + sc / 2.0) / Rb)
tr = ("translate(%g,%g) rotate(%g) translate(0,%g) scale(%g) translate(%g,%g)"
% (CX, CY, ang, -Rb, k, -w / 2.0, -H))
out.append('<g transform="%s"><path fill="%s" fill-rule="evenodd" d="%s"/></g>'
% (tr, col, d))
if dots and i < len(gl) - 1:
dang = a0 + math.degrees((s + sc + gap / 2.0) / Rb)
rr = Rb + ch * 0.44
dx = CX + rr * math.sin(math.radians(dang))
dy = CY - rr * math.cos(math.radians(dang))
out.append('<circle cx="%g" cy="%g" r="%g" fill="%s"/>'
% (dx, dy, ch * 0.075, col))
s += sc + gap
return "".join(out), Rb, gap, open_arc, arc
def center(Rb, col=INK, inset=0.90, cgap_frac=0.10):
"""圆心横排真迹四字,自动求能装进内切圆的最大字号。
约束:(总宽/2)^2 + (字高/2)^2 <= (Rb*inset)^2 —— 字行四角不许顶到环。"""
r = Rb * inset
def fits(c):
total = 4 * c + 3 * c * cgap_frac
return (total / 2.0) ** 2 + (c / 2.0) ** 2 <= r * r
lo, hi = 4.0, r
for _ in range(90):
mid = (lo + hi) / 2.0
if fits(mid):
lo = mid
else:
hi = mid
csize = lo
cg = csize * cgap_frac
total = 4 * csize + 3 * cg
x0 = CX - total / 2.0 + csize / 2.0
body = "".join(char_svg(i, x0 + i * (csize + cg), CY, csize, col)
for i in range(4))
return body, csize, (total / 2.0, csize / 2.0)
def corner_report(bx, by, opening, gap_at):
"""字行四角相对开口中心的方位。返回 (最深侵入角, 最近角半径/基线半径)。
侵入角 > 0 表示有字角伸进了开口扇形里 —— 那里没有环,字就失去了框。"""
pts = [(sx, sy) for sx in (-bx, bx) for sy in (-by, by)]
deep = -999.0
relmax = 0.0
for x, y in pts:
ang = math.degrees(math.atan2(x, -y)) # 与 gap_at 同一约定:正上=0,顺时针
rel = (ang - gap_at + 180.0) % 360.0 - 180.0
deep = max(deep, opening / 2.0 - abs(rel))
relmax = max(relmax, math.hypot(x, y))
return deep, relmax
def compose(ring_col=RED, char_col=INK, **kw):
body, Rb, gap, open_arc, arc = ring(col=ring_col, **kw)
cen, csize, (bx, by) = center(Rb, col=char_col)
opening = kw.get("opening", 100.0)
gap_at = kw.get("gap_at", 180.0)
deep, relmax = corner_report(bx, by, opening, gap_at)
return body + cen, dict(Rb=Rb, gap=gap, csize=csize, ch=kw.get("ch", 52.0),
open_arc=open_arc, arc=arc, deep=deep, corner=relmax / Rb)
def svg(inner, px, key=None):
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>%s</svg>'
% (S, S, px, px, px, px, k, inner))
VARIANTS = [
("R1 拱顶 · 均衡", dict(ch=52.0, opening=100.0, gap_at=180.0),
"字高 52、开口 100° 在正下方。字母自左下起、越过正上方、落到右下,"
"NOVALON 顺读;圆心真迹四字自动求到不顶环的最大字号。这是我对本 brief 的主张。"),
("R2 拱顶 · 字更重", dict(ch=60.0, opening=80.0, gap_at=180.0),
"字母加到 60、开口收到 80°。气势更足、更接近参照图那种压满的感觉,"
"代价是「通」的那口气小了 20°。"),
("R3 拱顶 · 细字疏朗", dict(ch=44.0, opening=100.0, gap_at=180.0),
"字母缩到 44。字高/半径只有 0.21,最像「环」,留白最多,也最静。"),
("R4 节 · 字间朱点", dict(ch=44.0, opening=100.0, gap_at=180.0, dots=True),
"在 R3 的每个字距中点落一颗朱砂小圆点,把被几何拉开的空隙变成节奏。"
"这是解决「7 个字母绕不满一圈」最正统的圆章语法。"),
("R5 大开口", dict(ch=52.0, opening=140.0, gap_at=180.0),
"开口放到 140°。环几乎成马蹄,一相圆的「缺一」说得最重,"
"但圆心字要被迫缩小避开缺口。"),
("R6 开口在右(对照)", dict(ch=52.0, opening=100.0, gap_at=90.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:1180px;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:82ch;margin:10px 0}
.lede{font-size:19px;color:#26221E;max-width:76ch}
.j{border-left:2px solid #C41E3A;padding:3px 0 3px 18px;margin:14px 0;color:#26221E;max-width:88ch}
.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:24px;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}
.strip{display:flex;gap:14px;align-items:flex-end;justify-content:center}
.why{font-size:14.5px;color:#4F4A42;margin:16px 0 0;max-width:92ch}
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}
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}
"""
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>NOVALON 环 · 一相圆</title><style>' + CSS + '</style></head><body><div class="wrap">']
P.append('<div class="ey">Cut 34 · 2026-10-14 · 环上 NOVALON + 圆心书法真迹 · repo 零改动</div>')
P.append('<h1>一相圆:<em>环上 NOVALON,圆心睿新致遠</em></h1>')
P.append('<p class="lede">照你锁定的形做:参照图那个字母排的开口环就是一相圆;'
'环上的英文是 NOVALON,圆心原来 Design Institute Inc. 的位置放书法体「睿新致遠」真迹。'
'环是朱砂、字是墨 —— 环是印,字是款。</p>')
P.append('<div class="j"><b>这一刀真正的工程量不在画,在把参数化反过来。</b>'
'上一版我让「半径由字母填满弧长解出」,量出 ch/Rb = '
'<code>0.68 ~ 0.87</code> —— 字母高度是半径的七到九成,那画出来是七芒星,不是环。'
'参照图是环,因为绕它的文本长得多。这一版<b>外缘钉死填满画布,字距由弧长解出</b>,'
'并把两个必须取舍的比值公开量出来:字距/字高、开口弧/字距。</div>')
built = []
for nm, kw, why in VARIANTS:
body, g = compose(**kw)
key = nm.split()[0]
ratio = g["ch"] / g["Rb"]
gapr = g["gap"] / g["ch"]
opr = g["open_arc"] / g["gap"]
built.append((nm, body, g, key, ratio, gapr, opr, why))
wht, _ = compose(ring_col=WHITE, char_col=WHITE, **kw)
solid, _ = compose(ring_col=RED, char_col=RED, **kw)
P.append('<div class="card"><div class="hd"><span class="nm">%s</span>'
'<span class="cx">基线半径 %g · 字距 %g(=字高的 %g 倍)· 开口弧 = %g 倍字距 · '
'字高/半径 %g · 圆心字高 %g · 字角伸入开口 %+g°</span></div><div class="row">'
% (nm, round(g["Rb"], 1), round(g["gap"], 1), round(gapr, 2),
round(opr, 2), round(ratio, 3), round(g["csize"], 1), round(g["deep"], 1)))
P.append('<div class="cell">%s<div class="lab">260px</div></div>'
% svg(body, 260, "%s@260" % key))
P.append('<div class="cell">%s<div class="lab">120px</div></div>'
% svg(body, 120, "%s@120" % key))
P.append('<div class="cell"><span class="tl" style="background:#C41E3A">%s</span>'
'<div class="lab">单色朱砂·满印</div></div>' % svg(solid, 150))
P.append('<div class="cell"><span class="tl" style="background:#141210">%s</span>'
'<div class="lab">暖墨底反白</div></div>' % svg(wht, 150))
P.append('<div class="cell"><div class="strip">')
for px in (64, 40, 24, 16):
P.append('<div><span class="tl" style="background:#fff">%s</span>'
'<div class="lab">%d</div></div>'
% (svg(body, px, "%s@%d" % (key, px)), px))
P.append('</div><div class="lab">应用阶梯</div></div>')
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">字距/字高</th>'
'<th class="n">开口弧/字距</th><th class="n">字角伸入开口</th>'
'<th class="n">字角半径/基线</th>'
'<th class="n">最细特征@40</th>'
'<th class="n">最细特征@16</th><th class="n">墨率@512</th>'
'<th class="n">漂移</th></tr></thead><tbody>')
for nm, body, g, key, ratio, gapr, opr, why in built:
P.append('<tr><td><b>%s</b></td><td class="n">%.2f</td>'
'<td class="n %s">%.2f</td>'
'<td class="n %s">%+.1f°</td>'
'<td class="n %s">%.2f</td>'
'<td class="n" data-cell="%s@40@min">…</td>'
'<td class="n" data-cell="%s@16@min">…</td>'
'<td class="n" data-cell="%s@40@ink">…</td>'
'<td class="n" data-cell="%s@40@drift">…</td></tr>'
% (nm, gapr, "pass" if opr >= 2.5 else "fail", opr,
"pass" if g["deep"] <= 0 else "fail", g["deep"],
"pass" if g["corner"] <= 0.92 else "fail", g["corner"],
key, key, key, key))
P.append('</tbody></table>')
P.append('<p>读法:<b>字距/字高</b>越大,字母越像散在圆周上的点而不是一个词;'
'<b>开口弧/字距</b>小于 2.5 时,开口读起来只是「一个特别宽的空格」,'
'一相圆就白画了;<b>字角伸入开口</b>为正表示圆心四字的角伸进了没有环的那段扇形,'
'字失去了框。圆章在 16px 仍然不成立(七字母加四书法字缩到 16 像素,'
'每笔不足一像素)—— 这是几何事实,照样量出来是为了把「不成立」量化,'
'简标那一档要另出(只留环,或只留「睿」)。</p>')
P.append('<h2><span class="no">2</span>16×16 栅格</h2><div class="row">')
for nm, body, g, key, ratio, gapr, opr, why in built[:3]:
P.append('<div class="cell"><pre data-g="%s@16">…</pre><div class="lab">%s @16</div></div>'
% (key, key))
P.append('</div>')
P.append('<footer>生成器 <code>novalon_ring.py</code> · 环上字母沿用 '
'<code>novalon.py</code> 构造几何(未改一个点)· 圆心四字取自 '
'<code>public/logo.svg</code> 字标组真迹路径(未改一个点,只缩放居中)· '
'外缘 = 画布半径 −10 固定,基线半径 = 外缘 − 字高,字距由可用弧长解出,'
'放不下直接断言 · 圆心字行按「四角不顶环 + 不伸进开口扇形」双重约束二分求最大 · '
'度量为本页浏览器栅格实测 · repo 零改动</footer>')
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 ink(im){const d=im.data;let n=0;for(let i=0;i<d.length;i+=4){
if(isAny([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(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 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+=(isAny(p,a)?'#':'.');}g.push(s);}return g;}
(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), i512=await ras(el,512);
if(!iS)continue;
out[el.dataset.k]={inkS:ink(iS),ink512:ink(i512),
hMin:runs(iS,n,false),vMin:runs(iS,n,true),g:grid(iS,n)};
}
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==='min'){const m=Math.min(o.hMin,o.vMin);td.textContent=m.toFixed(2)+'px';
td.className=m>=2?'pass':'fail';}
else if(f==='drift'){const d=Math.abs(o.ink512-o.inkS);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.__nr=out;
})();
</script>""")
P.append('</div></body></html>')
return "".join(P)
if __name__ == "__main__":
html = build()
out = os.path.join(HERE, "novalon-ring.html")
with open(out, "w", encoding="utf-8") as f:
f.write(html)
os.makedirs(os.path.join(HERE, "assets-novalon-ring"), exist_ok=True)
for nm, kw, why in VARIANTS:
body, g = compose(**kw)
key = nm.split()[0]
with open(os.path.join(HERE, "assets-novalon-ring", key + ".svg"), "w",
encoding="utf-8") as fh:
fh.write('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 %g %g">%s</svg>'
% (S, S, body))
print("%-3s Rb=%6.1f 字距=%5.1f(%.2fh) 开口/字距=%5.2f 字高/Rb=%.3f 圆心=%5.1f "
"角侵入=%+5.1f° 角半径=%.2f"
% (key, g["Rb"], g["gap"], g["gap"] / g["ch"],
g["open_arc"] / g["gap"], g["ch"] / g["Rb"], g["csize"],
g["deep"], g["corner"]))
print("novalon-ring.html %s B" % format(len(html.encode("utf-8")), ","))