@alexpeng/dsh-custom-plugin 0.10.0 → 0.12.0
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/CHANGELOG.md +92 -0
- package/NOTICE +17 -44
- package/README.i18n.yaml +2 -2
- package/README.md +7 -4
- package/README.zh.md +7 -4
- package/lib/client.js +10390 -3808
- package/lib/client.js.map +1 -1
- package/lib/index.js +41 -13
- package/lib/types/client/bg-focus.d.ts +23 -6
- package/lib/types/client/bg-layer.d.ts +7 -32
- package/lib/types/client/bg-params.d.ts +19 -9
- package/lib/types/client/bg-scene.d.ts +170 -0
- package/lib/types/client/bg-shader.d.ts +103 -265
- package/lib/types/client/palette.d.ts +2 -0
- package/lib/types/client/styles.d.ts +1 -1
- package/lib/types/client/ui/appearance-controls.d.ts +1 -0
- package/lib/types/protocol.d.ts +32 -19
- package/package.json +4 -2
- package/lib/types/balance.d.ts +0 -44
- package/lib/types/client/bg-ascii.d.ts +0 -397
- package/lib/types/client/bg-field.d.ts +0 -60
- package/lib/types/client/bg-ocean.d.ts +0 -31
- package/lib/types/client/bg-pointer.d.ts +0 -107
- package/lib/types/client/bg-wake.d.ts +0 -57
|
@@ -1,287 +1,132 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* WebGL2 light-and-shadow backdrop, built on Paper Shaders.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
4
|
+
* The shader tier used to be a hand-written full-screen triangle per style.
|
|
5
|
+
* It is now a thin wrapper around `@paper-design/shaders` (Apache-2.0,
|
|
6
|
+
* https://github.com/paper-design/shaders): each preset is one of their
|
|
7
|
+
* audited fragment shaders, mounted through `ShaderMount`, which owns the
|
|
8
|
+
* WebGL2 context, DPR/size handling, visibility pausing and teardown.
|
|
9
9
|
*
|
|
10
|
-
* The
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
10
|
+
* The page tint (`--vx-bg-tint`) is the shader's background colour, so a
|
|
11
|
+
* palette/theme flip keeps the page hue and only moves the ink. The calm zone
|
|
12
|
+
* is a CSS `mask-image` built from the same geometry as the scene tier
|
|
13
|
+
* (`bg-focus.ts`), and the user's 浓度 knob is the wrapper's opacity: the
|
|
14
|
+
* field fades toward the tint without the shader being recompiled.
|
|
15
15
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* never runs a frame loop, so it deliberately ignores both — a static speck
|
|
20
|
-
* field that reacts to the mouse would not be static any more.
|
|
21
|
-
*
|
|
22
|
-
* Styles are self-declared static or animated. A style that does not depend on
|
|
23
|
-
* `u_time` draws one frame and never schedules rAF; the caller never has to
|
|
24
|
-
* sniff pixels to discover that (readPixels would force a sync far more
|
|
25
|
-
* expensive than the frame it saves).
|
|
16
|
+
* A missing WebGL2 context makes `createShaderBackdrop` return null; the
|
|
17
|
+
* caller then falls back to the character tier, exactly like the old WebGL1
|
|
18
|
+
* gate did.
|
|
26
19
|
* @module @alexpeng/dsh-custom-plugin/client/bg-shader
|
|
27
20
|
*/
|
|
28
|
-
import {
|
|
29
|
-
import { type
|
|
30
|
-
/** Every shader style id.
|
|
31
|
-
|
|
32
|
-
|
|
21
|
+
import type { ShaderMountUniforms } from '@paper-design/shaders';
|
|
22
|
+
import { FOCUS_FEATHER_PX, FOCUS_FLOOR, type BgFocusRect } from './bg-focus.ts';
|
|
23
|
+
/** Every shader style id. Each one is a different Paper Shaders fragment
|
|
24
|
+
* shader, not one field with different knobs. */
|
|
25
|
+
export type ShaderStyle = 'mesh' | 'smoke' | 'rays' | 'dither' | 'grain' | 'warp' | 'swirl';
|
|
26
|
+
/** Inclusive numeric bounds for the settings panel. */
|
|
33
27
|
export interface ShaderRange {
|
|
34
28
|
readonly min: number;
|
|
35
29
|
readonly max: number;
|
|
36
30
|
}
|
|
37
|
-
/** Writable bounds per style
|
|
31
|
+
/** Writable bounds per style. */
|
|
38
32
|
export interface ShaderStyleRanges {
|
|
39
33
|
readonly speed: ShaderRange;
|
|
40
|
-
readonly density: ShaderRange;
|
|
41
34
|
readonly intensity: ShaderRange;
|
|
42
|
-
readonly
|
|
43
|
-
readonly fps: ShaderRange;
|
|
35
|
+
readonly opacity: ShaderRange;
|
|
44
36
|
}
|
|
45
|
-
/** Tunables of one style. `animated: false` means
|
|
46
|
-
*
|
|
37
|
+
/** Tunables of one style. `animated: false` means the shader only draws when
|
|
38
|
+
* a uniform changes; Paper's mount handles the rAF stop for speed 0. */
|
|
47
39
|
export interface ShaderStyleSpec {
|
|
48
40
|
readonly speed: number;
|
|
49
|
-
readonly density: number;
|
|
50
41
|
readonly intensity: number;
|
|
51
|
-
readonly
|
|
52
|
-
readonly fps: number;
|
|
42
|
+
readonly opacity: number;
|
|
53
43
|
readonly animated: boolean;
|
|
54
|
-
/** Per-style multiplier on the theme's base ΔL (see `inkFor`). The user's
|
|
55
|
-
* soft/standard/strong strength choice multiplies this again. */
|
|
56
|
-
readonly inkScale: number;
|
|
57
44
|
readonly ranges: ShaderStyleRanges;
|
|
58
45
|
}
|
|
59
|
-
/**
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
* a fine, static film grain with a soft edge falloff. Both derive their ink
|
|
63
|
-
* from the surface brightness, so they work on light, dark and every palette.
|
|
64
|
-
*/
|
|
46
|
+
/** The five shipped styles. `mesh` is the default: a soft, low-contrast field
|
|
47
|
+
* that leaves the copy alone; `dither` is the most graphic one. Defaults are
|
|
48
|
+
* the browser-harness values (1280×822, tint-matched colours, mask on). */
|
|
65
49
|
export declare const SHADER_STYLES: Record<ShaderStyle, ShaderStyleSpec>;
|
|
66
|
-
/**
|
|
67
|
-
|
|
50
|
+
/** Default style for the shader tier. */
|
|
51
|
+
export declare const DEFAULT_SHADER: ShaderStyle;
|
|
52
|
+
/** Resolve a stored id to a style; ASCII ids and unknown strings fall back. */
|
|
68
53
|
export declare function resolveShaderStyle(preset: string | undefined): ShaderStyle;
|
|
69
|
-
/** Panel overrides
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
*/
|
|
78
|
-
export
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
readonly
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
readonly
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
* is the same contract the ASCII canvas honours with its surface fill.
|
|
104
|
-
*/
|
|
105
|
-
export declare const SHADER_FRAGMENT_SOURCE: Record<ShaderStyle, string>;
|
|
106
|
-
/** Numeric values handed to the GPU for one draw. Plain data so the uniform
|
|
107
|
-
* mapping is unit-testable without a GL context. */
|
|
108
|
-
export interface ShaderUniformValues {
|
|
109
|
-
time: number;
|
|
110
|
-
width: number;
|
|
111
|
-
height: number;
|
|
112
|
-
dpr: number;
|
|
113
|
-
surface: [number, number, number];
|
|
114
|
-
ink: [number, number, number];
|
|
115
|
-
speed: number;
|
|
116
|
-
density: number;
|
|
117
|
-
intensity: number;
|
|
118
|
-
seed: number;
|
|
119
|
-
/** `[x, y, w, h]` in CSS px; `w <= 0` disables the mask. */
|
|
120
|
-
focus: [number, number, number, number];
|
|
121
|
-
focusFeather: number;
|
|
122
|
-
focusFloor: number;
|
|
123
|
-
/** `[x, y, active, speed]` in CSS px; `active <= 0` disables the eddy. */
|
|
124
|
-
pointer: [number, number, number, number];
|
|
125
|
-
/** `[x, y, age, active]` in CSS px; `active <= 0` disables the ring. */
|
|
126
|
-
pulse: [number, number, number, number];
|
|
127
|
-
}
|
|
128
|
-
/** One pointer sample for the shader. `speed` is 0..1 (already normalised). */
|
|
129
|
-
export interface ShaderPointerInput {
|
|
130
|
-
x: number;
|
|
131
|
-
y: number;
|
|
132
|
-
active: boolean;
|
|
133
|
-
speed: number;
|
|
134
|
-
}
|
|
135
|
-
/** One press sample for the shader; `age` is seconds since the press. */
|
|
136
|
-
export interface ShaderPulseInput {
|
|
137
|
-
x: number;
|
|
138
|
-
y: number;
|
|
139
|
-
age: number;
|
|
140
|
-
}
|
|
141
|
-
/** How long a press ring is allowed to expand, in seconds. */
|
|
142
|
-
export declare const SHADER_PULSE_LIFE = 2.6;
|
|
143
|
-
/** Inputs for {@link shaderUniforms}; `dark` is derived from the surface. */
|
|
144
|
-
export interface ShaderUniformInput {
|
|
145
|
-
time: number;
|
|
146
|
-
width: number;
|
|
147
|
-
height: number;
|
|
148
|
-
dpr: number;
|
|
149
|
-
spec: ShaderStyleSpec;
|
|
150
|
-
surface: string;
|
|
151
|
-
/** Multiplier applied by the degradation ladder (L2). */
|
|
152
|
-
densityScale?: number;
|
|
153
|
-
/** Reading-column calm zone from the appearance painter. */
|
|
154
|
-
focus?: BgFocusRect | null;
|
|
155
|
-
/** Live pointer sample; absent means "no eddy". */
|
|
156
|
-
pointer?: ShaderPointerInput | null;
|
|
157
|
-
/** Live press sample; absent or expired means "no ring". */
|
|
158
|
-
pulse?: ShaderPulseInput | null;
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* Map runtime state onto the uniform contract. Visibility time is clamped at
|
|
162
|
-
* zero; resolution is CSS pixels (never backing pixels); dpr honours the same
|
|
163
|
-
* 2× cap as the ASCII tier; density and the other knobs stay inside the
|
|
164
|
-
* documented ranges even if a future panel or a hand-edited state file writes
|
|
165
|
-
* something else. The ink is `inkFor(surface, dark)` so both tiers use exactly
|
|
166
|
-
* the same lightness delta.
|
|
167
|
-
*/
|
|
168
|
-
export declare function shaderUniforms(input: ShaderUniformInput): ShaderUniformValues;
|
|
169
|
-
/** The GL call surface this renderer uses (kept structural for tests). */
|
|
170
|
-
export interface ShaderGL {
|
|
171
|
-
readonly VERTEX_SHADER: number;
|
|
172
|
-
readonly FRAGMENT_SHADER: number;
|
|
173
|
-
readonly COMPILE_STATUS: number;
|
|
174
|
-
readonly LINK_STATUS: number;
|
|
175
|
-
readonly ARRAY_BUFFER: number;
|
|
176
|
-
readonly STATIC_DRAW: number;
|
|
177
|
-
readonly FLOAT: number;
|
|
178
|
-
readonly TRIANGLES: number;
|
|
179
|
-
readonly COLOR_BUFFER_BIT: number;
|
|
180
|
-
createShader(type: number): object | null;
|
|
181
|
-
shaderSource(shader: object, source: string): void;
|
|
182
|
-
compileShader(shader: object): void;
|
|
183
|
-
getShaderParameter(shader: object, pname: number): boolean;
|
|
184
|
-
getShaderInfoLog(shader: object): string | null;
|
|
185
|
-
deleteShader(shader: object): void;
|
|
186
|
-
createProgram(): object | null;
|
|
187
|
-
attachShader(program: object, shader: object): void;
|
|
188
|
-
linkProgram(program: object): void;
|
|
189
|
-
getProgramParameter(program: object, pname: number): boolean;
|
|
190
|
-
getProgramInfoLog(program: object): string | null;
|
|
191
|
-
deleteProgram(program: object): void;
|
|
192
|
-
useProgram(program: object | null): void;
|
|
193
|
-
createBuffer(): object | null;
|
|
194
|
-
bindBuffer(target: number, buffer: object | null): void;
|
|
195
|
-
bufferData(target: number, data: Float32Array, usage: number): void;
|
|
196
|
-
deleteBuffer(buffer: object): void;
|
|
197
|
-
getAttribLocation(program: object, name: string): number;
|
|
198
|
-
enableVertexAttribArray(index: number): void;
|
|
199
|
-
vertexAttribPointer(index: number, size: number, type: number, normalized: boolean, stride: number, offset: number): void;
|
|
200
|
-
getUniformLocation(program: object, name: string): object | null;
|
|
201
|
-
uniform1f(location: object | null, value: number): void;
|
|
202
|
-
uniform2f(location: object | null, x: number, y: number): void;
|
|
203
|
-
uniform3f(location: object | null, x: number, y: number, z: number): void;
|
|
204
|
-
uniform4f(location: object | null, x: number, y: number, z: number, w: number): void;
|
|
205
|
-
viewport(x: number, y: number, width: number, height: number): void;
|
|
206
|
-
drawArrays(mode: number, first: number, count: number): void;
|
|
207
|
-
clearColor(r: number, g: number, b: number, a: number): void;
|
|
208
|
-
clear(mask: number): void;
|
|
209
|
-
getExtension(name: string): unknown;
|
|
210
|
-
getParameter(pname: number): unknown;
|
|
211
|
-
}
|
|
212
|
-
/** WebGL context attributes the spec fixes. */
|
|
213
|
-
export interface ShaderContextAttributes {
|
|
214
|
-
readonly alpha: boolean;
|
|
215
|
-
readonly antialias: boolean;
|
|
216
|
-
readonly depth: boolean;
|
|
217
|
-
readonly stencil: boolean;
|
|
218
|
-
readonly powerPreference: 'low-power';
|
|
219
|
-
}
|
|
220
|
-
/** The canvas surface this renderer owns. */
|
|
221
|
-
export interface ShaderCanvasLike {
|
|
222
|
-
width: number;
|
|
223
|
-
height: number;
|
|
224
|
-
className: string;
|
|
225
|
-
style: {
|
|
226
|
-
width: string;
|
|
227
|
-
height: string;
|
|
228
|
-
};
|
|
229
|
-
getContext(contextId: 'webgl', attributes?: ShaderContextAttributes): ShaderGL | null;
|
|
230
|
-
addEventListener(type: 'webglcontextlost', listener: (event: ShaderContextLostEvent) => void): void;
|
|
231
|
-
removeEventListener(type: 'webglcontextlost', listener: (event: ShaderContextLostEvent) => void): void;
|
|
232
|
-
remove(): void;
|
|
233
|
-
}
|
|
234
|
-
/** The only context-loss field this renderer reads. */
|
|
235
|
-
export interface ShaderContextLostEvent {
|
|
236
|
-
preventDefault(): void;
|
|
237
|
-
}
|
|
238
|
-
/** The host element (`div#vx-bg`) as this renderer sees it. */
|
|
54
|
+
/** Panel overrides; every value is clamped into the style's own ranges. */
|
|
55
|
+
export interface ShaderParams {
|
|
56
|
+
readonly speed?: number;
|
|
57
|
+
readonly intensity?: number;
|
|
58
|
+
readonly opacity?: number;
|
|
59
|
+
/** Ink-strength multiplier from `BG_STRENGTH_SCALE`. */
|
|
60
|
+
readonly strength?: number;
|
|
61
|
+
}
|
|
62
|
+
/** Resolved values after merging overrides with the style defaults. */
|
|
63
|
+
export interface ShaderResolved {
|
|
64
|
+
readonly speed: number;
|
|
65
|
+
readonly intensity: number;
|
|
66
|
+
readonly opacity: number;
|
|
67
|
+
readonly strength: number;
|
|
68
|
+
}
|
|
69
|
+
export declare function resolveShaderSpec(style: ShaderStyle, params: ShaderParams): ShaderResolved;
|
|
70
|
+
/** The colour set one shader field is built from. All colours are derived from
|
|
71
|
+
* the page tint and the theme's ink, so the palette never turns neon. */
|
|
72
|
+
export interface ShaderPalette {
|
|
73
|
+
readonly back: string;
|
|
74
|
+
readonly ink: string;
|
|
75
|
+
readonly soft: string;
|
|
76
|
+
readonly mid: string;
|
|
77
|
+
readonly deep: string;
|
|
78
|
+
}
|
|
79
|
+
/** Blend two `#rrggbb` colours; `t = 0` is `a`, `t = 1` is `b`. */
|
|
80
|
+
export declare function mixHex(a: string, b: string, t: number): string;
|
|
81
|
+
/** Theme-aware colours for the shader tier. `strength` scales how far the
|
|
82
|
+
* field colours travel from the tint toward the ink. */
|
|
83
|
+
export declare function shaderPalette(tint: string, dark: boolean, strength: number): ShaderPalette;
|
|
84
|
+
/** Build one style's uniform set. Exported so a test can pin the mapping
|
|
85
|
+
* between the panel's 强度 knob and each shader's own parameter. */
|
|
86
|
+
export declare function shaderUniformsFor(style: ShaderStyle, palette: ShaderPalette, intensity: number): ShaderMountUniforms;
|
|
87
|
+
/** Host element (`div#vx-bg`) as the shader wrapper sees it. */
|
|
239
88
|
export interface ShaderHostLike {
|
|
240
89
|
readonly clientWidth: number;
|
|
241
90
|
readonly clientHeight: number;
|
|
242
91
|
getAttribute(name: string): string | null;
|
|
243
|
-
appendChild(node:
|
|
92
|
+
appendChild(node: ShaderElementLike): unknown;
|
|
244
93
|
style: {
|
|
245
94
|
getPropertyValue(name: string): string;
|
|
246
95
|
};
|
|
247
96
|
}
|
|
97
|
+
/** Wrapper element created inside the host. */
|
|
98
|
+
export interface ShaderElementLike {
|
|
99
|
+
readonly clientWidth: number;
|
|
100
|
+
readonly clientHeight: number;
|
|
101
|
+
style: Record<string, string>;
|
|
102
|
+
remove(): void;
|
|
103
|
+
}
|
|
248
104
|
/** The slice of `Document` this renderer touches. */
|
|
249
105
|
export interface ShaderDocLike {
|
|
250
|
-
createElement(tag: string):
|
|
251
|
-
addEventListener(type: 'visibilitychange', listener: () => void): void;
|
|
252
|
-
removeEventListener(type: 'visibilitychange', listener: () => void): void;
|
|
253
|
-
readonly hidden: boolean;
|
|
106
|
+
createElement(tag: string): ShaderElementLike;
|
|
254
107
|
}
|
|
255
|
-
/**
|
|
256
|
-
|
|
257
|
-
readonly matches: boolean;
|
|
258
|
-
addEventListener(type: 'change', listener: () => void): void;
|
|
259
|
-
removeEventListener(type: 'change', listener: () => void): void;
|
|
260
|
-
}
|
|
261
|
-
/** The slice of `ResizeObserver` this renderer touches. */
|
|
262
|
-
export interface ShaderResizeObserverLike {
|
|
263
|
-
observe(target: unknown): void;
|
|
264
|
-
disconnect(): void;
|
|
265
|
-
}
|
|
266
|
-
/** The slice of `Window` this renderer touches. Pointer listeners are optional
|
|
267
|
-
* so a minimal test window without them still boots the tier (the eddy is
|
|
268
|
-
* simply inert there). */
|
|
108
|
+
/** Kept for the appearance painter's structural typing; the mount owns window
|
|
109
|
+
* access, so only the pixel ratio is read here. */
|
|
269
110
|
export interface ShaderWinLike {
|
|
270
|
-
readonly devicePixelRatio
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
}
|
|
284
|
-
/**
|
|
111
|
+
readonly devicePixelRatio?: number;
|
|
112
|
+
}
|
|
113
|
+
/** Backing-store pixel cap for the shader tier. A page background does not
|
|
114
|
+
* need the full 8.3M default; 4M keeps 1920×1080 crisp while roughly halving
|
|
115
|
+
* the fill cost on high-DPR screens. */
|
|
116
|
+
export declare const SHADER_MAX_PIXELS = 4000000;
|
|
117
|
+
/** Clamp the renderer's DPR to the device's own ratio (max 2×). Forcing 2× on
|
|
118
|
+
* a 1×/1.25× display only wastes fill rate for a soft background. */
|
|
119
|
+
export declare function resolveShaderDpr(win: ShaderWinLike): number;
|
|
120
|
+
/** The slice of a canvas event target the context-loss watcher needs. */
|
|
121
|
+
export interface ContextLossTarget {
|
|
122
|
+
addEventListener(type: string, listener: (event: Event) => void): void;
|
|
123
|
+
removeEventListener(type: string, listener: (event: Event) => void): void;
|
|
124
|
+
}
|
|
125
|
+
/** Watch for a lost GPU context. The handler prevents the browser's automatic
|
|
126
|
+
* restore (Paper's mount does not reinitialise its resources) and reports once;
|
|
127
|
+
* the returned function detaches the listener. */
|
|
128
|
+
export declare function attachContextLoss(target: ContextLossTarget, onLost: () => void): () => void;
|
|
129
|
+
/** Observable renderer state. */
|
|
285
130
|
export interface ShaderBackdropStats {
|
|
286
131
|
level: number;
|
|
287
132
|
width: number;
|
|
@@ -290,7 +135,6 @@ export interface ShaderBackdropStats {
|
|
|
290
135
|
alive: boolean;
|
|
291
136
|
contextLost: boolean;
|
|
292
137
|
style: ShaderStyle;
|
|
293
|
-
/** Actual back-end string from `WEBGL_debug_renderer_info`, when exposed. */
|
|
294
138
|
renderer: string | null;
|
|
295
139
|
}
|
|
296
140
|
/** Options accepted by {@link createShaderBackdrop}. */
|
|
@@ -299,31 +143,25 @@ export interface ShaderBackdropOptions {
|
|
|
299
143
|
win: ShaderWinLike;
|
|
300
144
|
host: ShaderHostLike;
|
|
301
145
|
style?: ShaderStyle;
|
|
302
|
-
/** Panel overrides for the boot style; clamps to its `ranges`. */
|
|
303
146
|
params?: ShaderParams;
|
|
304
|
-
/** Called once when the GPU drops this context
|
|
305
|
-
*
|
|
147
|
+
/** Called once when the GPU drops this context; the caller falls back to the
|
|
148
|
+
* character tier. Paper's mount does not recover on its own. */
|
|
306
149
|
onFallback?: (reason: 'context-lost') => void;
|
|
307
150
|
}
|
|
308
151
|
/** Handle owned by the appearance painter. */
|
|
309
152
|
export interface ShaderBackdrop {
|
|
310
153
|
sync(): void;
|
|
311
|
-
/** Rebuild the
|
|
312
|
-
* the
|
|
154
|
+
/** Rebuild the mount for another style. False means WebGL2 creation failed
|
|
155
|
+
* and the caller should fall back to the character tier. */
|
|
313
156
|
setStyle(style: ShaderStyle): boolean;
|
|
314
|
-
/** Replace the panel overrides for the current style. Values are clamped
|
|
315
|
-
* into that style's `ranges`; a style switch keeps the overrides and
|
|
316
|
-
* re-clamps them. Repaints immediately so a dragging slider is visible. */
|
|
317
157
|
setParams(params: ShaderParams): void;
|
|
318
158
|
/** Move the calm zone (the reading column); `null` disables the mask. */
|
|
319
159
|
setFocus(rect: BgFocusRect | null): void;
|
|
320
160
|
destroy(): void;
|
|
321
161
|
readonly stats: ShaderBackdropStats;
|
|
322
162
|
}
|
|
323
|
-
/**
|
|
324
|
-
* Create the shader backdrop and attach its canvas. Returns null when WebGL1
|
|
325
|
-
* is unavailable or the program does not compile; in that case the canvas is
|
|
326
|
-
* removed and no context is left alive, and the caller falls back to ASCII and
|
|
327
|
-
* tells the user.
|
|
328
|
-
*/
|
|
163
|
+
/** Create the shader tier. Returns null when WebGL2 is unavailable. */
|
|
329
164
|
export declare function createShaderBackdrop(options: ShaderBackdropOptions): ShaderBackdrop | null;
|
|
165
|
+
/** Re-exported so the panel can mention the calm-zone constants without
|
|
166
|
+
* importing the focus module twice. */
|
|
167
|
+
export { FOCUS_FEATHER_PX, FOCUS_FLOOR };
|
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
* 天青灰 leads the list: it is the install default and renders first among
|
|
14
14
|
* the palette swatches, right after 无颜色. */
|
|
15
15
|
export declare const PALETTE: Array<[string, string, string]>;
|
|
16
|
+
/** A surface counts as dark below this weighted brightness (0..255). */
|
|
17
|
+
export declare function isDarkSurface(hex: string): boolean;
|
|
16
18
|
/** Parse a #rrggbb (or bare rrggbb) hex color; malformed input yields the
|
|
17
19
|
* palette's neutral gray rather than throwing. */
|
|
18
20
|
export declare function hexToRgb(hex: string): [number, number, number];
|