@zenux/dsh-theme-endfield 0.0.0-stage → 1.2.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +183 -2
- package/client.js +13923 -0
- package/cordis.patch.yml +17 -0
- package/docs/PR-description.md +141 -0
- package/docs/audio-notifications.md +159 -0
- package/docs/codemap.md +755 -0
- package/docs/contour-scan-bounds.md +24 -0
- package/docs/contour-trail.md +61 -0
- package/docs/contour-worker.md +38 -0
- package/docs/design-language.md +285 -0
- package/docs/engineering-notes.md +1413 -0
- package/docs/features.md +573 -0
- package/docs/glass.md +32 -0
- package/docs/palette/rekindle-red.html +521 -0
- package/docs/palette/submerge-blue.html +530 -0
- package/docs/preview.gif +0 -0
- package/docs/release.md +66 -0
- package/docs/sarkaz-script.md +101 -0
- package/docs/testing.md +536 -0
- package/index.js +1647 -0
- package/lib/audio.js +600 -0
- package/lib/slots.js +105 -0
- package/lib/tone.js +216 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/media/README.md +22 -0
- package/media/audio/loop.m4a +0 -0
- package/media/audio/rest.m4a +0 -0
- package/media/video/A.mp4 +0 -0
- package/media/video/B.mp4 +0 -0
- package/media/video/B_rev.mp4 +0 -0
- package/media/video/C.mp4 +0 -0
- package/package.json +122 -4
- package/sounds/attention.wav +0 -0
- package/sounds/boot.wav +0 -0
- package/sounds/login.wav +0 -0
- package/sounds/turn-done.wav +0 -0
- package/sounds/turn-fail.wav +0 -0
- package/sounds/turn-start.wav +0 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Exact bounds for contour extraction
|
|
2
|
+
|
|
3
|
+
Each row is divided into blocks of 16 cells. A block records the exact minimum
|
|
4
|
+
and maximum of its two vertex rows, including its shared right boundary. One
|
|
5
|
+
range pass is reused for all contour levels; blocks wholly on one side of a
|
|
6
|
+
level skip the original per-cell scan. Retained cells keep their original order,
|
|
7
|
+
interpolation, saddle handling, path stitching and filters. The grid, level
|
|
8
|
+
count, spatial smoothing and drawing functions are unchanged (with one
|
|
9
|
+
exception, noted after the buffer paragraph below).
|
|
10
|
+
|
|
11
|
+
The range buffers are allocated with the field and reused each frame. Calling
|
|
12
|
+
`contourEvaluate()` invalidates the ranges; direct level extraction falls back
|
|
13
|
+
to the full scan until `contourExtract()` prepares matching bounds.
|
|
14
|
+
|
|
15
|
+
> Since v1.1.6 the sampling STEP may coarsen on very large canvases
|
|
16
|
+
> (`contourStepFor()` / `CONTOUR_MAX_CELLS`), and the block layout follows
|
|
17
|
+
> `contourGeom.step` rather than a hard-coded 6. Every ordinary window still
|
|
18
|
+
> samples at the shipped 6px grid, which is what the comparison below covers.
|
|
19
|
+
|
|
20
|
+
Run `npm run test:bounds` for complete coordinate-array comparisons against a
|
|
21
|
+
forced full scan, including partial blocks, equality, plateaus and saddle cells.
|
|
22
|
+
The existing browser render, smoothness, coverage and performance runners remain
|
|
23
|
+
applicable. CPU extraction measurements do not establish GPU presentation FPS or
|
|
24
|
+
video dropped-frame improvements.
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# Optional mouse trail
|
|
2
|
+
|
|
3
|
+
Enable the contour background, its animation, and **Mouse trail** in the theme
|
|
4
|
+
settings. The persisted `contourTrail` string defaults to `'0'`; `'1'` enables a
|
|
5
|
+
local deformation that follows the mouse and fades. Chinese and English labels
|
|
6
|
+
follow the host locale. Touch and pen input do not produce a trail.
|
|
7
|
+
|
|
8
|
+
The idea and bounded decay model are adapted from the Endfield Glass plugin.
|
|
9
|
+
This port integrates into the current upstream Canvas pipeline and preserves
|
|
10
|
+
the original ambient field, smoothing, contour levels and curve drawing.
|
|
11
|
+
|
|
12
|
+
## Cost and lifecycle
|
|
13
|
+
|
|
14
|
+
- Reuses the existing contour animation loop and selected FPS. It consumes only
|
|
15
|
+
the latest pointer event per field frame, with 8 ms / 2 CSS px admission gates.
|
|
16
|
+
- The pointer handler only stores coordinates and timestamps. A frame reads the
|
|
17
|
+
host rectangle once when consuming a pending point, not on every pointer event
|
|
18
|
+
or streaming DOM mutation. Stored coordinates never leave page memory.
|
|
19
|
+
- At most 24 samples, a 900 ms exponential decay constant and 2700 ms lifetime.
|
|
20
|
+
Head quota is .9; older samples share a fixed .6 geometric tail budget. Expiry
|
|
21
|
+
cannot renormalize or brighten remaining samples. Only bounded neighborhoods
|
|
22
|
+
around samples receive field contributions.
|
|
23
|
+
- Smooth Gaussian contributions are added after the ambient smoothing/temporal
|
|
24
|
+
blend. They never enter ambient history, so expiry leaves no temporal ghost.
|
|
25
|
+
This port uses a 28 CSS px kernel; it does not claim pixel identity with the
|
|
26
|
+
Glass plugin's raw-field overlay followed by spatial smoothing.
|
|
27
|
+
- Static mode, reduced motion, hidden pages, scrolling (when pause is enabled)
|
|
28
|
+
and the startup loader suspend sampling and clear deformation. Resize, blur,
|
|
29
|
+
disabling and disposal also clear history. Mouse leave drops the pending event
|
|
30
|
+
while already drawn samples decay normally.
|
|
31
|
+
- Disabling removes mouse listeners. Unmount/disposal also removes visibility,
|
|
32
|
+
blur and media-query listeners. No second timer or animation loop is added.
|
|
33
|
+
|
|
34
|
+
This branch targets current upstream main independently of the proposed scan,
|
|
35
|
+
Worker/WebGL and glass PRs. Combining it with a Worker renderer requires carrying
|
|
36
|
+
the bounded samples and frame clock into that renderer's frame messages before
|
|
37
|
+
contour extraction; main-thread state must not be read inside a Worker.
|
|
38
|
+
|
|
39
|
+
## Validation
|
|
40
|
+
|
|
41
|
+
`npm run test:trail` runs dependency-free Node checks for bounded history,
|
|
42
|
+
timestamps, local support, monotonic decay, fixed total weight and expiry.
|
|
43
|
+
|
|
44
|
+
`npm run test:trail-browser` uses Chrome/Edge and Node 22+ (the same Node major
|
|
45
|
+
used by CI), with an isolated temporary browser profile. A controlled animation
|
|
46
|
+
clock and fixed terrain seed compare real Canvas pixels against a trail-off
|
|
47
|
+
control: idle and expired trails yield exactly the control image, while an active
|
|
48
|
+
mouse sample visibly deforms it. It also checks pointer-handler layout reads,
|
|
49
|
+
static mode, live reduced-motion changes, visibility/scroll pause, repeated
|
|
50
|
+
enable/disable and complete listener/canvas cleanup. This is not an FPS test.
|
|
51
|
+
|
|
52
|
+
The existing settings tests cover the default, disabled UI state, persisted
|
|
53
|
+
camelCase key and rereading that preference. Both new tests join `test:ci`.
|
|
54
|
+
|
|
55
|
+
Local validation (2026-09-19, Windows Chrome / Node 24.12): the new browser and
|
|
56
|
+
four logic checks pass. The final complete CI run passed 23 of 24 scripts; the
|
|
57
|
+
existing random-layout speck/coverage test reported one sparse region among five
|
|
58
|
+
random layouts. Its isolated rerun passed all five layouts. The original terrain
|
|
59
|
+
generator, coverage scorer, ambient evaluator, level extractor and curve painter
|
|
60
|
+
were also compared with the base commit and are unchanged. The initial random
|
|
61
|
+
failure is recorded rather than presented as an entirely green single CI run.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Optional Worker / WebGL contours
|
|
2
|
+
|
|
3
|
+
`contourRenderer` defaults to `canvas`, retaining the original rendering path.
|
|
4
|
+
Select **Worker / WebGL** in the contour settings to compute and draw the same
|
|
5
|
+
terrain in a dedicated Worker using a transferred OffscreenCanvas. WebGL2 batches
|
|
6
|
+
the smoothed curve segments in a single instanced draw. Canvas2D in the worker is
|
|
7
|
+
the fallback when WebGL2 is unavailable. Unsupported workers, transfer failure,
|
|
8
|
+
render timeouts, message errors or context loss fall back to the main Canvas2D
|
|
9
|
+
path on a fresh canvas; a transferred canvas is never reused for getContext.
|
|
10
|
+
|
|
11
|
+
The worker source is generated from the exact build/evaluate/extract/draw
|
|
12
|
+
functions in client.js, preserving field generation, smoothing, phase policy,
|
|
13
|
+
level filters, stroke colors and DPR. The GPU painter approximates cubic curves
|
|
14
|
+
within 0.04 backing pixels (with a bounded subdivision depth), so antialiasing
|
|
15
|
+
is not claimed to be pixel-identical to Canvas2D. No external URL, CDN, eval or
|
|
16
|
+
runtime dependency is used; a local Blob contains the embedded worker source.
|
|
17
|
+
|
|
18
|
+
The queue has one in-flight job plus at most one latest pending job. Pending
|
|
19
|
+
geometry work survives a later paint-only update. Hidden pages stop submitting
|
|
20
|
+
work; static/reduced-motion/scroll policies retain the existing switches.
|
|
21
|
+
Teardown terminates the worker, revokes its Blob URL and removes its canvas.
|
|
22
|
+
Failure is latched until the backend preference changes, preventing retry loops.
|
|
23
|
+
|
|
24
|
+
The contour wrapper exposes `data-endfield-renderer` (starting, worker-webgl2,
|
|
25
|
+
worker-canvas2d or main-canvas2d) and an explanatory fallback reason attribute.
|
|
26
|
+
CPU/worker completion rate is not display FPS; external video dropped frames
|
|
27
|
+
and total GPU cost require separate measurement on the target hardware.
|
|
28
|
+
|
|
29
|
+
## Developing
|
|
30
|
+
|
|
31
|
+
- `npm run build:worker`: regenerate the embedded source after kernel edits.
|
|
32
|
+
- `npm run check:worker`: fail if the embedded source is stale.
|
|
33
|
+
- `npm run test:worker`: real Chrome test (Node 22+, `CHROME_PATH` supported).
|
|
34
|
+
|
|
35
|
+
The browser test checks the actual backend, paused/static behavior, visibility
|
|
36
|
+
handler, injected message failure with a fresh-canvas fallback, explicit retry,
|
|
37
|
+
repeated enable/disable and final teardown. The temporary profile contains only
|
|
38
|
+
fixture data. The legacy CI suite continues to validate the default backend.
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
# 设计语言
|
|
2
|
+
|
|
3
|
+
本文是这套主题的设计说明:**颜色是什么、为什么是这个值、落在哪个界面角色上**。想拿它当设计语言学习入口的,读这一篇就够。
|
|
4
|
+
|
|
5
|
+
工程实现细节在 [engineering-notes.md](engineering-notes.md),测试在 [testing.md](testing.md)。
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 一、核心概念:工业编辑风
|
|
10
|
+
|
|
11
|
+
终末地官网的视觉不是「深色科技感」,而是**印刷编辑风**:一张有质感的纸、压在上面的墨黑字、以及一个用来做信号的高饱和色。三条规则贯穿全篇:
|
|
12
|
+
|
|
13
|
+
1. **纸与墨是主体,强调色是信号。** 强调色只用于「需要被看见的那一处」——按钮、悬停、选中行、焦点环——而不是大面积铺色。
|
|
14
|
+
2. **全直角。** 圆角会把界面推向「柔和产品」的观感;直角把它推向「技术文档 / 工程图纸」。只有形状本身是圆的(状态点、头像、加载圈)才保留圆形。
|
|
15
|
+
3. **数字等宽。** 开启 `tnum`,让表格、耗时、百分比在跳动时不产生横向抖动。
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## 二、色板
|
|
20
|
+
|
|
21
|
+
### 中性色(纸 / 墨 / 线)
|
|
22
|
+
|
|
23
|
+
两套模式共用同一套语义,只换取值。
|
|
24
|
+
|
|
25
|
+
| 角色 | 令牌 | 亮色 | 暗色 |
|
|
26
|
+
| --- | --- | --- | --- |
|
|
27
|
+
| 纸底(应用背景、侧栏) | `--dsw-alias-bg-base` | `#e8e8e2` | `#101110` |
|
|
28
|
+
| 面板 / 气泡 | `--dsw-alias-bg-layer-1` | `#f2f2ec` | `#181a18` |
|
|
29
|
+
| 沉底块 | `--dsw-alias-bg-layer-2` | `#dcddd6` | `#1e201d` |
|
|
30
|
+
| 浮层(菜单、弹层) | `--dsw-alias-bg-overlay` | `#f2f2ec` | `#1c1e1c` |
|
|
31
|
+
| 细线 | `--dsw-alias-border-l1` | `#d8d9d5` | `#343633` |
|
|
32
|
+
| 重线 | `--dsw-alias-border-l2` | `#b6b8b3` | `#4a4d49` |
|
|
33
|
+
| 正文 | `--dsw-alias-label-primary` | `#101110` | `#f5f5f0` |
|
|
34
|
+
| 次要文字 | `--dsw-alias-label-secondary` | `#4a4c48` | `#898d89` |
|
|
35
|
+
|
|
36
|
+
亮色不用纯白 `#fff`、暗色不用纯黑 `#000`:`#e8e8e2` 带一点暖灰,是「纸」而不是「屏幕」;`#101110` 留一点绿倾向,避免深灰界面常见的死黑。
|
|
37
|
+
|
|
38
|
+
### 强调色:五套配色
|
|
39
|
+
|
|
40
|
+
设置页「主题配色」是一个下拉菜单,五套配色一次列全:**谷地黄 / 武陵青 / 重燃赤 / 浸蓝 / 基石蓝**,选中的就是当前生效的那一套,默认谷地黄。
|
|
41
|
+
|
|
42
|
+
三套颜色时它还是循环按钮——点一下换下一套,按钮写着「下一次点击得到哪一个」。第四套进来时这个控件就不成立了:一次点击只能往一个方向挪一格,想从浸蓝回到谷地黄要点三下,而且按钮回答的是「下一套是什么」而不是「有哪几套」——用户得自己在脑子里排这个环。换下拉之后选项列表就是答案本身,跨套直选一次到位,选中项即当前配色,不需要从上一状态推断。第五套只是又加了一行 `<option>`:控件形态在第四套时就已经付过这次改造成本了。
|
|
43
|
+
|
|
44
|
+
| 配色 | 强调色 | 相对亮度 | 说明 |
|
|
45
|
+
| --- | --- | --- | --- |
|
|
46
|
+
| **谷地黄**(默认) | `#fff500` | 86.6% | 终末地官网的信号黄 |
|
|
47
|
+
| **武陵青** | `#14d0d0` | 49.8% | 青碧色 |
|
|
48
|
+
| **重燃赤** | `#ff3b2e` | 24.6% | 危机合约 / 重燃测试作战 KV 的战役红 |
|
|
49
|
+
| **浸蓝** | `#7d6fff` | 22.9% | 危机合约 / 浸蓝测试作战 KV 的蓝,沿色相提亮到能当芯片 |
|
|
50
|
+
| **基石蓝** | `#4b93ff` | 29.6% | The Foundation 圣所 KV 的电光蓝(issue #46),背景大字随之改为 THE FOUNDATION |
|
|
51
|
+
|
|
52
|
+
存储字段 `palette`(UI/存储键 `dsh-theme-endfield-palette`,由 `PREFS_KEY_TO_FIELD` 映射),取值 `valley` / `wuling` / `ember` / `abyss` / `foundation`。只有这几个精确值选中对应配色,未设置或异常值都回落到默认。
|
|
53
|
+
|
|
54
|
+
亮度从 86.6% 一路降到 22.9%。**谷地黄与武陵青有向下移动的余量**(悬停压深一档仍压得住墨字),所以它们的悬停是压深;**重燃赤与浸蓝没有**(同样的下压落差会让墨字掉到 3.99:1,悬停态直接不可读),所以它们是「点燃」而不是「压深」。基石蓝落在边界上:下压档(ΔL* -6.6)还能到 4.95:1,**不是不能压,只是只剩 0.45 的余量**,而原画里会发光的那一支蓝本来就只往亮处长——它于是也跟着提亮。这不是风格不一致,是同一套对比度规则在不同亮度色相上推出来的不同结论——三组数字见[下文](#红与蓝为什么悬停要变亮)。
|
|
55
|
+
|
|
56
|
+
### 语义状态色
|
|
57
|
+
|
|
58
|
+
不参与配色切换——错误就该是红的。
|
|
59
|
+
|
|
60
|
+
| 角色 | 亮色 | 暗色 |
|
|
61
|
+
| --- | --- | --- |
|
|
62
|
+
| 错误 | `#ff3b30` | `#ff6b61` |
|
|
63
|
+
| 成功 | `#2f9e44` | `#4fbf5c` |
|
|
64
|
+
| 警告 | `#d9822b` | `#ffb700` |
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## 三、强调色的派生角色
|
|
69
|
+
|
|
70
|
+
一个强调色不够用。同一个色在不同表面上需要不同的取值,这些派生量在样式表里都是 CSS 变量,**声明在 `body` 上**(原因见[工程笔记](engineering-notes.md#变量必须声明在-body-而不是-root))。
|
|
71
|
+
|
|
72
|
+
| 变量 | 谷地黄 | 武陵青 | 重燃赤 | 浸蓝 | 基石蓝 | 用途 |
|
|
73
|
+
| --- | --- | --- | --- | --- | --- | --- |
|
|
74
|
+
| `--edge-accent` | `#fff500` | `#14d0d0` | `#ff3b2e` | `#7d6fff` | `#4b93ff` | 实心底、图标、焦点环、光标 |
|
|
75
|
+
| `--edge-accent-rgb` | `255, 245, 0` | `20, 208, 208` | `255, 59, 46` | `125, 111, 255` | `75, 147, 255` | 约 30 处 `rgba(var(--edge-accent-rgb), α)` 半透明色块 |
|
|
76
|
+
| `--edge-accent-deep` | `#e8e000` | `#10b8b8` | `#ff5f4d` | `#8e82ff` | `#7ab2ff` | 悬停 / 按下(重燃赤、浸蓝与基石蓝是**提亮**,见下) |
|
|
77
|
+
| `--edge-accent-onpaper` | `#d9c700` | `#14d0d0` | `#b01f14` | `#2831cc` | `#1b3fb0` | 亮色模式「作填充压在纸上」的槽位;重燃赤配纸白字,浸蓝这一档就是原画蓝 |
|
|
78
|
+
| `--edge-status-light` | `#6b5d00` | `#006a6a` | `#b01f14` | `#2831cc` | `#1b3fb0` | 亮色模式回合状态文字(0.2 经 `--dsw-alias-label-deep-diving` 生效) |
|
|
79
|
+
| `--edge-status-light-mid` | `#3f3600` | `#003f3f` | `#7a1109` | `#121a72` | `#0b2a74` | 亮色模式流光亮带(0.2 经 `--dsw-alias-label-deep-diving-shimmer` 生效) |
|
|
80
|
+
| `--edge-status-dark` | `#fff500` | `#14d0d0` | `#ff3b2e` | `#7d6fff` | `#4b93ff` | 暗色模式回合状态文字(同上) |
|
|
81
|
+
| `--edge-status-dark-mid` | `#a08a00` | `#7ee7e7` | `#ff7a55` | `#c6bfff` | `#a9c6ff` | 暗色模式流光亮带(同上) |
|
|
82
|
+
| `--edge-glow-light` | `0.08` | `0.08` | `0.06` | `0.08` | `0.08` | hero 背景光晕透明度 |
|
|
83
|
+
| `--edge-glow-dark` | `0.05` | `0.04` | `0.10` | `0.10` | `0.085` | 同上,暗色 |
|
|
84
|
+
|
|
85
|
+
重燃赤另有一个 `--edge-danger: #7c1414`,只在它自己这一套里定义(原因见[下文](#重燃赤下拒绝不是主信号红));其余四套沿用应用自己的错误红。
|
|
86
|
+
|
|
87
|
+
### 为什么亮色模式的强调色要「下沉」
|
|
88
|
+
|
|
89
|
+
这是最容易踩的一条。**在奶油纸底上,`#fff500` 不是一种配色选择,而是一次抹除**——黄色文字压在纸底上只有 1.07:1(面板 `#f2f2ec` 上更低,1.02:1),完全不可见。同理青色也过不了:`#14d0d0` 在纸底上仅 1.56:1。
|
|
90
|
+
|
|
91
|
+
所以亮色模式里凡是「强调色作为文字」的地方,都换成同一色相的**深色档**:
|
|
92
|
+
|
|
93
|
+
- 谷地黄 → `#6b5d00`(5.35:1,亮色下第一个达标的金)
|
|
94
|
+
- 武陵青 → `#006a6a`(5.22:1)
|
|
95
|
+
- 重燃赤 → `#b01f14`(5.59:1;原色在纸上只有 2.89:1)
|
|
96
|
+
- 浸蓝 → `#2831cc`(7.11:1;提亮档在纸上只有 3.05:1,只能当填充)
|
|
97
|
+
- 基石蓝 → `#1b3fb0`(7.16:1;`#4b93ff` 在纸上只有 2.47:1)
|
|
98
|
+
|
|
99
|
+
在纸上,`#007070` 以上的青都过不了双底 AA——这是**纸的属性**,不是强调色亮度的问题,所以武陵青提亮后这两个值完全没变。红同理:`#ff3b2e` 在纸上只能当色块(3.16:1),当字必须落一档。蓝是唯一反过来的一套:强调色在暗色模式里要往上抬才看得见,到了纸上却已经太亮,于是落回**原画那支蓝**——五套里只有浸蓝的亮色档不是「新发明」,而是 KV 本来的值。(基石蓝也落在纸上更深的蓝,但方向相反:它本来就是从更亮的 `#6eb9ff` 降下来的,纸面档是继续降。)
|
|
100
|
+
|
|
101
|
+
而暗色模式方向相反:底是近黑,强调色本身就够亮,直接用原色。
|
|
102
|
+
|
|
103
|
+
### 为什么暗色的「亮带」方向不一致
|
|
104
|
+
|
|
105
|
+
回合状态标签(0.1.x 是渐变流光文字,0.2 是遮罩扫光文字,见[工程笔记](engineering-notes.md#四类回合状态标签))中间有一条亮带扫过字形。
|
|
106
|
+
|
|
107
|
+
- 谷地黄的亮带是**压暗**的 `#a08a00`——黄色向上已经到顶,再亮就成白色。
|
|
108
|
+
- 武陵青的亮带是**提亮**的 `#7ee7e7`——青色在这个亮度向下的余量比黄色小,更深的青(`#0a7d7d`)只有 3.54:1 不达标。
|
|
109
|
+
- 重燃赤的亮带也是**提亮**的 `#ff7a55`(6.81:1)——红在 `#ff3b2e` 以下几乎没有余量,任何更深的红都会跌破 AA。
|
|
110
|
+
- 浸蓝的亮带同样**提亮**到 `#c6bfff`(10.25:1)——靛蓝在 `#7d6fff` 以下也一样没有余量。
|
|
111
|
+
- 基石蓝的亮带取 **`#a9c6ff`**(10.18:1)——这不是新发明的淡蓝,而是同一张 KV 里那圈高光(`#6eb9ff` / `#cecee5`)的去饱和版本。
|
|
112
|
+
|
|
113
|
+
同一个规则(AA 4.5:1),两个相反的方向。这类「不能照抄」的地方是本主题最主要的复杂度来源。
|
|
114
|
+
|
|
115
|
+
### 武陵青为什么是 `#14d0d0`
|
|
116
|
+
|
|
117
|
+
初版用了 `#0daaaa`,相对亮度只有 31.7%——不到谷地黄(86.6%)的四成,在近黑页面上存在感明显弱一截。`#14d0d0` 保持同一条色轴(R 低、G = B,仍是青碧而非灰青),亮度提高到 49.8%。
|
|
118
|
+
|
|
119
|
+
上界同样有约束:到 `#16dcdc` 时,亮色模式下色块与纸底只剩 1.39:1(现行 1.56:1),开始「融进纸里」,而且那么浅的青读起来偏白。**`#14d0d0` 是两种模式下都还站得住的最亮一档。**
|
|
120
|
+
|
|
121
|
+
这两条边界写成了断言(亮度下限 45%、上限 56%、必须留在青碧色轴上)。
|
|
122
|
+
|
|
123
|
+
### 浸蓝为什么不是 KV 里那个蓝
|
|
124
|
+
|
|
125
|
+
浸蓝测试作战的 KV 里,那支蓝是 `#0a06d0`——整幅铺底、字大到以米计。它的相对亮度只有 4.7%,压在 `#101110` 上 **1.76:1**:作为海报的地,它成立;作为一行 28px 的芯片,它消失。这正是初版武陵青踩过的坑,只是深了一个数量级。
|
|
126
|
+
|
|
127
|
+
所以强调色是**同一支色相沿亮度轴抬起来**的那一档:`#7d6fff`(L* 26 → 55)。五套配色里它的位移最大,也是唯一把原画色相整支抬起、几乎不保留原画亮度的一套(基石蓝是反方向的同一件事:色相留下,亮度往下调)——测试把色相钉成断言(B 主导且 R > G),因为它和应用自己的皇家蓝 `#4d6bfe`(hue 229,G > R)只差十几度,一旦漂过去,整套主题就会读成「没装主题」。
|
|
128
|
+
|
|
129
|
+
反过来,暗色模式里它仍是最暗的一套:22.9% 的亮度压在近黑上,芯片靠的是色相而不是亮度,所以它的等高线描边要 0.38 的 alpha 才够到和其他配色一样的 1.7:1——与重燃赤的 0.40 同属表里最高的一档。
|
|
130
|
+
|
|
131
|
+
### 红与蓝为什么悬停要「变亮」
|
|
132
|
+
|
|
133
|
+
谷地黄与武陵青的悬停档都是加深:`#fff500 → #e8e000`、`#14d0d0 → #10b8b8`,因为它们在墨字下都有充足余量。红与蓝没有:把同样的观感落差落到 `#e02317` 与 `#6c5cf0`,墨字只剩 **3.99:1**——两套配色、两个色相、同一个数字,因为它们的亮度都压在 AA 的下沿附近。再深一点只会更糟,而「深到能看出区别」和「浅到能压住墨字」之间没有交集。
|
|
134
|
+
|
|
135
|
+
所以这两档都改成点燃:红 `#ff5f4d`(6.30:1,24.6% → 30.0%)、蓝 `#8e82ff`(6.12:1,22.9% → 28.9%),差别看得见。`--edge-accent-deep` 这个名字在别处被当成「更深」使用,这两处是有意的例外,测试里钉成方向断言(两套各一条),防止后人「统一一下」把它们改回去。
|
|
136
|
+
|
|
137
|
+
### 重燃赤下「拒绝」不是主信号红
|
|
138
|
+
|
|
139
|
+
审批白条的两个按钮:确认拿强调色,拒绝拿应用的错误红 `#ff3b30`。在重燃赤里这两个值几乎是同一支红(`#ff3b2e` / `#ff3b30`),并排时肉眼无法区分——而它们恰恰是最不能点错的一对。
|
|
140
|
+
|
|
141
|
+
所以这一套配色下危险动作落到**沉血** `#7c1414`(骨白字 9.76:1),悬停再深一档 `#5f0d09`。它与主信号同属红色家族,但明度差足够在余光里分开。规则用 `body.theme-endfield-ember` 限定,其余四套照旧使用应用的错误红;`palette-switch.test.js` 会注入应用那份错误红令牌再量两个色块,确认它们不同色。
|
|
142
|
+
|
|
143
|
+
### 基石蓝:从高光里取色,顺手把背景大字改了名
|
|
144
|
+
|
|
145
|
+
第五套配色来自 [issue #46](https://github.com/ymh0000123/dsh-theme-endfield/issues/46)。附带的 KV 是七个人物站在翼骨圣所前,整幅压在 `#000008` – `#181828` 的蓝黑里。那张图里有**两支蓝**,选哪一支就是这套配色的全部设计:
|
|
146
|
+
|
|
147
|
+
| 来源 | 值 | 色相 | 为什么用 / 不用 |
|
|
148
|
+
| --- | --- | --- | --- |
|
|
149
|
+
| 长袍 / 场地蓝 | `#2a3cd2` | 234 | 画面里饱和度最高的一块,但压在本套的近黑上只有 1.8:1——和浸蓝的 `#0a06d0` 同一个失效方式;而且它离浸蓝的强调色只差 12 度,做出来会是一套「和第四套分不清」的配色 |
|
|
150
|
+
| 圣所高光蓝 | `#6eb9ff` | 208 | 视线的落点,也是画面里唯一在发光的东西 |
|
|
151
|
+
|
|
152
|
+
所以强调色是**高光那一支**,沿自己的色相**往下**收到能压住墨字为止:`#6eb9ff`(L* 72)→ `#4b93ff`(L* 61,墨字 6.23:1)。这是五套里唯一一套强调色比取样色更暗的配色;另外四套都是往上抬。色相落在 216,既在 KV 自己的 208–234 区间内,也离应用自己的皇家蓝 `#4d6bfe`(229,G < R)足够远——测试把「B 主导且 G 明显高于 R」钉成断言,因为一旦漂到 229 那一带,整套主题就会读成「没装主题」。
|
|
153
|
+
|
|
154
|
+
**背景大字。** 提 issue 的人还要求:如果加了这套,希望背景里那行字写 The Foundation 而不是 Endfield。这条没有做成全局设置,也没有写第二份 `::before` 规则,而是把字本身变成变量:
|
|
155
|
+
|
|
156
|
+
```css
|
|
157
|
+
body { --edge-wordmark: 'ENDFIELD'; --edge-wordmark-size: 9.5vw; }
|
|
158
|
+
body.theme-endfield-foundation { --edge-wordmark: 'THE FOUNDATION'; --edge-wordmark-size: 5.3vw; }
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
字号必须跟着字走,否则宽的那一行会在画布边缘被切掉。5.3vw 不是估的:`ENDFIELD` 在 9.5vw + 0.1em 字距下排出来是 5.70em 宽,而 13 个字符的 `THE FOUNDATION` 是 10.24em,两者等宽解出 5.30vw。实拍对照(同一视口):`ENDFIELD` 占 305–960px,`THE FOUNDATION` 占 305–955px。
|
|
162
|
+
|
|
163
|
+
范围刻意只管**背景水印**。启动加载屏的 `END / FIELD` 字组保持原样——它是这个主题包自己的品牌落款,不是背景装饰;跟着配色改名会让「装的是终末地主题」这件事在每次刷新时被抹掉一次。
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
## 四、对比度规则
|
|
168
|
+
|
|
169
|
+
**每个角色都要对它实际落在的表面验算,不达标就构建失败。** `test/palette-contrast.test.js` 覆盖全部 85 项。
|
|
170
|
+
|
|
171
|
+
| 角色 | 谷地黄 | 武陵青 | 重燃赤 | 浸蓝 | 基石蓝 | 门槛 |
|
|
172
|
+
| --- | --- | --- | --- | --- | --- | --- |
|
|
173
|
+
| 实心强调底 + 墨色字 | 16.50:1 | 9.88:1 | 5.33:1 | 5.04:1 | 6.23:1 | AA 4.5 |
|
|
174
|
+
| 悬停档底 + 墨色字 | 13.60:1 | 7.72:1 | 6.30:1 | 6.12:1 | 8.69:1 | AA 4.5 |
|
|
175
|
+
| 暗色图标 / 链接强调色 | 15.26:1 | 9.14:1 | 4.93:1 | 4.66:1 | 5.76:1 | ≥3(文字 ≥4.5) |
|
|
176
|
+
| 回合状态·亮色主色 | 5.35:1 | 5.22:1 | 5.59:1 | 7.11:1 | 7.16:1 | AA 4.5 |
|
|
177
|
+
| 回合状态·亮色亮带 | 9.82:1 | 9.58:1 | 8.93:1 | 12.05:1 | 10.69:1 | AA 4.5 |
|
|
178
|
+
| 回合状态·暗色主色 | 15.26:1 | 9.14:1 | 4.93:1 | 4.66:1 | 5.76:1 | AA 4.5 |
|
|
179
|
+
| 回合状态·暗色亮带 | 5.11:1 | 12.06:1 | 6.81:1 | 10.25:1 | 10.18:1 | AA 4.5 |
|
|
180
|
+
|
|
181
|
+
暗色「图标」那一行对重燃赤、浸蓝与基石蓝同时是**文字**的下限(4.93 / 4.66 / 5.76):回合状态的流光文字读的就是这个值,所以 3:1 的图标门槛在这三套上不适用。
|
|
182
|
+
|
|
183
|
+
三条附加规则:
|
|
184
|
+
|
|
185
|
+
- **回合状态要对两种底色都达标**(`bg-base` 与 `bg-layer-1`),因为亮带会扫过字形;0.1.x 的渐变文字在 `prefers-reduced-motion` 下被上游把 `background-size` 钉成 100%,那条亮带会**永久留在**字里,0.2 的遮罩扫光同样要把两个令牌都按「会压在字形上」来取值。
|
|
186
|
+
- **每套新配色的等高线合成对比度都以谷地黄为基准,相差 ≤20%**:相同 alpha ≠ 相同存在感,所以 alpha 按「合成后对比度对齐」分别调参,而不是照抄。浸蓝用的是 0.38,重燃赤 0.40——低亮度的两套都落在表里最高的一档,因为它们的描边色本身带不了多少亮度。基石蓝反过来是最轻的一档(暗色 0.33、亮色 0.13):它是五套里最亮的强调色,同样的存在感用不着那么重的描边。
|
|
187
|
+
- **hero 光晕只许更轻,不许更响**:判据是单侧的——比它替换的 `#6187D8` @8% 更安静永远可接受。
|
|
188
|
+
|
|
189
|
+
> **装饰性表面的对比度描述的是「有多抢眼」,不是可读性。** 水印永远在正文之后,等高线在所有内容之下,它们的对比度数值用来控制干扰强度。经验下限约 `1.06:1`,低于此形同不存在。
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
## 五、令牌映射:中和残留品牌蓝
|
|
194
|
+
|
|
195
|
+
DSH 自带 DeepSeek 品牌蓝。主题把这些令牌整组重映射,否则会在纸墨界面里留下零散的蓝点。
|
|
196
|
+
|
|
197
|
+
| 令牌组 | 处理 |
|
|
198
|
+
| --- | --- |
|
|
199
|
+
| `--dsw-static-deepseek-50…900` | 整组换成中性灰阶(亮色为纸阶,暗色为墨阶) |
|
|
200
|
+
| `--dsw-static-deepseek-450` | 亮色 → `--edge-accent-onpaper`,暗色 → `--edge-accent` |
|
|
201
|
+
| `--dsw-static-deepseek-500/600` | → 墨 / 纸色(**不可动**,见下) |
|
|
202
|
+
| `--dsw-alias-button-info-fill` | 亮色 → 墨黑,暗色 → 强调色 |
|
|
203
|
+
| `--dsw-alias-state-business-primary` | 同上 |
|
|
204
|
+
| `--dsw-specific-sidebar-nav-item-active-accent` | 同上 |
|
|
205
|
+
| `--dsw-alias-label-primary-bluish` | → 正文色 |
|
|
206
|
+
| `--dsw-specific-bubble` / `-highlight` | → 面板 / 沉底块 |
|
|
207
|
+
|
|
208
|
+
`--dsw-static-deepseek-500/200` 是**共享令牌**:同时支撑 `button-info-fill`、`state-business-primary` 与 `bubble-highlight`。要改回合状态标签的颜色时不能动它们,只能覆盖那条规则自己的 `background-image`。
|
|
209
|
+
|
|
210
|
+
### 强调色交互一览
|
|
211
|
+
|
|
212
|
+
| 表面 | 声明 |
|
|
213
|
+
| --- | --- |
|
|
214
|
+
| 文本选中 | `::selection { color:#000; background: var(--edge-accent) }` |
|
|
215
|
+
| 输入光标 | `caret-color: var(--edge-accent)` |
|
|
216
|
+
| 焦点环 | `outline: 2px solid var(--edge-accent)`,`offset: 1px` |
|
|
217
|
+
| 滚动条 | 轨道透明,滑块 `--edge-line`,悬停 `--edge-accent` |
|
|
218
|
+
| 链接悬停 | 下划线着色;暗色模式下文字也变强调色 |
|
|
219
|
+
| 表格行悬停 | 实心强调底 + 墨色字 |
|
|
220
|
+
| 半透明色块 | `rgba(var(--edge-accent-rgb), α)`,亮色 α 略低于暗色 |
|
|
221
|
+
|
|
222
|
+
亮色与暗色的 α 不同:**在近黑底上叠加亮度,比在纸底上减去亮度显得响得多**。同一个 α 在暗色下更吵,所以暗色的半透明块普遍取更高的 α(因为强调色本身在暗色下要更突出),而装饰性图层(水印)在暗色下反而要**降低** α。
|
|
223
|
+
|
|
224
|
+
---
|
|
225
|
+
|
|
226
|
+
## 六、直角化怎么实现
|
|
227
|
+
|
|
228
|
+
直角不是逐个组件改,而是**先全部清零,再恢复该圆的**:
|
|
229
|
+
|
|
230
|
+
```css
|
|
231
|
+
body:not(.theme-endfield-round) [class] { border-radius: 0 !important; }
|
|
232
|
+
body:not(.theme-endfield-round) [class*='avatar'],
|
|
233
|
+
body:not(.theme-endfield-round) [class*='spinner'],
|
|
234
|
+
body:not(.theme-endfield-round) [class*='dot'],
|
|
235
|
+
body:not(.theme-endfield-round) [class$='_iconButton'] { border-radius: 50% !important; }
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
用 `[class]` 而非 `*`,避免命中无类名的结构性节点;用 `body:not(.theme-endfield-round)` 作前缀,让「主题圆角」开关只是 `<body>` 上加减一个 class,不需要重新注册样式表。
|
|
239
|
+
|
|
240
|
+
---
|
|
241
|
+
|
|
242
|
+
## 七、配色切换是一个 class
|
|
243
|
+
|
|
244
|
+
整份样式表里所有强调色都读**调色板变量**,所以切换配色只是 `<body>` 上加减一个 class:不重新注册令牌层、不重算样式、无 JS 重绘。
|
|
245
|
+
|
|
246
|
+
这一点能成立依赖一个事实:**应用是把主题令牌写成 `<body>` 的行内样式的**(`dsh-client-ui-layout` 对每个令牌调 `body.style.setProperty`)。因此主题把 `--dsw-alias-brand-primary` 的暗色值声明为 `var(--edge-accent)`,该令牌就随 class 自动重解析。
|
|
247
|
+
|
|
248
|
+
唯一需要 JS 介入的表面是**等高线画布**——canvas 描边不能是 CSS 变量,所以它由一个监听 `<body>` class 的 `MutationObserver` 触发重绘(顺带让「别的标签页改了配色」也能跟着变)。
|
|
249
|
+
|
|
250
|
+
配色切换后的实测像素占比(`test/tools/verify-shots.js` 解码真实截图统计):
|
|
251
|
+
|
|
252
|
+
| 截图 | 黄色像素 | 青色像素 |
|
|
253
|
+
| --- | --- | --- |
|
|
254
|
+
| 谷地黄 · 亮色 | **5.47%** | 0.44% |
|
|
255
|
+
| 武陵青 · 亮色 | 0.39% | **6.51%** |
|
|
256
|
+
| 谷地黄 · 暗色 | **2.51%** | 0.42% |
|
|
257
|
+
| 武陵青 · 暗色 | 0.34% | **5.40%** |
|
|
258
|
+
|
|
259
|
+
约 93% 的中性像素(纸底、墨字、边框)在两版之间基本不变——切换只动强调色。
|
|
260
|
+
|
|
261
|
+
---
|
|
262
|
+
|
|
263
|
+
## 八、可复用的几条经验
|
|
264
|
+
|
|
265
|
+
如果只带走几句话:
|
|
266
|
+
|
|
267
|
+
1. **颜色是量出来的,不是挑出来的。** 每个色值都对它实际落在的表面算过对比度;不达标的写法(哪怕看起来「就该是这个颜色」)一律改掉。
|
|
268
|
+
2. **同一个色在亮/暗模式下往往需要相反的处理。** 亮色下沉、暗色提亮,或者反过来,取决于该色相在那个亮度还剩多少余量。
|
|
269
|
+
3. **「装饰」和「前景」用两套标准。** 前景守 AA 4.5:1;装饰守「不抢眼但可见」的区间(约 1.06 ~ 1.6:1)。
|
|
270
|
+
4. **主题令牌自身可以是 `var()` 引用。** 这是把「换配色」从一次重绘降级成一次 class 切换的关键。
|
|
271
|
+
5. **底色归主题、文字归应用 = 裂缝。** 只接管背景令牌而不接管前景,会造出「白字压在黄底上」这类 1.05:1 的不可见组合。改一个背景令牌时,要一起检查谁在上面写字。
|
|
272
|
+
|
|
273
|
+
---
|
|
274
|
+
|
|
275
|
+
## 九、微调层与配色层的关系
|
|
276
|
+
|
|
277
|
+
配色(谷地黄 / 武陵青 / 重燃赤 / 浸蓝 / 基石蓝)回答的是「这套界面长成什么形状」——一键、成体系、每个色值都量过。
|
|
278
|
+
第七组设置「调整」回答的是另一个问题:**「我想要这个形状,但某一处颜色想不一样」**。两者刻意分层:
|
|
279
|
+
|
|
280
|
+
1. **默认从属。** 每个可调角色默认存空串 / `100`,语义是「跟随主题」;此时配色 class 是唯一决定者,切换配色的行为与之前逐像素一致。
|
|
281
|
+
2. **覆盖即接管。** 一旦某个角色被设了颜色,它就由内联变量(强调色 / 光标 / 焦点环 / 水印)或重注册的令牌层(墨 / 纸 / 描边)接管,**不再跟随配色切换**;重置才交还。这是有意的:微调若是「相对配色偏移」,用户换配色后看到的颜色就不是自己选的那个。
|
|
282
|
+
3. **派生关系仍成立。** 强调色的 hover 步(`-deep`)与「在奶油纸上当填充」的步(`-onpaper`)取自被选颜色,而不是写死的旧值——填充与 hover 永远属于同一色族。
|
|
283
|
+
4. **亮度是通道缩放,不是 HSL 提亮。** 60–140% 在通道上乘一个系数并夹到 0–255;对纯色相(如信号黄)表现为变暗,对中间调表现为整体浓淡,行为可预测且不需要色相空间。
|
|
284
|
+
5. **对比度不再有保证。** 微调允许把强调色压到 60% 不透明度——那是用户的显式选择;所以「文字墨色 / 纸底色」也开放了独立调节,让人能把对比度调回来。
|
|
285
|
+
6. **不透明度的作用面是「该角色画出来的那个颜色」**,不是整个版面:`--edge-accent-rgb` 供 ~30 处 wash 使用,它们跟随色相但保有自己的设计透明度,避免一个滑条把整页都变淡。
|