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

222 lines
11 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 -*-
"""
全案 · 印(第二十三刀)
依据:四族参照研究的第一份结论 ——
「朱砂的合法形态是印:带边框的实心块,印文白文或朱文。
纯几何实心块读作图标,读不出印,故与书法必然割裂。」
高级感变量第一位 = 曲线生成方式同源(运笔/雕刻/版画 > 圆弧拼接)。
第六位 = 最小尺寸是结果不是目标。我过去二十二刀把它当第一位在优化。
所以这一刀的印文**不自己画**,直接用字标组里的毛笔真迹「睿」(9 子路径 / 197 点 /
纯多边形轮廓,同一根扫描线上笔宽 7.7→265 单位)。印与字同源,不是并置。
要定的参数(每个都出图并排,靠眼睛判,不靠门禁判):
S1 栏宽 / 印文高 之比 —— 边栏多厚才像刻的
S2 印文在印面里的缩放 —— 满白汉印 vs 疏朗文人印
S3 破边(崩角)放在哪、放多大 —— 研究第五变量:一处不可复制的异常
S4 朱文 or 白文
"""
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
CH = json.load(open(os.path.join(HERE, "_wm-chars.json"), encoding="utf-8"))["chars"]
RUI = CH[0]["d"]
_nums = [float(x) for x in re.findall(r"-?\d+\.?\d*", RUI)]
_xs, _ys = _nums[0::2], _nums[1::2]
GX0, GX1 = min(_xs), max(_xs)
GY0, GY1 = min(_ys), max(_ys)
GW, GH = GX1 - GX0, GY1 - GY0
GOX, GOY = (GX0 + GX1) / 2.0, (GY0 + GY1) / 2.0
VB = 256.0
C = VB / 2.0
def seal(bars_ratio=0.115, fill=0.78, chip=0.0, chip_side="tr",
plate_col=RED, ink_col=WHITE, wen="bai"):
"""一枚印。返回 svg 片段。
wen="bai" 白文:实心印面,印文刻白(朱砂底上的白字)
wen="zhu" 朱文:印面留白,只画边栏,印文作红字(这是另一种刻法,
对照用 —— 上一版我给它传 ink_col=RED 配实心红底,
等于红字红底,整枚印是隐形的,那是我的 bug 不是朱文的样子)
plate_col / ink_col 用于反白稿
"""
side = VB * 0.80 # 印面边长
x0, y0 = C - side / 2.0, C - side / 2.0
b = side * bars_ratio # 边栏厚
inner = side - 2 * b
if wen == "zhu":
# 只有边栏是实色,中间是纸色(这里用透明,让底色透出来)
outer = [(x0, y0), (x0 + side, y0), (x0 + side, y0 + side), (x0, y0 + side)]
hole = [(x0 + b, y0 + b), (x0 + side - b, y0 + b),
(x0 + side - b, y0 + side - b), (x0 + b, y0 + side - b)]
d = ("M " + " L ".join("%g %g" % p for p in outer) + " Z "
+ "M " + " L ".join("%g %g" % p for p in hole) + " Z")
plate = '<path d="%s" fill="%s" fill-rule="evenodd"/>' % (d, plate_col)
else:
plate = '<rect x="%g" y="%g" width="%g" height="%g" fill="%s"/>' % (
x0, y0, side, side, plate_col)
# 破边:从角上咬掉一块两步台阶(石章磕崩的样子,不是 45° 裁角)
if chip > 0 and wen == "bai":
a = side * chip
pts = {
"tr": [(x0, y0), (x0 + side - a, y0), (x0 + side - a, y0 + a * 0.42),
(x0 + side - a * 0.42, y0 + a * 0.42), (x0 + side - a * 0.42, y0 + a),
(x0 + side, y0 + a), (x0 + side, y0 + side), (x0, y0 + side)],
"br": [(x0, y0), (x0 + side, y0), (x0 + side, y0 + side - a),
(x0 + side - a * 0.42, y0 + side - a),
(x0 + side - a * 0.42, y0 + side - a * 0.42),
(x0 + side - a, y0 + side - a * 0.42),
(x0 + side - a, y0 + side), (x0, y0 + side)],
}[chip_side]
plate = ('<polygon points="%s" fill="%s"/>'
% (" ".join("%g,%g" % p for p in pts), plate_col))
# 印文:真迹睿,按 fill 缩放后居中进内腔
k = min(inner * fill / GW, inner * fill / GH)
tr = ('translate(%g,%g) scale(%g) translate(%g,%g)' % (C, C, k, -GOX, -GOY))
glyph = '<g transform="%s"><path d="%s" fill="%s"/></g>' % (tr, RUI, ink_col)
return plate + glyph
def only(body, px):
return ('<span class="ico" style="width:%dpx;height:%dpx">'
'<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</svg>'
'</span>' % (px, px, VB, VB, px, px, px, px, body))
# 款识关系:研究给的尺度线索是「落款小章高度 ≈ 款字一行高」。
# 字标组在 4:1 画布里的实际块高:
CAL_H = 45.4 # 睿新致遠 四字块高(y 20.9..66.3)
CAL_X1 = 306.3
CAL_Y1 = 66.3
def lockup(body, h_seal, label=""):
"""把印缩到 h_seal,放在书法右下(款识位)。"""
k = h_seal / VB
return ('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 480 120" '
'width="480" height="120" style="width:480px;height:120px">%s'
'<g transform="translate(%g,%g) scale(%g) translate(%g,%g)">%s</g></svg>'
% (n5.wordmark_fixed(),
CAL_X1 + 4, CAL_Y1 - h_seal + 2, k, -C, -C, body))
VARIANTS = [
("S1 满白·厚栏", dict(bars_ratio=0.135, fill=0.94),
"汉印满白:印文撑到内腔 94%,边栏厚 13.5%。最像刻的,最重。"),
("S2 满白·薄栏", dict(bars_ratio=0.075, fill=0.94),
"同样满白,栏减到 7.5%。看栏的厚度是不是那个决定性的变量。"),
("S3 中栏·疏朗", dict(bars_ratio=0.105, fill=0.78),
"文人印的呼吸:印文收到 78%,四周留红多。"),
("S4 中栏·疏朗·破边", dict(bars_ratio=0.105, fill=0.78, chip=0.075),
"在 S3 上加一处右上磕崩 —— 研究第五变量:一处不可复制的异常。"),
("S5 朱文", dict(bars_ratio=0.105, fill=0.78, wen="zhu"),
"对照:朱文是红字白底、只画边栏。上一版我给它传了红字配实心红底,"
"整枚隐形——那是我的 bug,不是朱文长这样。"),
("S6 厚栏·破边·满白", dict(bars_ratio=0.135, fill=0.94, chip=0.06, chip_side="br"),
"满白加右下磕崩。破边和满白同时存在时,印会不会开始显得脏。"),
]
CSS = """
*{box-sizing:border-box}body{margin:0;padding:32px 38px 70px;background:#f6f7f8;
font:14px/1.7 -apple-system,"PingFang SC","Microsoft YaHei",sans-serif;color:#0A0E14}
h1{font-size:25px;margin:0 0 8px}h1 em{font-style:normal;color:#C41E3A}
.lede{color:#374151;max-width:940px;margin:0 0 20px}
.note{background:#fff;border-left:3px solid #C41E3A;padding:14px 18px;margin:0 0 24px;
font-size:13px;color:#374151;max-width:940px}
.card{background:#fff;padding:18px 20px;margin-bottom:16px;box-shadow:0 1px 2px rgba(0,0,0,.05)}
.hd{font-weight:650;font-size:15px;margin-bottom:12px}
.row{display:flex;gap:22px;align-items:flex-end;flex-wrap:wrap}
.item{text-align:center}
.item .lab{font-size:11px;color:#6b7280;margin-top:6px}
.ico{border-radius:22.5%;overflow:hidden;display:inline-flex;background:#fff;
box-shadow:0 0 0 1px #e5e7eb inset}
.onred{background:#C41E3A}
.why{font-size:12.5px;color:#4b5563;margin-top:10px;max-width:900px}
.paper{background:#fffdf9;border:1px solid #ece7dd;padding:26px 30px;margin-top:10px}
h2{font-size:18px;margin:36px 0 10px}
footer{margin-top:30px;font-size:12px;color:#6b7280}
code{background:#eef0f2;padding:1px 4px;font-size:12px}
"""
def build():
H = ['<!DOCTYPE html><html lang="zh-CN"><head><meta charset="utf-8">'
'<title>全案 · 印</title><style>' + CSS + '</style></head><body>']
H.append('<h1>印:<em>印文用真迹,不自己画</em></h1>')
H.append('<p class="lede">参照研究给的第一条:<b>朱砂的合法形态是「印」——带边栏的实心块,'
'印文白文或朱文;纯几何实心块读作图标,读不出印,所以和书法必然割裂。</b>'
'第二条:高级感最靠前的变量是"曲线生成方式同源"。'
'这一刀的印文直接取字标组里的毛笔真迹「睿」——9 条子路径、197 个点、'
'纯多边形轮廓,同一根扫描线上笔宽从 7.7 走到 265 单位。印与字同源,不是并置。</p>')
H.append('<div class="note"><b>这一屏先不跑门禁。</b>'
'研究的第六位结论是"最小尺寸是结果,不是目标"——'
'龟甲万的印文「萬」12 画,比我判死过的「睿」还复杂,它成立,'
'因为印文被读成<b>纹理</b>而不是<b>字</b>。'
'所以我上一轮那条"符号里只能放 ≤3 笔画的字"是错的:错的不是字,'
'是我拿图标的存活率去判一枚印。这一屏只靠眼睛判,门禁留到形定下来之后再做简标。</div>')
for nm, kw, why in VARIANTS:
body = seal(**kw)
H.append('<div class="card"><div class="hd">%s</div><div class="row">' % nm)
for px in (200, 96, 48, 24, 16):
H.append('<div class="item">%s<div class="lab">%dpx</div></div>' % (only(body, px), px))
kw2 = dict(kw)
kw2["chip"] = max(kw2.get("chip", 0.0), 0.075)
kw2["plate_col"] = WHITE
kw2["ink_col"] = RED
H.append('<div class="item"><span class="ico onred" style="width:96px;height:96px">'
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 %g %g" width="96" height="96" '
'style="width:96px;height:96px;display:block">%s</svg></span>'
'<div class="lab">朱砂底反白</div></div>'
% (VB, VB, seal(**kw2)))
H.append('</div>')
H.append('<div class="paper">%s</div>' % lockup(body, CAL_H * 0.92))
H.append('<div class="why">%s<br><b>款识位</b>:印高取字标块高的 0.92 倍——'
'研究给的线索是"落款小章高度约等于款字一行高"。'
'印压在「遠」的右下,不另起一栏。</div>' % why)
H.append('</div>')
H.append('<footer>生成器 <code>seal.py</code> · 印文= <code>_wm-chars.json</code> 第 1 字真迹路径 · '
'参数 bars_ratio / fill / chip / ink_col · repo 零改动</footer>')
H.append('</body></html>')
return "".join(H)
if __name__ == "__main__":
html = build()
out = os.path.join(HERE, "seal.html")
with open(out, "w", encoding="utf-8") as f:
f.write(html)
os.makedirs(os.path.join(HERE, "assets-seal"), exist_ok=True)
for i, (nm, kw, why) in enumerate(VARIANTS, 1):
with open(os.path.join(HERE, "assets-seal", "S%d.svg" % i), "w",
encoding="utf-8") as f:
f.write('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 %g %g">%s</svg>'
% (VB, VB, seal(**kw)))
print("seal.html %s B / %d 变体 / 印文 bbox %g×%g 宽高比 %g"
% (format(len(html.encode("utf-8")), ","), len(VARIANTS), GW, GH, GW / GH))