#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
一笔家族 —— E1 圆相之外的同路候选
用户裁定:N5-b 出局(N5 只留定稿矩形);并问"除了一相圆还有别的吗"。
从 E1 被选中反推的口味特征(这一族全部满足):
· 一笔写成,不是零件拼装
· 轻(E1 墨量 34.5%,对比 N5 的 70.9%)
· 有笔意,但不写具体的字
· 连续形 ⇒ 小尺寸下缝隙消失也不会读错
本文件只换"中心线",笔势机器(宽度轮廓 + 法向偏移)完全复用,
因此六版之间的差别是纯粹的手势差别,不是工艺差别。
候选:点 / 一 / 掠 / 螺旋 / 波,外加 E1 圆相与 N5 定稿作参照。
"""
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"))
en = load("en", os.path.join(HERE, "enso-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
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 densify(pts, n=120):
"""按弧长等距重采样,保证宽度变化与速度无关。"""
seg, acc = [], [0.0]
total = 0.0
for a, b in zip(pts, pts[1:]):
d = math.hypot(b[0] - a[0], b[1] - a[1])
total += d
seg.append(d)
acc.append(total)
out = []
for i in range(n + 1):
target = total * i / n
k = 1
while k < len(acc) - 1 and acc[k] < target:
k += 1
a, b = pts[k - 1], pts[k]
span = seg[k - 1] or 1.0
u = (target - acc[k - 1]) / span
out.append((a[0] + (b[0] - a[0]) * u, a[1] + (b[1] - a[1]) * u))
return out
def curve(pts, samples=60, bulge=0.0):
"""折线 → 带轻微弧度的平滑中心线(贝塞尔采样)。"""
if bulge == 0.0:
return pts
a, b = pts[0], pts[-1]
mx, my = (a[0] + b[0]) / 2, (a[1] + b[1]) / 2
dx, dy = b[0] - a[0], b[1] - a[1]
L = math.hypot(dx, dy) or 1.0
cx, cy = mx - dy / L * bulge, my + dx / L * bulge # 法向外推的控制点
out = []
for i in range(samples + 1):
t = i / samples
x = (1 - t) ** 2 * a[0] + 2 * (1 - t) * t * cx + t ** 2 * b[0]
y = (1 - t) ** 2 * a[1] + 2 * (1 - t) * t * cy + t ** 2 * b[1]
out.append((x, y))
return out
def stroke(center, prof, W, steps=90):
"""沿中心线做宽度轮廓偏移,生成实心闭合 path(可转曲、可单色)。"""
pts = densify(center, steps)
left, right = [], []
for i, (x, y) in enumerate(pts):
p0 = pts[max(i - 1, 0)]
p1 = pts[min(i + 1, len(pts) - 1)]
tx, ty = p1[0] - p0[0], p1[1] - p0[1]
L = math.hypot(tx, ty) or 1.0
nx, ny = -ty / L, tx / L
hw = W * interp(prof, i / steps) / 2.0
left.append((x + nx * hw, y + ny * hw))
right.append((x - nx * hw, y - ny * hw))
d = "M " + " L ".join("%g %g" % p for p in left + list(reversed(right))) + " Z"
return '' % (d, RED)
# ---------------------------------------------------------------------------
P_DOT = [(0.00, 0.12), (0.16, 0.80), (0.44, 1.00), (0.78, 0.78), (0.95, 0.34), (1.00, 0.16)]
P_HENG = [(0.00, 0.28), (0.10, 1.00), (0.52, 0.94), (0.88, 0.82), (1.00, 0.30)]
P_LUE = [(0.00, 0.42), (0.12, 1.00), (0.46, 0.74), (0.80, 0.28), (1.00, 0.03)]
P_SPIRAL = [(0.00, 0.30), (0.14, 1.00), (0.70, 0.82), (0.94, 0.30), (1.00, 0.12)]
P_WAVE = [(0.00, 0.22), (0.10, 1.00), (0.32, 0.42), (0.56, 0.98),
(0.80, 0.38), (0.96, 0.70), (1.00, 0.10)]
def g_dot():
return stroke(curve([(CX - 15, BCY - 17), (CX + 15, BCY + 17)], bulge=-9), P_DOT, 42)
def g_heng():
return stroke(curve([(ENV_X + 1, BCY + 4), (ENV_X + ENV_W - 1, BCY - 4)], bulge=-5),
P_HENG, 16)
def g_lue():
return stroke(curve([(ENV_X + 4, BB - 2), (ENV_X + ENV_W - 2, BT + 2)], bulge=-16),
P_LUE, 23)
def g_spiral():
pts = []
turns = 1.62
for i in range(150):
t = i / 149
ang = math.radians(-60) + t * turns * 2 * math.pi
r = 5 + t * 34
pts.append((CX + r * math.cos(ang), BCY + r * math.sin(ang)))
return stroke(pts, P_SPIRAL, 13)
def g_wave():
pts = [(ENV_X, BCY + 10), (ENV_X + ENV_W * 0.30, BCY - 13),
(ENV_X + ENV_W * 0.62, BCY + 12), (ENV_X + ENV_W, BCY - 11)]
return stroke(curve(pts, samples=90), P_WAVE, 14)
Sweep = 320.0
End = 270.0 + (360.0 - Sweep) / 2.0
E1_BODY = en.enso(prof=en.BRUSH, ecc=0.028, ephi=24.0, theta0=End - Sweep, sweep=Sweep)
ITEMS = [
dict(id="B1", nm="点 · 侧", body=g_dot, ref="书法第一笔「侧」/句读的一点",
line="一墨落地,起收分明。最小的书写单位,也是「答案先行」最直白的图形。",
risk="太接近一个句点或弹孔,独占性靠比例;单独放在深底上可能像未加载完。"),
dict(id="B2", nm="一 · 横", body=g_heng, ref="「道生一」/纲领线",
line="一道横画,起笔顿、行笔匀、收笔回。一字即纲领,也最接近「底线」的账本语言。",
risk="横画在 header 里容易被读成一条下划线或分隔线,脱离字标独立使用时最弱。"),
dict(id="B3", nm="掠 · 上扬", body=g_lue, ref="书法的「撇/掠」/上行折线",
line="从左下扫向右上的一记长笔,起笔厚重、收笔出锋。方向即语义:向上、致远。",
risk="斜向单笔画是最常见的「科技感」母题之一,撞形风险高于其余四版。"),
dict(id="B4", nm="螺旋", body=g_spiral, ref="一笔盘绕/生生不息",
line="一笔画出 1.6 圈,由内向外扩张——陪跑、迭代、持续放大。",
risk="小尺寸下圈与圈之间会并成实心饼;且螺旋有「加载中」的既视感。"),
dict(id="B5", nm="一波三折", body=g_wave, ref="书法行笔口诀/川水",
line="一道横出的波势,中段两次顿挫——「一波三折」既是笔法也是项目叙事。",
risk="最容易读成「波浪线/签名」,且横向构图与字标抢宽度。"),
dict(id="E1", nm="一相圆(参照)", body=lambda: E1_BODY, ref="禅圆/提笔未合",
line="已在入围名单上。此处只作同族对照,不重新讨论。", risk="—"),
dict(id="N5", nm="竹简定稿(参照)", body=lambda: n5.V1, ref="简册/编绳",
line="已在入围名单上。墨量与线数与一笔族差异明显,正好作参照。", risk="—"),
]
def lockup(mark, h, color=INK):
return ('' % (h, color, mark, n5.wordmark_fixed(color)))
def mark_only(mark, px):
return ('' % (px, mark))
CSS = ms.CSS + """
.be{display:grid;grid-template-columns:1fr 256px;border-bottom:1px solid var(--hair)}
.be>div:first-child{border-right:1px solid var(--hair);padding:16px 20px}
.be .big{background:#fff;border:1px solid var(--hair);padding:12px 16px;display:flex;
align-items:center;justify-content:center;min-height:104px}
.row2{display:flex;gap:16px;align-items:flex-end;flex-wrap:wrap;margin-top:10px}
.u{text-align:center}.u>span{display:block;font-size:10px;color:var(--muted);margin-top:5px}
.darkcell{background:var(--ink);padding:8px 12px;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}
.ref{font-size:11.5px;color:var(--muted);font-family:'PingFang SC',serif}
"""
JS = """
"""
def build():
P = []
w = P.append
w('
'
''
'一笔家族 · E1 之外的同路候选 · 2026-10-13')
w('')
w('
One-stroke family · 2026-10-13 · 评审稿(repo 零改动)
')
w('一笔家族:圆相之外的五记手势
')
w('从 E1 被选中反推你的口味:一笔写成、轻、有笔意但不写字、连续形不怕小尺寸。'
'这一页只换中心线,笔势机器(宽度轮廓 + 法向偏移)完全复用,'
'所以五版之间的差别是纯粹的手势差别。E1 与 N5 定稿并列在末尾作参照。
')
for it in ITEMS:
body = it["body"]()
w('
')
w('
%s
' % lockup(body, 92))
w('
')
for px in (40, 32):
w('
%s%dpx
' % (lockup(body, px), px))
w('
%s深底 40px
'
% lockup(body, 40, WHITE))
for px in (48, 32, 16):
w('
%s%dpx
' % (mark_only(body, px), px))
w('
%s深底 32px
'
% mark_only(body.replace('fill="%s"' % RED, 'fill="%s"' % WHITE), 32))
w('
')
w('
')
w('
' % (it["id"], body))
w('
按真实渲染重排(不是按概念)
')
w('下表"红占比"=红像素 ÷ 符号包络面积(84.3 × 84.07,512 栅格实测)。'
'早先我用"÷ 自身包围盒",那个口径下紧凑的点天生接近 100%、带洞的环天生偏低,'
'跨形状不可比——已改。
')
w('| 序 | 候选 | 红占比 | 渲染实际读成什么 | '
'16px | 判定 |
')
for rank, nm, d, reads, px16, verdict in [
("1", "B4 螺旋", "43.6%", "一枚干净的盘绕,圈与圈分明,笔势厚度看得见",
"仍可辨,中心略糊", '成立,可与 E1 同台'),
("2", "E1 一相圆", "35.4%", "提笔未合的圆相(在场参照,不重议)", "仍是环",
"已在入围"),
("3", "B3 掠·上扬", "22.5%", "一道斜笔——最轻,但也最容易读成"
"斜杠/对勾的一部分", "变细但不断", "成立但太通用"),
("4", "B2 一·横", "65.2%", "一条短横,在 header 里像下划线或分隔线",
"成一条虚线感的短横", "不建议"),
("5", "B5 一波三折", "35.6%", "折线/心电图,不是笔", "折角糊", "不建议"),
("6", "B1 点·侧", "74.0%", "一坨带棱角的红斑——法向偏移在短弧上鼓包,"
"没做出书法点的锋面", "一个小圆点", '做砸了,需回炉'),
]:
w('| %s | %s | %s | %s | '
'%s | %s |
' % (rank, nm, d, reads, px16, verdict))
w('
')
w('结论:这一族里只有 B4 螺旋值得进短名单。'
'它和 E1 同属"一笔写成 + 连续形 + 中等红量",但性格不同:E1 安静、有禅气,'
'B4 有动势、直接说"迭代与放大"。风险是螺旋的"加载中"既视感——'
'不过实测 16px 下它反而靠这个熟悉度不被误读。
'
'B1 的失败要记一笔:书法的"点"靠的是锋面与顿挫,我用等距法向偏移生成,'
'在短弧上必然鼓成多边形团块。这不是参数问题,是方法问题——'
'要做"点"得直接描贝塞尔轮廓,不能靠扫掠。同理,'
'我之前说"B1 比 E1 轻"是错的,实测 74.0% 对 35.4%,重了一倍。
')
w('')
w(JS)
w('
')
w('
')
return "".join(P)
def export():
d = os.path.join(HERE, "assets-brush-family")
os.makedirs(d, exist_ok=True)
for it in ITEMS:
if it["id"].startswith(("E1", "N5")):
continue
body = it["body"]()
for kind, color in (("logo", INK), ("logo-white", WHITE)):
open(os.path.join(d, "%s-%s.svg" % (it["id"], kind)), "w", encoding="utf-8").write(
'\n\n' % (body, n5.wordmark_fixed(color)))
open(os.path.join(d, "%s-mark.svg" % it["id"]), "w", encoding="utf-8").write(
'\n\n' % body)
print("assets-brush-family/ →", len(os.listdir(d)), "个文件")
def main():
path = os.path.join(HERE, "brush-family.html")
with open(path, "w", encoding="utf-8") as f:
f.write(build())
print("brush-family.html %s B" % f"{os.path.getsize(path):,}")
export()
if __name__ == "__main__":
main()