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 个文本/矢量件。
297 lines
14 KiB
Python
297 lines
14 KiB
Python
#!/usr/bin/env python3
|
||
# -*- coding: utf-8 -*-
|
||
"""
|
||
独立标志批:符号就是 logo,先让它独自站住
|
||
|
||
用户重新定义:符号=logo,可搭配公司名,也可单独使用。
|
||
这句话把评判标准换掉了——前十九刀我一直在问"它配在那张毛笔字旁边好不好看",
|
||
而那个问题天然把答案推向"小、安静、从属"(于是就成了项目符号)。
|
||
真正的标准是:**把它单独放进 1:1 的 app 图标、头像、水印里,它还成不成立。**
|
||
|
||
新的硬条件(在原语规则之上加三条):
|
||
N1 1:1 自足 —— 不靠文字也能被认出是"一个标志"而不是一个图标/占位符
|
||
N2 系统图标不撞车 —— 不能读成文件夹、九宫格、相机、播放、加载
|
||
N3 两档密度 —— 大尺寸可以复杂,16px 必须退到能活的简形;
|
||
这不是妥协,是成熟标识系统的标准做法(全徽 → 字徽)
|
||
|
||
五个候选:
|
||
L1 一相圆(双钝)—— 一笔成环,开口在正上
|
||
L2 方印·切角 —— 一个方块,一处 45° 切角
|
||
L3 外方内圆 —— 方盘挖圆池
|
||
L4 环 + 方点 —— 两原语,外圆内方
|
||
L5 白文睿印 —— 实心朱底,把仓库里那笔真「睿」刻成白
|
||
"""
|
||
import importlib.util
|
||
import json
|
||
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
|
||
|
||
|
||
n5 = load("n5", os.path.join(HERE, "n5-refine.py"))
|
||
pr = load("pr", os.path.join(HERE, "primitives.py"))
|
||
sy = load("sy", os.path.join(HERE, "symbol.py"))
|
||
e2 = load("e2", os.path.join(HERE, "enso2.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"]
|
||
|
||
# 1:1 画布:256×256 单位,便于直接当 app 图标母版
|
||
VB = 256.0
|
||
C = VB / 2.0
|
||
|
||
|
||
def tile(inner, pad_frac=0.16, col=RED):
|
||
"""1:1 母版:把形放进 256 画布,四周留 pad。"""
|
||
return ('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 %g %g">%s</svg>'
|
||
% (VB, VB, inner))
|
||
|
||
|
||
def sq_side(frac):
|
||
return frac * VB
|
||
|
||
|
||
def l1():
|
||
"""一相圆(双钝):搬到 1:1 画布上,半径按 0.72 边长取。"""
|
||
R = 0.36 * VB
|
||
W = 0.155 * VB
|
||
prof = e2.en.BRUSH
|
||
body = e2.en.enso(prof=e2.P_DUN, ecc=0.028, ephi=24.0, R=R, W=W,
|
||
theta0=270 + 20.0, sweep=320.0, cx=C, cy=C)
|
||
return body
|
||
|
||
|
||
def l2():
|
||
s = sq_side(0.66)
|
||
h = s / 2.0
|
||
leg = 0.30 * s
|
||
pts = [(C - h, C - h), (C + h - leg, C - h), (C + h, C - h + leg),
|
||
(C + h, C + h), (C - h, C + h)]
|
||
return sy.poly(pts)
|
||
|
||
|
||
def l3():
|
||
s = sq_side(0.66)
|
||
h = s / 2.0
|
||
r = 0.215 * VB
|
||
outer = [(C - h, C - h), (C + h, C - h), (C + h, C + h), (C - h, C + h)]
|
||
inner = [(C + r * math.cos(2 * math.pi * i / 96), C + r * math.sin(2 * math.pi * i / 96))
|
||
for i in range(96)]
|
||
return sy.poly(outer, holes=[inner])
|
||
|
||
|
||
def l4():
|
||
r_out, wall = 0.33 * VB, 0.115 * VB
|
||
return sy.ring_poly(C, C, r_out, wall) + sy.rect(C, C, 0.13 * VB, 0.13 * VB)
|
||
|
||
|
||
def l5():
|
||
"""白文睿印:实心朱底 + 真「睿」刻白。睿的 path 来自 public/logo.svg 字标组。"""
|
||
s = sq_side(0.70)
|
||
h = s / 2.0
|
||
plate = sy.rect(C, C, s, s)
|
||
# 把字标组的睿(绝对坐标)搬进 1:1 画布并居中放大
|
||
import re
|
||
d = CH[0]["d"]
|
||
nums = [float(x) for x in re.findall(r"-?\d+\.?\d*", d)]
|
||
xs, ys = nums[0::2], nums[1::2]
|
||
gw, gh = max(xs) - min(xs), max(ys) - min(ys)
|
||
k = (0.56 * VB) / gw
|
||
ox = (min(xs) + max(xs)) / 2.0
|
||
oy = (min(ys) + max(ys)) / 2.0
|
||
tr = 'translate(%g,%g) scale(%g) translate(%g,%g)' % (C, C, k, -ox, -oy)
|
||
return plate + '<g transform="%s"><path d="%s" fill="%s"/></g>' % (tr, d, WHITE)
|
||
|
||
|
||
CANDS = [
|
||
("L1 一相圆", l1, "一笔成环,开口在正上=通。它一直是唯一从没被你否掉的生成物。"),
|
||
("L2 方印·切角", l2, "一个方块加一处 45° 切角。切角是它唯一的动作。"),
|
||
("L3 外方内圆", l3, "方盘挖圆池:天圆地方,也是中国钱的骨架。"),
|
||
("L4 环 + 方点", l4, "两原语:厚环加中心方点。环是视野,点是判断。"),
|
||
("L5 白文睿印", l5, "实心朱底把真「睿」刻成白——北京 2008 那一步。大尺寸最强,16px 必死。"),
|
||
]
|
||
|
||
|
||
# --------------------------------------------------------------- 评审页
|
||
ENV_X0 = n5.ENV_X
|
||
|
||
|
||
def lockup(mark, h, color=INK, gap=10.0, size=0.36):
|
||
"""把 1:1 母版缩进 4:1 横排:符号高 = 字标块高 × size。"""
|
||
s = size * n5.BLOCK_H
|
||
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">'
|
||
'<g transform="translate(%g,%g) scale(%g)">%s</g>%s</svg>'
|
||
% (h, color, ENV_X0, n5.BLOCK_CY - s / 2.0, s / 256.0, mark,
|
||
n5.wordmark_fixed(color)))
|
||
|
||
|
||
CSS = pr.CSS + """
|
||
.tiles{display:flex;gap:18px;align-items:flex-end;flex-wrap:wrap;margin-top:12px}
|
||
.t{text-align:center}.t>span{display:block;font-size:10px;color:#6b7280;margin-top:5px}
|
||
.ico{border-radius:22.5%;overflow:hidden;display:inline-flex;background:#fff;
|
||
box-shadow:0 1px 0 rgba(0,0,0,.06),0 0 0 1px #e5e7eb inset}
|
||
.ico svg{display:block}
|
||
.solid{background:#C41E3A}
|
||
.g2{display:grid;grid-template-columns:1fr 1fr;gap:16px;margin-top:12px}
|
||
.pl{border:1px solid #eef0f2;padding:14px}
|
||
.pl b{display:block;font-size:10.5px;letter-spacing:.14em;text-transform:uppercase;
|
||
color:#6b7280;font-weight:500;margin-bottom:10px}
|
||
.solo{display:flex;align-items:center;justify-content:center;min-height:176px;
|
||
background:#fff;border:1px dashed #d7dade;margin-bottom:10px}
|
||
"""
|
||
|
||
JS = r"""
|
||
<script>
|
||
const RED=[196,30,58],WHT=[255,255,255],INK=[10,14,20],VB11='0 0 256 256';
|
||
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 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 minRun(im,px){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=(k*px+j)*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 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,VB11), i512=await ras(el,512,VB11);
|
||
out[k]={ink16:ink(i16), ink512:ink(i512), minRun:minRun(i16,16), 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==='minrun'){td.textContent=o.minRun+'px'; td.className=o.minRun>=2?'pass':'fail';return;}
|
||
if(f==='drift'){const d=Math.abs(o.ink512-o.ink16);td.textContent=d.toFixed(1)+'pt';
|
||
td.className=d<5?'pass':'fail';return;}
|
||
});
|
||
document.querySelectorAll('[data-g]').forEach(pre=>{
|
||
const o=out[pre.dataset.g]; if(o) pre.textContent=o.g16.join(String.fromCharCode(10));});
|
||
window.__sa=out;
|
||
})();
|
||
</script>
|
||
"""
|
||
|
||
|
||
def tile(mark, px, solid=False):
|
||
bg = 'solid' if solid else ''
|
||
inner = mark
|
||
if solid:
|
||
# 反白 = 红↔白互换。必须先借一个临时 token,否则第二次 replace
|
||
# 会把第一次刚变白的地方又涂回红色 —— 上一版整排 app 图标全是红底红形。
|
||
swapped = (mark.replace(RED, "\x00")
|
||
.replace(WHITE, RED)
|
||
.replace("\x00", WHITE))
|
||
inner = '<rect width="256" height="256" fill="%s"/>%s' % (RED, swapped)
|
||
return ('<span class="ico %s" style="width:%dpx;height:%dpx">'
|
||
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" '
|
||
'width="%d" height="%d" style="width:%dpx;height:%dpx;display:block">%s</svg>'
|
||
'</span>' % (bg, px, px, px, px, px, px, inner))
|
||
|
||
|
||
def build():
|
||
P = ['<!DOCTYPE html><html lang="zh-CN"><head><meta charset="utf-8">'
|
||
'<title>独立标志批 · 符号就是 logo</title><style>' + CSS + '</style></head><body><div class="wrap">']
|
||
P.append('<div class="ey">Standalone cut · 2026-10-13 · 评审稿(repo 零改动)</div>')
|
||
P.append('<h1>独立标志批:<em>符号就是 logo,先让它独自站住</em></h1>')
|
||
P.append('<p class="lede">你这句重新定义把标准换掉了。前十九刀我一直在问"它配在那张毛笔字'
|
||
'旁边好不好看",而那个问题天然把答案推向小、安静、从属——于是它就变成了项目符号。'
|
||
'真正的标准是:把它单独放进 1:1 的 app 图标、头像、水印里,它还成不成立。'
|
||
'所以这一批全部先做 1:1 母版(256×256),再缩进横排,顺序反过来。</p>')
|
||
P.append('<div class="note"><b>在原来的原语规则之上,加三条。</b>'
|
||
'N1 <b>1:1 自足</b>:不靠文字也要被认成"一个标志",不是占位符。'
|
||
'N2 <b>不撞系统图标</b>:不能读成文件夹、九宫格、相机、播放、加载。'
|
||
'N3 <b>两档密度</b>:大尺寸可以复杂,16px 必须退到能活的简形——'
|
||
'这不是妥协,是成熟标识系统的标准做法(全徽 → 字徽)。</div>')
|
||
|
||
for i, (nm, fn, why) in enumerate(CANDS):
|
||
mark = fn()
|
||
P.append('<div class="card"><div class="hd"><span class="id">S%d</span>%s'
|
||
'<span class="k">1:1 母版 256×256</span></div>' % (i + 1, nm))
|
||
P.append('<div class="tiles">')
|
||
for px in (128, 64, 40, 32, 16):
|
||
P.append('<div class="t">%s<span>%dpx</span></div>' % (tile(mark, px), px))
|
||
P.append('<div class="t">%s<span>app 图标 128(反白底)</span></div>' % tile(mark, 128, True))
|
||
P.append('</div>')
|
||
P.append('<div class="g2">')
|
||
P.append('<div class="pl"><b>A · 单独使用(符号即 logo)</b>'
|
||
'<span class="solo">%s</span>'
|
||
'<div class="small">无文字、无底框、无辅助图形 —— N1 只看这一格。</div></div>'
|
||
% ('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" '
|
||
'width="160" height="160" style="width:160px;height:160px;display:block">%s</svg>'
|
||
% mark))
|
||
P.append('<div class="pl"><b>B · 搭配公司名称</b>%s%s</div>'
|
||
% (lockup(mark, 84),
|
||
'<div class="tiles">%s%s</div>' % (lockup(mark, 40), lockup(mark, 32))))
|
||
P.append('</div><div class="small">%s</div></div>' % why)
|
||
P.append('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" '
|
||
'style="position:absolute;width:0;height:0" data-k="%s">%s</svg>'
|
||
% ("L%d" % (i + 1), mark))
|
||
|
||
P.append('<h2>16px 存活(1:1 口径,即 favicon 的真实取法)</h2>')
|
||
P.append('<table><thead><tr><th>候选</th><th>最细特征@16</th><th>墨率@16</th>'
|
||
'<th>墨率@512</th><th>缩放漂移</th></tr></thead><tbody>')
|
||
for i, (nm, fn, why) in enumerate(CANDS):
|
||
k = "L%d" % (i + 1)
|
||
P.append('<tr><td><b>%s %s</b></td>'
|
||
'<td class="n" data-cell="%s@minrun">…</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></tr>' % (k, nm, k, k, k, k))
|
||
P.append('</tbody></table>')
|
||
P.append('<p class="small">这次 viewBox 用的是 1:1 母版(0 0 256 256),'
|
||
'也就是符号自己占满画布——这是它作为独立 logo 应有的取法,'
|
||
'不再是从前那种"整条 4:1 裁到 16px"。红色即 <2px 判红。</p>')
|
||
|
||
P.append('<h2>16×16 栅格</h2><div class="grids" style="grid-template-columns:repeat(5,1fr)">')
|
||
for i, (nm, fn, why) in enumerate(CANDS):
|
||
P.append('<div><pre data-g="L%d">…</pre><i>%s</i></div>' % (i + 1, nm))
|
||
P.append('</div>')
|
||
P.append(JS)
|
||
P.append('<footer>生成器 <code>standalone.py</code> · 1:1 母版 256×256 · '
|
||
'横排搭配与落款位对照见 <code>symbol.html</code></footer></div></body></html>')
|
||
return "".join(P)
|
||
|
||
|
||
if __name__ == "__main__":
|
||
p = os.path.join(HERE, "standalone.html")
|
||
open(p, "w", encoding="utf-8").write(build())
|
||
print("standalone.html %s B" % f"{os.path.getsize(p):,}")
|
||
d = os.path.join(HERE, "assets-standalone")
|
||
os.makedirs(d, exist_ok=True)
|
||
for i, (nm, fn, why) in enumerate(CANDS):
|
||
mark = fn()
|
||
tag = nm.split()[0]
|
||
open(os.path.join(d, "%s-tile.svg" % tag), "w", encoding="utf-8").write(
|
||
'<?xml version="1.0" encoding="UTF-8"?>\n<svg xmlns="http://www.w3.org/2000/svg" '
|
||
'viewBox="0 0 256 256" width="256" height="256" role="img" aria-label="睿新致远">%s</svg>\n'
|
||
% mark)
|
||
open(os.path.join(d, "%s-logo.svg" % tag), "w", encoding="utf-8").write(
|
||
'<?xml version="1.0" encoding="UTF-8"?>\n<svg xmlns="http://www.w3.org/2000/svg" '
|
||
'viewBox="0 0 480 120" width="480" height="120" role="img" '
|
||
'aria-label="睿新致远 NOVALON">%s</svg>\n' % lockup(mark, 480))
|
||
print("assets-standalone/ →", len(os.listdir(d)), "个文件")
|