@basmilius/sparkle 2.1.0 → 2.3.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.
Files changed (108) hide show
  1. package/dist/index.d.mts +317 -459
  2. package/dist/index.d.mts.map +1 -1
  3. package/dist/index.mjs +1258 -949
  4. package/dist/index.mjs.map +1 -1
  5. package/package.json +6 -2
  6. package/src/aurora/index.ts +9 -3
  7. package/src/aurora/layer.ts +57 -29
  8. package/src/balloons/index.ts +9 -3
  9. package/src/balloons/layer.ts +50 -19
  10. package/src/bubbles/index.ts +9 -3
  11. package/src/bubbles/layer.ts +30 -17
  12. package/src/canvas.ts +92 -2
  13. package/src/color.ts +11 -2
  14. package/src/confetti/index.ts +15 -3
  15. package/src/confetti/layer.ts +8 -5
  16. package/src/confetti/particle.ts +12 -11
  17. package/src/confetti/shapes.ts +84 -97
  18. package/src/donuts/consts.ts +2 -2
  19. package/src/donuts/index.ts +9 -3
  20. package/src/donuts/layer.ts +43 -12
  21. package/src/effect.ts +107 -0
  22. package/src/fade.ts +87 -0
  23. package/src/fireflies/index.ts +9 -3
  24. package/src/fireflies/layer.ts +26 -9
  25. package/src/fireflies/particle.ts +2 -2
  26. package/src/firepit/index.ts +9 -3
  27. package/src/firepit/layer.ts +26 -7
  28. package/src/fireworks/create-explosion.ts +237 -0
  29. package/src/fireworks/explosion.ts +1 -1
  30. package/src/fireworks/index.ts +15 -3
  31. package/src/fireworks/layer.ts +55 -304
  32. package/src/fireworks/spark.ts +2 -2
  33. package/src/fireworks/types.ts +2 -2
  34. package/src/glitter/index.ts +9 -4
  35. package/src/glitter/layer.ts +15 -7
  36. package/src/glitter/types.ts +10 -0
  37. package/src/index.ts +3 -4
  38. package/src/lanterns/index.ts +9 -4
  39. package/src/lanterns/layer.ts +22 -10
  40. package/src/lanterns/types.ts +8 -0
  41. package/src/layer.ts +13 -11
  42. package/src/leaves/index.ts +9 -4
  43. package/src/leaves/layer.ts +21 -14
  44. package/src/leaves/types.ts +9 -0
  45. package/src/lightning/index.ts +9 -4
  46. package/src/lightning/layer.ts +4 -4
  47. package/src/lightning/system.ts +3 -3
  48. package/src/lightning/types.ts +10 -2
  49. package/src/matrix/index.ts +9 -4
  50. package/src/matrix/layer.ts +15 -7
  51. package/src/matrix/types.ts +9 -0
  52. package/src/orbits/index.ts +9 -4
  53. package/src/orbits/layer.ts +51 -21
  54. package/src/orbits/types.ts +12 -1
  55. package/src/particles/index.ts +9 -3
  56. package/src/particles/layer.ts +55 -12
  57. package/src/petals/index.ts +9 -3
  58. package/src/petals/layer.ts +29 -13
  59. package/src/plasma/index.ts +9 -3
  60. package/src/plasma/layer.ts +21 -6
  61. package/src/rain/index.ts +9 -3
  62. package/src/rain/layer.ts +30 -8
  63. package/src/sandstorm/index.ts +9 -3
  64. package/src/sandstorm/layer.ts +26 -9
  65. package/src/scene.ts +204 -0
  66. package/src/shooting-stars/system.ts +26 -24
  67. package/src/shooting-stars/types.ts +2 -1
  68. package/src/simulation-canvas.ts +45 -6
  69. package/src/snow/index.ts +9 -3
  70. package/src/snow/layer.ts +24 -11
  71. package/src/sparklers/index.ts +13 -3
  72. package/src/sparklers/layer.ts +61 -15
  73. package/src/stars/index.ts +9 -3
  74. package/src/stars/layer.ts +28 -22
  75. package/src/streamers/index.ts +9 -3
  76. package/src/streamers/layer.ts +18 -6
  77. package/src/streamers/types.ts +1 -1
  78. package/src/waves/index.ts +9 -3
  79. package/src/waves/layer.ts +42 -45
  80. package/src/waves/types.ts +1 -0
  81. package/src/wormhole/index.ts +9 -3
  82. package/src/wormhole/layer.ts +22 -6
  83. package/src/aurora/simulation.ts +0 -19
  84. package/src/balloons/simulation.ts +0 -19
  85. package/src/bubbles/simulation.ts +0 -20
  86. package/src/confetti/simulation.ts +0 -27
  87. package/src/donuts/simulation.ts +0 -25
  88. package/src/fireflies/simulation.ts +0 -18
  89. package/src/firepit/simulation.ts +0 -17
  90. package/src/fireworks/simulation.ts +0 -18
  91. package/src/glitter/simulation.ts +0 -19
  92. package/src/lanterns/simulation.ts +0 -17
  93. package/src/layered.ts +0 -185
  94. package/src/leaves/simulation.ts +0 -18
  95. package/src/lightning/simulation.ts +0 -17
  96. package/src/matrix/simulation.ts +0 -18
  97. package/src/orbits/simulation.ts +0 -19
  98. package/src/particles/simulation.ts +0 -26
  99. package/src/petals/simulation.ts +0 -18
  100. package/src/plasma/simulation.ts +0 -17
  101. package/src/rain/simulation.ts +0 -21
  102. package/src/sandstorm/simulation.ts +0 -18
  103. package/src/snow/simulation.ts +0 -17
  104. package/src/sparklers/simulation.ts +0 -30
  105. package/src/stars/simulation.ts +0 -22
  106. package/src/streamers/simulation.ts +0 -16
  107. package/src/waves/simulation.ts +0 -18
  108. package/src/wormhole/simulation.ts +0 -17
package/dist/index.d.mts CHANGED
@@ -6,57 +6,77 @@ type EdgeFade = {
6
6
  readonly left?: EdgeFadeSide;
7
7
  readonly right?: EdgeFadeSide;
8
8
  };
9
- declare abstract class SimulationLayer {
9
+ /**
10
+ * Internal interface implemented by all Effect subclasses. Used by SimulationCanvas
11
+ * and Scene to drive rendering without depending on the generic Effect<TConfig> type.
12
+ */
13
+ interface SimulationLayer {
14
+ fade: EdgeFade | null;
15
+ tick(dt: number, width: number, height: number): void;
16
+ draw(ctx: CanvasRenderingContext2D, width: number, height: number): void;
17
+ onResize(width: number, height: number): void;
18
+ onMount(canvas: HTMLCanvasElement): void;
19
+ onUnmount(canvas: HTMLCanvasElement): void;
20
+ }
21
+ //#endregion
22
+ //#region src/effect.d.ts
23
+ /**
24
+ * Base class for all visual effects. Implements the internal SimulationLayer interface
25
+ * so that effects can be used both standalone (via mount()) and composed in a Scene.
26
+ *
27
+ * @example Standalone usage
28
+ * const snow = new Snow({ particles: 200 });
29
+ * snow.mount(canvas).start();
30
+ *
31
+ * @example Scene composition
32
+ * const scene = new Scene()
33
+ * .mount(canvas)
34
+ * .layer(new Aurora())
35
+ * .layer(new Snow())
36
+ * .start();
37
+ */
38
+ declare abstract class Effect<TConfig = Record<string, unknown>> implements SimulationLayer {
39
+ #private;
10
40
  fade: EdgeFade | null;
11
41
  abstract tick(dt: number, width: number, height: number): void;
12
42
  abstract draw(ctx: CanvasRenderingContext2D, width: number, height: number): void;
43
+ configure(_config: Partial<TConfig>): void;
13
44
  onResize(_width: number, _height: number): void;
14
45
  onMount(_canvas: HTMLCanvasElement): void;
15
46
  onUnmount(_canvas: HTMLCanvasElement): void;
47
+ /**
48
+ * Apply an edge fade mask when rendering this effect standalone or in a Scene.
49
+ */
16
50
  withFade(fade: EdgeFade): this;
17
- }
18
- //#endregion
19
- //#region src/canvas.d.ts
20
- declare class LimitedFrameRateCanvas {
21
- #private;
22
- static get globalSpeed(): number;
23
- static set globalSpeed(value: number);
24
- get canvas(): HTMLCanvasElement;
25
- get context(): CanvasRenderingContext2D;
26
- get delta(): number;
27
- get deltaFactor(): number;
28
- get speed(): number;
29
- set speed(value: number);
30
- get frameRate(): number;
31
- get isSmall(): boolean;
32
- get isTicking(): boolean;
33
- get ticks(): number;
34
- get height(): number;
35
- get width(): number;
36
- constructor(canvas: HTMLCanvasElement, frameRate: number, options?: CanvasRenderingContext2DSettings);
37
- loop(): void;
38
- start(): void;
39
- stop(): void;
40
- draw(): void;
41
- tick(): void;
51
+ /**
52
+ * Mount this effect to a canvas element or CSS selector, creating the render loop.
53
+ * Must be called before start().
54
+ */
55
+ mount(canvas: HTMLCanvasElement | string, options?: CanvasRenderingContext2DSettings, frameRate?: number): this;
56
+ /**
57
+ * Remove this effect from its canvas and clean up the render loop.
58
+ */
59
+ unmount(): this;
60
+ /**
61
+ * Start the render loop. Call mount() first.
62
+ */
63
+ start(): this;
64
+ /**
65
+ * Pause rendering without destroying state. Use resume() to continue.
66
+ */
67
+ pause(): this;
68
+ /**
69
+ * Resume rendering after a pause().
70
+ */
71
+ resume(): this;
72
+ /**
73
+ * Stop rendering and call onUnmount(). Safe to call multiple times.
74
+ */
42
75
  destroy(): void;
43
- onResize(): void;
44
- onVisibilityChange(): void;
45
76
  }
46
77
  //#endregion
47
- //#region src/simulation-canvas.d.ts
48
- declare class SimulationCanvas extends LimitedFrameRateCanvas {
49
- #private;
50
- constructor(canvas: HTMLCanvasElement, simulation: SimulationLayer, frameRate?: number, options?: CanvasRenderingContext2DSettings);
51
- start(): void;
52
- destroy(): void;
53
- draw(): void;
54
- tick(): void;
55
- onResize(): void;
56
- }
57
- //#endregion
58
- //#region src/aurora/simulation.d.ts
59
- interface AuroraSimulationConfig {
78
+ //#region src/aurora/layer.d.ts
79
+ interface AuroraConfig {
60
80
  readonly bands?: number;
61
81
  readonly colors?: string[];
62
82
  readonly speed?: number;
@@ -64,18 +84,6 @@ interface AuroraSimulationConfig {
64
84
  readonly waveAmplitude?: number;
65
85
  readonly verticalPosition?: number;
66
86
  readonly scale?: number;
67
- readonly canvasOptions?: CanvasRenderingContext2DSettings;
68
- }
69
- declare class AuroraSimulation extends SimulationCanvas {
70
- constructor(canvas: HTMLCanvasElement, config?: AuroraSimulationConfig);
71
- }
72
- //#endregion
73
- //#region src/aurora/layer.d.ts
74
- declare class AuroraLayer extends SimulationLayer {
75
- #private;
76
- constructor(config?: AuroraSimulationConfig);
77
- tick(dt: number, width: number, height: number): void;
78
- draw(ctx: CanvasRenderingContext2D, width: number, height: number): void;
79
87
  }
80
88
  //#endregion
81
89
  //#region src/aurora/types.d.ts
@@ -93,16 +101,11 @@ type AuroraBand = {
93
101
  opacity: number;
94
102
  };
95
103
  //#endregion
96
- //#region src/color.d.ts
97
- declare function parseColor(fillStyle: string): {
98
- r: number;
99
- g: number;
100
- b: number;
101
- a: number;
102
- };
104
+ //#region src/aurora/index.d.ts
105
+ declare function createAurora(config?: AuroraConfig): Effect<AuroraConfig>;
103
106
  //#endregion
104
- //#region src/balloons/simulation.d.ts
105
- interface BalloonSimulationConfig {
107
+ //#region src/balloons/layer.d.ts
108
+ interface BalloonsConfig {
106
109
  readonly count?: number;
107
110
  readonly colors?: string[];
108
111
  readonly sizeRange?: [number, number];
@@ -110,18 +113,6 @@ interface BalloonSimulationConfig {
110
113
  readonly driftAmount?: number;
111
114
  readonly stringLength?: number;
112
115
  readonly scale?: number;
113
- readonly canvasOptions?: CanvasRenderingContext2DSettings;
114
- }
115
- declare class BalloonSimulation extends SimulationCanvas {
116
- constructor(canvas: HTMLCanvasElement, config?: BalloonSimulationConfig);
117
- }
118
- //#endregion
119
- //#region src/balloons/layer.d.ts
120
- declare class BalloonLayer extends SimulationLayer {
121
- #private;
122
- constructor(config?: BalloonSimulationConfig);
123
- tick(dt: number, width: number, height: number): void;
124
- draw(ctx: CanvasRenderingContext2D, width: number, height: number): void;
125
116
  }
126
117
  //#endregion
127
118
  //#region src/point.d.ts
@@ -167,8 +158,11 @@ type Balloon = {
167
158
  stringLength: number;
168
159
  };
169
160
  //#endregion
170
- //#region src/bubbles/simulation.d.ts
171
- interface BubbleSimulationConfig {
161
+ //#region src/balloons/index.d.ts
162
+ declare function createBalloons(config?: BalloonsConfig): Effect<BalloonsConfig>;
163
+ //#endregion
164
+ //#region src/bubbles/layer.d.ts
165
+ interface BubblesConfig {
172
166
  readonly count?: number;
173
167
  readonly sizeRange?: [number, number];
174
168
  readonly speed?: number;
@@ -177,20 +171,6 @@ interface BubbleSimulationConfig {
177
171
  readonly colors?: string[];
178
172
  readonly wobbleAmount?: number;
179
173
  readonly scale?: number;
180
- readonly canvasOptions?: CanvasRenderingContext2DSettings;
181
- }
182
- declare class BubbleSimulation extends SimulationCanvas {
183
- constructor(canvas: HTMLCanvasElement, config?: BubbleSimulationConfig);
184
- }
185
- //#endregion
186
- //#region src/bubbles/layer.d.ts
187
- declare class BubbleLayer extends SimulationLayer {
188
- #private;
189
- constructor(config?: BubbleSimulationConfig);
190
- onMount(canvas: HTMLCanvasElement): void;
191
- onUnmount(canvas: HTMLCanvasElement): void;
192
- tick(dt: number, width: number, height: number): void;
193
- draw(ctx: CanvasRenderingContext2D, width: number, height: number): void;
194
174
  }
195
175
  //#endregion
196
176
  //#region src/bubbles/types.d.ts
@@ -215,6 +195,58 @@ type PopParticle = {
215
195
  decay: number;
216
196
  };
217
197
  //#endregion
198
+ //#region src/bubbles/index.d.ts
199
+ declare function createBubbles(config?: BubblesConfig): Effect<BubblesConfig>;
200
+ //#endregion
201
+ //#region src/canvas.d.ts
202
+ declare class LimitedFrameRateCanvas {
203
+ #private;
204
+ static get globalSpeed(): number;
205
+ static set globalSpeed(value: number);
206
+ /**
207
+ * Global frame rate override for all canvas instances.
208
+ * null = use each instance's own frame rate.
209
+ * 0 = unlimited (render as fast as the browser allows).
210
+ * Any positive number = cap at that many frames per second.
211
+ */
212
+ static get globalFrameRate(): number | null;
213
+ static set globalFrameRate(value: number | null);
214
+ static get showFps(): boolean;
215
+ static set showFps(value: boolean);
216
+ get canvas(): HTMLCanvasElement;
217
+ get context(): CanvasRenderingContext2D;
218
+ get delta(): number;
219
+ get deltaFactor(): number;
220
+ get speed(): number;
221
+ set speed(value: number);
222
+ get dpr(): number;
223
+ get frameRate(): number;
224
+ get isSmall(): boolean;
225
+ get isTicking(): boolean;
226
+ get ticks(): number;
227
+ get height(): number;
228
+ get width(): number;
229
+ constructor(canvas: HTMLCanvasElement, frameRate: number, options?: CanvasRenderingContext2DSettings);
230
+ loop(): void;
231
+ start(): void;
232
+ stop(): void;
233
+ pause(): void;
234
+ resume(): void;
235
+ draw(): void;
236
+ tick(): void;
237
+ destroy(): void;
238
+ onResize(): void;
239
+ onVisibilityChange(): void;
240
+ }
241
+ //#endregion
242
+ //#region src/color.d.ts
243
+ declare function parseColor(fillStyle: string): {
244
+ r: number;
245
+ g: number;
246
+ b: number;
247
+ a: number;
248
+ };
249
+ //#endregion
218
250
  //#region src/confetti/types.d.ts
219
251
  type Config = {
220
252
  readonly angle: number;
@@ -233,26 +265,9 @@ type Config = {
233
265
  type Palette = "classic" | "pastel" | "vibrant" | "warm";
234
266
  type Shape = "bowtie" | "circle" | "crescent" | "diamond" | "heart" | "hexagon" | "ribbon" | "ring" | "square" | "star" | "triangle";
235
267
  //#endregion
236
- //#region src/confetti/simulation.d.ts
237
- interface ConfettiSimulationConfig {
238
- readonly scale?: number;
239
- readonly canvasOptions?: CanvasRenderingContext2DSettings;
240
- }
241
- declare class ConfettiSimulation extends SimulationCanvas {
242
- #private;
243
- constructor(canvas: HTMLCanvasElement, config?: ConfettiSimulationConfig);
244
- fire(config: Partial<Config>): void;
245
- }
246
- //#endregion
247
268
  //#region src/confetti/layer.d.ts
248
- declare class ConfettiLayer extends SimulationLayer {
249
- #private;
250
- constructor(config?: ConfettiSimulationConfig);
251
- onResize(width: number, height: number): void;
252
- fire(config: Partial<Config>): void;
253
- get hasParticles(): boolean;
254
- tick(dt: number, _width: number, _height: number): void;
255
- draw(ctx: CanvasRenderingContext2D, width: number, height: number): void;
269
+ interface ConfettiConfig {
270
+ readonly scale?: number;
256
271
  }
257
272
  //#endregion
258
273
  //#region src/confetti/particle.d.ts
@@ -279,10 +294,15 @@ declare const PALETTES: Record<Palette, string[]>;
279
294
  //#region src/confetti/shapes.d.ts
280
295
  declare const SHAPE_PATHS: Record<Shape, Path2D>;
281
296
  //#endregion
282
- //#region src/donuts/simulation.d.ts
283
- interface DonutSimulationConfig {
297
+ //#region src/confetti/index.d.ts
298
+ interface ConfettiInstance extends Effect<ConfettiConfig> {
299
+ burst(config: Partial<Config>): void;
300
+ }
301
+ declare function createConfetti(config?: ConfettiConfig): ConfettiInstance;
302
+ //#endregion
303
+ //#region src/donuts/layer.d.ts
304
+ interface DonutsConfig {
284
305
  readonly background?: string;
285
- readonly canvasOptions?: CanvasRenderingContext2DSettings;
286
306
  readonly collisionPadding?: number;
287
307
  readonly colors?: string[];
288
308
  readonly count?: number;
@@ -296,41 +316,18 @@ interface DonutSimulationConfig {
296
316
  readonly speedRange?: [number, number];
297
317
  readonly thickness?: number;
298
318
  }
299
- declare class DonutSimulation extends SimulationCanvas {
300
- constructor(canvas: HTMLCanvasElement, config?: DonutSimulationConfig);
301
- }
302
319
  //#endregion
303
- //#region src/donuts/layer.d.ts
304
- declare class DonutLayer extends SimulationLayer {
305
- #private;
306
- constructor(config?: DonutSimulationConfig);
307
- onResize(width: number, height: number): void;
308
- onMount(canvas: HTMLCanvasElement): void;
309
- onUnmount(canvas: HTMLCanvasElement): void;
310
- tick(dt: number, width: number, height: number): void;
311
- draw(ctx: CanvasRenderingContext2D, width: number, height: number): void;
312
- }
320
+ //#region src/donuts/index.d.ts
321
+ declare function createDonuts(config?: DonutsConfig): Effect<DonutsConfig>;
313
322
  //#endregion
314
- //#region src/fireflies/simulation.d.ts
315
- interface FireflySimulationConfig {
323
+ //#region src/fireflies/layer.d.ts
324
+ interface FirefliesConfig {
316
325
  readonly count?: number;
317
326
  readonly color?: string;
318
327
  readonly size?: number;
319
328
  readonly speed?: number;
320
329
  readonly glowSpeed?: number;
321
330
  readonly scale?: number;
322
- readonly canvasOptions?: CanvasRenderingContext2DSettings;
323
- }
324
- declare class FireflySimulation extends SimulationCanvas {
325
- constructor(canvas: HTMLCanvasElement, config?: FireflySimulationConfig);
326
- }
327
- //#endregion
328
- //#region src/fireflies/layer.d.ts
329
- declare class FireflyLayer extends SimulationLayer {
330
- #private;
331
- constructor(config?: FireflySimulationConfig);
332
- tick(dt: number, _width: number, _height: number): void;
333
- draw(ctx: CanvasRenderingContext2D, width: number, height: number): void;
334
331
  }
335
332
  //#endregion
336
333
  //#region src/fireflies/particle.d.ts
@@ -374,25 +371,16 @@ type Firefly = {
374
371
  amplitudeY: number;
375
372
  };
376
373
  //#endregion
377
- //#region src/firepit/simulation.d.ts
378
- interface FirepitSimulationConfig {
374
+ //#region src/fireflies/index.d.ts
375
+ declare function createFireflies(config?: FirefliesConfig): Effect<FirefliesConfig>;
376
+ //#endregion
377
+ //#region src/firepit/layer.d.ts
378
+ interface FirepitConfig {
379
379
  readonly embers?: number;
380
380
  readonly flameWidth?: number;
381
381
  readonly flameHeight?: number;
382
382
  readonly intensity?: number;
383
383
  readonly scale?: number;
384
- readonly canvasOptions?: CanvasRenderingContext2DSettings;
385
- }
386
- declare class FirepitSimulation extends SimulationCanvas {
387
- constructor(canvas: HTMLCanvasElement, config?: FirepitSimulationConfig);
388
- }
389
- //#endregion
390
- //#region src/firepit/layer.d.ts
391
- declare class FirepitLayer extends SimulationLayer {
392
- #private;
393
- constructor(config?: FirepitSimulationConfig);
394
- tick(dt: number, _width: number, _height: number): void;
395
- draw(ctx: CanvasRenderingContext2D, width: number, height: number): void;
396
384
  }
397
385
  //#endregion
398
386
  //#region src/firepit/types.d.ts
@@ -416,6 +404,9 @@ type FlameLayer = {
416
404
  height: number;
417
405
  };
418
406
  //#endregion
407
+ //#region src/firepit/index.d.ts
408
+ declare function createFirepit(config?: FirepitConfig): Effect<FirepitConfig>;
409
+ //#endregion
419
410
  //#region src/fireworks/types.d.ts
420
411
  type ExplosionType = "peony" | "chrysanthemum" | "willow" | "ring" | "palm" | "crackle" | "crossette" | "dahlia" | "brocade" | "horsetail" | "strobe" | "heart" | "spiral" | "flower";
421
412
  type FireworkVariant = ExplosionType | "saturn" | "concentric";
@@ -436,10 +427,10 @@ interface ExplosionConfig {
436
427
  readonly spread3d: boolean;
437
428
  readonly glowSize: number;
438
429
  }
439
- interface FireworkSimulationConfig {
430
+ interface FireworksConfig {
440
431
  readonly scale?: number;
441
432
  readonly autoSpawn?: boolean;
442
- readonly canvasOptions?: CanvasRenderingContext2DSettings;
433
+ readonly variants?: FireworkVariant[];
443
434
  }
444
435
  declare const FIREWORK_VARIANTS: FireworkVariant[];
445
436
  declare const EXPLOSION_CONFIGS: Record<ExplosionType, ExplosionConfig>;
@@ -459,6 +450,23 @@ declare class Explosion {
459
450
  tick(dt: number): void;
460
451
  }
461
452
  //#endregion
453
+ //#region src/fireworks/create-explosion.d.ts
454
+ /**
455
+ * Creates an array of {@link Explosion} particles for the given firework variant.
456
+ * Use this to fire a fully formed explosion burst in your own render loop without
457
+ * needing a {@link Fireworks} instance.
458
+ *
459
+ * @param variant - The firework variant to create.
460
+ * @param position - The center position of the explosion in canvas pixels.
461
+ * @param hue - Base hue in degrees (0–360).
462
+ * @param options - Optional overrides for `lineWidth` (default `5`) and `scale` (default `1`).
463
+ * @param rng - RNG function returning values in [0, 1). Defaults to `Math.random`.
464
+ */
465
+ declare function createExplosion(variant: FireworkVariant, position: Point, hue: number, options?: {
466
+ lineWidth?: number;
467
+ scale?: number;
468
+ }, rng?: () => number): Explosion[];
469
+ //#endregion
462
470
  //#region src/fireworks/spark.d.ts
463
471
  declare class Spark {
464
472
  #private;
@@ -480,25 +488,14 @@ declare class Firework extends EventTarget {
480
488
  tick(dt: number): void;
481
489
  }
482
490
  //#endregion
483
- //#region src/fireworks/layer.d.ts
484
- declare class FireworkLayer extends SimulationLayer {
485
- #private;
486
- constructor(config?: FireworkSimulationConfig);
487
- onResize(width: number, height: number): void;
488
- fireExplosion(variant: FireworkVariant, position?: Point): void;
489
- tick(dt: number, width: number, height: number): void;
490
- draw(ctx: CanvasRenderingContext2D, width: number, height: number): void;
491
- }
492
- //#endregion
493
- //#region src/fireworks/simulation.d.ts
494
- declare class FireworkSimulation extends SimulationCanvas {
495
- #private;
496
- constructor(canvas: HTMLCanvasElement, config?: FireworkSimulationConfig);
497
- fireExplosion(variant: FireworkVariant, position?: Point): void;
491
+ //#region src/fireworks/index.d.ts
492
+ interface FireworksInstance extends Effect<FireworksConfig> {
493
+ launch(variant: FireworkVariant, position?: Point): void;
498
494
  }
495
+ declare function createFireworks(config?: FireworksConfig): FireworksInstance;
499
496
  //#endregion
500
- //#region src/glitter/simulation.d.ts
501
- interface GlitterSimulationConfig {
497
+ //#region src/glitter/types.d.ts
498
+ interface GlitterConfig {
502
499
  readonly count?: number;
503
500
  readonly colors?: string[];
504
501
  readonly size?: number;
@@ -506,21 +503,7 @@ interface GlitterSimulationConfig {
506
503
  readonly groundLevel?: number;
507
504
  readonly maxSettled?: number;
508
505
  readonly scale?: number;
509
- readonly canvasOptions?: CanvasRenderingContext2DSettings;
510
- }
511
- declare class GlitterSimulation extends SimulationCanvas {
512
- constructor(canvas: HTMLCanvasElement, config?: GlitterSimulationConfig);
513
506
  }
514
- //#endregion
515
- //#region src/glitter/layer.d.ts
516
- declare class GlitterLayer extends SimulationLayer {
517
- #private;
518
- constructor(config?: GlitterSimulationConfig);
519
- tick(dt: number, _width: number, _height: number): void;
520
- draw(ctx: CanvasRenderingContext2D, width: number, height: number): void;
521
- }
522
- //#endregion
523
- //#region src/glitter/types.d.ts
524
507
  type FallingGlitter = {
525
508
  x: number;
526
509
  y: number;
@@ -544,28 +527,17 @@ type SettledGlitter = {
544
527
  colorIndex: number;
545
528
  };
546
529
  //#endregion
547
- //#region src/lanterns/simulation.d.ts
548
- interface LanternSimulationConfig {
530
+ //#region src/glitter/index.d.ts
531
+ declare function createGlitter(config?: GlitterConfig): Effect<GlitterConfig>;
532
+ //#endregion
533
+ //#region src/lanterns/types.d.ts
534
+ interface LanternsConfig {
549
535
  readonly count?: number;
550
536
  readonly colors?: string[];
551
537
  readonly size?: number;
552
538
  readonly speed?: number;
553
539
  readonly scale?: number;
554
- readonly canvasOptions?: CanvasRenderingContext2DSettings;
555
- }
556
- declare class LanternSimulation extends SimulationCanvas {
557
- constructor(canvas: HTMLCanvasElement, config?: LanternSimulationConfig);
558
540
  }
559
- //#endregion
560
- //#region src/lanterns/layer.d.ts
561
- declare class LanternLayer extends SimulationLayer {
562
- #private;
563
- constructor(config?: LanternSimulationConfig);
564
- tick(dt: number, width: number, height: number): void;
565
- draw(ctx: CanvasRenderingContext2D, width: number, height: number): void;
566
- }
567
- //#endregion
568
- //#region src/lanterns/types.d.ts
569
541
  type Lantern = {
570
542
  x: number;
571
543
  y: number;
@@ -581,42 +553,18 @@ type Lantern = {
581
553
  opacity: number;
582
554
  };
583
555
  //#endregion
584
- //#region src/layered.d.ts
585
- declare class LayeredSimulation extends LimitedFrameRateCanvas {
586
- #private;
587
- constructor(canvas: HTMLCanvasElement, frameRate?: number, options?: CanvasRenderingContext2DSettings);
588
- add(layer: SimulationLayer): this;
589
- start(): void;
590
- destroy(): void;
591
- draw(): void;
592
- tick(): void;
593
- onResize(): void;
594
- }
556
+ //#region src/lanterns/index.d.ts
557
+ declare function createLanterns(config?: LanternsConfig): Effect<LanternsConfig>;
595
558
  //#endregion
596
- //#region src/leaves/simulation.d.ts
597
- interface LeafSimulationConfig {
559
+ //#region src/leaves/types.d.ts
560
+ interface LeavesConfig {
598
561
  readonly count?: number;
599
562
  readonly colors?: string[];
600
563
  readonly size?: number;
601
564
  readonly speed?: number;
602
565
  readonly wind?: number;
603
566
  readonly scale?: number;
604
- readonly canvasOptions?: CanvasRenderingContext2DSettings;
605
- }
606
- declare class LeafSimulation extends SimulationCanvas {
607
- constructor(canvas: HTMLCanvasElement, config?: LeafSimulationConfig);
608
- }
609
- //#endregion
610
- //#region src/leaves/layer.d.ts
611
- declare class LeafLayer extends SimulationLayer {
612
- #private;
613
- constructor(config?: LeafSimulationConfig);
614
- onResize(_width: number, height: number): void;
615
- tick(dt: number, _width: number, height: number): void;
616
- draw(ctx: CanvasRenderingContext2D, width: number, height: number): void;
617
567
  }
618
- //#endregion
619
- //#region src/leaves/types.d.ts
620
568
  type Leaf = {
621
569
  x: number;
622
570
  y: number;
@@ -634,26 +582,34 @@ type Leaf = {
634
582
  colorIndex: number;
635
583
  };
636
584
  //#endregion
637
- //#region src/lightning/simulation.d.ts
638
- interface LightningSimulationConfig {
585
+ //#region src/leaves/index.d.ts
586
+ declare function createLeaves(config?: LeavesConfig): Effect<LeavesConfig>;
587
+ //#endregion
588
+ //#region src/lightning/types.d.ts
589
+ interface LightningConfig {
639
590
  readonly frequency?: number;
640
591
  readonly color?: string;
641
592
  readonly branches?: boolean;
642
593
  readonly flash?: boolean;
643
594
  readonly scale?: number;
644
- readonly canvasOptions?: CanvasRenderingContext2DSettings;
645
- }
646
- declare class LightningSimulation extends SimulationCanvas {
647
- constructor(canvas: HTMLCanvasElement, config?: LightningSimulationConfig);
648
- }
649
- //#endregion
650
- //#region src/lightning/layer.d.ts
651
- declare class LightningLayer extends SimulationLayer {
652
- #private;
653
- constructor(config?: LightningSimulationConfig);
654
- tick(dt: number, _width: number, _height: number): void;
655
- draw(ctx: CanvasRenderingContext2D, width: number, height: number): void;
656
595
  }
596
+ type LightningBranch = {
597
+ segments: {
598
+ x: number;
599
+ y: number;
600
+ }[];
601
+ alpha: number;
602
+ };
603
+ type LightningBolt = {
604
+ segments: {
605
+ x: number;
606
+ y: number;
607
+ }[];
608
+ branches: LightningBranch[];
609
+ alpha: number;
610
+ lifetime: number;
611
+ ticksAlive: number;
612
+ };
657
613
  //#endregion
658
614
  //#region src/lightning/system.d.ts
659
615
  interface LightningSystemConfig {
@@ -672,49 +628,18 @@ declare class LightningSystem {
672
628
  draw(ctx: CanvasRenderingContext2D, width: number, height: number): void;
673
629
  }
674
630
  //#endregion
675
- //#region src/lightning/types.d.ts
676
- type LightningBranch = {
677
- segments: {
678
- x: number;
679
- y: number;
680
- }[];
681
- alpha: number;
682
- };
683
- type LightningBolt = {
684
- segments: {
685
- x: number;
686
- y: number;
687
- }[];
688
- branches: LightningBranch[];
689
- alpha: number;
690
- lifetime: number;
691
- ticksAlive: number;
692
- };
631
+ //#region src/lightning/index.d.ts
632
+ declare function createLightning(config?: LightningConfig): Effect<LightningConfig>;
693
633
  //#endregion
694
- //#region src/matrix/simulation.d.ts
695
- interface MatrixSimulationConfig {
634
+ //#region src/matrix/types.d.ts
635
+ interface MatrixConfig {
696
636
  readonly columns?: number;
697
637
  readonly speed?: number;
698
638
  readonly color?: string;
699
639
  readonly fontSize?: number;
700
640
  readonly trailLength?: number;
701
641
  readonly scale?: number;
702
- readonly canvasOptions?: CanvasRenderingContext2DSettings;
703
642
  }
704
- declare class MatrixSimulation extends SimulationCanvas {
705
- constructor(canvas: HTMLCanvasElement, config?: MatrixSimulationConfig);
706
- }
707
- //#endregion
708
- //#region src/matrix/layer.d.ts
709
- declare class MatrixLayer extends SimulationLayer {
710
- #private;
711
- constructor(config?: MatrixSimulationConfig);
712
- onResize(width: number, height: number): void;
713
- tick(dt: number, width: number, height: number): void;
714
- draw(ctx: CanvasRenderingContext2D, width: number, height: number): void;
715
- }
716
- //#endregion
717
- //#region src/matrix/types.d.ts
718
643
  type MatrixColumn = {
719
644
  x: number;
720
645
  y: number;
@@ -724,8 +649,11 @@ type MatrixColumn = {
724
649
  headBrightness: number;
725
650
  };
726
651
  //#endregion
727
- //#region src/orbits/simulation.d.ts
728
- interface OrbitSimulationConfig {
652
+ //#region src/matrix/index.d.ts
653
+ declare function createMatrix(config?: MatrixConfig): Effect<MatrixConfig>;
654
+ //#endregion
655
+ //#region src/orbits/types.d.ts
656
+ interface OrbitsConfig {
729
657
  readonly centers?: number;
730
658
  readonly orbitersPerCenter?: number;
731
659
  readonly speed?: number;
@@ -733,22 +661,7 @@ interface OrbitSimulationConfig {
733
661
  readonly trailLength?: number;
734
662
  readonly showCenters?: boolean;
735
663
  readonly scale?: number;
736
- readonly canvasOptions?: CanvasRenderingContext2DSettings;
737
664
  }
738
- declare class OrbitSimulation extends SimulationCanvas {
739
- constructor(canvas: HTMLCanvasElement, config?: OrbitSimulationConfig);
740
- }
741
- //#endregion
742
- //#region src/orbits/layer.d.ts
743
- declare class OrbitLayer extends SimulationLayer {
744
- #private;
745
- constructor(config?: OrbitSimulationConfig);
746
- onResize(_width: number, _height: number): void;
747
- tick(dt: number, width: number, height: number): void;
748
- draw(ctx: CanvasRenderingContext2D, width: number, height: number): void;
749
- }
750
- //#endregion
751
- //#region src/orbits/types.d.ts
752
665
  type OrbitalCenter = {
753
666
  x: number;
754
667
  y: number;
@@ -766,8 +679,12 @@ type Orbiter = {
766
679
  x: number;
767
680
  y: number;
768
681
  }[];
682
+ trailHead: number;
769
683
  };
770
684
  //#endregion
685
+ //#region src/orbits/index.d.ts
686
+ declare function createOrbits(config?: OrbitsConfig): Effect<OrbitsConfig>;
687
+ //#endregion
771
688
  //#region src/particles/types.d.ts
772
689
  type ParticleMouseMode = "attract" | "repel" | "connect" | "none";
773
690
  type NetworkParticle = {
@@ -779,8 +696,8 @@ type NetworkParticle = {
779
696
  baseSpeed: number;
780
697
  };
781
698
  //#endregion
782
- //#region src/particles/simulation.d.ts
783
- interface ParticleSimulationConfig {
699
+ //#region src/particles/layer.d.ts
700
+ interface ParticlesConfig {
784
701
  readonly count?: number;
785
702
  readonly color?: string;
786
703
  readonly lineColor?: string;
@@ -795,43 +712,19 @@ interface ParticleSimulationConfig {
795
712
  readonly glow?: boolean;
796
713
  readonly background?: string | null;
797
714
  readonly scale?: number;
798
- readonly canvasOptions?: CanvasRenderingContext2DSettings;
799
- }
800
- declare class ParticleSimulation extends SimulationCanvas {
801
- constructor(canvas: HTMLCanvasElement, config?: ParticleSimulationConfig);
802
715
  }
803
716
  //#endregion
804
- //#region src/particles/layer.d.ts
805
- declare class ParticleLayer extends SimulationLayer {
806
- #private;
807
- constructor(config?: ParticleSimulationConfig);
808
- onResize(width: number, height: number): void;
809
- onMount(canvas: HTMLCanvasElement): void;
810
- onUnmount(canvas: HTMLCanvasElement): void;
811
- tick(dt: number, width: number, height: number): void;
812
- draw(ctx: CanvasRenderingContext2D, width: number, height: number): void;
813
- }
717
+ //#region src/particles/index.d.ts
718
+ declare function createParticles(config?: ParticlesConfig): Effect<ParticlesConfig>;
814
719
  //#endregion
815
- //#region src/petals/simulation.d.ts
816
- interface PetalSimulationConfig {
720
+ //#region src/petals/layer.d.ts
721
+ interface PetalsConfig {
817
722
  readonly count?: number;
818
723
  readonly colors?: string[];
819
724
  readonly size?: number;
820
725
  readonly speed?: number;
821
726
  readonly wind?: number;
822
727
  readonly scale?: number;
823
- readonly canvasOptions?: CanvasRenderingContext2DSettings;
824
- }
825
- declare class PetalSimulation extends SimulationCanvas {
826
- constructor(canvas: HTMLCanvasElement, config?: PetalSimulationConfig);
827
- }
828
- //#endregion
829
- //#region src/petals/layer.d.ts
830
- declare class PetalLayer extends SimulationLayer {
831
- #private;
832
- constructor(config?: PetalSimulationConfig);
833
- tick(dt: number, _width: number, height: number): void;
834
- draw(ctx: CanvasRenderingContext2D, width: number, height: number): void;
835
728
  }
836
729
  //#endregion
837
730
  //#region src/petals/types.d.ts
@@ -851,6 +744,9 @@ type Petal = {
851
744
  colorIndex: number;
852
745
  };
853
746
  //#endregion
747
+ //#region src/petals/index.d.ts
748
+ declare function createPetals(config?: PetalsConfig): Effect<PetalsConfig>;
749
+ //#endregion
854
750
  //#region src/plasma/types.d.ts
855
751
  type PlasmaColor = {
856
752
  r: number;
@@ -858,25 +754,16 @@ type PlasmaColor = {
858
754
  b: number;
859
755
  };
860
756
  //#endregion
861
- //#region src/plasma/simulation.d.ts
862
- interface PlasmaSimulationConfig {
757
+ //#region src/plasma/layer.d.ts
758
+ interface PlasmaConfig {
863
759
  readonly speed?: number;
864
760
  readonly scale?: number;
865
761
  readonly resolution?: number;
866
762
  readonly palette?: PlasmaColor[];
867
- readonly canvasOptions?: CanvasRenderingContext2DSettings;
868
- }
869
- declare class PlasmaSimulation extends SimulationCanvas {
870
- constructor(canvas: HTMLCanvasElement, config?: PlasmaSimulationConfig);
871
763
  }
872
764
  //#endregion
873
- //#region src/plasma/layer.d.ts
874
- declare class PlasmaLayer extends SimulationLayer {
875
- #private;
876
- constructor(config?: PlasmaSimulationConfig);
877
- tick(dt: number, _width: number, _height: number): void;
878
- draw(ctx: CanvasRenderingContext2D, width: number, height: number): void;
879
- }
765
+ //#region src/plasma/index.d.ts
766
+ declare function createPlasma(config?: PlasmaConfig): Effect<PlasmaConfig>;
880
767
  //#endregion
881
768
  //#region src/rain/types.d.ts
882
769
  type RainVariant = "drizzle" | "downpour" | "thunderstorm";
@@ -900,8 +787,8 @@ type Splash = {
900
787
  gravity: number;
901
788
  };
902
789
  //#endregion
903
- //#region src/rain/simulation.d.ts
904
- interface RainSimulationConfig {
790
+ //#region src/rain/layer.d.ts
791
+ interface RainConfig {
905
792
  readonly variant?: RainVariant;
906
793
  readonly drops?: number;
907
794
  readonly wind?: number;
@@ -910,18 +797,6 @@ interface RainSimulationConfig {
910
797
  readonly color?: string;
911
798
  readonly groundLevel?: number;
912
799
  readonly scale?: number;
913
- readonly canvasOptions?: CanvasRenderingContext2DSettings;
914
- }
915
- declare class RainSimulation extends SimulationCanvas {
916
- constructor(canvas: HTMLCanvasElement, config?: RainSimulationConfig);
917
- }
918
- //#endregion
919
- //#region src/rain/layer.d.ts
920
- declare class RainLayer extends SimulationLayer {
921
- #private;
922
- constructor(config?: RainSimulationConfig);
923
- tick(dt: number, width: number, height: number): void;
924
- draw(ctx: CanvasRenderingContext2D, width: number, height: number): void;
925
800
  }
926
801
  //#endregion
927
802
  //#region src/rain/particle.d.ts
@@ -954,26 +829,17 @@ declare class SplashParticle {
954
829
  tick(dt?: number): void;
955
830
  }
956
831
  //#endregion
957
- //#region src/sandstorm/simulation.d.ts
958
- interface SandstormSimulationConfig {
832
+ //#region src/rain/index.d.ts
833
+ declare function createRain(config?: RainConfig): Effect<RainConfig>;
834
+ //#endregion
835
+ //#region src/sandstorm/layer.d.ts
836
+ interface SandstormConfig {
959
837
  readonly count?: number;
960
838
  readonly wind?: number;
961
839
  readonly turbulence?: number;
962
840
  readonly color?: string;
963
841
  readonly hazeOpacity?: number;
964
842
  readonly scale?: number;
965
- readonly canvasOptions?: CanvasRenderingContext2DSettings;
966
- }
967
- declare class SandstormSimulation extends SimulationCanvas {
968
- constructor(canvas: HTMLCanvasElement, config?: SandstormSimulationConfig);
969
- }
970
- //#endregion
971
- //#region src/sandstorm/layer.d.ts
972
- declare class SandstormLayer extends SimulationLayer {
973
- #private;
974
- constructor(config?: SandstormSimulationConfig);
975
- tick(dt: number, width: number, height: number): void;
976
- draw(ctx: CanvasRenderingContext2D, width: number, height: number): void;
977
843
  }
978
844
  //#endregion
979
845
  //#region src/sandstorm/types.d.ts
@@ -988,6 +854,57 @@ type SandGrain = {
988
854
  turbulenceOffset: number;
989
855
  };
990
856
  //#endregion
857
+ //#region src/sandstorm/index.d.ts
858
+ declare function createSandstorm(config?: SandstormConfig): Effect<SandstormConfig>;
859
+ //#endregion
860
+ //#region src/scene.d.ts
861
+ /**
862
+ * Composable canvas that renders multiple Effect layers in order (first = bottom, last = top).
863
+ *
864
+ * @example
865
+ * const scene = new Scene()
866
+ * .mount(canvas)
867
+ * .layer(new Aurora({ bands: 5 }))
868
+ * .layer(new Stars().withFade({ bottom: 0.4 }))
869
+ * .start();
870
+ */
871
+ declare class Scene {
872
+ #private;
873
+ constructor(frameRate?: number, options?: CanvasRenderingContext2DSettings);
874
+ /**
875
+ * Mount the scene to a canvas element or CSS selector.
876
+ */
877
+ mount(canvas: HTMLCanvasElement | string, options?: CanvasRenderingContext2DSettings): this;
878
+ /**
879
+ * Add an effect layer. Layers are rendered in the order they are added.
880
+ * If the scene is already running, the layer is mounted immediately.
881
+ */
882
+ layer(effect: SimulationLayer): this;
883
+ /**
884
+ * Start the render loop.
885
+ */
886
+ start(): this;
887
+ /**
888
+ * Pause rendering without destroying state. Use resume() to continue.
889
+ */
890
+ pause(): this;
891
+ /**
892
+ * Resume rendering after pause().
893
+ */
894
+ resume(): this;
895
+ /**
896
+ * Stop and destroy all layers.
897
+ */
898
+ destroy(): void;
899
+ get speed(): number;
900
+ set speed(value: number);
901
+ get isTicking(): boolean;
902
+ }
903
+ /**
904
+ * Factory alternative to `new Scene()`. Call .mount() and .layer() on the returned instance.
905
+ */
906
+ declare function createScene(frameRate?: number, options?: CanvasRenderingContext2DSettings): Scene;
907
+ //#endregion
991
908
  //#region src/shooting-stars/system.d.ts
992
909
  interface ShootingStarSystemConfig {
993
910
  readonly interval: [number, number];
@@ -1000,7 +917,6 @@ interface ShootingStarSystemConfig {
1000
917
  readonly alphaRange?: number;
1001
918
  readonly decayMin?: number;
1002
919
  readonly decayRange?: number;
1003
- readonly verticalFade?: [number, number];
1004
920
  }
1005
921
  declare class ShootingStarSystem {
1006
922
  #private;
@@ -1022,32 +938,23 @@ type ShootingStar = {
1022
938
  x: number;
1023
939
  y: number;
1024
940
  }[];
941
+ trailHead: number;
1025
942
  };
1026
943
  //#endregion
1027
- //#region src/snow/simulation.d.ts
1028
- interface SnowSimulationConfig {
944
+ //#region src/snow/layer.d.ts
945
+ interface SnowConfig {
1029
946
  readonly fillStyle?: string;
1030
947
  readonly particles?: number;
1031
948
  readonly scale?: number;
1032
949
  readonly size?: number;
1033
950
  readonly speed?: number;
1034
- readonly canvasOptions?: CanvasRenderingContext2DSettings;
1035
- }
1036
- declare class SnowSimulation extends SimulationCanvas {
1037
- constructor(canvas: HTMLCanvasElement, config?: SnowSimulationConfig);
1038
951
  }
1039
952
  //#endregion
1040
- //#region src/snow/layer.d.ts
1041
- declare class SnowLayer extends SimulationLayer {
1042
- #private;
1043
- constructor(config?: SnowSimulationConfig);
1044
- onResize(_width: number, height: number): void;
1045
- tick(dt: number, _width: number, height: number): void;
1046
- draw(ctx: CanvasRenderingContext2D, width: number, height: number): void;
1047
- }
953
+ //#region src/snow/index.d.ts
954
+ declare function createSnow(config?: SnowConfig): Effect<SnowConfig>;
1048
955
  //#endregion
1049
- //#region src/sparklers/simulation.d.ts
1050
- interface SparklerSimulationConfig {
956
+ //#region src/sparklers/layer.d.ts
957
+ interface SparklersConfig {
1051
958
  readonly emitRate?: number;
1052
959
  readonly maxSparks?: number;
1053
960
  readonly colors?: string[];
@@ -1058,23 +965,6 @@ interface SparklerSimulationConfig {
1058
965
  readonly trailLength?: number;
1059
966
  readonly hoverMode?: boolean;
1060
967
  readonly scale?: number;
1061
- readonly canvasOptions?: CanvasRenderingContext2DSettings;
1062
- }
1063
- declare class SparklerSimulation extends SimulationCanvas {
1064
- #private;
1065
- constructor(canvas: HTMLCanvasElement, config?: SparklerSimulationConfig);
1066
- setPosition(x: number, y: number): void;
1067
- }
1068
- //#endregion
1069
- //#region src/sparklers/layer.d.ts
1070
- declare class SparklerLayer extends SimulationLayer {
1071
- #private;
1072
- constructor(config?: SparklerSimulationConfig);
1073
- setPosition(x: number, y: number): void;
1074
- onMount(canvas: HTMLCanvasElement): void;
1075
- onUnmount(canvas: HTMLCanvasElement): void;
1076
- tick(dt: number, width: number, height: number): void;
1077
- draw(ctx: CanvasRenderingContext2D, width: number, height: number): void;
1078
968
  }
1079
969
  //#endregion
1080
970
  //#region src/sparklers/particle.d.ts
@@ -1108,6 +998,12 @@ type SparklerSpark = {
1108
998
  trail: Point[];
1109
999
  };
1110
1000
  //#endregion
1001
+ //#region src/sparklers/index.d.ts
1002
+ interface SparklersInstance extends Effect<SparklersConfig> {
1003
+ moveTo(x: number, y: number): void;
1004
+ }
1005
+ declare function createSparklers(config?: SparklersConfig): SparklersInstance;
1006
+ //#endregion
1111
1007
  //#region src/stars/types.d.ts
1112
1008
  type StarMode = "sky" | "shooting" | "both";
1113
1009
  type Star = {
@@ -1119,8 +1015,8 @@ type Star = {
1119
1015
  brightness: number;
1120
1016
  };
1121
1017
  //#endregion
1122
- //#region src/stars/simulation.d.ts
1123
- interface StarSimulationConfig {
1018
+ //#region src/stars/layer.d.ts
1019
+ interface StarsConfig {
1124
1020
  readonly mode?: StarMode;
1125
1021
  readonly starCount?: number;
1126
1022
  readonly shootingInterval?: [number, number];
@@ -1130,40 +1026,17 @@ interface StarSimulationConfig {
1130
1026
  readonly shootingColor?: string;
1131
1027
  readonly trailLength?: number;
1132
1028
  readonly scale?: number;
1133
- readonly verticalFade?: [number, number];
1134
- readonly canvasOptions?: CanvasRenderingContext2DSettings;
1135
- }
1136
- declare class StarSimulation extends SimulationCanvas {
1137
- constructor(canvas: HTMLCanvasElement, config?: StarSimulationConfig);
1138
1029
  }
1139
1030
  //#endregion
1140
- //#region src/stars/layer.d.ts
1141
- declare class StarLayer extends SimulationLayer {
1142
- #private;
1143
- constructor(config?: StarSimulationConfig);
1144
- tick(dt: number, width: number, height: number): void;
1145
- draw(ctx: CanvasRenderingContext2D, width: number, height: number): void;
1146
- }
1031
+ //#region src/stars/index.d.ts
1032
+ declare function createStars(config?: StarsConfig): Effect<StarsConfig>;
1147
1033
  //#endregion
1148
- //#region src/streamers/simulation.d.ts
1149
- interface StreamerSimulationConfig {
1034
+ //#region src/streamers/layer.d.ts
1035
+ interface StreamersConfig {
1150
1036
  readonly count?: number;
1151
1037
  readonly colors?: string[];
1152
1038
  readonly speed?: number;
1153
1039
  readonly scale?: number;
1154
- readonly canvasOptions?: CanvasRenderingContext2DSettings;
1155
- }
1156
- declare class StreamerSimulation extends SimulationCanvas {
1157
- constructor(canvas: HTMLCanvasElement, config?: StreamerSimulationConfig);
1158
- }
1159
- //#endregion
1160
- //#region src/streamers/layer.d.ts
1161
- declare class StreamerLayer extends SimulationLayer {
1162
- #private;
1163
- constructor(config?: StreamerSimulationConfig);
1164
- onResize(width: number, height: number): void;
1165
- tick(dt: number, width: number, height: number): void;
1166
- draw(ctx: CanvasRenderingContext2D, width: number, height: number): void;
1167
1040
  }
1168
1041
  //#endregion
1169
1042
  //#region src/streamers/types.d.ts
@@ -1185,6 +1058,9 @@ type Streamer = {
1185
1058
  depth: number;
1186
1059
  };
1187
1060
  //#endregion
1061
+ //#region src/streamers/index.d.ts
1062
+ declare function createStreamers(config?: StreamersConfig): Effect<StreamersConfig>;
1063
+ //#endregion
1188
1064
  //#region src/trail.d.ts
1189
1065
  interface TrailConfig {
1190
1066
  readonly acceleration?: number;
@@ -1206,26 +1082,14 @@ declare class Trail {
1206
1082
  tick(dt?: number): void;
1207
1083
  }
1208
1084
  //#endregion
1209
- //#region src/waves/simulation.d.ts
1210
- interface WaveSimulationConfig {
1085
+ //#region src/waves/layer.d.ts
1086
+ interface WavesConfig {
1211
1087
  readonly layers?: number;
1212
1088
  readonly speed?: number;
1213
1089
  readonly colors?: string[];
1214
1090
  readonly foamColor?: string;
1215
1091
  readonly foamAmount?: number;
1216
1092
  readonly scale?: number;
1217
- readonly canvasOptions?: CanvasRenderingContext2DSettings;
1218
- }
1219
- declare class WaveSimulation extends SimulationCanvas {
1220
- constructor(canvas: HTMLCanvasElement, config?: WaveSimulationConfig);
1221
- }
1222
- //#endregion
1223
- //#region src/waves/layer.d.ts
1224
- declare class WaveLayer extends SimulationLayer {
1225
- #private;
1226
- constructor(config?: WaveSimulationConfig);
1227
- tick(dt: number, width: number, height: number): void;
1228
- draw(ctx: CanvasRenderingContext2D, width: number, height: number): void;
1229
1093
  }
1230
1094
  //#endregion
1231
1095
  //#region src/waves/types.d.ts
@@ -1237,8 +1101,12 @@ type Wave = {
1237
1101
  baseY: number;
1238
1102
  color: string;
1239
1103
  foamThreshold: number;
1104
+ rgb: [number, number, number];
1240
1105
  };
1241
1106
  //#endregion
1107
+ //#region src/waves/index.d.ts
1108
+ declare function createWaves(config?: WavesConfig): Effect<WavesConfig>;
1109
+ //#endregion
1242
1110
  //#region src/wormhole/types.d.ts
1243
1111
  type WormholeDirection = "inward" | "outward";
1244
1112
  type WormholeParticle = {
@@ -1250,27 +1118,17 @@ type WormholeParticle = {
1250
1118
  trail: number;
1251
1119
  };
1252
1120
  //#endregion
1253
- //#region src/wormhole/simulation.d.ts
1254
- interface WormholeSimulationConfig {
1121
+ //#region src/wormhole/layer.d.ts
1122
+ interface WormholeConfig {
1255
1123
  readonly count?: number;
1256
1124
  readonly speed?: number;
1257
1125
  readonly color?: string;
1258
1126
  readonly direction?: WormholeDirection;
1259
1127
  readonly scale?: number;
1260
- readonly canvasOptions?: CanvasRenderingContext2DSettings;
1261
- }
1262
- declare class WormholeSimulation extends SimulationCanvas {
1263
- constructor(canvas: HTMLCanvasElement, config?: WormholeSimulationConfig);
1264
1128
  }
1265
1129
  //#endregion
1266
- //#region src/wormhole/layer.d.ts
1267
- declare class WormholeLayer extends SimulationLayer {
1268
- #private;
1269
- constructor(config?: WormholeSimulationConfig);
1270
- onResize(width: number, height: number): void;
1271
- tick(dt: number, width: number, height: number): void;
1272
- draw(ctx: CanvasRenderingContext2D, width: number, height: number): void;
1273
- }
1130
+ //#region src/wormhole/index.d.ts
1131
+ declare function createWormhole(config?: WormholeConfig): Effect<WormholeConfig>;
1274
1132
  //#endregion
1275
- export { AuroraBand, AuroraLayer, AuroraSimulation, AuroraSimulationConfig, Balloon, BalloonLayer, BalloonParticle, BalloonParticleConfig, BalloonSimulation, BalloonSimulationConfig, Bubble, BubbleLayer, BubbleSimulation, BubbleSimulationConfig, ConfettiLayer, ConfettiParticle, type ConfettiParticleConfig, type Shape as ConfettiShape, ConfettiSimulation, type ConfettiSimulationConfig, DonutLayer, DonutSimulation, DonutSimulationConfig, EXPLOSION_CONFIGS, EdgeFade, EdgeFadeSide, Ember, Explosion, ExplosionConfig, ExplosionType, FIREWORK_VARIANTS, FallingGlitter, Firefly, FireflyLayer, FireflyParticle, FireflyParticleConfig, FireflySimulation, FireflySimulationConfig, FirepitLayer, FirepitSimulation, FirepitSimulationConfig, Firework, FireworkLayer, FireworkSimulation, FireworkSimulationConfig, FireworkVariant, FlameLayer, GlitterLayer, GlitterSimulation, GlitterSimulationConfig, Lantern, LanternLayer, LanternSimulation, LanternSimulationConfig, LayeredSimulation, Leaf, LeafLayer, LeafSimulation, LeafSimulationConfig, LightningBolt, LightningBranch, LightningLayer, LightningSimulation, LightningSimulationConfig, LightningSystem, LightningSystemConfig, LimitedFrameRateCanvas, MatrixColumn, MatrixLayer, MatrixSimulation, MatrixSimulationConfig, NetworkParticle, OrbitLayer, OrbitSimulation, OrbitSimulationConfig, OrbitalCenter, Orbiter, PALETTES, type Palette, ParticleLayer, ParticleMouseMode, ParticleShape, ParticleSimulation, ParticleSimulationConfig, Petal, PetalLayer, PetalSimulation, PetalSimulationConfig, PlasmaColor, PlasmaLayer, PlasmaSimulation, PlasmaSimulationConfig, PopParticle, RainLayer, RainSimulation, RainSimulationConfig, RainVariant, Raindrop, RaindropParticle, RaindropParticleConfig, SHAPE_PATHS, SandGrain, SandstormLayer, SandstormSimulation, SandstormSimulationConfig, SettledGlitter, type ShootingStar, ShootingStarSystem, ShootingStarSystemConfig, SimulationCanvas, SimulationLayer, SnowLayer, SnowSimulation, SnowSimulationConfig, Spark, SparklerLayer, SparklerParticle, SparklerParticleConfig, SparklerSimulation, SparklerSimulationConfig, SparklerSpark, Splash, SplashParticle, SplashParticleConfig, Star, StarLayer, StarMode, StarSimulation, StarSimulationConfig, Streamer, StreamerLayer, StreamerSimulation, StreamerSimulationConfig, Trail, TrailConfig, Wave, WaveLayer, WaveSimulation, WaveSimulationConfig, WormholeDirection, WormholeLayer, WormholeParticle, WormholeSimulation, WormholeSimulationConfig, createFireflySprite, parseColor };
1133
+ export { type AuroraBand, type AuroraConfig, type Balloon, BalloonParticle, type BalloonParticleConfig, type BalloonsConfig, type Bubble, type BubblesConfig, type Config as ConfettiBurstConfig, type ConfettiConfig, ConfettiInstance, ConfettiParticle, type ConfettiParticleConfig, type Shape as ConfettiShape, type DonutsConfig, EXPLOSION_CONFIGS, type EdgeFade, type EdgeFadeSide, Effect, type Ember, Explosion, type ExplosionConfig, type ExplosionType, FIREWORK_VARIANTS, type FallingGlitter, type FirefliesConfig, type Firefly, FireflyParticle, type FireflyParticleConfig, type FirepitConfig, Firework, type FireworkVariant, type FireworksConfig, FireworksInstance, type FlameLayer, type GlitterConfig, type Lantern, type LanternsConfig, type Leaf, type LeavesConfig, type LightningBolt, type LightningBranch, type LightningConfig, LightningSystem, type LightningSystemConfig, LimitedFrameRateCanvas, type MatrixColumn, type MatrixConfig, type NetworkParticle, type OrbitalCenter, type Orbiter, type OrbitsConfig, PALETTES, type Palette, type ParticleMouseMode, type ParticleShape, type ParticlesConfig, type Petal, type PetalsConfig, type PlasmaColor, type PlasmaConfig, type PopParticle, type RainConfig, type RainVariant, type Raindrop, RaindropParticle, type RaindropParticleConfig, SHAPE_PATHS, type SandGrain, type SandstormConfig, Scene, type SettledGlitter, type ShootingStar, ShootingStarSystem, ShootingStarSystemConfig, type SnowConfig, Spark, SparklerParticle, type SparklerParticleConfig, type SparklerSpark, type SparklersConfig, SparklersInstance, type Splash, SplashParticle, type SplashParticleConfig, type Star, type StarMode, type StarsConfig, type Streamer, type StreamersConfig, Trail, TrailConfig, type Wave, type WavesConfig, type WormholeConfig, type WormholeDirection, type WormholeParticle, createAurora, createBalloons, createBubbles, createConfetti, createDonuts, createExplosion, createFireflies, createFireflySprite, createFirepit, createFireworks, createGlitter, createLanterns, createLeaves, createLightning, createMatrix, createOrbits, createParticles, createPetals, createPlasma, createRain, createSandstorm, createScene, createSnow, createSparklers, createStars, createStreamers, createWaves, createWormhole, parseColor };
1276
1134
  //# sourceMappingURL=index.d.mts.map