#!/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 '' % (
x0, y0, x1, y0, x1, y1, x0, y1, col)
def circle(cx, cy, r, col=RED):
return '' % (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 '' % (" 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 '' % (" 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 '' % (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 ('' % (h, color, body, n5.wordmark_fixed(color)))
def only(body, px):
return ('' % (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"""
"""
def build():
P = ['
'
'原语批 · 一两个基本形,不讲故事']
P.append('
Primitive cut · 2026-10-13 · 评审稿(repo 零改动)
')
P.append('
原语批:一两个基本形,不讲故事
')
P.append('
十七刀之后我怀疑问题不在"还没找到对的形",而在我一直在做会讲图的组合:'
'罗盘有盘有池有针,印面有崩口有露白,摆线有曲线有两端点。'
'而这个品类的标志——BCG 是一个方块、Microsoft 是四个方块、McKinsey 是三个点、'
'Vercel 是一个三角形——几乎什么都不说,全部质量在比例、光学校正与间距里。'
'这一批反过来做:每个候选只用 1–4 个基本形,不配任何叙事。
')
P.append('
评分台量的是品类真正在意的东西。'
'A1 基本形数(≤4)· A2 最细特征@16px(≥2px)· A3 墨率与缩放不变 · '
'A4 符号面积对字标块(<1,落款律)· A5 角度只用 0/45/90 · A6 对称只选一型 · '
'A7 不描绘可识别物体。其中 A2/A3 以浏览器 16×16 栅格为真值——'
'Python 侧的包围盒扫描只能当粗筛(它看不见环的孔,也会在中心线正好落在缝里时返回空)。
')
for c in CANDS:
body = c["body"]()
r = measure(body)
P.append('
%s%s'
'%d 个基本形 · 对称:%s · 符号宽 %.1f 单位(包络 %.1f)
'
% (c["id"], c["nm"], c["figs"], c["sym"], r["w"], ENV_W))
P.append('
')
P.append('
%s主标识 88px
' % lockup(body, 88))
P.append('
%s40px header
' % lockup(body, 40))
P.append('
%s32px 移动
' % lockup(body, 32))
P.append('
%s深底 40px
' % lockup(body, 40, WHITE))
for px in (48, 32, 24, 16):
P.append('
%s%dpx
' % (only(body, px), px))
P.append('
%s
' % c["why"])
P.append('
' % (c["id"], body))
P.append('
评分
| 候选 | 基本形 | '
'最细特征@16 | 横/纵段数 | 墨率@16 | 墨率@512 | '
'缩放漂移 | 判定 |
')
for c in CANDS:
ok = c["figs"] <= 4
P.append('| %s %s | %d | '
'… | '
'…/… | '
'… | … | '
'… | '
'%s |
'
% (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('
')
P.append('
「最细特征」取 16×16 栅格里任一行横向实心段的最短长度;'
'<2px 判红。这一条正是 P3 三竖与 P2 四象限的生死线——缝比形先死。
')
P.append('
16×16 栅格
')
for c in CANDS:
P.append('
' % (c["id"], c["id"]))
P.append('
')
P.append('
口径:包络 viewBox 画到 16×16(真 favicon 取法)。'
'# 判红、. 接近纯白、+ 抗锯齿中间调。全部数值由浏览器实测,不读注释。
')
P.append(JS)
P.append('
')
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):,}")