@tsparticles/engine 3.0.0-beta.2 → 3.0.0-beta.4

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 (186) hide show
  1. package/browser/Core/Canvas.js +2 -2
  2. package/browser/Core/Container.js +39 -24
  3. package/browser/Core/Engine.js +26 -53
  4. package/browser/Core/Particle.js +88 -53
  5. package/browser/Core/Particles.js +51 -26
  6. package/browser/Core/Retina.js +0 -2
  7. package/browser/Core/Utils/QuadTree.js +1 -1
  8. package/browser/Options/Classes/BackgroundMask/BackgroundMask.js +1 -2
  9. package/browser/Options/Classes/ColorAnimation.js +4 -24
  10. package/browser/Options/Classes/Particles/Bounce/ParticlesBounceFactor.js +0 -1
  11. package/browser/Options/Classes/Particles/Effect/Effect.js +32 -0
  12. package/browser/Options/Classes/Particles/Number/ParticlesNumber.js +3 -5
  13. package/browser/Options/Classes/Particles/Number/ParticlesNumberLimit.js +17 -0
  14. package/browser/Options/Classes/Particles/Opacity/Opacity.js +2 -3
  15. package/browser/Options/Classes/Particles/ParticlesOptions.js +3 -0
  16. package/browser/Options/Classes/Particles/Size/Size.js +2 -3
  17. package/browser/Options/Classes/ValueWithRandom.js +1 -10
  18. package/browser/Utils/CanvasUtils.js +29 -21
  19. package/browser/Utils/ColorUtils.js +24 -38
  20. package/browser/Utils/NumberUtils.js +7 -16
  21. package/browser/Utils/Utils.js +13 -7
  22. package/browser/export-types.js +4 -2
  23. package/browser/exports.js +2 -3
  24. package/cjs/Core/Canvas.js +2 -2
  25. package/cjs/Core/Container.js +39 -24
  26. package/cjs/Core/Engine.js +25 -52
  27. package/cjs/Core/Particle.js +87 -52
  28. package/cjs/Core/Particles.js +51 -26
  29. package/cjs/Core/Retina.js +0 -2
  30. package/cjs/Core/Utils/QuadTree.js +1 -1
  31. package/cjs/Options/Classes/BackgroundMask/BackgroundMask.js +1 -2
  32. package/cjs/Options/Classes/ColorAnimation.js +4 -24
  33. package/cjs/Options/Classes/Particles/Bounce/ParticlesBounceFactor.js +0 -1
  34. package/cjs/Options/Classes/Particles/Effect/Effect.js +36 -0
  35. package/cjs/Options/Classes/Particles/Number/ParticlesNumber.js +3 -5
  36. package/cjs/Options/Classes/Particles/Number/ParticlesNumberLimit.js +21 -0
  37. package/cjs/Options/Classes/Particles/Opacity/Opacity.js +1 -2
  38. package/cjs/Options/Classes/Particles/ParticlesOptions.js +3 -0
  39. package/cjs/Options/Classes/Particles/Size/Size.js +2 -3
  40. package/cjs/Options/Classes/ValueWithRandom.js +1 -10
  41. package/cjs/Utils/CanvasUtils.js +32 -24
  42. package/cjs/Utils/ColorUtils.js +24 -38
  43. package/cjs/Utils/NumberUtils.js +8 -18
  44. package/cjs/Utils/Utils.js +14 -7
  45. package/cjs/export-types.js +4 -2
  46. package/cjs/exports.js +2 -3
  47. package/esm/Core/Canvas.js +2 -2
  48. package/esm/Core/Container.js +39 -24
  49. package/esm/Core/Engine.js +26 -53
  50. package/esm/Core/Particle.js +88 -53
  51. package/esm/Core/Particles.js +51 -26
  52. package/esm/Core/Retina.js +0 -2
  53. package/esm/Core/Utils/QuadTree.js +1 -1
  54. package/esm/Options/Classes/BackgroundMask/BackgroundMask.js +1 -2
  55. package/esm/Options/Classes/ColorAnimation.js +4 -24
  56. package/esm/Options/Classes/Particles/Bounce/ParticlesBounceFactor.js +0 -1
  57. package/esm/Options/Classes/Particles/Effect/Effect.js +32 -0
  58. package/esm/Options/Classes/Particles/Number/ParticlesNumber.js +3 -5
  59. package/esm/Options/Classes/Particles/Number/ParticlesNumberLimit.js +17 -0
  60. package/esm/Options/Classes/Particles/Opacity/Opacity.js +2 -3
  61. package/esm/Options/Classes/Particles/ParticlesOptions.js +3 -0
  62. package/esm/Options/Classes/Particles/Size/Size.js +2 -3
  63. package/esm/Options/Classes/ValueWithRandom.js +1 -10
  64. package/esm/Utils/CanvasUtils.js +29 -21
  65. package/esm/Utils/ColorUtils.js +24 -38
  66. package/esm/Utils/NumberUtils.js +7 -16
  67. package/esm/Utils/Utils.js +13 -7
  68. package/esm/export-types.js +4 -2
  69. package/esm/exports.js +2 -3
  70. package/package.json +1 -1
  71. package/report.html +4 -22
  72. package/tsparticles.engine.js +461 -347
  73. package/tsparticles.engine.min.js +1 -1
  74. package/tsparticles.engine.min.js.LICENSE.txt +1 -1
  75. package/types/Core/Canvas.d.ts +0 -1
  76. package/types/Core/Container.d.ts +9 -8
  77. package/types/Core/Engine.d.ts +9 -5
  78. package/types/Core/Interfaces/IContainerPlugin.d.ts +2 -3
  79. package/types/Core/Interfaces/IEffectDrawer.d.ts +10 -0
  80. package/types/Core/Interfaces/IExternalInteractor.d.ts +3 -4
  81. package/types/Core/Interfaces/IInteractor.d.ts +3 -3
  82. package/types/Core/Interfaces/IParticleRetinaProps.d.ts +0 -1
  83. package/types/Core/Interfaces/IParticlesInteractor.d.ts +3 -3
  84. package/types/Core/Interfaces/IShapeDrawData.d.ts +10 -0
  85. package/types/Core/Interfaces/IShapeDrawer.d.ts +11 -9
  86. package/types/Core/Particle.d.ts +7 -5
  87. package/types/Core/Particles.d.ts +10 -7
  88. package/types/Core/Retina.d.ts +0 -1
  89. package/types/Core/Utils/ExternalInteractorBase.d.ts +4 -4
  90. package/types/Core/Utils/InteractionManager.d.ts +1 -2
  91. package/types/Core/Utils/ParticlesInteractorBase.d.ts +5 -5
  92. package/types/Enums/Modes/LimitMode.d.ts +4 -0
  93. package/types/Enums/Types/EasingType.d.ts +3 -0
  94. package/types/Enums/Types/EventType.d.ts +1 -0
  95. package/types/Options/Classes/BackgroundMask/BackgroundMask.d.ts +1 -1
  96. package/types/Options/Classes/ColorAnimation.d.ts +2 -7
  97. package/types/Options/Classes/Interactivity/Events/ClickEvent.d.ts +1 -2
  98. package/types/Options/Classes/Interactivity/Events/DivEvent.d.ts +1 -2
  99. package/types/Options/Classes/Interactivity/Events/Events.d.ts +3 -3
  100. package/types/Options/Classes/Interactivity/Events/HoverEvent.d.ts +2 -3
  101. package/types/Options/Classes/Interactivity/Interactivity.d.ts +2 -2
  102. package/types/Options/Classes/Options.d.ts +6 -6
  103. package/types/Options/Classes/Particles/Bounce/ParticlesBounce.d.ts +2 -2
  104. package/types/Options/Classes/Particles/Collisions/Collisions.d.ts +3 -3
  105. package/types/Options/Classes/Particles/Effect/Effect.d.ts +13 -0
  106. package/types/Options/Classes/Particles/Move/Move.d.ts +8 -8
  107. package/types/Options/Classes/Particles/Move/MoveTrail.d.ts +1 -1
  108. package/types/Options/Classes/Particles/Number/ParticlesNumber.d.ts +3 -2
  109. package/types/Options/Classes/Particles/Number/ParticlesNumberLimit.d.ts +10 -0
  110. package/types/Options/Classes/Particles/Opacity/Opacity.d.ts +3 -3
  111. package/types/Options/Classes/Particles/ParticlesOptions.d.ts +12 -10
  112. package/types/Options/Classes/Particles/Size/Size.d.ts +3 -3
  113. package/types/Options/Classes/Theme/Theme.d.ts +1 -1
  114. package/types/Options/Classes/ValueWithRandom.d.ts +2 -4
  115. package/types/Options/Interfaces/IValueWithRandom.d.ts +0 -2
  116. package/types/Options/Interfaces/Interactivity/Events/IClickEvent.d.ts +1 -2
  117. package/types/Options/Interfaces/Interactivity/Events/IDivEvent.d.ts +1 -2
  118. package/types/Options/Interfaces/Interactivity/Events/IHoverEvent.d.ts +1 -2
  119. package/types/Options/Interfaces/Particles/Effect/IEffect.d.ts +8 -0
  120. package/types/Options/Interfaces/Particles/IParticlesOptions.d.ts +2 -0
  121. package/types/Options/Interfaces/Particles/Number/IParticlesNumber.d.ts +2 -1
  122. package/types/Options/Interfaces/Particles/Number/IParticlesNumberLimit.d.ts +5 -0
  123. package/types/Types/CustomEventArgs.d.ts +1 -1
  124. package/types/Utils/CanvasUtils.d.ts +12 -3
  125. package/types/Utils/ColorUtils.d.ts +2 -2
  126. package/types/Utils/NumberUtils.d.ts +0 -2
  127. package/types/Utils/Utils.d.ts +6 -6
  128. package/types/export-types.d.ts +5 -2
  129. package/types/exports.d.ts +2 -3
  130. package/umd/Core/Canvas.js +2 -2
  131. package/umd/Core/Container.js +40 -25
  132. package/umd/Core/Engine.js +25 -52
  133. package/umd/Core/Particle.js +87 -52
  134. package/umd/Core/Particles.js +51 -26
  135. package/umd/Core/Retina.js +0 -2
  136. package/umd/Core/Utils/QuadTree.js +1 -1
  137. package/umd/Options/Classes/BackgroundMask/BackgroundMask.js +1 -2
  138. package/umd/Options/Classes/ColorAnimation.js +5 -25
  139. package/umd/Options/Classes/Particles/Bounce/ParticlesBounceFactor.js +0 -1
  140. package/umd/Options/Classes/Particles/Effect/Effect.js +46 -0
  141. package/umd/Options/Classes/Particles/Number/ParticlesNumber.js +4 -6
  142. package/umd/Options/Classes/{Random.js → Particles/Number/ParticlesNumberLimit.js} +9 -9
  143. package/umd/Options/Classes/Particles/Opacity/Opacity.js +1 -2
  144. package/umd/Options/Classes/Particles/ParticlesOptions.js +4 -1
  145. package/umd/Options/Classes/Particles/Size/Size.js +3 -4
  146. package/umd/Options/Classes/ValueWithRandom.js +2 -11
  147. package/umd/Utils/CanvasUtils.js +32 -24
  148. package/umd/Utils/ColorUtils.js +24 -38
  149. package/umd/Utils/NumberUtils.js +9 -19
  150. package/umd/Utils/Utils.js +14 -7
  151. package/umd/export-types.js +5 -3
  152. package/umd/exports.js +3 -4
  153. package/browser/Options/Classes/Random.js +0 -17
  154. package/cjs/Options/Classes/Random.js +0 -21
  155. package/cjs/Types/ShapeDrawerFunctions.js +0 -2
  156. package/esm/Options/Classes/Random.js +0 -17
  157. package/esm/Options/Interfaces/IRandom.js +0 -1
  158. package/esm/Types/ShapeDrawerFunctions.js +0 -1
  159. package/types/Core/Interfaces/IParticle.d.ts +0 -48
  160. package/types/Enums/Modes/ClickMode.d.ts +0 -9
  161. package/types/Enums/Modes/DivMode.d.ts +0 -5
  162. package/types/Enums/Modes/HoverMode.d.ts +0 -11
  163. package/types/Options/Classes/Random.d.ts +0 -9
  164. package/types/Options/Interfaces/IRandom.d.ts +0 -4
  165. package/types/Types/ShapeDrawerFunctions.d.ts +0 -10
  166. package/umd/Types/ShapeDrawerFunctions.js +0 -12
  167. /package/browser/Core/Interfaces/{IParticle.js → IEffectDrawer.js} +0 -0
  168. /package/browser/{Enums/Modes/ClickMode.js → Core/Interfaces/IShapeDrawData.js} +0 -0
  169. /package/browser/Enums/Modes/{DivMode.js → LimitMode.js} +0 -0
  170. /package/browser/{Enums/Modes/HoverMode.js → Options/Interfaces/Particles/Effect/IEffect.js} +0 -0
  171. /package/browser/Options/Interfaces/{IRandom.js → Particles/Number/IParticlesNumberLimit.js} +0 -0
  172. /package/cjs/Core/Interfaces/{IParticle.js → IEffectDrawer.js} +0 -0
  173. /package/cjs/{Enums/Modes/ClickMode.js → Core/Interfaces/IShapeDrawData.js} +0 -0
  174. /package/cjs/Enums/Modes/{DivMode.js → LimitMode.js} +0 -0
  175. /package/cjs/{Enums/Modes/HoverMode.js → Options/Interfaces/Particles/Effect/IEffect.js} +0 -0
  176. /package/cjs/Options/Interfaces/{IRandom.js → Particles/Number/IParticlesNumberLimit.js} +0 -0
  177. /package/{browser/Types/ShapeDrawerFunctions.js → esm/Core/Interfaces/IEffectDrawer.js} +0 -0
  178. /package/esm/Core/Interfaces/{IParticle.js → IShapeDrawData.js} +0 -0
  179. /package/esm/Enums/Modes/{ClickMode.js → LimitMode.js} +0 -0
  180. /package/esm/{Enums/Modes/DivMode.js → Options/Interfaces/Particles/Effect/IEffect.js} +0 -0
  181. /package/esm/{Enums/Modes/HoverMode.js → Options/Interfaces/Particles/Number/IParticlesNumberLimit.js} +0 -0
  182. /package/umd/Core/Interfaces/{IParticle.js → IEffectDrawer.js} +0 -0
  183. /package/umd/{Enums/Modes/ClickMode.js → Core/Interfaces/IShapeDrawData.js} +0 -0
  184. /package/umd/Enums/Modes/{DivMode.js → LimitMode.js} +0 -0
  185. /package/umd/{Enums/Modes/HoverMode.js → Options/Interfaces/Particles/Effect/IEffect.js} +0 -0
  186. /package/umd/Options/Interfaces/{IRandom.js → Particles/Number/IParticlesNumberLimit.js} +0 -0
@@ -1,5 +1,6 @@
1
1
  import type { IAnimatableColor } from "../IAnimatableColor.js";
2
2
  import type { ICollisions } from "./Collisions/ICollisions.js";
3
+ import type { IEffect } from "./Effect/IEffect.js";
3
4
  import type { IInteractivity } from "../Interactivity/IInteractivity.js";
4
5
  import type { IMove } from "./Move/IMove.js";
5
6
  import type { IOpacity } from "./Opacity/IOpacity.js";
@@ -18,6 +19,7 @@ export interface IParticlesOptions {
18
19
  bounce: IParticlesBounce;
19
20
  collisions: ICollisions;
20
21
  color: IAnimatableColor;
22
+ effect: IEffect;
21
23
  groups: ParticlesGroups;
22
24
  interactivity?: RecursivePartial<IInteractivity>;
23
25
  move: IMove;
@@ -1,6 +1,7 @@
1
1
  import type { IParticlesDensity } from "./IParticlesDensity.js";
2
+ import type { IParticlesNumberLimit } from "./IParticlesNumberLimit.js";
2
3
  export interface IParticlesNumber {
3
4
  density: IParticlesDensity;
4
- limit: number;
5
+ limit: IParticlesNumberLimit;
5
6
  value: number;
6
7
  }
@@ -0,0 +1,5 @@
1
+ import type { LimitMode } from "../../../../Enums/Modes/LimitMode.js";
2
+ export interface IParticlesNumberLimit {
3
+ mode: LimitMode | keyof typeof LimitMode;
4
+ value: number;
5
+ }
@@ -1,5 +1,5 @@
1
1
  import type { Container } from "../Core/Container.js";
2
2
  export type CustomEventArgs = {
3
- container: Container;
3
+ container?: Container;
4
4
  data?: unknown;
5
5
  };
@@ -8,13 +8,22 @@ import type { IDrawParticleParams } from "../Core/Interfaces/IDrawParticleParams
8
8
  import type { IHsl } from "../Core/Interfaces/Colors.js";
9
9
  import type { Particle } from "../Core/Particle.js";
10
10
  export declare function drawLine(context: CanvasRenderingContext2D, begin: ICoordinates, end: ICoordinates): void;
11
- export declare function drawTriangle(context: CanvasRenderingContext2D, p1: ICoordinates, p2: ICoordinates, p3: ICoordinates): void;
12
11
  export declare function paintBase(context: CanvasRenderingContext2D, dimension: IDimension, baseColor?: string): void;
13
12
  export declare function paintImage(context: CanvasRenderingContext2D, dimension: IDimension, image: HTMLImageElement | undefined, opacity: number): void;
14
13
  export declare function clear(context: CanvasRenderingContext2D, dimension: IDimension): void;
15
14
  export declare function drawParticle(data: IDrawParticleParams): void;
16
- export declare function drawShape(container: Container, context: CanvasRenderingContext2D, particle: Particle, radius: number, opacity: number, delta: IDelta): void;
17
- export declare function drawShapeAfterEffect(container: Container, context: CanvasRenderingContext2D, particle: Particle, radius: number, opacity: number, delta: IDelta): void;
15
+ type DrawShapeData = {
16
+ container: Container;
17
+ context: CanvasRenderingContext2D;
18
+ delta: IDelta;
19
+ opacity: number;
20
+ particle: Particle;
21
+ radius: number;
22
+ };
23
+ export declare function drawEffect(data: DrawShapeData): void;
24
+ export declare function drawShape(data: DrawShapeData): void;
25
+ export declare function drawShapeAfterDraw(data: DrawShapeData): void;
18
26
  export declare function drawPlugin(context: CanvasRenderingContext2D, plugin: IContainerPlugin, delta: IDelta): void;
19
27
  export declare function drawParticlePlugin(context: CanvasRenderingContext2D, plugin: IContainerPlugin, particle: Particle, delta: IDelta): void;
20
28
  export declare function alterHsl(color: IHsl, type: AlterType, value: number): IHsl;
29
+ export {};
@@ -2,8 +2,8 @@ import type { IColor, IHsl, IHsla, IRangeColor, IRgb, IRgba } from "../Core/Inte
2
2
  import type { HslAnimation } from "../Options/Classes/HslAnimation.js";
3
3
  import type { IColorManager } from "../Core/Interfaces/IColorManager.js";
4
4
  import type { IOptionsColor } from "../Options/Interfaces/IOptionsColor.js";
5
- import type { IParticle } from "../Core/Interfaces/IParticle.js";
6
5
  import type { IParticleHslAnimation } from "../Core/Interfaces/IParticleHslAnimation.js";
6
+ import type { Particle } from "../Core/Particle.js";
7
7
  export declare function addColorManager(manager: IColorManager): void;
8
8
  export declare function rangeColorToRgb(input?: string | IRangeColor, index?: number, useIndex?: boolean): IRgb | undefined;
9
9
  export declare function colorToRgb(input?: string | IColor, index?: number, useIndex?: boolean): IRgb | undefined;
@@ -18,7 +18,7 @@ export declare function getRandomRgbColor(min?: number): IRgb;
18
18
  export declare function getStyleFromRgb(color: IRgb, opacity?: number): string;
19
19
  export declare function getStyleFromHsl(color: IHsl, opacity?: number): string;
20
20
  export declare function colorMix(color1: IRgb | IHsl, color2: IRgb | IHsl, size1: number, size2: number): IRgb;
21
- export declare function getLinkColor(p1: IParticle, p2?: IParticle, linkColor?: string | IRgb): IRgb | undefined;
21
+ export declare function getLinkColor(p1: Particle, p2?: Particle, linkColor?: string | IRgb): IRgb | undefined;
22
22
  export declare function getLinkRandomColor(optColor: string | IOptionsColor, blink: boolean, consent: boolean): IRgb | string | undefined;
23
23
  export declare function getHslFromAnimation(animation?: IParticleHslAnimation): IHsl | undefined;
24
24
  export declare function getHslAnimationFromHsl(hsl: IHsl, animationOptions: HslAnimation | undefined, reduceFactor: number): IParticleHslAnimation;
@@ -1,7 +1,6 @@
1
1
  import type { EasingType, EasingTypeAlt } from "../Enums/Types/EasingType.js";
2
2
  import type { IPositionFromSizeParams, IRangedPositionFromSizeParams } from "../Core/Interfaces/IPositionFromSizeParams.js";
3
3
  import type { ICoordinates } from "../Core/Interfaces/ICoordinates.js";
4
- import type { IValueWithRandom } from "../Options/Interfaces/IValueWithRandom.js";
5
4
  import { MoveDirection } from "../Enums/Directions/MoveDirection.js";
6
5
  import type { MoveDirectionAlt } from "../Enums/Directions/MoveDirection.js";
7
6
  import type { RangeValue } from "../Types/RangeValue.js";
@@ -18,7 +17,6 @@ export declare function getRangeValue(value: RangeValue): number;
18
17
  export declare function getRangeMin(value: RangeValue): number;
19
18
  export declare function getRangeMax(value: RangeValue): number;
20
19
  export declare function setRangeValue(source: RangeValue, value?: number): RangeValue;
21
- export declare function getValue(options: IValueWithRandom): number;
22
20
  export declare function getDistances(pointA: ICoordinates, pointB: ICoordinates): {
23
21
  distance: number;
24
22
  dx: number;
@@ -1,13 +1,12 @@
1
1
  import type { ICoordinates, ICoordinatesWithMode } from "../Core/Interfaces/ICoordinates.js";
2
2
  import type { IDimension, IDimensionWithMode } from "../Core/Interfaces/IDimension.js";
3
3
  import type { DivEvent } from "../Options/Classes/Interactivity/Events/DivEvent.js";
4
- import type { DivMode } from "../Enums/Modes/DivMode.js";
5
4
  import type { IBounds } from "../Core/Interfaces/IBounds.js";
6
5
  import type { ICircleBouncer } from "../Core/Interfaces/ICircleBouncer.js";
7
6
  import type { IModeDiv } from "../Options/Interfaces/Interactivity/Modes/IModeDiv.js";
8
- import type { IParticle } from "../Core/Interfaces/IParticle.js";
9
7
  import type { IParticleNumericValueAnimation } from "../Core/Interfaces/IParticleValueAnimation.js";
10
8
  import { OutModeDirection } from "../Enums/Directions/OutModeDirection.js";
9
+ import type { Particle } from "../Core/Particle.js";
11
10
  import type { RangedAnimationValueWithRandom } from "../Options/Classes/ValueWithRandom.js";
12
11
  import type { SingleOrMultiple } from "../Types/SingleOrMultiple.js";
13
12
  interface ILogger {
@@ -23,6 +22,7 @@ export declare function getLogger(): ILogger;
23
22
  export declare function isSsr(): boolean;
24
23
  export declare function hasMatchMedia(): boolean;
25
24
  export declare function safeMatchMedia(query: string): MediaQueryList | undefined;
25
+ export declare function safeIntersectionObserver(callback: (records: IntersectionObserverEntry[]) => void): IntersectionObserver | undefined;
26
26
  export declare function safeMutationObserver(callback: (records: MutationRecord[]) => void): MutationObserver | undefined;
27
27
  export declare function isInArray<T>(value: T, array: SingleOrMultiple<T>): boolean;
28
28
  export declare function loadFont(font?: string, weight?: string): Promise<void>;
@@ -32,13 +32,13 @@ export declare function isPointInside(point: ICoordinates, size: IDimension, off
32
32
  export declare function areBoundsInside(bounds: IBounds, size: IDimension, offset: ICoordinates, direction?: OutModeDirection): boolean;
33
33
  export declare function calculateBounds(point: ICoordinates, radius: number): IBounds;
34
34
  export declare function deepExtend(destination: unknown, ...sources: unknown[]): unknown;
35
- export declare function isDivModeEnabled(mode: DivMode, divs: SingleOrMultiple<DivEvent>): boolean;
36
- export declare function divModeExecute(mode: DivMode, divs: SingleOrMultiple<DivEvent>, callback: (id: string, div: DivEvent) => void): void;
35
+ export declare function isDivModeEnabled(mode: string, divs: SingleOrMultiple<DivEvent>): boolean;
36
+ export declare function divModeExecute(mode: string, divs: SingleOrMultiple<DivEvent>, callback: (id: string, div: DivEvent) => void): void;
37
37
  export declare function singleDivModeExecute(div: DivEvent, callback: (selector: string, div: DivEvent) => void): void;
38
38
  export declare function divMode<T extends IModeDiv>(divs?: SingleOrMultiple<T>, element?: HTMLElement): T | undefined;
39
- export declare function circleBounceDataFromParticle(p: IParticle): ICircleBouncer;
39
+ export declare function circleBounceDataFromParticle(p: Particle): ICircleBouncer;
40
40
  export declare function circleBounce(p1: ICircleBouncer, p2: ICircleBouncer): void;
41
- export declare function rectBounce(particle: IParticle, divBounds: IBounds): void;
41
+ export declare function rectBounce(particle: Particle, divBounds: IBounds): void;
42
42
  export declare function executeOnSingleOrMultiple<T, U = void>(obj: SingleOrMultiple<T>, callback: (obj: T, index: number) => U): SingleOrMultiple<U>;
43
43
  export declare function itemFromSingleOrMultiple<T>(obj: SingleOrMultiple<T>, index?: number, useIndex?: boolean): T;
44
44
  export declare function findItemFromSingleOrMultiple<T>(obj: SingleOrMultiple<T>, callback: (obj: T, index: number) => boolean): T | undefined;
@@ -11,12 +11,12 @@ export * from "./Core/Interfaces/IDelta.js";
11
11
  export * from "./Core/Interfaces/IDimension.js";
12
12
  export * from "./Core/Interfaces/IDistance.js";
13
13
  export * from "./Core/Interfaces/IDrawParticleParams.js";
14
+ export * from "./Core/Interfaces/IEffectDrawer.js";
14
15
  export * from "./Core/Interfaces/IExternalInteractor.js";
15
16
  export * from "./Core/Interfaces/IInteractor.js";
16
17
  export * from "./Core/Interfaces/ILoadParams.js";
17
18
  export * from "./Core/Interfaces/IMouseData.js";
18
19
  export * from "./Core/Interfaces/IMovePathGenerator.js";
19
- export * from "./Core/Interfaces/IParticle.js";
20
20
  export * from "./Core/Interfaces/IParticleColorStyle.js";
21
21
  export * from "./Core/Interfaces/IParticleHslAnimation.js";
22
22
  export * from "./Core/Interfaces/IParticleLife.js";
@@ -31,6 +31,7 @@ export * from "./Core/Interfaces/IPlugin.js";
31
31
  export * from "./Core/Interfaces/IPositionFromSizeParams.js";
32
32
  export * from "./Core/Interfaces/IRangeValue.js";
33
33
  export * from "./Core/Interfaces/IRectSideResult.js";
34
+ export * from "./Core/Interfaces/IShapeDrawData.js";
34
35
  export * from "./Core/Interfaces/IShapeDrawer.js";
35
36
  export * from "./Core/Interfaces/IShapeValues.js";
36
37
  export * from "./Core/Interfaces/ISlowParticleData.js";
@@ -63,6 +64,7 @@ export * from "./Options/Interfaces/Particles/Bounce/IParticlesBounce.js";
63
64
  export * from "./Options/Interfaces/Particles/Collisions/ICollisions.js";
64
65
  export * from "./Options/Interfaces/Particles/Collisions/ICollisionsAbsorb.js";
65
66
  export * from "./Options/Interfaces/Particles/Collisions/ICollisionsOverlap.js";
67
+ export * from "./Options/Interfaces/Particles/Effect/IEffect.js";
66
68
  export * from "./Options/Interfaces/Particles/IParticlesOptions.js";
67
69
  export * from "./Options/Interfaces/Particles/IShadow.js";
68
70
  export * from "./Options/Interfaces/Particles/IStroke.js";
@@ -77,6 +79,7 @@ export * from "./Options/Interfaces/Particles/Move/ISpin.js";
77
79
  export * from "./Options/Interfaces/Particles/Move/IMoveTrail.js";
78
80
  export * from "./Options/Interfaces/Particles/Number/IParticlesDensity.js";
79
81
  export * from "./Options/Interfaces/Particles/Number/IParticlesNumber.js";
82
+ export * from "./Options/Interfaces/Particles/Number/IParticlesNumberLimit.js";
80
83
  export * from "./Options/Interfaces/Particles/Opacity/IOpacity.js";
81
84
  export * from "./Options/Interfaces/Particles/Opacity/IOpacityAnimation.js";
82
85
  export * from "./Options/Interfaces/Particles/Shape/IShape.js";
@@ -94,7 +97,6 @@ export * from "./Types/PathOptions.js";
94
97
  export * from "./Types/RangeValue.js";
95
98
  export * from "./Types/RecursivePartial.js";
96
99
  export * from "./Types/ShapeData.js";
97
- export * from "./Types/ShapeDrawerFunctions.js";
98
100
  export * from "./Types/SingleOrMultiple.js";
99
101
  export type { EventListeners } from "./Core/Utils/EventListeners.js";
100
102
  export type { InteractionManager } from "./Core/Utils/InteractionManager.js";
@@ -105,3 +107,4 @@ export type { Particle } from "./Core/Particle.js";
105
107
  export type { Particles } from "./Core/Particles.js";
106
108
  export type { Retina } from "./Core/Retina.js";
107
109
  export type { Engine, Engine as Main };
110
+ export type { IParticlesNumberLimit } from "./Options/Interfaces/Particles/Number/IParticlesNumberLimit.js";
@@ -11,10 +11,8 @@ export * from "./Enums/Directions/MoveDirection.js";
11
11
  export * from "./Enums/Directions/RotateDirection.js";
12
12
  export * from "./Enums/Directions/OutModeDirection.js";
13
13
  export * from "./Enums/Modes/AnimationMode.js";
14
- export * from "./Enums/Modes/ClickMode.js";
15
- export * from "./Enums/Modes/DivMode.js";
16
- export * from "./Enums/Modes/HoverMode.js";
17
14
  export * from "./Enums/Modes/CollisionMode.js";
15
+ export * from "./Enums/Modes/LimitMode.js";
18
16
  export * from "./Enums/Modes/OutMode.js";
19
17
  export * from "./Enums/Modes/PixelMode.js";
20
18
  export * from "./Enums/Modes/ThemeMode.js";
@@ -69,6 +67,7 @@ export * from "./Options/Classes/Particles/Move/Path/MovePath.js";
69
67
  export * from "./Options/Classes/Particles/Move/Spin.js";
70
68
  export * from "./Options/Classes/Particles/Move/MoveTrail.js";
71
69
  export * from "./Options/Classes/Particles/Number/ParticlesNumber.js";
70
+ export * from "./Options/Classes/Particles/Number/ParticlesNumberLimit.js";
72
71
  export * from "./Options/Classes/Particles/Number/ParticlesDensity.js";
73
72
  export * from "./Options/Classes/Particles/Opacity/Opacity.js";
74
73
  export * from "./Options/Classes/Particles/Opacity/OpacityAnimation.js";
@@ -414,10 +414,10 @@
414
414
  this.element.width = size.width = this.element.offsetWidth * pxRatio;
415
415
  this.element.height = size.height = this.element.offsetHeight * pxRatio;
416
416
  if (this.container.started) {
417
- this.resizeFactor = {
417
+ container.particles.setResizeFactor({
418
418
  width: size.width / oldSize.width,
419
419
  height: size.height / oldSize.height,
420
- };
420
+ });
421
421
  }
422
422
  return true;
423
423
  }
@@ -4,19 +4,19 @@
4
4
  if (v !== undefined) module.exports = v;
5
5
  }
6
6
  else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports", "./Canvas.js", "./Utils/EventListeners.js", "../Options/Classes/Options.js", "./Particles.js", "./Retina.js", "./Utils/Constants.js", "../Utils/Utils.js", "../Utils/NumberUtils.js", "../Utils/OptionsUtils.js"], factory);
7
+ define(["require", "exports", "../Utils/Utils.js", "./Canvas.js", "./Utils/EventListeners.js", "../Options/Classes/Options.js", "./Particles.js", "./Retina.js", "./Utils/Constants.js", "../Utils/NumberUtils.js", "../Utils/OptionsUtils.js"], factory);
8
8
  }
9
9
  })(function (require, exports) {
10
10
  "use strict";
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.Container = void 0;
13
+ const Utils_js_1 = require("../Utils/Utils.js");
13
14
  const Canvas_js_1 = require("./Canvas.js");
14
15
  const EventListeners_js_1 = require("./Utils/EventListeners.js");
15
16
  const Options_js_1 = require("../Options/Classes/Options.js");
16
17
  const Particles_js_1 = require("./Particles.js");
17
18
  const Retina_js_1 = require("./Retina.js");
18
19
  const Constants_js_1 = require("./Utils/Constants.js");
19
- const Utils_js_1 = require("../Utils/Utils.js");
20
20
  const NumberUtils_js_1 = require("../Utils/NumberUtils.js");
21
21
  const OptionsUtils_js_1 = require("../Utils/OptionsUtils.js");
22
22
  function guardCheck(container) {
@@ -35,7 +35,6 @@
35
35
  }
36
36
  class Container {
37
37
  constructor(engine, id, sourceOptions) {
38
- this.id = id;
39
38
  this._intersectionManager = (entries) => {
40
39
  if (!guardCheck(this) || !this.actualOptions.pauseOnOutsideViewport) {
41
40
  return;
@@ -49,16 +48,16 @@
49
48
  };
50
49
  this._nextFrame = async (timestamp) => {
51
50
  try {
52
- if (!this.smooth &&
53
- this.lastFrameTime !== undefined &&
54
- timestamp < this.lastFrameTime + 1000 / this.fpsLimit) {
51
+ if (!this._smooth &&
52
+ this._lastFrameTime !== undefined &&
53
+ timestamp < this._lastFrameTime + 1000 / this.fpsLimit) {
55
54
  this.draw(false);
56
55
  return;
57
56
  }
58
- this.lastFrameTime ??= timestamp;
59
- const delta = initDelta(timestamp - this.lastFrameTime, this.fpsLimit, this.smooth);
57
+ this._lastFrameTime ??= timestamp;
58
+ const delta = initDelta(timestamp - this._lastFrameTime, this.fpsLimit, this._smooth);
60
59
  this.addLifeTime(delta.value);
61
- this.lastFrameTime = timestamp;
60
+ this._lastFrameTime = timestamp;
62
61
  if (delta.value > 1000) {
63
62
  this.draw(false);
64
63
  return;
@@ -77,8 +76,9 @@
77
76
  }
78
77
  };
79
78
  this._engine = engine;
79
+ this.id = Symbol(id);
80
80
  this.fpsLimit = 120;
81
- this.smooth = false;
81
+ this._smooth = false;
82
82
  this._delay = 0;
83
83
  this._duration = 0;
84
84
  this._lifeTime = 0;
@@ -86,7 +86,7 @@
86
86
  this.started = false;
87
87
  this.destroyed = false;
88
88
  this._paused = true;
89
- this.lastFrameTime = 0;
89
+ this._lastFrameTime = 0;
90
90
  this.zLayers = 100;
91
91
  this.pageHidden = false;
92
92
  this._sourceOptions = sourceOptions;
@@ -102,13 +102,12 @@
102
102
  },
103
103
  };
104
104
  this.plugins = new Map();
105
- this.drawers = new Map();
105
+ this.effectDrawers = new Map();
106
+ this.shapeDrawers = new Map();
106
107
  this._options = loadContainerOptions(this._engine, this);
107
108
  this.actualOptions = loadContainerOptions(this._engine, this);
108
109
  this._eventListeners = new EventListeners_js_1.EventListeners(this);
109
- if (typeof IntersectionObserver !== "undefined" && IntersectionObserver) {
110
- this._intersectionObserver = new IntersectionObserver((entries) => this._intersectionManager(entries));
111
- }
110
+ this._intersectionObserver = (0, Utils_js_1.safeIntersectionObserver)((entries) => this._intersectionManager(entries));
112
111
  this._engine.dispatchEvent("containerBuilt", { container: this });
113
112
  }
114
113
  get options() {
@@ -214,11 +213,17 @@
214
213
  this.stop();
215
214
  this.particles.destroy();
216
215
  this.canvas.destroy();
217
- for (const [, drawer] of this.drawers) {
218
- drawer.destroy && drawer.destroy(this);
216
+ for (const [, effectDrawer] of this.effectDrawers) {
217
+ effectDrawer.destroy && effectDrawer.destroy(this);
218
+ }
219
+ for (const [, shapeDrawer] of this.shapeDrawers) {
220
+ shapeDrawer.destroy && shapeDrawer.destroy(this);
221
+ }
222
+ for (const key of this.effectDrawers.keys()) {
223
+ this.effectDrawers.delete(key);
219
224
  }
220
- for (const key of this.drawers.keys()) {
221
- this.drawers.delete(key);
225
+ for (const key of this.shapeDrawers.keys()) {
226
+ this.shapeDrawers.delete(key);
222
227
  }
223
228
  this._engine.clearPlugins(this);
224
229
  this.destroyed = true;
@@ -235,7 +240,7 @@
235
240
  let refreshTime = force;
236
241
  this._drawAnimationFrame = requestAnimationFrame(async (timestamp) => {
237
242
  if (refreshTime) {
238
- this.lastFrameTime = undefined;
243
+ this._lastFrameTime = undefined;
239
244
  refreshTime = false;
240
245
  }
241
246
  await this._nextFrame(timestamp);
@@ -270,11 +275,18 @@
270
275
  if (!guardCheck(this)) {
271
276
  return;
272
277
  }
278
+ const effects = this._engine.getSupportedEffects();
279
+ for (const type of effects) {
280
+ const drawer = this._engine.getEffectDrawer(type);
281
+ if (drawer) {
282
+ this.effectDrawers.set(type, drawer);
283
+ }
284
+ }
273
285
  const shapes = this._engine.getSupportedShapes();
274
286
  for (const type of shapes) {
275
287
  const drawer = this._engine.getShapeDrawer(type);
276
288
  if (drawer) {
277
- this.drawers.set(type, drawer);
289
+ this.shapeDrawers.set(type, drawer);
278
290
  }
279
291
  }
280
292
  this._options = loadContainerOptions(this._engine, this, this._initialSourceOptions, this.sourceOptions);
@@ -293,8 +305,11 @@
293
305
  this._delay = (0, NumberUtils_js_1.getRangeValue)(this.actualOptions.delay) * 1000;
294
306
  this._lifeTime = 0;
295
307
  this.fpsLimit = this.actualOptions.fpsLimit > 0 ? this.actualOptions.fpsLimit : 120;
296
- this.smooth = this.actualOptions.smooth;
297
- for (const [, drawer] of this.drawers) {
308
+ this._smooth = this.actualOptions.smooth;
309
+ for (const [, drawer] of this.effectDrawers) {
310
+ drawer.init && (await drawer.init(this));
311
+ }
312
+ for (const [, drawer] of this.shapeDrawers) {
298
313
  drawer.init && (await drawer.init(this));
299
314
  }
300
315
  for (const [, plugin] of this.plugins) {
@@ -423,10 +438,10 @@
423
438
  this.actualOptions.responsive = [];
424
439
  const newMaxWidth = this.actualOptions.setResponsive(this.canvas.size.width, this.retina.pixelRatio, this._options);
425
440
  this.actualOptions.setTheme(this._currentTheme);
426
- if (this.responsiveMaxWidth === newMaxWidth) {
441
+ if (this._responsiveMaxWidth === newMaxWidth) {
427
442
  return false;
428
443
  }
429
- this.responsiveMaxWidth = newMaxWidth;
444
+ this._responsiveMaxWidth = newMaxWidth;
430
445
  return true;
431
446
  }
432
447
  }
@@ -51,7 +51,8 @@
51
51
  this.movers = new Map();
52
52
  this.updaters = new Map();
53
53
  this.presets = new Map();
54
- this.drawers = new Map();
54
+ this.effectDrawers = new Map();
55
+ this.shapeDrawers = new Map();
55
56
  this.pathGenerators = new Map();
56
57
  }
57
58
  get configs() {
@@ -62,18 +63,18 @@
62
63
  return res;
63
64
  }
64
65
  get version() {
65
- return "3.0.0-beta.2";
66
+ return "3.0.0-beta.4";
66
67
  }
67
- addConfig(nameOrConfig, config) {
68
- if ((0, Utils_js_1.isString)(nameOrConfig)) {
69
- if (config) {
70
- config.name = nameOrConfig;
71
- this._configs.set(nameOrConfig, config);
72
- }
73
- }
74
- else {
75
- this._configs.set(nameOrConfig.name ?? "default", nameOrConfig);
76
- }
68
+ addConfig(config) {
69
+ const name = config.name ?? "default";
70
+ this._configs.set(name, config);
71
+ this._eventDispatcher.dispatchEvent("configAdded", { data: { name, config } });
72
+ }
73
+ async addEffect(effect, drawer, refresh = true) {
74
+ (0, Utils_js_1.executeOnSingleOrMultiple)(effect, (type) => {
75
+ !this.getEffectDrawer(type) && this.effectDrawers.set(type, drawer);
76
+ });
77
+ await this.refresh(refresh);
77
78
  }
78
79
  addEventListener(type, listener) {
79
80
  this._eventDispatcher.addEventListener(type, listener);
@@ -102,45 +103,11 @@
102
103
  (override || !this.getPreset(preset)) && this.presets.set(preset, options);
103
104
  await this.refresh(refresh);
104
105
  }
105
- async addShape(shape, drawer, initOrRefresh, afterEffectOrRefresh, destroyOrRefresh, refresh = true) {
106
- let customDrawer;
107
- let realRefresh = refresh, realInit, realAfterEffect, realDestroy;
108
- if ((0, Utils_js_1.isBoolean)(initOrRefresh)) {
109
- realRefresh = initOrRefresh;
110
- realInit = undefined;
111
- }
112
- else {
113
- realInit = initOrRefresh;
114
- }
115
- if ((0, Utils_js_1.isBoolean)(afterEffectOrRefresh)) {
116
- realRefresh = afterEffectOrRefresh;
117
- realAfterEffect = undefined;
118
- }
119
- else {
120
- realAfterEffect = afterEffectOrRefresh;
121
- }
122
- if ((0, Utils_js_1.isBoolean)(destroyOrRefresh)) {
123
- realRefresh = destroyOrRefresh;
124
- realDestroy = undefined;
125
- }
126
- else {
127
- realDestroy = destroyOrRefresh;
128
- }
129
- if ((0, Utils_js_1.isFunction)(drawer)) {
130
- customDrawer = {
131
- afterEffect: realAfterEffect,
132
- destroy: realDestroy,
133
- draw: drawer,
134
- init: realInit,
135
- };
136
- }
137
- else {
138
- customDrawer = drawer;
139
- }
106
+ async addShape(shape, drawer, refresh = true) {
140
107
  (0, Utils_js_1.executeOnSingleOrMultiple)(shape, (type) => {
141
- !this.getShapeDrawer(type) && this.drawers.set(type, customDrawer);
108
+ !this.getShapeDrawer(type) && this.shapeDrawers.set(type, drawer);
142
109
  });
143
- await this.refresh(realRefresh);
110
+ await this.refresh(refresh);
144
111
  }
145
112
  clearPlugins(container) {
146
113
  this.updaters.delete(container);
@@ -168,6 +135,9 @@
168
135
  }
169
136
  return res;
170
137
  }
138
+ getEffectDrawer(type) {
139
+ return this.effectDrawers.get(type);
140
+ }
171
141
  getInteractors(container, force = false) {
172
142
  return getItemsFromInitializer(container, this.interactors, this._initializers.interactors, force);
173
143
  }
@@ -184,10 +154,13 @@
184
154
  return this.presets.get(preset);
185
155
  }
186
156
  getShapeDrawer(type) {
187
- return this.drawers.get(type);
157
+ return this.shapeDrawers.get(type);
158
+ }
159
+ getSupportedEffects() {
160
+ return this.effectDrawers.keys();
188
161
  }
189
162
  getSupportedShapes() {
190
- return this.drawers.keys();
163
+ return this.shapeDrawers.keys();
191
164
  }
192
165
  getUpdaters(container, force = false) {
193
166
  return getItemsFromInitializer(container, this.updaters, this._initializers.updaters, force);
@@ -206,7 +179,7 @@
206
179
  domContainer.id = id;
207
180
  document.body.append(domContainer);
208
181
  }
209
- const currentOptions = (0, Utils_js_1.itemFromSingleOrMultiple)(options, index), dom = this.dom(), oldIndex = dom.findIndex((v) => v.id === id);
182
+ const currentOptions = (0, Utils_js_1.itemFromSingleOrMultiple)(options, index), dom = this.dom(), oldIndex = dom.findIndex((v) => v.id.description === id);
210
183
  if (oldIndex >= 0) {
211
184
  const old = this.domItem(oldIndex);
212
185
  if (old && !old.destroyed) {