WorkbenchBackdrop.tsx
6.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
/**
* 工作台右下角底图(纯装饰:aria-hidden + pointer-events:none,无状态)。
*
* 视觉语言与登录页 uj-login-coverage 同源——透视纵深点阵、链节点虚线、
* 以基站为心的扫描弧与双层环、青绿脉冲核——配色从登录页的深空反转为
* 浅底上的品牌蓝低透明度水印:贴合登录页主题,又不压过内容卡片,
* 只在右侧与下部的空白处透出来。
* 固定坐标 + 固定种子伪随机(分布一致、非真实数据);脉冲动画尊重
* prefers-reduced-motion(见 design.css 的 .uj-wb-pulse)。
*/
const W = 640;
const H = 520;
const HORIZON = 74; // 远处地平线 y
const NEAR = 498; // 近处地面 y
const VP = { x: 300, y: HORIZON - 6 }; // 消失点
const BASE = { x: 462, y: 428 }; // 近景基站(右下,贴工作台空白区)
const AXIS_TOP = { x: 252, y: 106 }; // 链节点纵深起点
function makeRand(seed: number) {
let s = seed % 233280;
return () => {
s = (s * 9301 + 49297) % 233280;
return s / 233280;
};
}
const rand = makeRand(73);
const lerp = (a: number, b: number, t: number) => a + (b - a) * t;
type Dot = { x: number; y: number; r: number; op: number };
// 透视点阵:4 排 × 8 列,约 55% 保留;越近越大越亮,整体压低做背景层
const DOTS: Dot[] = (() => {
const out: Dot[] = [];
const rows = [0.16, 0.4, 0.64, 0.88];
const cols = [-0.8, -0.58, -0.36, -0.14, 0.1, 0.32, 0.54, 0.76];
for (const t of rows) {
const pp = Math.pow(t, 0.82);
const y = lerp(HORIZON, NEAR, pp);
const spread = lerp(60, 300, pp);
for (const c of cols) {
if (rand() < 0.55) {
out.push({
x: VP.x + c * spread + (rand() - 0.5) * 14,
y: y + (rand() - 0.5) * 8,
r: lerp(0.9, 2.6, t),
op: lerp(0.07, 0.2, t),
});
}
}
}
return out;
})();
// 链节点:沿纵深逐级放大/提亮,末端不重复(那里是基站)
const CHAIN = Array.from({ length: 4 }, (_, i) => {
const pp = Math.pow((i + 1) / 5, 0.82);
return {
x: lerp(AXIS_TOP.x, BASE.x, pp),
y: lerp(AXIS_TOP.y, BASE.y, pp),
r: lerp(1.2, 4, pp),
op: lerp(0.14, 0.4, pp),
};
});
const CHAIN_DASH = [...CHAIN.slice(-2), { x: BASE.x, y: BASE.y }];
// 2 道扫描弧:以基站为心向上展开,两端渐隐由 stroke 渐变承担
const ARCS = [150, 224].map((r) => {
const a0 = Math.PI * 1.05;
const a1 = Math.PI * 1.95;
return {
r,
d: `M ${BASE.x + r * Math.cos(a0)} ${BASE.y + r * Math.sin(a0)} A ${r} ${r} 0 0 1 ${BASE.x + r * Math.cos(a1)} ${BASE.y + r * Math.sin(a1)}`,
};
});
// 2 条极淡经线:从近处地面两侧收向消失点
const MERIDIANS = [-0.62, 0.62].map((lx) => ({
x1: VP.x + lx * 300,
y1: NEAR,
x2: VP.x,
y2: VP.y,
}));
// 上方留白区 6 颗极淡星点
const STARS = Array.from({ length: 6 }, () => ({
x: 40 + rand() * (W - 80),
y: 14 + rand() * (HORIZON * 0.5),
r: 0.7 + rand() * 0.9,
op: 0.08 + rand() * 0.08,
}));
const CORE_R = 4.5; // 青绿脉冲/实心核半径
export function WorkbenchBackdrop() {
return (
<div className="uj-wb-backdrop" aria-hidden="true">
<svg
viewBox={`0 0 ${W} ${H}`}
width="100%"
height="auto"
preserveAspectRatio="xMidYMax meet"
focusable="false"
>
<defs>
{/* 大光场:以基站为心,中心 0.12 → 边缘 0 */}
<radialGradient id="ujWbFocus" cx="50%" cy="50%" r="50%">
<stop offset="0%" stopColor="#2b5ce6" stopOpacity="0.12" />
<stop offset="55%" stopColor="#2b5ce6" stopOpacity="0.05" />
<stop offset="100%" stopColor="#2b5ce6" stopOpacity="0" />
</radialGradient>
{/* 基站中层辉光 */}
<radialGradient id="ujWbGlow" cx="50%" cy="50%" r="50%">
<stop offset="0%" stopColor="#5b8def" stopOpacity="0.18" />
<stop offset="100%" stopColor="#5b8def" stopOpacity="0" />
</radialGradient>
{/* 经线垂直渐隐:远处化掉不形成硬线 */}
<linearGradient id="ujWbMeridian" x1="0" y1="0" x2="0" y2="1">
<stop offset="0%" stopColor="#2b5ce6" stopOpacity="0.1" />
<stop offset="100%" stopColor="#2b5ce6" stopOpacity="0" />
</linearGradient>
</defs>
{/* 明暗底层:以基站为心的大光场 */}
<ellipse cx={BASE.x} cy={BASE.y - 30} rx={330} ry={250} fill="url(#ujWbFocus)" />
{/* 2 道扫描弧(两端渐隐) */}
<g fill="none" stroke="#2b5ce6" strokeWidth="1">
{ARCS.map((arc) => (
<path key={arc.r} d={arc.d} strokeOpacity="0.1" />
))}
</g>
{/* 2 条极淡经线收向消失点 */}
<g fill="none" stroke="url(#ujWbMeridian)" strokeWidth="0.8">
{MERIDIANS.map((m, i) => (
<line key={i} x1={m.x1} y1={m.y1} x2={m.x2} y2={m.y2} />
))}
</g>
{/* 背景点阵:近大远小、近亮远淡 */}
<g fill="#2b5ce6">
{DOTS.map((dot, i) => (
<circle key={i} cx={dot.x} cy={dot.y} r={dot.r} fillOpacity={dot.op} />
))}
</g>
{/* 链节点虚线:末段渐淡接入基站 */}
<g fill="none" stroke="#5b8def" strokeWidth="1.1" strokeDasharray="4 5" strokeLinecap="round">
{CHAIN_DASH.slice(1).map((c, i) => (
<line
key={i}
x1={CHAIN_DASH[i].x}
y1={CHAIN_DASH[i].y}
x2={c.x}
y2={c.y}
strokeOpacity={i === 1 ? 0.12 : 0.2}
/>
))}
</g>
{/* 链节点 */}
<g fill="#5b8def">
{CHAIN.map((c, i) => (
<circle key={i} cx={c.x} cy={c.y} r={c.r} fillOpacity={c.op} />
))}
</g>
{/* 基站:大光场 + 辉光 + 双层环 + 青绿脉冲 + 实心核 */}
<g>
<circle cx={BASE.x} cy={BASE.y} r={96} fill="url(#ujWbGlow)" />
<circle cx={BASE.x} cy={BASE.y} r={44} fill="none" stroke="#2b5ce6" strokeOpacity="0.16" strokeWidth="1.1" />
<circle cx={BASE.x} cy={BASE.y} r={25} fill="none" stroke="#2b5ce6" strokeOpacity="0.26" strokeWidth="1.2" />
<circle
className="uj-wb-pulse"
cx={BASE.x}
cy={BASE.y}
r={CORE_R}
fill="none"
stroke="#2de2c4"
strokeWidth="1.2"
vectorEffect="non-scaling-stroke"
/>
<circle cx={BASE.x} cy={BASE.y} r={CORE_R} fill="#1fe0c8" fillOpacity="0.8" />
</g>
{/* 上方 6 颗极淡星点 */}
<g fill="#2b5ce6">
{STARS.map((star, i) => (
<circle key={i} cx={star.x} cy={star.y} r={star.r} fillOpacity={star.op} />
))}
</g>
</svg>
</div>
);
}