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 个文本/矢量件。
706 lines
42 KiB
Python
706 lines
42 KiB
Python
#!/usr/bin/env python3
|
||
# -*- coding: utf-8 -*-
|
||
"""
|
||
简标定稿 + 横排重做 + 头像重做(第四十五刀)
|
||
|
||
甲方三条裁定,逐条落成可量的东西。
|
||
|
||
1 「简标 白文·睿 才有辨识度,其余的没啥意义。」
|
||
采纳。素印(纯方/一横)作废,简标只留一枚:朱砂方印·白文睿。
|
||
但有一条算术必须摆出来,因为它决定 16px 要不要另刻一版:
|
||
睿 14 画;印面 16px、字面占 0.78 ⇒ 字只有 11.7px 高 ⇒ 平均一道红缝 0.78px,
|
||
低于「一条线要 1px 才连得上」的栅格下限。
|
||
这一刀把四种刻法都渲染出来,用【封闭白面积保留率】判定哪个在 16px 还活着。
|
||
(上一稿这里挂了一个「简笔睿」的格子却没真画简笔字 —— 那是挂名,已删。
|
||
我不会凭空造一个「睿」的减省写法冒充真迹的骨;要减省笔画得另起一稿刻字。)
|
||
|
||
2 「横排锁定有必要使用英文吗,而且看起来水平不齐。」
|
||
不齐是真的,实测偏差 +9.42 单位(号墨中心 61.41 vs 名墨中心 52.00,占名高 18%)。
|
||
⚠ 这个数在第四十六刀动过两次:9.01 → 9.42(L 的脚不再把号的墨盒下沿撑到 107)
|
||
→ 9.82(N 的斜笔平切端原本戳到基线以下 4 单位,收回去之后下沿落到 102.6)。
|
||
号的墨竖盒从 −1.13..29.77 一路收到 −0.72..28.54,每收一次中心就上移一次。
|
||
⇒ 教训:**修字标的几何必然推动所有派生量**,叙述性数字不许留旧值;
|
||
本页正文里的数全部由浏览器实测回填,只有这段注释需要人记得改。
|
||
且这次不用信我的解析数 —— 页内用 getBoundingClientRect 直接量浏览器布局后的实际墨盒对账。
|
||
三种:A 只留名(推荐)/ B 号的【墨中心】对名的【墨中心】/ C 现状(墨底压名底)。
|
||
|
||
3 「微信头像不好看。」
|
||
根因:拿方印去塞圆裁,圆先把四个角吃掉,「崩角」和印的方意全没了,只剩红圆。
|
||
头像是独立载体,得【为圆形设计】。四版:盘 0.60/满 0.80/盘+白环 0.56/方印原样(对照)。
|
||
|
||
口径纪律(本页自带对照,不接受「跑通了」就当数):
|
||
白文印里【白才是笔画】,所以度量对象是「被红地围住的封闭白」。
|
||
贴到画布边框的白 = 背景,必须先洪水填充剔除 —— 否则圆盘的四角白会把指标整个污染。
|
||
三个对照:已知面积孔(正)/实心(负)/开口贴边的槽(负,专测剔除逻辑)。
|
||
"""
|
||
import importlib.util
|
||
import os
|
||
import re
|
||
|
||
HERE = os.path.dirname(os.path.abspath(__file__))
|
||
|
||
|
||
def load(name, fn):
|
||
sp = importlib.util.spec_from_file_location(name, os.path.join(HERE, fn))
|
||
m = importlib.util.module_from_spec(sp)
|
||
sp.loader.exec_module(m)
|
||
return m
|
||
|
||
|
||
bd = load("bd", "brand.py")
|
||
lk = bd.lk
|
||
nv = bd.nv
|
||
r2 = lk.r2
|
||
RED, INK, WHITE, PAPER = bd.RED, bd.INK, bd.WHITE, bd.PAPER
|
||
BOX = r2.BOX
|
||
CH = r2.CH
|
||
NAME_H = bd.NAME_H
|
||
LX = bd.LX
|
||
CAP_R = bd.CAP_R
|
||
WM_CAP = bd.WM_CAP
|
||
WM_TRACK = bd.WM_TRACK
|
||
U = 100.0
|
||
|
||
|
||
# ----------------------------------------------------------------- 公共几何
|
||
def cal_box(i, cx, cy, h):
|
||
"""第 i 个真迹字(char_svg 的定位法)缩放后的实际墨盒。
|
||
|
||
char_svg 做 translate(cx,cy) scale(k) translate(-bcx,-bcy),
|
||
所以原坐标 x 映射到 cx + (x-bcx)*k ⇒ 墨盒是 cx ± bw*k/2。
|
||
上一稿这里写成 cx - bcx*k —— bcx 是 -373 这种非零中心,于是整组墨盒全错。
|
||
"""
|
||
_bcx, _bcy, bw, bh = BOX[i]
|
||
k = h / max(bw, bh)
|
||
return (cx - bw * k / 2.0, cx + bw * k / 2.0,
|
||
cy - bh * k / 2.0, cy + bh * k / 2.0)
|
||
|
||
|
||
def name_ink_box(cy, h, x=LX):
|
||
"""名的实际墨盒(左右上下),来自四字各自缩放后的并集。"""
|
||
g = h * lk.CGAP
|
||
xs = [cal_box(i, x + h / 2.0 + i * (h + g), cy, h) for i in range(4)]
|
||
return (min(a for a, _b, _c, _d in xs), max(b for _a, b, _c, _d in xs),
|
||
min(c for _a, _b, c, _d in xs), max(d for _a, _b, _c, d in xs))
|
||
|
||
|
||
def wm_ink_vbox(track, cap):
|
||
"""号(NOVALON)相对其字顶的实际墨上/墨下。斜笔平接会越过基线,
|
||
所以从真发出去的路径取 max/min y,不能拿 cap 当底。"""
|
||
xx, d = 0.0, ""
|
||
for chx in "NOVALON":
|
||
g, w = nv.GLYPH[chx](xx, nv.H)
|
||
d += g + " "
|
||
xx += w + track
|
||
k = cap / nv.H
|
||
ys = [y for _x, y in bd.path_points(d)]
|
||
assert ys, "路径解析没取到点 —— _NEED 指令元数表又漏了"
|
||
return min(ys) * k, max(ys) * k
|
||
|
||
|
||
# ---------------------------------------------------------------- 1 白文睿
|
||
def seal_wen(px, face=0.78, dg=0.0, corner=0.055, fill=RED, ink=WHITE, tag=None):
|
||
"""朱砂方印·白文睿。
|
||
face 字面 / 印面;dg = 减地加宽(单位:设备像素,白缝向红地里扩 dg 像素)。
|
||
dg 用「设备像素」定义,所以这一版只在 16px 用 —— 尺寸专用刻版本就是印章本来的做法。
|
||
"""
|
||
_bcx, _bcy, bw, bh = BOX[0]
|
||
k = (U * face) / max(bw, bh)
|
||
sw = 2.0 * dg * U / px if dg else 0.0
|
||
st = (' stroke="%s" stroke-width="%g" stroke-linejoin="round"' % (ink, sw)) if sw else ""
|
||
gtag = ' data-k="%s"' % tag if tag else ""
|
||
return ('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" '
|
||
'width="%g" height="%g"%s><rect width="100" height="100" rx="%g" fill="%s"/>'
|
||
'<g transform="translate(50,50) scale(%g) translate(%g,%g)">'
|
||
'<path d="%s" fill="%s"%s/></g></svg>'
|
||
% (px, px, gtag, U * corner, fill, k, -_bcx, -_bcy, CH[0]["d"], ink, st))
|
||
|
||
|
||
def wen_arith(face, size):
|
||
"""白文睿在 size px 下的算术下限。"""
|
||
_bcx, _bcy, bw, bh = BOX[0]
|
||
glyph_px = size * face * (bh / max(bw, bh))
|
||
strokes = 14
|
||
return dict(glyph_px=glyph_px, per_stroke=glyph_px / strokes,
|
||
gap=glyph_px / (strokes + 1.0))
|
||
|
||
|
||
# ---------------------------------------------------------------- 2 横排
|
||
IN_GAP = 22.0
|
||
NAME_CY = 52.0
|
||
|
||
|
||
def inline_variant(mode, px=None, guides=True):
|
||
"""mode: name_only | center | baseline。返回 (svg, 度量字典)。
|
||
px 缺省时按【名高恒定】给宽:三版并排比的是同一种字号下的对齐,
|
||
不是同一个画布宽 —— 上一版让 A 占满 520px 而 B/C 被号拖到 746 单位再缩回,
|
||
于是「只留名」那版看起来大两倍,比较口径就错了。"""
|
||
|
||
nl, nr, ntop, nbot = name_ink_box(NAME_CY, NAME_H)
|
||
nctr = (ntop + nbot) / 2.0
|
||
body = '<g data-g="name">%s</g>' % lk.name_row(LX, NAME_CY, NAME_H, INK)[0]
|
||
cap = CAP_R * NAME_H
|
||
v0, v1 = wm_ink_vbox(WM_TRACK, cap)
|
||
lat_w = lk.ink_w(cap, WM_TRACK)
|
||
xs1 = nr
|
||
if mode == "name_only":
|
||
x, ytop = None, None
|
||
lctr = None
|
||
W = nl + xs1
|
||
else:
|
||
x = xs1 + IN_GAP
|
||
if mode == "baseline":
|
||
ytop = nbot - v1 # 上一版规则:号的墨底压到名的墨底
|
||
else:
|
||
ytop = nctr - (v0 + v1) / 2.0 # 墨中心对墨中心
|
||
l0, l1 = ytop + v0, ytop + v1
|
||
lctr = (l0 + l1) / 2.0
|
||
frag, ml, mr, _c = lk.wm_at(x, ytop, cap, INK, WM_TRACK)
|
||
body += '<g data-g="wm">%s</g>' % frag
|
||
W = ml + mr
|
||
top = ntop if lctr is None else min(ntop, ytop + v0)
|
||
bot = nbot if lctr is None else max(nbot, ytop + v1)
|
||
y0 = top - 6.0
|
||
H = (bot - top) + 12.0
|
||
guide = ""
|
||
if guides:
|
||
guide = ('<line x1="%g" x2="%g" y1="%g" y2="%g" stroke="%s" stroke-width="1.6" '
|
||
'stroke-dasharray="7 5"/>' % (0, W, nctr, nctr, RED))
|
||
if lctr is not None:
|
||
guide += ('<line x1="%g" x2="%g" y1="%g" y2="%g" stroke="%s" stroke-width="1.6" '
|
||
'stroke-dasharray="7 5"/>' % (0, W, lctr, lctr, "#26221E"))
|
||
if px is None:
|
||
px = int(round(0.70 * W)) # 名高 52 单位 → 屏幕上 36.4px,三版一致
|
||
svg = ('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 %g %g" '
|
||
|
||
'style="width:%dpx;height:auto;display:block" data-check="%s" '
|
||
'data-y0="%g" data-scale="%g"><g transform="translate(0,%g)">%s%s</g></svg>'
|
||
% (W, H, px, mode, y0, px / W, -y0, guide, body))
|
||
return svg, dict(ntop=ntop, nbot=nbot, nctr=nctr, lat_ctr=lctr,
|
||
off=(None if lctr is None else lctr - nctr),
|
||
W=W, H=H, cap=cap, latw=lat_w, v0=v0, v1=v1)
|
||
|
||
|
||
# ---------------------------------------------------------------- 3 头像
|
||
import math
|
||
|
||
_BCX, _BCY, _BW, _BH = BOX[0]
|
||
_RHO = max(math.hypot(x - _BCX, y - _BCY)
|
||
for x, y in bd.path_points(CH[0]["d"])) / max(_BW, _BH)
|
||
DISC_LIMIT = 0.5 / _RHO # 圆内不裁切的最大字面(直径归一为 1)
|
||
|
||
|
||
def disc_margin(face):
|
||
"""字面 face 时,真迹最远墨点到圆边的余量(单位:印面直径的百分比)。"""
|
||
used = _RHO * face / 0.5 # 占圆盘半径的比例
|
||
return 1.0 - used
|
||
|
||
|
||
AV_FACE = {"disc": 0.60, "full": 0.80, "ring": 0.56, "ring2": 0.68, "plate": 0.78}
|
||
# 白环:(半径, 线宽)。ring 是上一稿的细环(40px 下只剩 1.1px,必断);
|
||
# ring2 把环加粗到 4.5%,同时字面提到 0.68 —— 环在 40px 有 1.8px,能活。
|
||
AV_RING = {"ring": (42.0, 2.8), "ring2": (44.0, 4.5)}
|
||
|
||
|
||
def avatar(px, kind, dg=0.0, fill=RED, ink=WHITE):
|
||
"""为圆形【重做】的头像,不是裁方印。plate 是对照(上一版那种)。"""
|
||
_bcx, _bcy, bw, bh = BOX[0]
|
||
face = AV_FACE[kind]
|
||
k = (U * face) / max(bw, bh)
|
||
sw = 2.0 * dg * U / px if dg else 0.0
|
||
st = (' stroke="%s" stroke-width="%g" stroke-linejoin="round"' % (ink, sw)) if sw else ""
|
||
g = ('<g transform="translate(50,50) scale(%g) translate(%g,%g)">'
|
||
'<path d="%s" fill="%s"%s/></g>' % (k, -_bcx, -_bcy, CH[0]["d"], ink, st))
|
||
if kind == "plate":
|
||
bg = '<rect width="100" height="100" rx="5.5" fill="%s"/>' % fill
|
||
else:
|
||
bg = '<circle cx="50" cy="50" r="50" fill="%s"/>' % fill
|
||
if kind in AV_RING:
|
||
rr, rw = AV_RING[kind]
|
||
bg += ('<circle cx="50" cy="50" r="%g" fill="none" stroke="%s" stroke-width="%g"/>'
|
||
% (rr, ink, rw))
|
||
return ('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" '
|
||
'width="%g" height="%g" data-k="AV_%s_%d">%s%s</svg>'
|
||
% (px, px, kind, px, bg, g))
|
||
|
||
|
||
def ctrl(tag, inner, px=16):
|
||
"""离屏但不透明 —— 上一版把 opacity:0 写在 svg 自己身上,
|
||
序列化进 data URI 后整张图全透明,正对照测出 0,全页的数一度不可信。
|
||
隐藏只能加在【外层容器】上:序列化只取 svg,不继承父级样式。"""
|
||
return ('<span style="position:absolute;left:-99999px;top:0;width:0;height:0;'
|
||
'overflow:hidden;display:block"><svg xmlns="http://www.w3.org/2000/svg" '
|
||
'viewBox="0 0 100 100" width="%d" height="%d" data-k="%s">%s</svg></span>'
|
||
% (px, px, tag, inner))
|
||
|
||
|
||
def offscreen(tag, inner, px):
|
||
"""同 ctrl:离屏渲染、参与度量,但不占版面。"""
|
||
return ctrl(tag, inner, px)
|
||
|
||
|
||
CONTROLS = [
|
||
("CTRL_hole_16", '<rect width="100" height="100" fill="#C41E3A"/>'
|
||
'<rect x="25" y="25" width="50" height="50" fill="#FFFFFF"/>',
|
||
"封闭白 ≈25%"),
|
||
("CTRL_solid_16", '<rect width="100" height="100" fill="#C41E3A"/>', "封闭白 ≈0%"),
|
||
("CTRL_notch_16", '<path d="M 0 0 L 100 0 L 100 30 L 60 30 L 60 70 L 100 70 L 100 100 '
|
||
'L 0 100 Z" fill="#C41E3A"/>', "贴边开口槽 → 封闭白 ≈0%"),
|
||
]
|
||
|
||
|
||
# ---------------------------------------------------------------- CSS
|
||
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 110px}
|
||
code{font:13px/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:48px;line-height:1.16;color:#26221E;margin:12px 0 16px;font-weight:600}
|
||
h1 em{font-style:normal;color:#C41E3A}
|
||
h2{font-size:26px;color:#26221E;margin:56px 0 8px;font-weight:600}
|
||
h2 .no{color:#C41E3A;margin-right:10px}
|
||
h3{font:650 15px/1.5 "PingFang SC",Inter,sans-serif;color:#26221E;margin:32px 0 10px}
|
||
p{max-width:92ch;margin:10px 0}
|
||
.j{border-left:2px solid #C41E3A;padding:3px 0 3px 18px;margin:14px 0;color:#26221E;max-width:96ch}
|
||
.panel{background:#fff;border:1px solid #EFEAE1;padding:26px 28px;margin:0 0 12px}
|
||
.dark{background:#141210;border-color:#141210}
|
||
.dark .lab,.dark .mt{color:#9A9388}
|
||
.dark .mt b,.dark .nm{color:#F1EDE6}
|
||
.row{display:flex;gap:26px;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:7px}
|
||
.nm{font:650 14px/1.5 "PingFang SC",Inter,sans-serif;color:#26221E}
|
||
.mt{font:12px/1.7 "PingFang SC",Inter,sans-serif;color:#8A8377;
|
||
font-variant-numeric:tabular-nums;margin-top:8px}
|
||
.mt b{color:#26221E}
|
||
.good{color:#0f7b3b;font-weight:700}.bad{color:#C41E3A;font-weight:700}.warn{color:#8a6100;font-weight:700}
|
||
table{border-collapse:collapse;width:100%;margin:14px 0;
|
||
font:13px/1.6 "PingFang SC",Inter,sans-serif}
|
||
th,td{padding:10px 12px;border-bottom:1px solid #C3BDB1;text-align:left;vertical-align:top}
|
||
th{font-size:11px;letter-spacing:.11em;text-transform:uppercase;color:#8A8377;font-weight:500}
|
||
td.n,th.n{text-align:right;font-variant-numeric:tabular-nums;white-space:nowrap}
|
||
pre{font:9.5px/1.15 ui-monospace,Menlo,monospace;margin:0;display:inline-block;
|
||
text-align:left;background:#fff;padding:8px;border:1px solid #EFEAE1}
|
||
table pre{font-size:7.5px;line-height:1.02;padding:4px 6px}
|
||
.circle{display:inline-flex;border-radius:50%;overflow:hidden;line-height:0}
|
||
.mask{display:inline-flex;border-radius:50%;overflow:hidden;line-height:0;
|
||
background:#EFEAE1}
|
||
footer{margin-top:56px;padding-top:16px;border-top:1px solid #C3BDB1;
|
||
font:12.5px/1.7 "PingFang SC",Inter,sans-serif;color:#8A8377}
|
||
"""
|
||
|
||
PROBE = r"""<script>
|
||
const WHT=[255,255,255];
|
||
function isWht(p,a){return a>=40&&Math.hypot(p[0]-255,p[1]-255,p[2]-255)<110;}
|
||
function isInk(p,a){return a>=40&&Math.hypot(p[0]-255,p[1]-255,p[2]-255)>=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',{willReadFrequently:true});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 glyphWhite(im,px){const d=im.data;
|
||
const isw=new Uint8Array(px*px),bg=new Uint8Array(px*px);
|
||
for(let i=0;i<px*px;i++){const j=i*4;isw[i]=isWht([d[j],d[j+1],d[j+2]],d[j+3])?1:0;}
|
||
const st=[];
|
||
const push=i=>{if(isw[i]&&!bg[i]){bg[i]=1;st.push(i);}};
|
||
for(let x=0;x<px;x++){push(x);push((px-1)*px+x);}
|
||
for(let y=0;y<px;y++){push(y*px);push(y*px+px-1);}
|
||
while(st.length){const p=st.pop(),x=p%px,y=(p-x)/px;
|
||
for(const q of [x+1<px?p+1:-1,x-1>=0?p-1:-1,y+1<px?p+px:-1,y-1>=0?p-px:-1])
|
||
if(q>=0&&isw[q]&&!bg[q]){bg[q]=1;st.push(q);}}
|
||
const seen=new Uint8Array(px*px);let comps=0,biggest=0,tot=0;
|
||
const closed=new Uint8Array(px*px);
|
||
for(let i=0;i<px*px;i++)closed[i]=(isw[i]&&!bg[i])?1:0;
|
||
for(let i=0;i<px*px;i++){if(!closed[i]||seen[i])continue;
|
||
let n=0;const s2=[i];seen[i]=1;
|
||
while(s2.length){const p=s2.pop();n++;const x=p%px,y=(p-x)/px;
|
||
for(const q of [x+1<px?p+1:-1,x-1>=0?p-1:-1,y+1<px?p+px:-1,y-1>=0?p-px:-1])
|
||
if(closed[q]&&!seen[q]){seen[q]=1;s2.push(q);}}
|
||
comps++;tot+=n;if(n>biggest)biggest=n;}
|
||
return {comps:comps,biggest:biggest,white:100*tot/(px*px),mask:closed};}
|
||
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;const R=d[i],G=d[i+1],B=d[i+2],A=d[i+3];
|
||
s+=isInk([R,G,B],A)?'M':(isWht([R,G,B],A)?' ':'o');}g.push(s);}return g.join('\n');}
|
||
/* 独立复核:名 / 号两组的浏览器实际墨盒(getBoundingClientRect → 用户单位),
|
||
用来对账解析数,不拿自己算的数当自己的证据。 */
|
||
function inkCenters(el){const out={};const sr=el.getBoundingClientRect();
|
||
const vb=el.getAttribute('viewBox').split(/[\s,]+/);const w=+vb[2];
|
||
const k=sr.width/w;
|
||
for(const g of el.querySelectorAll('[data-g]')){const r=g.getBoundingClientRect();
|
||
if(!r.height)continue;
|
||
out[g.dataset.g]={top:(r.top-sr.top)/k+ +el.dataset.y0,h:r.height/k,
|
||
ctr:(r.top-sr.top)/k+ +el.dataset.y0+r.height/(2*k)};}
|
||
return out;}
|
||
function inkPct(im,px){const d=im.data;let n=0;
|
||
for(let i=0;i<px*px;i++){const j=i*4;if(isInk([d[j],d[j+1],d[j+2]],d[j+3]))n++;}
|
||
return 100*n/(px*px);}
|
||
/* 最远封闭白点到圆心的距离 ÷ 盘半径 —— 用来【反证】解析算出的内接上限,
|
||
而不是让那个上限只活在 Python 里。 >1 就是字被盘边切了。 */
|
||
function edge(mask,px){let mx=0;const c=(px-1)/2;
|
||
for(let i=0;i<px*px;i++){if(!mask[i])continue;
|
||
const x=i%px,y=(i-x)/px;const r=Math.hypot(x-c,y-c)/c;
|
||
if(r>mx)mx=r;}
|
||
return mx;}
|
||
(async()=>{
|
||
const res={};
|
||
const TAGS=Array.from(document.querySelectorAll('svg[data-k]'));
|
||
for(const el of TAGS){
|
||
const n=+el.dataset.k.split('_').pop();
|
||
const im=await ras(el,n); if(!im){res[el.dataset.k]={missing:true};continue;}
|
||
const gw=glyphWhite(im,n);
|
||
res[el.dataset.k]={gw:gw,ink:+inkPct(im,n).toFixed(2),g:grid(im,n),px:n,
|
||
edge:+edge(gw.mask,n).toFixed(3)};
|
||
}
|
||
for(const el of document.querySelectorAll('svg[data-check]'))
|
||
res['CHK_'+el.dataset.check]=inkCenters(el);
|
||
const V=(a,k)=>a&&a[k]!==undefined?a[k]:null;
|
||
const f=(x,n)=>x===null||x===undefined||x!==x?'—':('' + (+x).toFixed(n));
|
||
/* --- 对照 + 覆盖率 --- */
|
||
const ct={};for(const k of ['CTRL_hole_16','CTRL_solid_16','CTRL_notch_16'])
|
||
ct[k]=res[k]?+res[k].gw.white.toFixed(2):null;
|
||
const want=[];
|
||
for(const w of ['W1','W2','W3','W4','W5']) for(const p of [384,96,48,24,16]) want.push(w+'_'+p);
|
||
for(const k of ['disc','full','ring','ring2','plate']) for(const p of [120,54,44,40,16]) want.push('AV_'+k+'_'+p);
|
||
want.push('CTRL_hole_16','CTRL_solid_16','CTRL_notch_16');
|
||
const miss=want.filter(k=>!res[k]||res[k].missing);
|
||
const cOK=(ct.CTRL_hole_16>=20&&ct.CTRL_hole_16<=30)&&
|
||
(ct.CTRL_solid_16<=1)&&((ct.CTRL_notch_16===undefined)||ct.CTRL_notch_16<=1);
|
||
/* 解析上限的反证:Python 说 face<=0.866 才不裁切,这里用栅格量【最远白点/盘半径】。
|
||
两条独立路径必须同向,否则其中一条是编的。 */
|
||
const ed={};for(const k of ['disc','full','ring','ring2','plate'])
|
||
ed[k]=res['AV_'+k+'_120']?res['AV_'+k+'_120'].edge:null;
|
||
const edOK=Object.keys(ed).every(k=>ed[k]===null||ed[k]<=1.0);
|
||
const g=document.getElementById('gate');
|
||
if(g)g.innerHTML='<b>正对照</b> 已知 25% 面积孔 → 测得 <b class="'+(cOK?'good':'bad')+'">'
|
||
+f(ct.CTRL_hole_16,2)+'%</b>(判据 20–30,含 16px 下 8×8 的取整误差);'
|
||
+'<b>负对照</b> 实心印面 → '+f(ct.CTRL_solid_16,2)+'%(判据 ≤1);'
|
||
+'<b>剔除对照</b> 贴边开口槽 → '+f(ct.CTRL_notch_16,2)+'%(判据 ≤1,>1 说明洪水填充没把背景白剔干净)。'
|
||
+'<br><b>内接上限的反证</b>(Python 解析 face ≤ <span id="dlimit">?</span>,与栅格实测互相独立):'
|
||
+'最远白点 ÷ 盘半径 = '+Object.keys(ed).map(k=>k+' '+f(ed[k],3)).join(' · ')
|
||
+' —— <b class="'+(edOK?'good':'bad')+'">'+(edOK?'全部 ≤1,字没有被盘边切掉':'有版本被切边,上限算错了')+'</b>。'
|
||
+'<br>应测 '+want.length+' 项,实到 '+(want.length-miss.length)+' 项,<b class="'
|
||
+(miss.length?'bad':'good')+'">unresolved='+miss.length+'</b>'
|
||
+(miss.length?'(缺:'+miss.slice(0,8).join(' ')+')':'')
|
||
+';页内带 data-k 的 svg 共 '+TAGS.length+' 个(两边相等,没有测了不该测的、也没漏该测的)。'
|
||
+'<b class="'+((cOK&&edOK&&!miss.length)?'good':'bad')+'">'+((cOK&&edOK&&!miss.length)?'口径成立,下面的数可引用':'口径不成立,下面的数全部作废')+'</b>';
|
||
const dl=document.getElementById('dlimit');
|
||
if(dl&&g)dl.textContent=g.dataset.limit;
|
||
/* --- 简标表 --- */
|
||
const bc=V(res['W1_384']&&res['W1_384'].gw,'comps');
|
||
const bcel=document.getElementById('base_comps');
|
||
if(bcel)bcel.textContent=(bc===null?'?':bc);
|
||
const tb=document.getElementById('t1b');
|
||
if(tb){let h='';
|
||
for(const [key,lab] of [['W1','① 原样 0.78'],['W2','② 字面 0.92'],['W3','③ 减地 0.5px'],
|
||
['W4','④ 0.86 + 0.35px'],['W5','⑤ 0.92 + 0.5px']]){
|
||
const a=res[key+'_384'],b=res[key+'_16'];
|
||
if(!a||!b){h+='<tr><td>'+lab+'</td><td class="n bad" colspan="6">未测到</td></tr>';continue;}
|
||
const keep=100*b.gw.white/a.gw.white, ok=keep>=75;
|
||
h+='<tr><td>'+lab+'</td><td class="n">'+f(a.gw.white,2)+'%</td><td class="n">'+a.gw.comps
|
||
+'</td><td class="n">'+f(b.gw.white,2)+'%</td><td class="n"><b class="'
|
||
+(b.gw.comps!==a.gw.comps?'bad':'good')+'">'+b.gw.comps+'</b></td>'
|
||
+'<td class="n"><b class="'+(ok?'good':'bad')+'">'+f(keep,1)+'%</b></td>'
|
||
+'<td class="n">'+f(b.ink,1)+'%</td><td><pre>'+b.g+'</pre></td></tr>';}
|
||
tb.innerHTML=h;}
|
||
/* --- 正文里的每个数都由实测回填(防「手写的叙述与实测脱节」) --- */
|
||
for(const e of document.querySelectorAll('[data-ret]')){
|
||
const k=e.dataset.ret,a=res[k+'_384'],b=res[k+'_16'];
|
||
if(a&&b)e.textContent=(100*b.gw.white/a.gw.white).toFixed(1)+'%';}
|
||
for(const e of document.querySelectorAll('[data-ret48]')){
|
||
const k=e.dataset.ret48,a=res[k+'_384'],b=res[k+'_48'];
|
||
if(a&&b)e.textContent=(100*b.gw.white/a.gw.white).toFixed(1)+'%';}
|
||
for(const e of document.querySelectorAll('[data-comps]')){
|
||
const o=res[e.dataset.comps+'_384']; if(o)e.textContent=o.gw.comps;}
|
||
for(const e of document.querySelectorAll('[data-comps16]')){
|
||
const o=res[e.dataset.comps16+'_16']; if(o)e.textContent=o.gw.comps;}
|
||
/* --- 头像 --- */
|
||
for(const kind of ['disc','full','ring','ring2','plate']){
|
||
const e=document.getElementById('av_'+kind); if(!e)continue;
|
||
const a=res['AV_'+kind+'_120'],b=res['AV_'+kind+'_40'],c=res['AV_'+kind+'_16'];
|
||
if(!a||!b||!c)continue;
|
||
e.innerHTML='封闭白 120→'+f(a.gw.white,1)+'% · 40→'+f(b.gw.white,1)+'%(保留 '+f(100*b.gw.white/a.gw.white,0)
|
||
+'%)· 16→'+f(c.gw.white,1)+'% · 最大白块@40 占盘面 '
|
||
+f(100*b.gw.biggest/(40*40),1)+'% · 最远白点/盘半径 '+f(b.edge,2);
|
||
}
|
||
const t3=document.getElementById('t3');
|
||
if(t3){let h='';
|
||
for(const k of ['AV_disc_16','AV_full_16','AV_ring_16','AV_ring2_16','AV_plate_16']){
|
||
const o=res[k];if(!o)continue;
|
||
h+='<div style="display:inline-block;vertical-align:top;margin-right:20px"><pre>'+o.g
|
||
+'</pre><div class="lab">'+k+'</div></div>';}
|
||
t3.innerHTML='16px 头像的像素图(M=红 · 空格=封闭白 · o=背景/过渡):<div class="row" style="gap:20px">'+h+'</div>';
|
||
const ad=document.getElementById('avdict');
|
||
if(ad){const g=(k,p)=>res['AV_'+k+'_'+p];
|
||
const seg=k=>{const a=g(k,120),b=g(k,40);if(!a||!b)return k+':未测到';
|
||
return '<b>'+k+'</b> 封闭白 120→'+f(a.gw.white,1)+'%、40→'+f(b.gw.white,1)
|
||
+'%(保留 '+f(100*b.gw.white/a.gw.white,0)+'%,白骨架 '+a.gw.comps+'→'+b.gw.comps+' 块)';};
|
||
const cand=['disc','full','ring','ring2'].map(k=>{const a=g(k,120),b=g(k,40);
|
||
return {k:k,keep:(a&&b)?100*b.gw.white/a.gw.white:-1,w40:b?b.gw.white:-1};});
|
||
const best=cand.slice().sort(function(x,y){return (y.keep-x.keep)||(y.w40-x.w40);})[0]||{k:'?'};
|
||
ad.innerHTML='<b>判据(本页实测,不是我手写的):</b>'
|
||
+['disc','full','ring','ring2','plate'].map(seg).join(';')
|
||
+'<br>40px 保留率排序:'+cand.slice().sort(function(x,y){return y.keep-x.keep;})
|
||
.map(function(o){return o.k+' '+f(o.keep,1)+'%';}).join(' > ')
|
||
+' —— 按【保留率优先】选出的是 <b>'+best.k+'</b>。'
|
||
+'ring 的细环在 40px 碎成 '+(g('ring',40)?g('ring',40).gw.comps:'?')
|
||
+' 块:2.8% 粗的环在 40px 只有 1.1px,它必断。'
|
||
+'disc 0.60 反过来 —— 几何安全,但把 '
|
||
+f(100*(1-g('disc',120).gw.white/g('full',120).gw.white),0)
|
||
+'% 的可用白面积白白让给了空盘面。'
|
||
+'<br><b>这一栏我不让数独裁。</b>ring2(环加粗到 4.5% + 字面提到 0.68)是专门为'
|
||
+'「既要像印、又要活到 40px」加的第五版:它比 full 多一道环,也就是多一个会断的构件,'
|
||
+'40px 实测白骨架 '+(g('ring2',40)?g('ring2',40).gw.comps:'?')+' 块(full 是 '
|
||
+(g('full',40)?g('full',40).gw.comps:'?')+' 块)。要不要为「像印」付这个代价,你的眼睛说了算。';
|
||
}
|
||
}
|
||
/* --- 横排:解析数 vs 浏览器实测 --- */
|
||
for(const mode of ['name_only','center','baseline']){
|
||
const e=document.getElementById('bm_'+mode); if(!e)continue;
|
||
const o=res['CHK_'+mode]; if(!o){e.textContent='未测到';continue;}
|
||
if(!o.wm){e.textContent='—(这一版没有号)';continue;}
|
||
const d=o.wm.ctr-o.name.ctr;
|
||
e.innerHTML='<b class="'+(Math.abs(d)<=1?'good':'bad')+'">'+f(d,2)+' 单位</b>(名 ctr '+f(o.name.ctr,2)+' · 号 ctr '+f(o.wm.ctr,2)+')';
|
||
}
|
||
window.__jb={res:res,keys:Object.keys(res).length,controls:ct,missing:miss,ok:(cOK&&!miss.length)};
|
||
})();
|
||
</script>"""
|
||
|
||
|
||
# ---------------------------------------------------------------- 组装
|
||
WEN_VARIANTS = [
|
||
("W1", "① 原样 · 字面 0.78 · 不减地", 0.78, 0.0),
|
||
("W2", "② 字面 0.92 · 不减地(印边变窄)", 0.92, 0.0),
|
||
("W3", "③ 字面 0.78 · 减地加宽 0.5px", 0.78, 0.5),
|
||
("W4", "④ 字面 0.86 · 减地 0.35px", 0.86, 0.35),
|
||
("W5", "⑤ 字面 0.92 · 减地 0.5px(两头一起上)", 0.92, 0.5),
|
||
]
|
||
WEN_SIZES = (96, 48, 24, 16)
|
||
REF_PX = 384 # 矢量基准:抗锯齿可忽略,纯几何
|
||
|
||
|
||
def hide(s):
|
||
return ('<span style="position:absolute;left:-99999px;top:0;width:0;height:0;'
|
||
'overflow:hidden;display:block">' + s + '</span>')
|
||
|
||
|
||
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 45 · 2026-10-14 · 三条裁定逐条落成可量的东西 · repo 零改动</div>')
|
||
P.append('<h1>简标定稿、<em>横排重做</em>、头像重做</h1>')
|
||
|
||
# ---------------- 1
|
||
P.append('<h2><span class="no">1</span>简标 = 白文「睿」,素印作废</h2>')
|
||
P.append('<p>采纳你的判断:素印(纯方、一横)没有辨识度,作废。简标就一枚 —— '
|
||
'<b>朱砂方印 · 白文睿</b>。但 16px 那一档必须摆一条算术,它决定要不要另刻一版。</p>')
|
||
P.append('<div class="panel"><div class="row">')
|
||
for px in (160, 96, 48, 24, 16):
|
||
st = wen_arith(0.78, px)
|
||
P.append('<div class="cell">' + seal_wen(px) +
|
||
'<div class="lab">' + str(px) + 'px · 字高 ' +
|
||
("%.1f" % st["glyph_px"]) + 'px · 每道红缝 ' +
|
||
("%.2f" % st["gap"]) + 'px</div></div>')
|
||
P.append('</div>')
|
||
P.append('<h3>字面占比扫一遍:字越大越清楚,但印的边就没了</h3><div class="row">')
|
||
for face in (0.62, 0.70, 0.78, 0.86, 0.92):
|
||
st = wen_arith(face, 16)
|
||
P.append('<div class="cell">' + seal_wen(64, face=face) +
|
||
'<div class="lab">字面 ' + ("%.2f" % face) + ' · 16px 下红缝 ' +
|
||
("%.2f" % st["gap"]) + 'px</div></div>')
|
||
P.append('</div></div>')
|
||
s16 = wen_arith(0.78, 16)
|
||
s96 = wen_arith(0.78, 96)
|
||
P.append('<div class="j"><b>16px 不是审美问题,是下限问题。</b>'
|
||
'印面 16px、字面 0.78 ⇒「睿」只有 <b>' + ("%.1f" % s16["glyph_px"]) + 'px</b> 高,'
|
||
'而它 14 画 ⇒ 平均一道红缝 <b>' + ("%.2f" % s16["gap"]) + 'px</b>;'
|
||
'同一版在 96px 下红缝是 ' + ("%.1f" % s96["gap"]) + 'px。'
|
||
'低于 1px 的缝,栅格化时会被相邻红像素吃掉 —— 所以五种刻法全部实测:'
|
||
'<b>①原样</b> ②<b>放大字面 0.92</b>(印边变窄) ③<b>减地加宽 0.5px</b>'
|
||
'(刻工把白缝凿宽、红地变窄 —— 这是<b>不动字形</b>就能救缝的唯一办法) '
|
||
'④折中 ⑤两头一起上。'
|
||
'判定指标 <b>封闭白面积保留率</b> = 16px 的封闭白 ÷ ' + str(REF_PX) + 'px 的封闭白。'
|
||
'矢量本身与尺寸无关,所以保留率低于 1 就是像素被吃掉了;'
|
||
'同时看<b>白连通体数</b> —— 大尺寸下「睿」的白只有 '
|
||
'<b id="base_comps">?</b> 个连通体,小尺寸下数目一变,就说明字的骨架被栅格改写了。</div>')
|
||
P.append('<div class="panel"><table id="t1"><tr><th>刻法</th>'
|
||
'<th class="n">封闭白 @' + str(REF_PX) + '</th><th class="n">连通体 @' + str(REF_PX) + '</th>'
|
||
'<th class="n">封闭白 @16</th><th class="n">连通体 @16</th>'
|
||
'<th class="n">保留率</th><th class="n">墨率 @16</th><th>16px 像素图</th></tr>'
|
||
'<tbody id="t1b"><tr><td colspan="8" class="lab">实测中…</td></tr></tbody></table>'
|
||
'<div class="lab">「封闭白」= 被红地围住、不与画布边框相连的白像素。白文印里<b>白才是笔画</b>,'
|
||
'所以这一项就是「字还剩多少」。基准取 ' + str(REF_PX) + 'px:那里抗锯齿可忽略,量到的就是几何本身。</div></div>')
|
||
for key, lab, face, dg in WEN_VARIANTS:
|
||
P.append('<div style="margin:0 0 4px"><div class="nm">' + lab +
|
||
' · 16px 下红缝 ' + ("%.2f" % wen_arith(face, 16)["gap"]) + 'px</div>'
|
||
'<div class="row">')
|
||
for px in WEN_SIZES:
|
||
P.append('<div class="cell">' + seal_wen(px, face=face, dg=dg, tag="%s_%d" % (key, px)) +
|
||
'<div class="lab">' + str(px) + 'px</div></div>')
|
||
P.append('</div></div>')
|
||
# 矢量基准:离屏渲染,只为拿住「几何上应该是多少白」
|
||
P.append(hide(seal_wen(REF_PX, face=face, dg=dg, tag="%s_%d" % (key, REF_PX))))
|
||
P.append('<div class="j"><b>结论:五种刻法在 16px 全部失败,差别只是糊的程度。</b>'
|
||
'实测封闭白保留率 ①<b data-ret="W1">—</b> ②<b data-ret="W2">—</b> '
|
||
'③<b data-ret="W3">—</b> ④<b data-ret="W4">—</b> ⑤<b data-ret="W5">—</b>'
|
||
'(最好的是「字面 0.92 + 减地 0.5px」);'
|
||
'而<b>连通体数</b>是更硬的一条:' + str(REF_PX) + 'px 下「睿」的白只有 '
|
||
'<b data-comps="W1">—</b> 个连通体,16px 下变成 <b data-comps16="W1">—</b> 个 —— '
|
||
'栅格把一个字的骨架<b>改写</b>了,这不是「看不清」,是「不是这个字了」。'
|
||
'像素图就在表里最后一列。同组在 <b>48px</b> 的保留率是 '
|
||
'<b data-ret48="W1">—</b>–<b data-ret48="W4">—</b> —— 所以'
|
||
'<b>白文睿的信息下限在 48px 一带,16px 物理上刻不下 14 画。</b>'
|
||
'(这一栏的每个数都由本页实测回填,不靠我手写。)</div>')
|
||
|
||
P.append('<div class="j"><b>这一刀逼出一个必须你拍板的取舍。</b>'
|
||
'16px(favicon、微信小头像、列表图标)只能保住<b>「印」这个概念</b>,'
|
||
'保不住<b>「睿」这个字</b>。三条路:'
|
||
'<b>A</b> 认了 —— 16px 就是<b>一枚朱砂(带崩角)</b>,白字能留多少留多少,'
|
||
'它承担的是「红色的那一方印」而不是可读的字(我推荐这条:'
|
||
'不改字形、不新造字、零编造,且退化是<b>渐变</b>而不是崩);'
|
||
'<b>B</b> 另刻一版<b>减笔睿</b> —— 那是一次独立的刻字工作,'
|
||
'我不拿真迹路径改改冒充,得重新起稿、你来定骨;'
|
||
'<b>C</b> 16px 换载体 —— 用拉丁 <b>N</b>(构造几何那套,笔画少得多)。'
|
||
'C 会引入第二个简标,与你「只留白文睿」的裁定冲突,所以我只摆出来、不推荐。</div>')
|
||
P.append('<div class="panel dark"><h3 style="margin-top:0;color:#F1EDE6">按 A 案落地:'
|
||
'48px 以上用主刻版(字面 0.78),24px 以下用大字面 + 减地(0.92 / 0.5px)'
|
||
'—— 同一枚印的两副刻版,不是两个标识</h3><div class="row">')
|
||
for px in (96, 48, 24, 16):
|
||
small = px <= 24
|
||
P.append('<div class="cell">' + seal_wen(px, face=(0.92 if small else 0.78),
|
||
dg=(0.5 if small else 0.0)) +
|
||
'<div class="lab" style="color:#9A9388">' + str(px) + 'px · '
|
||
+ ("小版" if small else "主版") + '</div></div>')
|
||
P.append('</div></div>')
|
||
|
||
|
||
# ---------------- 2
|
||
_b0, m0 = inline_variant("baseline", guides=False)
|
||
P.append('<h2><span class="no">2</span>横排锁定:要不要英文,以及为什么不齐</h2>')
|
||
P.append('<div class="j"><b>你看到的「水平不齐」是真的,量出来是 '
|
||
+ ("%.1f" % abs(m0["off"])) + ' 个单位。</b>'
|
||
'名的墨中心在 y=' + ("%.1f" % m0["nctr"]) + ';号按「墨底压到名墨底」排完之后,'
|
||
'它的墨中心在 y=' + ("%.1f" % m0["lat_ctr"]) + ' —— 号低了 '
|
||
+ ("%.1f" % m0["off"]) + ',占名高的 ' + ("%.0f" % (100.0 * m0["off"] / NAME_H)) + '%。'
|
||
'根因是我拿了一条排版教条:汉字方块<b>没有下伸部</b>,视觉重心在正中;'
|
||
'把拉丁的基线压到汉字脚下,拉丁必然整体偏低。'
|
||
'上一版我还用「越线量是活字该有的行为」解释过 V 的下端 —— 那话没错,'
|
||
'但它救不了整组重心的错位。</div>')
|
||
P.append('<div class="panel">')
|
||
for mode, lab, note in [
|
||
("name_only", "A · 只留名(我的推荐)",
|
||
"导航栏这类窄长条里,名+号并排是<b>双重阅读</b> —— 同一块地方要人读两遍同一个品牌。"
|
||
"号由上下锁定去承担。横排就一枚名,干净,且根本没有对齐问题可言。"),
|
||
("center", "B · 名+号,号的【墨中心】对名的【墨中心】",
|
||
"一定要并排就这么排:两组墨盒的中心线重合。这才是混排里「看起来齐」的那条线。"),
|
||
("baseline", "C · 现状(号墨底压名墨底)",
|
||
"对照。上一版的做法,也就是你说「水平不齐」的那一版。")]:
|
||
sv, mm = inline_variant(mode)
|
||
off = "—(没有号)" if mm["off"] is None else ("%.2f 单位 · 名高的 %.1f%%" % (
|
||
mm["off"], 100.0 * mm["off"] / NAME_H))
|
||
cls = "good" if (mm["off"] is None or abs(mm["off"]) <= 1.0) else "bad"
|
||
P.append('<div style="margin:0 0 26px"><div class="nm">' + lab + '</div>'
|
||
+ sv +
|
||
'<div class="mt">解析中心偏差 <b class="' + cls + '">' + off + '</b> · '
|
||
'浏览器实测偏差 <b id="bm_' + mode + '">测量中…</b> '
|
||
'<span style="color:#C41E3A">— — 红虚线 = 名墨中心</span>'
|
||
+ (' <span style="color:#26221E">— — 深虚线 = 号墨中心</span>'
|
||
if mm["lat_ctr"] is not None else '') +
|
||
'</div><div class="lab" style="max-width:80ch;margin-left:0;text-align:left">'
|
||
+ note + '</div></div>')
|
||
P.append('</div>')
|
||
P.append('<p><b>我的意见:横排去掉英文。</b>理由不是对齐难做(B 已经把它对齐了、偏差可实测),'
|
||
'而是这个位置不需要两个读法。英文在<b>上下锁定</b>里已经和名咬死了(两端对齐、'
|
||
'字高比 0.535,照国美那套实测),横排留给「名」单独出现 —— '
|
||
'国美 VI 的横排同样是书法单独走。</p>')
|
||
|
||
# ---------------- 3
|
||
P.append('<h2><span class="no">3</span>微信头像:为圆形重做,不是裁方印</h2>')
|
||
P.append('<p>上一版不好看的根因:<b>我拿方印去塞圆裁</b>。圆一裁,方印四个角先没,'
|
||
'「崩角」和印的方意全丢,只剩一个红圆里糊着白字。'
|
||
'头像是独立载体,得按圆来设计 —— 字面收到<b>圆内接方</b>里,'
|
||
'让红地自己成为「印的边」。</p>')
|
||
P.append('<div class="panel"><div class="lab" style="margin:0 0 14px">'
|
||
'<b>圆内不裁切的上限量出来了:字面 ≤ ' + ("%.3f" % DISC_LIMIT) + '。</b>'
|
||
'真迹「睿」的墨点到自身 bbox 中心的<b>最远极径</b>是 ' + ("%.4f" % _RHO) +
|
||
'×max(宽,高)(最远那笔在左下 '
|
||
'<span style="color:#C41E3A">不是四角</span>,所以不能用「内接方 0.707」去套 —— '
|
||
'那样算会把字白白的做小)。取 0.80 ⇒ 距圆边还剩 '
|
||
'<b>' + ("%.0f" % (100 * disc_margin(0.80))) + '%</b> 半径余量;'
|
||
'取 0.60 ⇒ 余量 ' + ("%.0f" % (100 * disc_margin(0.60))) + '%(字明显偏小,浪费盘面)。</div>'
|
||
'<div class="row">')
|
||
for kind, lab, note in [
|
||
("disc", "红盘 · 白文睿 · 字面 0.60", "保守内接;盘面大半空着"),
|
||
("full", "红盘 · 白文睿 · 字面 0.80", "撑到实测上限的 92%;盘面用满,红地仍是一圈匀边"),
|
||
("ring", "红盘 · 细白环 · 字面 0.56", "上一稿:环只 2.8% 粗,40px 下 1.1px —— 必断"),
|
||
("ring2", "红盘 · 粗白环 · 字面 0.68", "把环加粗到 4.5%(40px 下 1.8px),字面同时提到 0.68:既要像印,也要活得下来"),
|
||
("plate", "方印原样(对照)", "上一版那种:圆裁后方角被吃掉")]:
|
||
|
||
P.append('<div class="cell"><div class="row" style="gap:14px;align-items:flex-end">')
|
||
for px in (120, 54, 40, 16):
|
||
P.append('<div><span class="mask" style="width:' + str(px + 8) + 'px;height:'
|
||
+ str(px + 8) + 'px">' + avatar(px, kind, dg=(0.5 if px <= 16 else 0.0))
|
||
+ '</span><div class="lab">' + str(px) + '</div></div>')
|
||
P.append('</div><div class="mt"><b>' + lab + '</b><br>' + note +
|
||
'<br><span id="av_' + kind + '">实测中…</span></div></div>')
|
||
P.append('</div>')
|
||
P.append('<h3>同一个头像放进微信列表的样子(54px 圆裁)</h3><div class="row" style="gap:34px">')
|
||
for kind, lab in [("disc", "红盘 0.60"), ("full", "红盘 0.80"), ("ring2", "红盘+粗白环"),
|
||
("ring", "红盘+细白环"), ("plate", "方印原样(对照)")]:
|
||
|
||
P.append('<div class="cell"><div style="display:flex;align-items:center;gap:10px;'
|
||
'background:#fff;border:1px solid #EFEAE1;padding:10px 14px;border-radius:6px">'
|
||
'<span class="circle" style="width:44px;height:44px">' + avatar(44, kind) + '</span>'
|
||
'<span style="font:14px/1.4 PingFang SC,sans-serif;color:#26221E">' + lab +
|
||
'<br><span style="font-size:11.5px;color:#8A8377">睿新致遠 · NOVALON</span></span>'
|
||
'</div></div>')
|
||
P.append('</div></div>')
|
||
P.append('<p id="t3">头像实测:计算中…</p>')
|
||
P.append('<div class="j" id="avdict">头像判据:计算中…</div>')
|
||
|
||
for tag, inner, expect in CONTROLS:
|
||
P.append(ctrl(tag, inner))
|
||
P.append('<h2><span class="no">4</span>口径自检(这一栏不通过,本页所有数都不作数)</h2>'
|
||
'<p class="lab" id="gate" data-limit="' + ("%.3f" % DISC_LIMIT)
|
||
+ '">对照与覆盖率:测量中…</p>')
|
||
P.append('<p class="lab">三个对照:' + ' · '.join(
|
||
"%s(%s)" % (t, e) for t, _i, e in CONTROLS) + '</p>')
|
||
|
||
P.append('<footer>生成器 <code>jianbiao.py</code>(复用 <code>brand.py</code> / '
|
||
'<code>lockup.py</code> 的墨盒解算)· 真迹路径取自 <code>public/logo.svg</code> · '
|
||
'封闭白面积、白连通体、名/号实际墨盒均为本页浏览器栅格与布局实测 · repo 零改动</footer>')
|
||
P.append(PROBE)
|
||
P.append('</div></body></html>')
|
||
return "".join(P)
|
||
|
||
|
||
if __name__ == "__main__":
|
||
html = build()
|
||
out = os.path.join(HERE, "jianbiao.html")
|
||
with open(out, "w", encoding="utf-8") as f:
|
||
f.write(html)
|
||
_b0, m0 = inline_variant("baseline", guides=False)
|
||
_b1, m1 = inline_variant("center", guides=False)
|
||
_b2, m2 = inline_variant("name_only", guides=False)
|
||
print("名墨盒 top %.2f bot %.2f ctr %.2f" % (m0["ntop"], m0["nbot"], m0["nctr"]))
|
||
print("号墨竖盒 rel top %.2f bot %.2f (cap %.2f)" % (m0["v0"], m0["v1"], m0["cap"]))
|
||
print("baseline 号墨中心 %.2f 偏差 %+.2f" % (m0["lat_ctr"], m0["off"]))
|
||
print("center 号墨中心 %.2f 偏差 %+.2f" % (m1["lat_ctr"], m1["off"]))
|
||
print("name_only 画布 %.1fx%.1f baseline 画布 %.1fx%.1f" % (m2["W"], m2["H"], m0["W"], m0["H"]))
|
||
assert abs(m1["off"]) <= 0.01, "center 版没真把中心对齐"
|
||
assert m0["off"] > 5.0, "baseline 版偏低量没到预期,前面的诊断要重做"
|
||
for key, lab, face, dg in WEN_VARIANTS:
|
||
a, b, c = (wen_arith(face, s) for s in (16, 96, 48))
|
||
print("%s 字面 %.2f 减地 %.2f:16px 字高 %.1f 缝 %.2fpx · 48px 缝 %.2f · 96px 缝 %.2f"
|
||
% (key, face, dg, a["glyph_px"], a["gap"], c["gap"], b["gap"]))
|
||
print("圆内不裁切上限 face=%.4f(真迹最远极径 %.4f×max);头像 0.80 余量 %.1f%%,0.60 余量 %.1f%%"
|
||
% (DISC_LIMIT, _RHO, 100 * disc_margin(0.80), 100 * disc_margin(0.60)))
|
||
assert 0.80 < DISC_LIMIT, "头像 0.80 超出圆内不裁切上限,会被盘边切字"
|
||
assert DISC_LIMIT < 0.707 + 0.25, "内接极限算得离谱,检查极径取值"
|
||
print("jianbiao.html %s B" % format(len(html.encode("utf-8")), ","))
|