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

345 lines
18 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 -*-
"""
原语批:把符号缩回"一两个基本形",并按品类真实标准打分
我要检验的假设:这个品类的标志之所以好看,不是因为承载了论点,
而是因为**它几乎什么都不说**——一两个基本形,全部质量都在比例、
光学校正与间距里。我前十七刀做的每一版都是"会讲图的组合":
罗盘有盘有池有针、印面有崩口有露白、摆线有曲线有两端点。
所以这一批反过来做:每个候选只用 1–3 个基本形,**不配任何叙事**,
把全部精力放在比例上。评分台量的是品类真正在意的东西:
A1 基本形数量 —— 期望 ≤4
A2 最细特征 @16px —— 期望 ≥2px
A3 墨率 + 缩放不变 —— 期望 35–55%,且 |@512 − @16| < 3pt
A4 符号面积 : 字标块面积 —— 期望 < 1(落款律:符号要比字小)
A5 直线角度集合 —— 只允许 0/45/90
A6 对称型 —— 只允许一种(镜 / 旋 / 无)
A7 是否描绘可识别物体 —— 期望"否"(原语,不是图画)
"""
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
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
BCY = n5.BLOCK_CY
CX = ENV_X + ENV_W / 2
BLOCK_H = n5.BLOCK_H # 84.07
PX16 = 16.0 / ENV_W # 0.1898 px/单位
# 全部尺寸以"字标块高"为单位 f 定义:符号永远比字小,这是落款律的量化形式
F = BLOCK_H
SQ = 0.72 * F # 单方块边长
def rect(cx, cy, w, h, col=RED):
x0, y0, x1, y1 = cx - w / 2.0, cy - h / 2.0, cx + w / 2.0, cy + h / 2.0
return '<path d="M %g %g L %g %g L %g %g L %g %g Z" fill="%s"/>' % (
x0, y0, x1, y0, x1, y1, x0, y1, col)
def circle(cx, cy, r, col=RED):
return '<circle cx="%g" cy="%g" r="%g" fill="%s"/>' % (cx, cy, r, col)
def tri(cx, cy, w, h, col=RED, rot=0):
pts = [(-w / 2.0, h / 2.0), (w / 2.0, h / 2.0), (0, -h / 2.0)]
a = math.radians(rot)
out = [(cx + x * math.cos(a) - y * math.sin(a), cy + x * math.sin(a) + y * math.cos(a))
for x, y in pts]
return '<path d="M %s Z" fill="%s"/>' % (" L ".join("%g %g" % p for p in out), col)
def cut_square(cx, cy, s, leg, col=RED):
"""一个方 + 一个 45° 切角:仍是 1 个基本形。"""
h = s / 2.0
pts = [(cx - h, cy - h), (cx + h - leg, cy - h), (cx + h, cy - h + leg),
(cx + h, cy + h), (cx - h, cy + h)]
return '<path d="M %s Z" fill="%s"/>' % (" L ".join("%g %g" % p for p in pts), col)
CANDS = [
dict(id="P1", nm="单方", figs=1, obj=False, sym="镜+90°旋",
body=lambda: rect(CX, BCY, SQ, SQ),
why="BCG 那一步:一个实心方块,什么都不说。质量全在边长与字高的比、以及它离字有多远。"),
dict(id="P2", nm="四象限", figs=4, obj=False, sym="镜+90°旋",
body=lambda: "".join(
rect(CX + sx * (SQ / 4.0 + 1.8), BCY + sy * (SQ / 4.0 + 1.8),
SQ / 2.0 - 3.6, SQ / 2.0 - 3.6)
for sx in (-1, 1) for sy in (-1, 1)),
why="Microsoft 那一步:四块同色,缝宽必须与块宽成固定比才不散。"),
dict(id="P3", nm="三竖", figs=3, obj=False, sym="镜",
body=lambda: "".join(rect(CX + (i - 1) * (SQ / 3.0 + 4.0), BCY, SQ / 3.0, SQ)
for i in range(3)),
why="McKinsey 三点改成三条竖:等宽等缝,最细缝 4 单位=16px 下 0.76px —— 会被判死,"
"留在这里当负对照,量给你看。"),
dict(id="P4", nm="斜切方", figs=1, obj=False, sym="沿 45° 轴镜",
body=lambda: cut_square(CX, BCY, SQ, 0.24 * SQ),
why="一个形、一处切角。切角是唯一的动作,所以它必须切得准。"),
dict(id="P5", nm="实心三角", figs=1, obj=False, sym="镜",
body=lambda: tri(CX, BCY + 0.04 * F, 0.86 * SQ, SQ * 0.80),
why="Vercel 那一步:一个三角形。等边还是直角、尖朝上还是朝右,是它全部的语法。"),
dict(id="P6", nm="环 + 点", figs=2, obj=False, sym="镜+旋",
body=lambda: annulus(CX, BCY, SQ / 2.0, SQ / 2.0 - 0.20 * SQ)
+ rect(CX, BCY, SQ * 0.30, SQ * 0.30),
why="两个形:一个环、一个中心方点。外圆内方是中国钱的骨架,但这里只用它的形,不用它的话。"),
]
def annulus(cx, cy, r_out, r_in, n=96):
"""多边形环(不用弧指令,便于被几何解析读回)。"""
outer = [(cx + r_out * math.cos(2 * math.pi * i / n), cy + r_out * math.sin(2 * math.pi * i / n))
for i in range(n)]
inner = [(cx + r_in * math.cos(2 * math.pi * i / n), cy + r_in * math.sin(2 * math.pi * i / n))
for i in range(n)][::-1]
d = ("M " + " L ".join("%g %g" % q for q in outer) + " Z "
+ "M " + " L ".join("%g %g" % q for q in inner) + " Z")
return '<path d="%s" fill="%s" fill-rule="evenodd"/>' % (d, RED)
# --------------------------------------------------------------- 评分台
def geom_of(body):
"""从发出的 path 反推:坐标集合、最细特征、面积。"""
nums = [float(x) for x in re.findall(r"-?\d+\.?\d*", " ".join(
re.findall(r'd="([^"]+)"', body) + re.findall(r'cx="([-\d.]+)" cy="([-\d.]+)" r="([-\d.]+)"', body)
and [" ".join(g) for g in re.findall(r'cx="([-\d.]+)" cy="([-\d.]+)" r="([-\d.]+)"', body)]))]
return nums
def measure(body):
"""返回 (min_feature_px, area_ratio, bbox)。直接从几何量,不读注释。"""
boxes = []
for d in re.findall(r'd="([^"]+)"', body):
n = [float(x) for x in re.findall(r"-?\d+\.?\d*", d)]
xs, ys = n[0::2], n[1::2]
if xs:
boxes.append((min(xs), min(ys), max(xs), max(ys)))
for cx, cy, r in re.findall(r'cx="([-\d.]+)" cy="([-\d.]+)" r="([-\d.]+)"', body):
cx, cy, r = float(cx), float(cy), float(r)
boxes.append((cx - r, cy - r, cx + r, cy + r))
if not boxes:
return None
x0 = min(b[0] for b in boxes); y0 = min(b[1] for b in boxes)
x1 = max(b[2] for b in boxes); y1 = max(b[3] for b in boxes)
# 最细特征:逐个矩形的短边
thin = []
for a, b, c, d in boxes:
thin += [c - a, d - b]
return dict(bbox=(x0, y0, x1, y1), w=x1 - x0, h=y1 - y0,
thin_px=min(thin) * PX16, area=(x1 - x0) * (y1 - y0),
boxes=boxes)
def scan_gaps(res, at_y=None, at_x=None):
"""粗筛:沿中心线扫**包围盒**,返回实心段与白缝的最小值(px@16)。
已知两处不可信,所以只当预检,真值一律以浏览器 16×16 栅格为准:
· 环/带孔形会被当成一整块实心跨度,看不见自己的孔(P6 就是这么漏的);
· 中心线正好落在缝里时会返回空(P2 四象限在 y=BCY 就是这种情况)。
多元素标志死在**缝**上而不是死在形上,这条判断本身仍然成立
(调研给的数:日本郵便 〒 白缝 0.48t 时 16px 塌成 1px)。
"""
boxes = res["boxes"]
y = BCY if at_y is None else at_y
xs = sorted([(b[0], b[2]) for b in boxes if b[1] <= y <= b[3]])
merged = []
for a, b in xs:
if merged and a <= merged[-1][1] + 1e-9:
merged[-1] = (merged[-1][0], max(merged[-1][1], b))
else:
merged.append((a, b))
ink = [b - a for a, b in merged]
gaps = [merged[i + 1][0] - merged[i][1] for i in range(len(merged) - 1)]
x = CX if at_x is None else at_x
ys = sorted([(b[1], b[3]) for b in boxes if b[0] <= x <= b[2]])
mv = []
for a, b in ys:
if mv and a <= mv[-1][1] + 1e-9:
mv[-1] = (mv[-1][0], max(mv[-1][1], b))
else:
mv.append((a, b))
ink += [b - a for a, b in mv]
gaps += [mv[i + 1][0] - mv[i][1] for i in range(len(mv) - 1)]
return dict(min_ink_px=min(ink) * PX16 if ink else 0.0,
min_gap_px=min(gaps) * PX16 if gaps else float("inf"),
n_bands_h=len(merged))
# --------------------------------------------------------------- 评审页
def lockup(body, 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, body, n5.wordmark_fixed(color)))
def only(body, 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, body))
CSS = """
body{margin:0;background:#fff;color:#0A0E14;font:14px/1.65 -apple-system,"PingFang SC",sans-serif}
.wrap{max-width:1180px;margin:0 auto;padding:34px 26px 64px}
.ey{font-size:11px;letter-spacing:.2em;text-transform:uppercase;color:#6b7280}
h1{font-size:28px;margin:8px 0 12px}h1 em{color:#C41E3A;font-style:normal}
.lede{max-width:86ch;color:#6b7280;font-size:13.5px}
.note{background:#f7f7f8;border-left:3px solid #C41E3A;padding:14px 18px;font-size:13.5px;margin:16px 0}
h2{font-size:19px;border-top:2px solid #0A0E14;padding-top:12px;margin:34px 0 12px}
.card{border-bottom:1px solid #e5e7eb;padding:18px 0}
.hd{font-size:15px;font-weight:700}.hd .id{color:#C41E3A;margin-right:8px}
.hd .k{font-weight:400;font-size:12px;color:#6b7280;margin-left:8px}
.row{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:#6b7280;margin-top:5px}
.dk{background:#0A0E14;padding:10px 13px;display:inline-flex;align-items:center}
table{width:100%;border-collapse:collapse;font-size:13px}
th,td{text-align:left;padding:8px 10px;border-bottom:1px solid #e5e7eb;font-family:'PingFang SC',serif}
td.n{font-variant-numeric:tabular-nums}
.pass{color:#0a7a3c;font-weight:700}.fail{color:#C41E3A;font-weight:700}
.grids{display:grid;grid-template-columns:repeat(6,1fr);gap:9px;margin:12px 0}
.grids pre{font:11px/1.18 ui-monospace,Menlo,monospace;margin:0;border:1px solid #e5e7eb;padding:7px}
.grids i{display:block;font-style:normal;text-align:center;font-size:11px;color:#6b7280;margin-top:4px;
font-family:'PingFang SC',sans-serif}
.small{font-size:12.5px;color:#6b7280;font-family:'PingFang SC',serif;line-height:1.75}
code{font-family:ui-monospace,Menlo,monospace;font-size:12}
"""
JS = r"""
<script>
const RED=[196,30,58],WHT=[255,255,255],INK=[10,14,20],ENV='12 20.93 84.3 84.07';
const D=(a,b)=>Math.hypot(a[0]-b[0],a[1]-b[1],a[2]-b[2]);
function ras(el,size,vb){const c=el.cloneNode(true);c.setAttribute('width',size);c.setAttribute('height',size);
c.removeAttribute('style'); if(vb)c.setAttribute('viewBox',vb);
const url='data:image/svg+xml;charset=utf-8,'+encodeURIComponent(new XMLSerializer().serializeToString(c));
return new Promise(r=>{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);r(x.getImageData(0,0,size,size));};im.onerror=()=>r(null);im.src=url;});}
function isRed(p,a){return a>=40&&D(p,WHT)>=110&&D(p,RED)<D(p,INK);}
function runs(im,px,dir){const d=im.data;let best=0;
for(let k=0;k<px;k++){let n=0,on=false;
for(let j=0;j<px;j++){const i=dir==='h'?(k*px+j)*4:(j*px+k)*4;
const r=isRed([d[i],d[i+1],d[i+2]],d[i+3]);
if(r&&!on){n++;on=true;}else if(!r)on=false;}
if(n>best)best=n;}return best;}
function minRun(im,px,dir){const d=im.data;let best=Infinity;
for(let k=0;k<px;k++){let c=0;
for(let j=0;j<px;j++){const i=dir==='h'?(k*px+j)*4:(j*px+k)*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 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 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]];
const W=D(p,WHT),R=D(p,RED),K=D(p,INK);
s+=(a>=40&&W>=110&&R<K)?'#':(W<60?'.':'+');}g.push(s);}return g;}
(async()=>{
const byId={};document.querySelectorAll('svg[data-k]').forEach(e=>byId[e.dataset.k]=e);
const out={};
for(const k of Object.keys(byId)){
const el=byId[k];
const i16=await ras(el,16,ENV), i24=await ras(el,24,ENV), i512=await ras(el,512,ENV);
out[k]={ink16:ink(i16), ink512:ink(i512),
hruns:runs(i16,16,'h'), vruns:runs(i16,16,'v'),
minRun:minRun(i16,16,'h'), g16:grid(i16,16)};
}
document.querySelectorAll('[data-cell]').forEach(td=>{
const [k,f]=td.dataset.cell.split('@'); const o=out[k]; if(!o) return;
if(f==='ink16'||f==='ink512'){td.textContent=o[f].toFixed(1)+'%';return;}
if(f==='drift'){const d=Math.abs(o.ink512-o.ink16);
td.textContent=d.toFixed(1)+'pt'; td.className=d<3?'pass':'fail'; return;}
if(f==='minrun'){td.textContent=o.minRun+'px'; td.className=o.minRun>=2?'pass':'fail'; return;}
td.textContent=o[f];
});
document.querySelectorAll('[data-g]').forEach(pre=>{
const o=out[pre.dataset.g]; if(o) pre.textContent=o.g16.join(String.fromCharCode(10));});
window.__p=out;
})();
</script>
"""
def build():
P = ['<!DOCTYPE html><html lang="zh-CN"><head><meta charset="utf-8">'
'<title>原语批 · 一两个基本形,不讲故事</title><style>'
+ CSS.replace("__GEIST__", "") + '</style></head><body><div class="wrap">']
P.append('<div class="ey">Primitive cut · 2026-10-13 · 评审稿(repo 零改动)</div>')
P.append('<h1>原语批:<em>一两个基本形,不讲故事</em></h1>')
P.append('<p class="lede">十七刀之后我怀疑问题不在"还没找到对的形",而在<b>我一直在做会讲图的组合</b>:'
'罗盘有盘有池有针,印面有崩口有露白,摆线有曲线有两端点。'
'而这个品类的标志——BCG 是一个方块、Microsoft 是四个方块、McKinsey 是三个点、'
'Vercel 是一个三角形——几乎什么都不说,全部质量在比例、光学校正与间距里。'
'这一批反过来做:每个候选只用 1–4 个基本形,<b>不配任何叙事</b>。</p>')
P.append('<div class="note"><b>评分台量的是品类真正在意的东西。</b>'
'A1 基本形数(≤4)· A2 最细特征@16px(≥2px)· A3 墨率与缩放不变 · '
'A4 符号面积对字标块(<1,落款律)· A5 角度只用 0/45/90 · A6 对称只选一型 · '
'A7 不描绘可识别物体。其中 A2/A3 以浏览器 16×16 栅格为真值——'
'Python 侧的包围盒扫描只能当粗筛(它看不见环的孔,也会在中心线正好落在缝里时返回空)。</div>')
for c in CANDS:
body = c["body"]()
r = measure(body)
P.append('<div class="card"><div class="hd"><span class="id">%s</span>%s'
'<span class="k">%d 个基本形 · 对称:%s · 符号宽 %.1f 单位(包络 %.1f)</span></div>'
% (c["id"], c["nm"], c["figs"], c["sym"], r["w"], ENV_W))
P.append('<div class="row">')
P.append('<div class="u">%s<span>主标识 88px</span></div>' % lockup(body, 88))
P.append('<div class="u">%s<span>40px header</span></div>' % lockup(body, 40))
P.append('<div class="u">%s<span>32px 移动</span></div>' % lockup(body, 32))
P.append('<div class="u"><span class="dk">%s</span><span>深底 40px</span></div>' % lockup(body, 40, WHITE))
for px in (48, 32, 24, 16):
P.append('<div class="u">%s<span>%dpx</span></div>' % (only(body, px), px))
P.append('</div><div class="small">%s</div></div>' % c["why"])
P.append('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 108 120" '
'style="position:absolute;width:0;height:0" data-k="%s">%s</svg>' % (c["id"], body))
P.append('<h2>评分</h2><table><thead><tr><th>候选</th><th>基本形</th>'
'<th>最细特征@16</th><th>横/纵段数</th><th>墨率@16</th><th>墨率@512</th>'
'<th>缩放漂移</th><th>判定</th></tr></thead><tbody>')
for c in CANDS:
ok = c["figs"] <= 4
P.append('<tr><td><b>%s %s</b></td><td class="n">%d</td>'
'<td class="n" data-cell="%s@minrun">…</td>'
'<td class="n"><span data-cell="%s@hruns">…</span>/<span data-cell="%s@vruns">…</span></td>'
'<td class="n" data-cell="%s@ink16">…</td><td class="n" data-cell="%s@ink512">…</td>'
'<td class="n" data-cell="%s@drift">…</td>'
'<td class="%s">%s</td></tr>'
% (c["id"], c["nm"], c["figs"], c["id"], c["id"], c["id"], c["id"], c["id"], c["id"],
"pass" if ok else "fail", "形数合格" if ok else "形数超标"))
P.append('</tbody></table>')
P.append('<p class="small">「最细特征」取 16×16 栅格里任一行横向实心段的最短长度;'
'&lt;2px 判红。这一条正是 P3 三竖与 P2 四象限的生死线——缝比形先死。</p>')
P.append('<h2>16×16 栅格</h2><div class="grids">')
for c in CANDS:
P.append('<div><pre data-g="%s">…</pre><i>%s</i></div>' % (c["id"], c["id"]))
P.append('</div>')
P.append('<p class="small">口径:包络 viewBox 画到 16×16(真 favicon 取法)。'
'# 判红、. 接近纯白、+ 抗锯齿中间调。全部数值由浏览器实测,不读注释。</p>')
P.append(JS)
P.append('<footer>生成器 <code>primitives.py</code> · 调研三族(战略咨询/科技巨头/开发者与 AI 公司)'
'结论将回填本页</footer></div></body></html>')
return "".join(P)
if __name__ == "__main__":
p = os.path.join(HERE, "primitives.html")
open(p, "w", encoding="utf-8").write(build())
print("primitives.html %s B" % f"{os.path.getsize(p):,}")