@burdenoff/fe-libs 2026.1118.4 → 2026.1118.5
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/dist/platform-pages/AppearanceSettingsPage.d.ts +9 -13
- package/dist/platform-pages/AppearanceSettingsPage.js +7 -4
- package/dist/platform-pages/index.d.ts +1 -1
- package/dist/shared/assistant/home/AssistantHomePage.d.ts +29 -1
- package/dist/shared/assistant/home/AssistantHomePage.js +63 -36
- package/dist/shared/assistant/home/AssistantHomeStart.d.ts +12 -0
- package/dist/shared/assistant/home/AssistantHomeStart.js +24 -15
- package/dist/shared/assistant/home.js +5 -5
- package/dist/shared/backgrounds/BackgroundEffect.d.ts +7 -0
- package/dist/shared/backgrounds/BackgroundEffect.js +24 -0
- package/dist/shared/backgrounds/BackgroundPicker.d.ts +49 -0
- package/dist/shared/backgrounds/BackgroundPicker.js +133 -0
- package/dist/shared/backgrounds/BackgroundRoot.d.ts +13 -0
- package/dist/shared/backgrounds/BackgroundRoot.js +44 -0
- package/dist/shared/backgrounds/CursorWave.d.ts +19 -0
- package/dist/shared/backgrounds/CursorWave.js +40 -0
- package/dist/shared/backgrounds/DottedWaves.d.ts +20 -0
- package/dist/shared/backgrounds/DottedWaves.js +36 -0
- package/dist/shared/backgrounds/Glimmer.d.ts +18 -0
- package/dist/shared/backgrounds/Glimmer.js +38 -0
- package/dist/shared/backgrounds/backgroundGround.d.ts +5 -0
- package/dist/shared/backgrounds/backgroundGround.js +16 -0
- package/dist/shared/backgrounds/backgroundTypes.d.ts +38 -0
- package/dist/shared/backgrounds/backgroundTypes.js +20 -0
- package/dist/shared/backgrounds/canvasEffect.d.ts +51 -0
- package/dist/shared/backgrounds/canvasEffect.js +97 -0
- package/dist/shared/backgrounds/color.d.ts +56 -0
- package/dist/shared/backgrounds/color.js +153 -0
- package/dist/shared/backgrounds/cursorWavePool.d.ts +7 -0
- package/dist/shared/backgrounds/cursorWavePool.js +14 -0
- package/dist/shared/backgrounds/cursorWaveRenderer.d.ts +43 -0
- package/dist/shared/backgrounds/cursorWaveRenderer.js +146 -0
- package/dist/shared/backgrounds/dottedWavesRenderer.d.ts +72 -0
- package/dist/shared/backgrounds/dottedWavesRenderer.js +176 -0
- package/dist/shared/backgrounds/glimmerRenderer.d.ts +65 -0
- package/dist/shared/backgrounds/glimmerRenderer.js +254 -0
- package/dist/shared/backgrounds/index.d.ts +31 -0
- package/dist/shared/backgrounds/noise.d.ts +19 -0
- package/dist/shared/backgrounds/noise.js +143 -0
- package/dist/shared/backgrounds/originalPalettes.d.ts +36 -0
- package/dist/shared/backgrounds/originalPalettes.js +24 -0
- package/dist/shared/backgrounds/useBackgroundColors.d.ts +40 -0
- package/dist/shared/backgrounds/useBackgroundColors.js +165 -0
- package/dist/shared/backgrounds/useBackgroundPreference.d.ts +26 -0
- package/dist/shared/backgrounds/useBackgroundPreference.js +109 -0
- package/dist/shared-assistant.js +79 -79
- package/dist/shared-backgrounds.d.ts +2 -0
- package/dist/shared-backgrounds.js +16 -0
- package/package.json +9 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CursorWaveColor } from './cursorWaveRenderer';
|
|
2
|
+
/** A colour in a pool given as props: a CSS colour, or a two-stop gradient (top → bottom). */
|
|
3
|
+
export type CursorWaveColorInput = string | {
|
|
4
|
+
stops: readonly [string, string];
|
|
5
|
+
};
|
|
6
|
+
/** A pool from props, resolved (unreadable entries are left out; none left: null). */
|
|
7
|
+
export declare function explicitPool(pool: readonly CursorWaveColorInput[]): readonly CursorWaveColor[] | null;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { readColor as e } from "./color.js";
|
|
2
|
+
// src/shared/backgrounds/cursorWavePool.ts
|
|
3
|
+
function t(t) {
|
|
4
|
+
let n = [];
|
|
5
|
+
for (let r of t) if (typeof r == "string") {
|
|
6
|
+
let t = e(r);
|
|
7
|
+
t && n.push(t);
|
|
8
|
+
} else {
|
|
9
|
+
let t = e(r.stops[0]), i = e(r.stops[1]);
|
|
10
|
+
t && i && n.push({ stops: [t, i] });
|
|
11
|
+
}
|
|
12
|
+
return n.length > 0 ? n : null;
|
|
13
|
+
}
|
|
14
|
+
export { t as explicitPool };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { CanvasRenderer } from './canvasEffect';
|
|
2
|
+
import { Rgba } from './color';
|
|
3
|
+
export type CursorWaveShape = 'circle' | 'triangle' | 'square';
|
|
4
|
+
/** A colour in the pool: solid, or a two-stop gradient (top → bottom). */
|
|
5
|
+
export type CursorWaveColor = Rgba | {
|
|
6
|
+
stops: readonly [Rgba, Rgba];
|
|
7
|
+
};
|
|
8
|
+
/** The effect's parameters (the documented ones, with their documented defaults). */
|
|
9
|
+
export interface CursorWaveParams {
|
|
10
|
+
/** Pixel spacing between cell centres (16–96). */
|
|
11
|
+
cellSize: number;
|
|
12
|
+
/** Cursor influence radius, % of min(width, height) (5–80). */
|
|
13
|
+
influenceRadiusVmin: number;
|
|
14
|
+
/** Time constant (s) of the swell-up ease (0.05–2). */
|
|
15
|
+
attackTime: number;
|
|
16
|
+
/** Time constant (s) of the relax-down ease (0.05–2). */
|
|
17
|
+
releaseTime: number;
|
|
18
|
+
/** Resting scale of every shape (0–0.5). */
|
|
19
|
+
idleScale: number;
|
|
20
|
+
/** Lowest peak scale a cell is given (0.5–4). */
|
|
21
|
+
minPeakScale: number;
|
|
22
|
+
/** Highest peak scale a cell is given (1–6). */
|
|
23
|
+
maxPeakScale: number;
|
|
24
|
+
/** Burst ring speed, px/s (200–4000). */
|
|
25
|
+
burstSpeed: number;
|
|
26
|
+
/** Burst ring thickness, px (40–600). */
|
|
27
|
+
burstThickness: number;
|
|
28
|
+
/** Pool of shapes assigned across the grid (repeat entries to bias it). */
|
|
29
|
+
shapes: readonly CursorWaveShape[];
|
|
30
|
+
/** Master alpha, 0–1. */
|
|
31
|
+
opacity: number;
|
|
32
|
+
}
|
|
33
|
+
export declare const CURSOR_WAVE_DEFAULTS: CursorWaveParams;
|
|
34
|
+
export interface CursorWaveSettings extends CursorWaveParams {
|
|
35
|
+
/** The colour pool, resolved. */
|
|
36
|
+
colors: readonly CursorWaveColor[];
|
|
37
|
+
}
|
|
38
|
+
export interface CursorWaveRenderer extends CanvasRenderer {
|
|
39
|
+
update(settings: CursorWaveSettings): void;
|
|
40
|
+
/** Rolls a ring out from (x, y), fractions of the frame (the centre by default). */
|
|
41
|
+
burst(x?: number, y?: number): void;
|
|
42
|
+
}
|
|
43
|
+
export declare function createCursorWaveRenderer(initial: CursorWaveSettings, seed?: number): CursorWaveRenderer;
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { cssRgba as e } from "./color.js";
|
|
2
|
+
import { createRandom as t } from "./noise.js";
|
|
3
|
+
// src/shared/backgrounds/cursorWaveRenderer.ts
|
|
4
|
+
var n = {
|
|
5
|
+
cellSize: 40,
|
|
6
|
+
influenceRadiusVmin: 30,
|
|
7
|
+
attackTime: .5,
|
|
8
|
+
releaseTime: .6,
|
|
9
|
+
idleScale: .09,
|
|
10
|
+
minPeakScale: 1,
|
|
11
|
+
maxPeakScale: 3,
|
|
12
|
+
burstSpeed: 1200,
|
|
13
|
+
burstThickness: 180,
|
|
14
|
+
shapes: [
|
|
15
|
+
"circle",
|
|
16
|
+
"triangle",
|
|
17
|
+
"square"
|
|
18
|
+
],
|
|
19
|
+
opacity: 1
|
|
20
|
+
}, r = {
|
|
21
|
+
base: .44,
|
|
22
|
+
falloff: 1.25,
|
|
23
|
+
plateau: .42,
|
|
24
|
+
burstGain: .74,
|
|
25
|
+
burstRampFrom: .7,
|
|
26
|
+
burstRamp: .4,
|
|
27
|
+
attackEase: 6,
|
|
28
|
+
releaseEase: 3,
|
|
29
|
+
corner: .12,
|
|
30
|
+
burstReach: 2.25
|
|
31
|
+
}, i = (e) => e < 0 ? 0 : e > 1 ? 1 : e, a = Math.PI * 2;
|
|
32
|
+
function o(o, s = 5) {
|
|
33
|
+
let c = o, l = [], u = 0, d = 0, f = -1, p = {
|
|
34
|
+
x: 0,
|
|
35
|
+
y: 0,
|
|
36
|
+
inside: !1
|
|
37
|
+
}, m = [], h = null, g = [], _ = () => {
|
|
38
|
+
let e = Math.min(96, Math.max(16, c.cellSize)), r = Math.max(1, Math.floor(u / e)), i = Math.max(1, Math.floor(d / e)), o = (u - r * e) / 2 + e / 2, f = (d - i * e) / 2 + e / 2, p = t(s), m = c.shapes.length > 0 ? c.shapes : n.shapes, h = Math.max(1, c.colors.length), g = new Map(l.map((e) => [`${e.x},${e.y}`, e.scale])), _ = [], v = Math.min(c.minPeakScale, c.maxPeakScale), y = Math.max(c.minPeakScale, c.maxPeakScale);
|
|
39
|
+
for (let t = 0; t < i; t++) for (let n = 0; n < r; n++) {
|
|
40
|
+
let r = o + n * e, i = f + t * e;
|
|
41
|
+
_.push({
|
|
42
|
+
x: r,
|
|
43
|
+
y: i,
|
|
44
|
+
shape: m[Math.floor(p() * m.length) % m.length],
|
|
45
|
+
color: Math.floor(p() * h) % h,
|
|
46
|
+
rotation: p() * a,
|
|
47
|
+
peak: v + p() * (y - v),
|
|
48
|
+
scale: g.get(`${r},${i}`) ?? c.idleScale
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
l = _;
|
|
52
|
+
}, v = () => {
|
|
53
|
+
g = c.colors.map((t) => "stops" in t ? e(t.stops[0]) : e(t));
|
|
54
|
+
};
|
|
55
|
+
v();
|
|
56
|
+
let y = (t, n, r) => {
|
|
57
|
+
let i = c.colors[n.color];
|
|
58
|
+
if (!i || !("stops" in i)) return g[n.color] ?? "transparent";
|
|
59
|
+
let a = t.createRadialGradient(n.x, n.y - r * .45, 0, n.x, n.y - r * .45, r * 1.05);
|
|
60
|
+
return a.addColorStop(0, e(i.stops[0])), a.addColorStop(1, e(i.stops[1])), a;
|
|
61
|
+
}, b = (e, t, n) => {
|
|
62
|
+
let i = n / 2;
|
|
63
|
+
if (t.shape === "circle") {
|
|
64
|
+
e.moveTo(t.x + i, t.y), e.arc(t.x, t.y, i, 0, a);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
let o = t.shape === "triangle" ? 3 : 4, s = t.shape === "triangle" ? i * 1.25 : i * Math.SQRT2, c = n * r.corner, l = [];
|
|
68
|
+
for (let e = 0; e < o; e++) {
|
|
69
|
+
let n = t.rotation + e * a / o + (o === 4 ? Math.PI / 4 : -Math.PI / 2);
|
|
70
|
+
l.push([t.x + Math.cos(n) * s, t.y + Math.sin(n) * s]);
|
|
71
|
+
}
|
|
72
|
+
let u = (e, t) => [(e[0] + t[0]) / 2, (e[1] + t[1]) / 2], d = u(l[o - 1], l[0]);
|
|
73
|
+
e.moveTo(d[0], d[1]);
|
|
74
|
+
for (let t = 0; t < o; t++) {
|
|
75
|
+
let n = l[t], r = u(l[t], l[(t + 1) % o]);
|
|
76
|
+
e.arcTo(n[0], n[1], r[0], r[1], c);
|
|
77
|
+
}
|
|
78
|
+
e.closePath();
|
|
79
|
+
};
|
|
80
|
+
return {
|
|
81
|
+
update(e) {
|
|
82
|
+
let t = e.cellSize !== c.cellSize || e.shapes !== c.shapes || e.colors.length !== c.colors.length || e.minPeakScale !== c.minPeakScale || e.maxPeakScale !== c.maxPeakScale, n = e.colors !== c.colors;
|
|
83
|
+
c = e, n && v(), t && u > 0 && _();
|
|
84
|
+
},
|
|
85
|
+
resize(e, t) {
|
|
86
|
+
u = e, d = t, _();
|
|
87
|
+
},
|
|
88
|
+
burst(e = .5, t = .5) {
|
|
89
|
+
h = {
|
|
90
|
+
x: e,
|
|
91
|
+
y: t
|
|
92
|
+
};
|
|
93
|
+
},
|
|
94
|
+
pointerMove(e, t, n) {
|
|
95
|
+
p.x = e, p.y = t, p.inside = n;
|
|
96
|
+
},
|
|
97
|
+
pointerDown(e, t) {
|
|
98
|
+
u > 0 && d > 0 && (h = {
|
|
99
|
+
x: e / u,
|
|
100
|
+
y: t / d
|
|
101
|
+
});
|
|
102
|
+
},
|
|
103
|
+
pointerLeave() {
|
|
104
|
+
p.inside = !1;
|
|
105
|
+
},
|
|
106
|
+
dispose() {
|
|
107
|
+
l = [];
|
|
108
|
+
},
|
|
109
|
+
draw(e, t) {
|
|
110
|
+
if (e.clearRect(0, 0, u, d), l.length === 0 && u > 0 && d > 0 && _(), u <= 0 || d <= 0 || l.length === 0) return;
|
|
111
|
+
let n = t.time, a = f < 0 ? 0 : Math.max(0, Math.min(.05, n - f));
|
|
112
|
+
f = n, h &&= (m.push({
|
|
113
|
+
x: h.x * u,
|
|
114
|
+
y: h.y * d,
|
|
115
|
+
born: n
|
|
116
|
+
}), m.length > 4 && m.shift(), null);
|
|
117
|
+
let o = Math.min(80, Math.max(5, c.influenceRadiusVmin)) / 100 * Math.min(u, d), s = Math.hypot(u, d), g = Math.max(1, c.burstThickness / 2) * r.burstReach, v = t.still ? [] : m.filter((e) => (n - e.born) * c.burstSpeed - g * 2 < s);
|
|
118
|
+
v.length !== m.length && (m.length = 0, m.push(...v));
|
|
119
|
+
let x = Math.max(.05, c.attackTime), S = Math.max(.05, c.releaseTime), C = 1 - Math.exp(-a * r.attackEase / x), w = 1 - Math.exp(-a * r.releaseEase / S), T = Math.min(96, Math.max(16, c.cellSize)) * r.base, E = Math.max(0, c.idleScale), D = p.inside && !t.still;
|
|
120
|
+
e.save(), e.globalAlpha = i(c.opacity);
|
|
121
|
+
for (let i of l) {
|
|
122
|
+
let a = 0;
|
|
123
|
+
if (D) {
|
|
124
|
+
let e = Math.hypot(i.x - p.x, i.y - p.y);
|
|
125
|
+
if (e < o) {
|
|
126
|
+
let t = e / o, n = (1 - t) ** r.falloff, i = Math.min(1, t / r.plateau);
|
|
127
|
+
a = n + (1 - n) * (1 - i * i * (3 - 2 * i));
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
for (let e of v) {
|
|
131
|
+
let t = n - e.born, o = t * c.burstSpeed, s = Math.abs(Math.hypot(i.x - e.x, i.y - e.y) - o);
|
|
132
|
+
if (s < g) {
|
|
133
|
+
let e = Math.min(1, t / r.burstRamp), n = r.burstRampFrom + (1 - r.burstRampFrom) * e * e * (3 - 2 * e);
|
|
134
|
+
a = Math.max(a, r.burstGain * n * (1 - (s / g) ** 2));
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
let s = E + (i.peak - E) * a;
|
|
138
|
+
t.still ? i.scale = E : i.scale += (s - i.scale) * (s > i.scale ? C : w);
|
|
139
|
+
let l = T * i.scale;
|
|
140
|
+
l < .4 || (e.beginPath(), b(e, i, l), e.fillStyle = y(e, i, l), e.fill());
|
|
141
|
+
}
|
|
142
|
+
e.restore();
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
export { n as CURSOR_WAVE_DEFAULTS, o as createCursorWaveRenderer };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { CanvasRenderer } from './canvasEffect';
|
|
2
|
+
import { Rgba } from './color';
|
|
3
|
+
export type DottedWavesPattern = 'noise' | 'wave' | 'rings' | 'spiral';
|
|
4
|
+
export type DottedWavesShape = 'circle' | 'ring' | 'square' | 'diamond';
|
|
5
|
+
export type DottedWavesColorBy = 'depth' | 'height' | 'position' | 'random';
|
|
6
|
+
/** The effect's parameters (the documented ones, with their documented defaults). */
|
|
7
|
+
export interface DottedWavesParams {
|
|
8
|
+
/** How the waves are laid out. */
|
|
9
|
+
pattern: DottedWavesPattern;
|
|
10
|
+
/** Distance between dots, px. */
|
|
11
|
+
spacing: number;
|
|
12
|
+
/** Radius of a dot at the crest of its wave, px. */
|
|
13
|
+
size: number;
|
|
14
|
+
/** How far each dot rises and falls, in rows (0: only the size pulses). */
|
|
15
|
+
jump: number;
|
|
16
|
+
/** Wave cycles per second (negative runs backwards). */
|
|
17
|
+
speed: number;
|
|
18
|
+
/** How tightly the waves pack together. */
|
|
19
|
+
frequency: number;
|
|
20
|
+
/** Extra fine noise in the wave shapes, 0–2. */
|
|
21
|
+
turbulence: number;
|
|
22
|
+
/** How fast the noise field slides along `direction`. */
|
|
23
|
+
drift: number;
|
|
24
|
+
/** Direction of travel, degrees. */
|
|
25
|
+
direction: number;
|
|
26
|
+
/** Arms of the spiral pattern, 1–12. */
|
|
27
|
+
arms: number;
|
|
28
|
+
/** How much dots shrink in the trough (1: they vanish). */
|
|
29
|
+
shrink: number;
|
|
30
|
+
/** How much dots fade in the back half of their cycle. */
|
|
31
|
+
depth: number;
|
|
32
|
+
shape: DottedWavesShape;
|
|
33
|
+
/** Offset every other row by half a cell. */
|
|
34
|
+
stagger: boolean;
|
|
35
|
+
/** Rotation of the grid, degrees. */
|
|
36
|
+
rotation: number;
|
|
37
|
+
/** Tilt of the grid back into perspective, 0–80 degrees. */
|
|
38
|
+
tilt: number;
|
|
39
|
+
/** Camera distance for the tilted view, relative to the larger side. */
|
|
40
|
+
perspective: number;
|
|
41
|
+
/** Grid origin, -1 (left) to 1 (right). */
|
|
42
|
+
centerX: number;
|
|
43
|
+
/** Grid origin, -1 (top) to 1 (bottom). */
|
|
44
|
+
centerY: number;
|
|
45
|
+
/** What picks each dot's colour. */
|
|
46
|
+
colorBy: DottedWavesColorBy;
|
|
47
|
+
/** Soft halo around each dot, 0–1. */
|
|
48
|
+
glow: number;
|
|
49
|
+
/** Blurred dot edges, 0–1. */
|
|
50
|
+
softness: number;
|
|
51
|
+
/** Overall opacity of the dots, 0–1. */
|
|
52
|
+
opacity: number;
|
|
53
|
+
/** Fade towards the edges of the frame, 0–1. */
|
|
54
|
+
fade: number;
|
|
55
|
+
/** Ripples left by the moving pointer (0: off). */
|
|
56
|
+
wake: number;
|
|
57
|
+
/** The wave a press rolls out (0: off). */
|
|
58
|
+
splash: number;
|
|
59
|
+
/** How fast ripples travel, rows per second. */
|
|
60
|
+
rippleSpeed: number;
|
|
61
|
+
}
|
|
62
|
+
export declare const DOTTED_WAVES_DEFAULTS: DottedWavesParams;
|
|
63
|
+
export interface DottedWavesSettings extends DottedWavesParams {
|
|
64
|
+
/** Back and front colours, resolved. */
|
|
65
|
+
colors: readonly [Rgba, Rgba];
|
|
66
|
+
}
|
|
67
|
+
export interface DottedWavesRenderer extends CanvasRenderer {
|
|
68
|
+
update(settings: DottedWavesSettings): void;
|
|
69
|
+
/** Rolls out a wave from (x, y), fractions of the frame (the centre by default). */
|
|
70
|
+
splash(x?: number, y?: number): void;
|
|
71
|
+
}
|
|
72
|
+
export declare function createDottedWavesRenderer(initial: DottedWavesSettings, seed?: number): DottedWavesRenderer;
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { cssRgba as e, mixOklab as t } from "./color.js";
|
|
2
|
+
import { createNoise3 as n, createRandom as r, planarNoise as i } from "./noise.js";
|
|
3
|
+
// src/shared/backgrounds/dottedWavesRenderer.ts
|
|
4
|
+
var a = {
|
|
5
|
+
pattern: "noise",
|
|
6
|
+
spacing: 20,
|
|
7
|
+
size: 4,
|
|
8
|
+
jump: 3,
|
|
9
|
+
speed: .25,
|
|
10
|
+
frequency: .08,
|
|
11
|
+
turbulence: .25,
|
|
12
|
+
drift: .06,
|
|
13
|
+
direction: 0,
|
|
14
|
+
arms: 2,
|
|
15
|
+
shrink: 1,
|
|
16
|
+
depth: .5,
|
|
17
|
+
shape: "circle",
|
|
18
|
+
stagger: !1,
|
|
19
|
+
rotation: 0,
|
|
20
|
+
tilt: 0,
|
|
21
|
+
perspective: 1.2,
|
|
22
|
+
centerX: 0,
|
|
23
|
+
centerY: 0,
|
|
24
|
+
colorBy: "depth",
|
|
25
|
+
glow: 0,
|
|
26
|
+
softness: 0,
|
|
27
|
+
opacity: 1,
|
|
28
|
+
fade: 0,
|
|
29
|
+
wake: 1,
|
|
30
|
+
splash: 1,
|
|
31
|
+
rippleSpeed: 10
|
|
32
|
+
}, o = {
|
|
33
|
+
noiseCycles: .4,
|
|
34
|
+
noiseScale: .82,
|
|
35
|
+
broadScale: .33,
|
|
36
|
+
broadWeight: .18,
|
|
37
|
+
turbulenceScale: 1.9,
|
|
38
|
+
turbulenceWeight: .25,
|
|
39
|
+
jumpScale: 1,
|
|
40
|
+
morph: 0,
|
|
41
|
+
rippleLife: 2.4,
|
|
42
|
+
rippleWidth: 1.4
|
|
43
|
+
}, s = .5, c = 32, l = 16, u = Math.PI * 2, d = (e) => e < 0 ? 0 : e > 1 ? 1 : e;
|
|
44
|
+
function f(a, f = 7) {
|
|
45
|
+
let p = a, ee = i(n(f)), te = i(n(f + 101)), ne = i(n(f + 202)), m = r(f + 13), h = /* @__PURE__ */ new Float32Array(4096);
|
|
46
|
+
for (let e = 0; e < h.length; e++) h[e] = m();
|
|
47
|
+
let g = 0, _ = 0, v = [], y = 0, b = [], x = {
|
|
48
|
+
x: 0,
|
|
49
|
+
y: 0,
|
|
50
|
+
time: -1
|
|
51
|
+
}, S = null, C = () => {
|
|
52
|
+
let [n, r] = p.colors, i = Array(512);
|
|
53
|
+
for (let a = 0; a < c; a++) {
|
|
54
|
+
let o = t(n, r, a / 31);
|
|
55
|
+
for (let t = 0; t < l; t++) i[a * l + t] = e(o, (t + 1) / l);
|
|
56
|
+
}
|
|
57
|
+
v = i;
|
|
58
|
+
};
|
|
59
|
+
C();
|
|
60
|
+
let w = (e, t, n) => {
|
|
61
|
+
n <= .01 || (b.push({
|
|
62
|
+
x: e,
|
|
63
|
+
y: t,
|
|
64
|
+
born: y,
|
|
65
|
+
amp: n
|
|
66
|
+
}), b.length > 28 && b.shift());
|
|
67
|
+
}, T = /* @__PURE__ */ new Map();
|
|
68
|
+
return {
|
|
69
|
+
update(e) {
|
|
70
|
+
let t = e.colors[0] !== p.colors[0] || e.colors[1] !== p.colors[1];
|
|
71
|
+
p = e, t && C();
|
|
72
|
+
},
|
|
73
|
+
resize(e, t) {
|
|
74
|
+
g = e, _ = t;
|
|
75
|
+
},
|
|
76
|
+
splash(e = .5, t = .5) {
|
|
77
|
+
S = {
|
|
78
|
+
x: e,
|
|
79
|
+
y: t
|
|
80
|
+
};
|
|
81
|
+
},
|
|
82
|
+
pointerMove(e, t, n) {
|
|
83
|
+
if (!n || p.wake <= 0) {
|
|
84
|
+
x.time = -1;
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
if (x.time < 0) {
|
|
88
|
+
x = {
|
|
89
|
+
x: e,
|
|
90
|
+
y: t,
|
|
91
|
+
time: y
|
|
92
|
+
};
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
let r = e - x.x, i = t - x.y, a = Math.hypot(r, i), o = Math.max(1 / 120, y - x.time);
|
|
96
|
+
if (a < p.spacing * 1.6 && o < .12) return;
|
|
97
|
+
let s = a / o;
|
|
98
|
+
w(e, t, p.wake * .55 * d(s / 1400)), x = {
|
|
99
|
+
x: e,
|
|
100
|
+
y: t,
|
|
101
|
+
time: y
|
|
102
|
+
};
|
|
103
|
+
},
|
|
104
|
+
pointerDown(e, t) {
|
|
105
|
+
w(e, t, p.splash);
|
|
106
|
+
},
|
|
107
|
+
pointerLeave() {
|
|
108
|
+
x.time = -1;
|
|
109
|
+
},
|
|
110
|
+
draw(e, t) {
|
|
111
|
+
if (y = t.time, S &&= (w(S.x * g, S.y * _, p.splash), null), e.clearRect(0, 0, g, _), g <= 0 || _ <= 0 || p.opacity <= 0) return;
|
|
112
|
+
let n = Math.max(4, p.spacing), r = t.time, i = g / 2 + p.centerX * g / 2, a = _ / 2 + p.centerY * _ / 2, c = p.rotation * Math.PI / 180, f = Math.cos(c), m = Math.sin(c), x = Math.min(80, Math.max(0, p.tilt)) * Math.PI / 180, C = Math.cos(x), re = Math.sin(x), E = Math.max(.2, p.perspective) * Math.max(g, _), D = p.direction * Math.PI / 180, O = Math.cos(D), k = Math.sin(D), A = Math.max(.001, p.frequency), ie = p.jump * n * o.jumpScale, j = p.drift / A * r, M = r * o.morph, ae = u * p.speed * r, N = Math.min(2, Math.max(0, p.turbulence)), P = p.fade > 0 ? p.fade * .5 * Math.min(g, _) : 0, F = t.still ? [] : b.filter((e) => r - e.born < o.rippleLife);
|
|
113
|
+
F.length !== b.length && (b.length = 0, b.push(...F));
|
|
114
|
+
let oe = p.rippleSpeed * n, I = o.rippleWidth * n, L = Math.hypot(g, _) / 2 + Math.hypot(i - g / 2, a - _ / 2), R = x > 0 ? 1 / Math.max(.15, C) : 1, z = Math.ceil(p.jump * o.jumpScale) + 2, B = Math.ceil((x > 0 || c !== 0 ? L : g / 2 + Math.abs(i - g / 2)) / n) + 2, V = Math.ceil((x > 0 || c !== 0 ? L : _ / 2 + Math.abs(a - _ / 2)) * R / n) + z, H = Math.min(B * (x > 0 ? 3 : 1), 400), U = Math.min(V * (x > 0 ? 3 : 1), 400);
|
|
115
|
+
T.clear();
|
|
116
|
+
for (let e = -U; e <= U; e++) {
|
|
117
|
+
let t = p.stagger && e & 1 ? .5 : 0;
|
|
118
|
+
for (let c = -H; c <= H; c++) {
|
|
119
|
+
let v = c + t, y = e, b = v * n, S = y * n, w = b * f - S * m, D = b * m + S * f, L = w / n, R = D / n, z;
|
|
120
|
+
if (p.pattern === "wave") z = u * A * (L * O + R * k);
|
|
121
|
+
else if (p.pattern === "rings") z = u * A * Math.hypot(L, R);
|
|
122
|
+
else if (p.pattern === "spiral") z = u * A * Math.hypot(L, R) + Math.round(Math.min(12, Math.max(1, p.arms))) * Math.atan2(R, L);
|
|
123
|
+
else {
|
|
124
|
+
let e = A * o.noiseScale, t = L * e - O * j * e, n = R * e - k * j * e, r = e * o.broadScale;
|
|
125
|
+
z = u * o.noiseCycles * (ee(t, n, M) + o.broadWeight * ne(L * r - O * j * r, R * r - k * j * r, M * .5));
|
|
126
|
+
}
|
|
127
|
+
if (N > 0) {
|
|
128
|
+
let e = A * o.turbulenceScale;
|
|
129
|
+
z += Math.PI * o.turbulenceWeight * N * te(L * e - O * j * e, R * e - k * j * e, M * 1.6);
|
|
130
|
+
}
|
|
131
|
+
let B = z - ae, V = Math.sin(B), H = 0;
|
|
132
|
+
if (F.length > 0) {
|
|
133
|
+
let e = i + w, t = a + D * C;
|
|
134
|
+
for (let n of F) {
|
|
135
|
+
let i = r - n.born, a = Math.hypot(e - n.x, t - n.y) - oe * i;
|
|
136
|
+
H += n.amp * Math.exp(-(a * a) / (I * I)) * (1 - i / o.rippleLife);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
let U = V + H, W = d((1 + U) / 2), G = d((1 + V) / 2), K = ie * U, se = D * C - K, q = -D * re, J = x > 0 ? E / Math.max(.001, E + q) : 1;
|
|
140
|
+
if (x > 0 && E + q <= E * .05) continue;
|
|
141
|
+
let Y = i + w * J, X = a + se * J, Z = p.size * (1 - p.shrink * (1 - W)) * J;
|
|
142
|
+
if (Y < -Z * 3 || Y > g + Z * 3 || X < -Z * 3 || X > _ + Z * 3) continue;
|
|
143
|
+
let Q = p.opacity * (1 - p.depth * (1 - G));
|
|
144
|
+
if (P > 0) {
|
|
145
|
+
let e = Math.min(Y, X, g - Y, _ - X);
|
|
146
|
+
Q *= d(e / P);
|
|
147
|
+
}
|
|
148
|
+
if (Z < s && (Q *= (Z + .12) / .62, Z = s), Q < .02) continue;
|
|
149
|
+
let ce;
|
|
150
|
+
ce = p.colorBy === "height" ? W : p.colorBy === "position" ? d(Y / g) : p.colorBy === "random" ? h[(c * 73856093 ^ e * 19349663) & 4095] : G;
|
|
151
|
+
let le = Math.round(ce * 31) * l + Math.min(15, Math.floor(Q * l)), $ = T.get(le);
|
|
152
|
+
$ || ($ = [], T.set(le, $)), $.push(Y, X, Z);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
let W = p.shape, G = Math.min(1, Math.max(0, p.glow)), K = Math.min(1, Math.max(0, p.softness));
|
|
156
|
+
e.save(), K > 0 && (e.filter = `blur(${(K * p.size * .45).toFixed(2)}px)`);
|
|
157
|
+
for (let [t, n] of T) {
|
|
158
|
+
let r = v[t];
|
|
159
|
+
e.beginPath();
|
|
160
|
+
for (let t = 0; t < n.length; t += 3) {
|
|
161
|
+
let r = n[t], i = n[t + 1], a = n[t + 2];
|
|
162
|
+
if (W === "square" || W === "diamond") {
|
|
163
|
+
let t = c + (W === "diamond" ? Math.PI / 4 : 0), n = Math.cos(t) * a, o = Math.sin(t) * a;
|
|
164
|
+
e.moveTo(r + n - o, i + o + n), e.lineTo(r - n - o, i - o + n), e.lineTo(r - n + o, i - o - n), e.lineTo(r + n + o, i + o - n), e.closePath();
|
|
165
|
+
} else if (e.moveTo(r + a, i), e.arc(r, i, a, 0, u), W === "ring") {
|
|
166
|
+
let t = a * .55;
|
|
167
|
+
e.moveTo(r + t, i), e.arc(r, i, t, 0, u, !0);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
G > 0 && (e.shadowColor = r, e.shadowBlur = G * p.size * 3), e.fillStyle = r, e.fill(W === "ring" ? "evenodd" : "nonzero");
|
|
171
|
+
}
|
|
172
|
+
e.restore();
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
export { a as DOTTED_WAVES_DEFAULTS, f as createDottedWavesRenderer };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { CanvasRenderer } from './canvasEffect';
|
|
2
|
+
import { Rgba } from './color';
|
|
3
|
+
export type GlimmerDirection = 'outward' | 'inward';
|
|
4
|
+
/** The effect's parameters (the documented ones, with their documented defaults). */
|
|
5
|
+
export interface GlimmerParams {
|
|
6
|
+
/** Number of glints, up to 9000. */
|
|
7
|
+
count: number;
|
|
8
|
+
/** Size of a glint at the middle of the field, px. */
|
|
9
|
+
size: number;
|
|
10
|
+
/** How much glint sizes vary. */
|
|
11
|
+
sizeVariance: number;
|
|
12
|
+
/** Overall brightness. */
|
|
13
|
+
brightness: number;
|
|
14
|
+
/** Width of the field around the centre. */
|
|
15
|
+
spread: number;
|
|
16
|
+
/** The empty core around the centre, 0 (filled) to 0.95 (a tunnel). */
|
|
17
|
+
hollow: number;
|
|
18
|
+
/** Depth of the field: higher flings near glints wider and faster. */
|
|
19
|
+
perspective: number;
|
|
20
|
+
/** Vanishing point, fractions of the frame. */
|
|
21
|
+
centerX: number;
|
|
22
|
+
centerY: number;
|
|
23
|
+
/** Speed of travel (0 holds still). */
|
|
24
|
+
speed: number;
|
|
25
|
+
direction: GlimmerDirection;
|
|
26
|
+
/** Spiral twist with depth (negative twists the other way). */
|
|
27
|
+
twist: number;
|
|
28
|
+
/** Gentle wobble in each glint's path. */
|
|
29
|
+
turbulence: number;
|
|
30
|
+
/** Shutter length for motion streaks. */
|
|
31
|
+
trail: number;
|
|
32
|
+
/** How often glints flash into four-point stars (0: never). */
|
|
33
|
+
glitter: number;
|
|
34
|
+
/** Length of the four-point flash. */
|
|
35
|
+
glintSize: number;
|
|
36
|
+
/** Gentle brightness shimmer of every glint. */
|
|
37
|
+
twinkle: number;
|
|
38
|
+
/** Depth in sharp focus, 0 (nearest) to 1 (farthest). */
|
|
39
|
+
focus: number;
|
|
40
|
+
/** Depth of field: higher turns out-of-focus glints into soft bokeh. */
|
|
41
|
+
aperture: number;
|
|
42
|
+
/** Speed multiplier while the pointer is held (1: off). */
|
|
43
|
+
boost: number;
|
|
44
|
+
/** How far the view turns toward the pointer. */
|
|
45
|
+
parallax: number;
|
|
46
|
+
/** Clicks send a wave of light through the field. */
|
|
47
|
+
waves: boolean;
|
|
48
|
+
/** Arrive out of warp: the field fades in at speed and settles. */
|
|
49
|
+
intro: boolean;
|
|
50
|
+
}
|
|
51
|
+
export declare const GLIMMER_DEFAULTS: GlimmerParams;
|
|
52
|
+
export interface GlimmerSettings extends GlimmerParams {
|
|
53
|
+
/** Colours A and B, resolved (on a light page the colour hook passes their inks). */
|
|
54
|
+
colors: readonly [Rgba, Rgba];
|
|
55
|
+
}
|
|
56
|
+
export interface GlimmerRenderer extends CanvasRenderer {
|
|
57
|
+
update(settings: GlimmerSettings): void;
|
|
58
|
+
/** Sends a wave of light from (x, y), fractions of the frame (the centre by default). */
|
|
59
|
+
wave(x?: number, y?: number): void;
|
|
60
|
+
/** Warps the field for `seconds`. */
|
|
61
|
+
warp(seconds?: number): void;
|
|
62
|
+
/** Plays the arrival again. */
|
|
63
|
+
replay(): void;
|
|
64
|
+
}
|
|
65
|
+
export declare function createGlimmerRenderer(initial: GlimmerSettings, seed?: number): GlimmerRenderer;
|