@basmilius/sparkle 2.1.0 → 2.2.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 (107) hide show
  1. package/dist/index.d.mts +306 -459
  2. package/dist/index.d.mts.map +1 -1
  3. package/dist/index.mjs +1106 -848
  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 +12 -0
  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/donuts/consts.ts +2 -2
  18. package/src/donuts/index.ts +9 -3
  19. package/src/donuts/layer.ts +43 -12
  20. package/src/effect.ts +107 -0
  21. package/src/fade.ts +87 -0
  22. package/src/fireflies/index.ts +9 -3
  23. package/src/fireflies/layer.ts +26 -9
  24. package/src/fireflies/particle.ts +2 -2
  25. package/src/firepit/index.ts +9 -3
  26. package/src/firepit/layer.ts +26 -7
  27. package/src/fireworks/create-explosion.ts +237 -0
  28. package/src/fireworks/explosion.ts +1 -1
  29. package/src/fireworks/index.ts +15 -3
  30. package/src/fireworks/layer.ts +55 -304
  31. package/src/fireworks/spark.ts +2 -2
  32. package/src/fireworks/types.ts +2 -2
  33. package/src/glitter/index.ts +9 -4
  34. package/src/glitter/layer.ts +15 -7
  35. package/src/glitter/types.ts +10 -0
  36. package/src/index.ts +3 -4
  37. package/src/lanterns/index.ts +9 -4
  38. package/src/lanterns/layer.ts +22 -10
  39. package/src/lanterns/types.ts +8 -0
  40. package/src/layer.ts +13 -11
  41. package/src/leaves/index.ts +9 -4
  42. package/src/leaves/layer.ts +21 -14
  43. package/src/leaves/types.ts +9 -0
  44. package/src/lightning/index.ts +9 -4
  45. package/src/lightning/layer.ts +4 -4
  46. package/src/lightning/system.ts +3 -3
  47. package/src/lightning/types.ts +10 -2
  48. package/src/matrix/index.ts +9 -4
  49. package/src/matrix/layer.ts +15 -7
  50. package/src/matrix/types.ts +9 -0
  51. package/src/orbits/index.ts +9 -4
  52. package/src/orbits/layer.ts +51 -21
  53. package/src/orbits/types.ts +12 -1
  54. package/src/particles/index.ts +9 -3
  55. package/src/particles/layer.ts +55 -12
  56. package/src/petals/index.ts +9 -3
  57. package/src/petals/layer.ts +29 -13
  58. package/src/plasma/index.ts +9 -3
  59. package/src/plasma/layer.ts +21 -6
  60. package/src/rain/index.ts +9 -3
  61. package/src/rain/layer.ts +30 -8
  62. package/src/sandstorm/index.ts +9 -3
  63. package/src/sandstorm/layer.ts +26 -9
  64. package/src/scene.ts +201 -0
  65. package/src/shooting-stars/system.ts +26 -24
  66. package/src/shooting-stars/types.ts +2 -1
  67. package/src/simulation-canvas.ts +40 -4
  68. package/src/snow/index.ts +9 -3
  69. package/src/snow/layer.ts +24 -11
  70. package/src/sparklers/index.ts +13 -3
  71. package/src/sparklers/layer.ts +61 -15
  72. package/src/stars/index.ts +9 -3
  73. package/src/stars/layer.ts +28 -22
  74. package/src/streamers/index.ts +9 -3
  75. package/src/streamers/layer.ts +18 -6
  76. package/src/streamers/types.ts +1 -1
  77. package/src/waves/index.ts +9 -3
  78. package/src/waves/layer.ts +42 -45
  79. package/src/waves/types.ts +1 -0
  80. package/src/wormhole/index.ts +9 -3
  81. package/src/wormhole/layer.ts +22 -6
  82. package/src/aurora/simulation.ts +0 -19
  83. package/src/balloons/simulation.ts +0 -19
  84. package/src/bubbles/simulation.ts +0 -20
  85. package/src/confetti/simulation.ts +0 -27
  86. package/src/donuts/simulation.ts +0 -25
  87. package/src/fireflies/simulation.ts +0 -18
  88. package/src/firepit/simulation.ts +0 -17
  89. package/src/fireworks/simulation.ts +0 -18
  90. package/src/glitter/simulation.ts +0 -19
  91. package/src/lanterns/simulation.ts +0 -17
  92. package/src/layered.ts +0 -185
  93. package/src/leaves/simulation.ts +0 -18
  94. package/src/lightning/simulation.ts +0 -17
  95. package/src/matrix/simulation.ts +0 -18
  96. package/src/orbits/simulation.ts +0 -19
  97. package/src/particles/simulation.ts +0 -26
  98. package/src/petals/simulation.ts +0 -18
  99. package/src/plasma/simulation.ts +0 -17
  100. package/src/rain/simulation.ts +0 -21
  101. package/src/sandstorm/simulation.ts +0 -18
  102. package/src/snow/simulation.ts +0 -17
  103. package/src/sparklers/simulation.ts +0 -30
  104. package/src/stars/simulation.ts +0 -22
  105. package/src/streamers/simulation.ts +0 -16
  106. package/src/waves/simulation.ts +0 -18
  107. 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): 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,47 @@ 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
+ get canvas(): HTMLCanvasElement;
207
+ get context(): CanvasRenderingContext2D;
208
+ get delta(): number;
209
+ get deltaFactor(): number;
210
+ get speed(): number;
211
+ set speed(value: number);
212
+ get frameRate(): number;
213
+ get isSmall(): boolean;
214
+ get isTicking(): boolean;
215
+ get ticks(): number;
216
+ get height(): number;
217
+ get width(): number;
218
+ constructor(canvas: HTMLCanvasElement, frameRate: number, options?: CanvasRenderingContext2DSettings);
219
+ loop(): void;
220
+ start(): void;
221
+ stop(): void;
222
+ pause(): void;
223
+ resume(): void;
224
+ draw(): void;
225
+ tick(): void;
226
+ destroy(): void;
227
+ onResize(): void;
228
+ onVisibilityChange(): void;
229
+ }
230
+ //#endregion
231
+ //#region src/color.d.ts
232
+ declare function parseColor(fillStyle: string): {
233
+ r: number;
234
+ g: number;
235
+ b: number;
236
+ a: number;
237
+ };
238
+ //#endregion
218
239
  //#region src/confetti/types.d.ts
219
240
  type Config = {
220
241
  readonly angle: number;
@@ -233,26 +254,9 @@ type Config = {
233
254
  type Palette = "classic" | "pastel" | "vibrant" | "warm";
234
255
  type Shape = "bowtie" | "circle" | "crescent" | "diamond" | "heart" | "hexagon" | "ribbon" | "ring" | "square" | "star" | "triangle";
235
256
  //#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
257
  //#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;
258
+ interface ConfettiConfig {
259
+ readonly scale?: number;
256
260
  }
257
261
  //#endregion
258
262
  //#region src/confetti/particle.d.ts
@@ -279,10 +283,15 @@ declare const PALETTES: Record<Palette, string[]>;
279
283
  //#region src/confetti/shapes.d.ts
280
284
  declare const SHAPE_PATHS: Record<Shape, Path2D>;
281
285
  //#endregion
282
- //#region src/donuts/simulation.d.ts
283
- interface DonutSimulationConfig {
286
+ //#region src/confetti/index.d.ts
287
+ interface ConfettiInstance extends Effect<ConfettiConfig> {
288
+ burst(config: Partial<Config>): void;
289
+ }
290
+ declare function createConfetti(config?: ConfettiConfig): ConfettiInstance;
291
+ //#endregion
292
+ //#region src/donuts/layer.d.ts
293
+ interface DonutsConfig {
284
294
  readonly background?: string;
285
- readonly canvasOptions?: CanvasRenderingContext2DSettings;
286
295
  readonly collisionPadding?: number;
287
296
  readonly colors?: string[];
288
297
  readonly count?: number;
@@ -296,41 +305,18 @@ interface DonutSimulationConfig {
296
305
  readonly speedRange?: [number, number];
297
306
  readonly thickness?: number;
298
307
  }
299
- declare class DonutSimulation extends SimulationCanvas {
300
- constructor(canvas: HTMLCanvasElement, config?: DonutSimulationConfig);
301
- }
302
308
  //#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
- }
309
+ //#region src/donuts/index.d.ts
310
+ declare function createDonuts(config?: DonutsConfig): Effect<DonutsConfig>;
313
311
  //#endregion
314
- //#region src/fireflies/simulation.d.ts
315
- interface FireflySimulationConfig {
312
+ //#region src/fireflies/layer.d.ts
313
+ interface FirefliesConfig {
316
314
  readonly count?: number;
317
315
  readonly color?: string;
318
316
  readonly size?: number;
319
317
  readonly speed?: number;
320
318
  readonly glowSpeed?: number;
321
319
  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
320
  }
335
321
  //#endregion
336
322
  //#region src/fireflies/particle.d.ts
@@ -374,25 +360,16 @@ type Firefly = {
374
360
  amplitudeY: number;
375
361
  };
376
362
  //#endregion
377
- //#region src/firepit/simulation.d.ts
378
- interface FirepitSimulationConfig {
363
+ //#region src/fireflies/index.d.ts
364
+ declare function createFireflies(config?: FirefliesConfig): Effect<FirefliesConfig>;
365
+ //#endregion
366
+ //#region src/firepit/layer.d.ts
367
+ interface FirepitConfig {
379
368
  readonly embers?: number;
380
369
  readonly flameWidth?: number;
381
370
  readonly flameHeight?: number;
382
371
  readonly intensity?: number;
383
372
  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
373
  }
397
374
  //#endregion
398
375
  //#region src/firepit/types.d.ts
@@ -416,6 +393,9 @@ type FlameLayer = {
416
393
  height: number;
417
394
  };
418
395
  //#endregion
396
+ //#region src/firepit/index.d.ts
397
+ declare function createFirepit(config?: FirepitConfig): Effect<FirepitConfig>;
398
+ //#endregion
419
399
  //#region src/fireworks/types.d.ts
420
400
  type ExplosionType = "peony" | "chrysanthemum" | "willow" | "ring" | "palm" | "crackle" | "crossette" | "dahlia" | "brocade" | "horsetail" | "strobe" | "heart" | "spiral" | "flower";
421
401
  type FireworkVariant = ExplosionType | "saturn" | "concentric";
@@ -436,10 +416,10 @@ interface ExplosionConfig {
436
416
  readonly spread3d: boolean;
437
417
  readonly glowSize: number;
438
418
  }
439
- interface FireworkSimulationConfig {
419
+ interface FireworksConfig {
440
420
  readonly scale?: number;
441
421
  readonly autoSpawn?: boolean;
442
- readonly canvasOptions?: CanvasRenderingContext2DSettings;
422
+ readonly variants?: FireworkVariant[];
443
423
  }
444
424
  declare const FIREWORK_VARIANTS: FireworkVariant[];
445
425
  declare const EXPLOSION_CONFIGS: Record<ExplosionType, ExplosionConfig>;
@@ -459,6 +439,23 @@ declare class Explosion {
459
439
  tick(dt: number): void;
460
440
  }
461
441
  //#endregion
442
+ //#region src/fireworks/create-explosion.d.ts
443
+ /**
444
+ * Creates an array of {@link Explosion} particles for the given firework variant.
445
+ * Use this to fire a fully formed explosion burst in your own render loop without
446
+ * needing a {@link Fireworks} instance.
447
+ *
448
+ * @param variant - The firework variant to create.
449
+ * @param position - The center position of the explosion in canvas pixels.
450
+ * @param hue - Base hue in degrees (0–360).
451
+ * @param options - Optional overrides for `lineWidth` (default `5`) and `scale` (default `1`).
452
+ * @param rng - RNG function returning values in [0, 1). Defaults to `Math.random`.
453
+ */
454
+ declare function createExplosion(variant: FireworkVariant, position: Point, hue: number, options?: {
455
+ lineWidth?: number;
456
+ scale?: number;
457
+ }, rng?: () => number): Explosion[];
458
+ //#endregion
462
459
  //#region src/fireworks/spark.d.ts
463
460
  declare class Spark {
464
461
  #private;
@@ -480,25 +477,14 @@ declare class Firework extends EventTarget {
480
477
  tick(dt: number): void;
481
478
  }
482
479
  //#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;
480
+ //#region src/fireworks/index.d.ts
481
+ interface FireworksInstance extends Effect<FireworksConfig> {
482
+ launch(variant: FireworkVariant, position?: Point): void;
498
483
  }
484
+ declare function createFireworks(config?: FireworksConfig): FireworksInstance;
499
485
  //#endregion
500
- //#region src/glitter/simulation.d.ts
501
- interface GlitterSimulationConfig {
486
+ //#region src/glitter/types.d.ts
487
+ interface GlitterConfig {
502
488
  readonly count?: number;
503
489
  readonly colors?: string[];
504
490
  readonly size?: number;
@@ -506,21 +492,7 @@ interface GlitterSimulationConfig {
506
492
  readonly groundLevel?: number;
507
493
  readonly maxSettled?: number;
508
494
  readonly scale?: number;
509
- readonly canvasOptions?: CanvasRenderingContext2DSettings;
510
- }
511
- declare class GlitterSimulation extends SimulationCanvas {
512
- constructor(canvas: HTMLCanvasElement, config?: GlitterSimulationConfig);
513
495
  }
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
496
  type FallingGlitter = {
525
497
  x: number;
526
498
  y: number;
@@ -544,28 +516,17 @@ type SettledGlitter = {
544
516
  colorIndex: number;
545
517
  };
546
518
  //#endregion
547
- //#region src/lanterns/simulation.d.ts
548
- interface LanternSimulationConfig {
519
+ //#region src/glitter/index.d.ts
520
+ declare function createGlitter(config?: GlitterConfig): Effect<GlitterConfig>;
521
+ //#endregion
522
+ //#region src/lanterns/types.d.ts
523
+ interface LanternsConfig {
549
524
  readonly count?: number;
550
525
  readonly colors?: string[];
551
526
  readonly size?: number;
552
527
  readonly speed?: number;
553
528
  readonly scale?: number;
554
- readonly canvasOptions?: CanvasRenderingContext2DSettings;
555
- }
556
- declare class LanternSimulation extends SimulationCanvas {
557
- constructor(canvas: HTMLCanvasElement, config?: LanternSimulationConfig);
558
529
  }
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
530
  type Lantern = {
570
531
  x: number;
571
532
  y: number;
@@ -581,42 +542,18 @@ type Lantern = {
581
542
  opacity: number;
582
543
  };
583
544
  //#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
- }
545
+ //#region src/lanterns/index.d.ts
546
+ declare function createLanterns(config?: LanternsConfig): Effect<LanternsConfig>;
595
547
  //#endregion
596
- //#region src/leaves/simulation.d.ts
597
- interface LeafSimulationConfig {
548
+ //#region src/leaves/types.d.ts
549
+ interface LeavesConfig {
598
550
  readonly count?: number;
599
551
  readonly colors?: string[];
600
552
  readonly size?: number;
601
553
  readonly speed?: number;
602
554
  readonly wind?: number;
603
555
  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
556
  }
618
- //#endregion
619
- //#region src/leaves/types.d.ts
620
557
  type Leaf = {
621
558
  x: number;
622
559
  y: number;
@@ -634,26 +571,34 @@ type Leaf = {
634
571
  colorIndex: number;
635
572
  };
636
573
  //#endregion
637
- //#region src/lightning/simulation.d.ts
638
- interface LightningSimulationConfig {
574
+ //#region src/leaves/index.d.ts
575
+ declare function createLeaves(config?: LeavesConfig): Effect<LeavesConfig>;
576
+ //#endregion
577
+ //#region src/lightning/types.d.ts
578
+ interface LightningConfig {
639
579
  readonly frequency?: number;
640
580
  readonly color?: string;
641
581
  readonly branches?: boolean;
642
582
  readonly flash?: boolean;
643
583
  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
584
  }
585
+ type LightningBranch = {
586
+ segments: {
587
+ x: number;
588
+ y: number;
589
+ }[];
590
+ alpha: number;
591
+ };
592
+ type LightningBolt = {
593
+ segments: {
594
+ x: number;
595
+ y: number;
596
+ }[];
597
+ branches: LightningBranch[];
598
+ alpha: number;
599
+ lifetime: number;
600
+ ticksAlive: number;
601
+ };
657
602
  //#endregion
658
603
  //#region src/lightning/system.d.ts
659
604
  interface LightningSystemConfig {
@@ -672,49 +617,18 @@ declare class LightningSystem {
672
617
  draw(ctx: CanvasRenderingContext2D, width: number, height: number): void;
673
618
  }
674
619
  //#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
- };
620
+ //#region src/lightning/index.d.ts
621
+ declare function createLightning(config?: LightningConfig): Effect<LightningConfig>;
693
622
  //#endregion
694
- //#region src/matrix/simulation.d.ts
695
- interface MatrixSimulationConfig {
623
+ //#region src/matrix/types.d.ts
624
+ interface MatrixConfig {
696
625
  readonly columns?: number;
697
626
  readonly speed?: number;
698
627
  readonly color?: string;
699
628
  readonly fontSize?: number;
700
629
  readonly trailLength?: number;
701
630
  readonly scale?: number;
702
- readonly canvasOptions?: CanvasRenderingContext2DSettings;
703
631
  }
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
632
  type MatrixColumn = {
719
633
  x: number;
720
634
  y: number;
@@ -724,8 +638,11 @@ type MatrixColumn = {
724
638
  headBrightness: number;
725
639
  };
726
640
  //#endregion
727
- //#region src/orbits/simulation.d.ts
728
- interface OrbitSimulationConfig {
641
+ //#region src/matrix/index.d.ts
642
+ declare function createMatrix(config?: MatrixConfig): Effect<MatrixConfig>;
643
+ //#endregion
644
+ //#region src/orbits/types.d.ts
645
+ interface OrbitsConfig {
729
646
  readonly centers?: number;
730
647
  readonly orbitersPerCenter?: number;
731
648
  readonly speed?: number;
@@ -733,22 +650,7 @@ interface OrbitSimulationConfig {
733
650
  readonly trailLength?: number;
734
651
  readonly showCenters?: boolean;
735
652
  readonly scale?: number;
736
- readonly canvasOptions?: CanvasRenderingContext2DSettings;
737
653
  }
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
654
  type OrbitalCenter = {
753
655
  x: number;
754
656
  y: number;
@@ -766,8 +668,12 @@ type Orbiter = {
766
668
  x: number;
767
669
  y: number;
768
670
  }[];
671
+ trailHead: number;
769
672
  };
770
673
  //#endregion
674
+ //#region src/orbits/index.d.ts
675
+ declare function createOrbits(config?: OrbitsConfig): Effect<OrbitsConfig>;
676
+ //#endregion
771
677
  //#region src/particles/types.d.ts
772
678
  type ParticleMouseMode = "attract" | "repel" | "connect" | "none";
773
679
  type NetworkParticle = {
@@ -779,8 +685,8 @@ type NetworkParticle = {
779
685
  baseSpeed: number;
780
686
  };
781
687
  //#endregion
782
- //#region src/particles/simulation.d.ts
783
- interface ParticleSimulationConfig {
688
+ //#region src/particles/layer.d.ts
689
+ interface ParticlesConfig {
784
690
  readonly count?: number;
785
691
  readonly color?: string;
786
692
  readonly lineColor?: string;
@@ -795,43 +701,19 @@ interface ParticleSimulationConfig {
795
701
  readonly glow?: boolean;
796
702
  readonly background?: string | null;
797
703
  readonly scale?: number;
798
- readonly canvasOptions?: CanvasRenderingContext2DSettings;
799
- }
800
- declare class ParticleSimulation extends SimulationCanvas {
801
- constructor(canvas: HTMLCanvasElement, config?: ParticleSimulationConfig);
802
704
  }
803
705
  //#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
- }
706
+ //#region src/particles/index.d.ts
707
+ declare function createParticles(config?: ParticlesConfig): Effect<ParticlesConfig>;
814
708
  //#endregion
815
- //#region src/petals/simulation.d.ts
816
- interface PetalSimulationConfig {
709
+ //#region src/petals/layer.d.ts
710
+ interface PetalsConfig {
817
711
  readonly count?: number;
818
712
  readonly colors?: string[];
819
713
  readonly size?: number;
820
714
  readonly speed?: number;
821
715
  readonly wind?: number;
822
716
  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
717
  }
836
718
  //#endregion
837
719
  //#region src/petals/types.d.ts
@@ -851,6 +733,9 @@ type Petal = {
851
733
  colorIndex: number;
852
734
  };
853
735
  //#endregion
736
+ //#region src/petals/index.d.ts
737
+ declare function createPetals(config?: PetalsConfig): Effect<PetalsConfig>;
738
+ //#endregion
854
739
  //#region src/plasma/types.d.ts
855
740
  type PlasmaColor = {
856
741
  r: number;
@@ -858,25 +743,16 @@ type PlasmaColor = {
858
743
  b: number;
859
744
  };
860
745
  //#endregion
861
- //#region src/plasma/simulation.d.ts
862
- interface PlasmaSimulationConfig {
746
+ //#region src/plasma/layer.d.ts
747
+ interface PlasmaConfig {
863
748
  readonly speed?: number;
864
749
  readonly scale?: number;
865
750
  readonly resolution?: number;
866
751
  readonly palette?: PlasmaColor[];
867
- readonly canvasOptions?: CanvasRenderingContext2DSettings;
868
- }
869
- declare class PlasmaSimulation extends SimulationCanvas {
870
- constructor(canvas: HTMLCanvasElement, config?: PlasmaSimulationConfig);
871
752
  }
872
753
  //#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
- }
754
+ //#region src/plasma/index.d.ts
755
+ declare function createPlasma(config?: PlasmaConfig): Effect<PlasmaConfig>;
880
756
  //#endregion
881
757
  //#region src/rain/types.d.ts
882
758
  type RainVariant = "drizzle" | "downpour" | "thunderstorm";
@@ -900,8 +776,8 @@ type Splash = {
900
776
  gravity: number;
901
777
  };
902
778
  //#endregion
903
- //#region src/rain/simulation.d.ts
904
- interface RainSimulationConfig {
779
+ //#region src/rain/layer.d.ts
780
+ interface RainConfig {
905
781
  readonly variant?: RainVariant;
906
782
  readonly drops?: number;
907
783
  readonly wind?: number;
@@ -910,18 +786,6 @@ interface RainSimulationConfig {
910
786
  readonly color?: string;
911
787
  readonly groundLevel?: number;
912
788
  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
789
  }
926
790
  //#endregion
927
791
  //#region src/rain/particle.d.ts
@@ -954,26 +818,17 @@ declare class SplashParticle {
954
818
  tick(dt?: number): void;
955
819
  }
956
820
  //#endregion
957
- //#region src/sandstorm/simulation.d.ts
958
- interface SandstormSimulationConfig {
821
+ //#region src/rain/index.d.ts
822
+ declare function createRain(config?: RainConfig): Effect<RainConfig>;
823
+ //#endregion
824
+ //#region src/sandstorm/layer.d.ts
825
+ interface SandstormConfig {
959
826
  readonly count?: number;
960
827
  readonly wind?: number;
961
828
  readonly turbulence?: number;
962
829
  readonly color?: string;
963
830
  readonly hazeOpacity?: number;
964
831
  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
832
  }
978
833
  //#endregion
979
834
  //#region src/sandstorm/types.d.ts
@@ -988,6 +843,57 @@ type SandGrain = {
988
843
  turbulenceOffset: number;
989
844
  };
990
845
  //#endregion
846
+ //#region src/sandstorm/index.d.ts
847
+ declare function createSandstorm(config?: SandstormConfig): Effect<SandstormConfig>;
848
+ //#endregion
849
+ //#region src/scene.d.ts
850
+ /**
851
+ * Composable canvas that renders multiple Effect layers in order (first = bottom, last = top).
852
+ *
853
+ * @example
854
+ * const scene = new Scene()
855
+ * .mount(canvas)
856
+ * .layer(new Aurora({ bands: 5 }))
857
+ * .layer(new Stars().withFade({ bottom: 0.4 }))
858
+ * .start();
859
+ */
860
+ declare class Scene {
861
+ #private;
862
+ constructor(frameRate?: number, options?: CanvasRenderingContext2DSettings);
863
+ /**
864
+ * Mount the scene to a canvas element or CSS selector.
865
+ */
866
+ mount(canvas: HTMLCanvasElement | string, options?: CanvasRenderingContext2DSettings): this;
867
+ /**
868
+ * Add an effect layer. Layers are rendered in the order they are added.
869
+ * If the scene is already running, the layer is mounted immediately.
870
+ */
871
+ layer(effect: SimulationLayer): this;
872
+ /**
873
+ * Start the render loop.
874
+ */
875
+ start(): this;
876
+ /**
877
+ * Pause rendering without destroying state. Use resume() to continue.
878
+ */
879
+ pause(): this;
880
+ /**
881
+ * Resume rendering after pause().
882
+ */
883
+ resume(): this;
884
+ /**
885
+ * Stop and destroy all layers.
886
+ */
887
+ destroy(): void;
888
+ get speed(): number;
889
+ set speed(value: number);
890
+ get isTicking(): boolean;
891
+ }
892
+ /**
893
+ * Factory alternative to `new Scene()`. Call .mount() and .layer() on the returned instance.
894
+ */
895
+ declare function createScene(frameRate?: number, options?: CanvasRenderingContext2DSettings): Scene;
896
+ //#endregion
991
897
  //#region src/shooting-stars/system.d.ts
992
898
  interface ShootingStarSystemConfig {
993
899
  readonly interval: [number, number];
@@ -1000,7 +906,6 @@ interface ShootingStarSystemConfig {
1000
906
  readonly alphaRange?: number;
1001
907
  readonly decayMin?: number;
1002
908
  readonly decayRange?: number;
1003
- readonly verticalFade?: [number, number];
1004
909
  }
1005
910
  declare class ShootingStarSystem {
1006
911
  #private;
@@ -1022,32 +927,23 @@ type ShootingStar = {
1022
927
  x: number;
1023
928
  y: number;
1024
929
  }[];
930
+ trailHead: number;
1025
931
  };
1026
932
  //#endregion
1027
- //#region src/snow/simulation.d.ts
1028
- interface SnowSimulationConfig {
933
+ //#region src/snow/layer.d.ts
934
+ interface SnowConfig {
1029
935
  readonly fillStyle?: string;
1030
936
  readonly particles?: number;
1031
937
  readonly scale?: number;
1032
938
  readonly size?: number;
1033
939
  readonly speed?: number;
1034
- readonly canvasOptions?: CanvasRenderingContext2DSettings;
1035
- }
1036
- declare class SnowSimulation extends SimulationCanvas {
1037
- constructor(canvas: HTMLCanvasElement, config?: SnowSimulationConfig);
1038
940
  }
1039
941
  //#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
- }
942
+ //#region src/snow/index.d.ts
943
+ declare function createSnow(config?: SnowConfig): Effect<SnowConfig>;
1048
944
  //#endregion
1049
- //#region src/sparklers/simulation.d.ts
1050
- interface SparklerSimulationConfig {
945
+ //#region src/sparklers/layer.d.ts
946
+ interface SparklersConfig {
1051
947
  readonly emitRate?: number;
1052
948
  readonly maxSparks?: number;
1053
949
  readonly colors?: string[];
@@ -1058,23 +954,6 @@ interface SparklerSimulationConfig {
1058
954
  readonly trailLength?: number;
1059
955
  readonly hoverMode?: boolean;
1060
956
  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
957
  }
1079
958
  //#endregion
1080
959
  //#region src/sparklers/particle.d.ts
@@ -1108,6 +987,12 @@ type SparklerSpark = {
1108
987
  trail: Point[];
1109
988
  };
1110
989
  //#endregion
990
+ //#region src/sparklers/index.d.ts
991
+ interface SparklersInstance extends Effect<SparklersConfig> {
992
+ moveTo(x: number, y: number): void;
993
+ }
994
+ declare function createSparklers(config?: SparklersConfig): SparklersInstance;
995
+ //#endregion
1111
996
  //#region src/stars/types.d.ts
1112
997
  type StarMode = "sky" | "shooting" | "both";
1113
998
  type Star = {
@@ -1119,8 +1004,8 @@ type Star = {
1119
1004
  brightness: number;
1120
1005
  };
1121
1006
  //#endregion
1122
- //#region src/stars/simulation.d.ts
1123
- interface StarSimulationConfig {
1007
+ //#region src/stars/layer.d.ts
1008
+ interface StarsConfig {
1124
1009
  readonly mode?: StarMode;
1125
1010
  readonly starCount?: number;
1126
1011
  readonly shootingInterval?: [number, number];
@@ -1130,40 +1015,17 @@ interface StarSimulationConfig {
1130
1015
  readonly shootingColor?: string;
1131
1016
  readonly trailLength?: number;
1132
1017
  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
1018
  }
1139
1019
  //#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
- }
1020
+ //#region src/stars/index.d.ts
1021
+ declare function createStars(config?: StarsConfig): Effect<StarsConfig>;
1147
1022
  //#endregion
1148
- //#region src/streamers/simulation.d.ts
1149
- interface StreamerSimulationConfig {
1023
+ //#region src/streamers/layer.d.ts
1024
+ interface StreamersConfig {
1150
1025
  readonly count?: number;
1151
1026
  readonly colors?: string[];
1152
1027
  readonly speed?: number;
1153
1028
  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
1029
  }
1168
1030
  //#endregion
1169
1031
  //#region src/streamers/types.d.ts
@@ -1185,6 +1047,9 @@ type Streamer = {
1185
1047
  depth: number;
1186
1048
  };
1187
1049
  //#endregion
1050
+ //#region src/streamers/index.d.ts
1051
+ declare function createStreamers(config?: StreamersConfig): Effect<StreamersConfig>;
1052
+ //#endregion
1188
1053
  //#region src/trail.d.ts
1189
1054
  interface TrailConfig {
1190
1055
  readonly acceleration?: number;
@@ -1206,26 +1071,14 @@ declare class Trail {
1206
1071
  tick(dt?: number): void;
1207
1072
  }
1208
1073
  //#endregion
1209
- //#region src/waves/simulation.d.ts
1210
- interface WaveSimulationConfig {
1074
+ //#region src/waves/layer.d.ts
1075
+ interface WavesConfig {
1211
1076
  readonly layers?: number;
1212
1077
  readonly speed?: number;
1213
1078
  readonly colors?: string[];
1214
1079
  readonly foamColor?: string;
1215
1080
  readonly foamAmount?: number;
1216
1081
  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
1082
  }
1230
1083
  //#endregion
1231
1084
  //#region src/waves/types.d.ts
@@ -1237,8 +1090,12 @@ type Wave = {
1237
1090
  baseY: number;
1238
1091
  color: string;
1239
1092
  foamThreshold: number;
1093
+ rgb: [number, number, number];
1240
1094
  };
1241
1095
  //#endregion
1096
+ //#region src/waves/index.d.ts
1097
+ declare function createWaves(config?: WavesConfig): Effect<WavesConfig>;
1098
+ //#endregion
1242
1099
  //#region src/wormhole/types.d.ts
1243
1100
  type WormholeDirection = "inward" | "outward";
1244
1101
  type WormholeParticle = {
@@ -1250,27 +1107,17 @@ type WormholeParticle = {
1250
1107
  trail: number;
1251
1108
  };
1252
1109
  //#endregion
1253
- //#region src/wormhole/simulation.d.ts
1254
- interface WormholeSimulationConfig {
1110
+ //#region src/wormhole/layer.d.ts
1111
+ interface WormholeConfig {
1255
1112
  readonly count?: number;
1256
1113
  readonly speed?: number;
1257
1114
  readonly color?: string;
1258
1115
  readonly direction?: WormholeDirection;
1259
1116
  readonly scale?: number;
1260
- readonly canvasOptions?: CanvasRenderingContext2DSettings;
1261
- }
1262
- declare class WormholeSimulation extends SimulationCanvas {
1263
- constructor(canvas: HTMLCanvasElement, config?: WormholeSimulationConfig);
1264
1117
  }
1265
1118
  //#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
- }
1119
+ //#region src/wormhole/index.d.ts
1120
+ declare function createWormhole(config?: WormholeConfig): Effect<WormholeConfig>;
1274
1121
  //#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 };
1122
+ 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
1123
  //# sourceMappingURL=index.d.mts.map