@tsparticles/engine 3.3.0 → 3.5.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 (272) hide show
  1. package/README.md +0 -4
  2. package/browser/Core/Canvas.js +27 -22
  3. package/browser/Core/Container.js +57 -44
  4. package/browser/Core/Engine.js +82 -74
  5. package/browser/Core/Particle.js +29 -15
  6. package/browser/Core/Particles.js +23 -24
  7. package/browser/Core/Utils/EventListeners.js +18 -17
  8. package/browser/Core/Utils/ExternalInteractorBase.js +2 -1
  9. package/browser/Core/Utils/InteractionManager.js +3 -2
  10. package/browser/Core/Utils/ParticlesInteractorBase.js +2 -1
  11. package/browser/Core/Utils/QuadTree.js +1 -1
  12. package/browser/Core/Utils/Ranges.js +5 -4
  13. package/browser/Enums/AnimationStatus.js +5 -1
  14. package/browser/Enums/Directions/MoveDirection.js +14 -1
  15. package/browser/Enums/Directions/OutModeDirection.js +7 -1
  16. package/browser/Enums/Directions/RotateDirection.js +6 -1
  17. package/browser/Enums/InteractivityDetect.js +6 -1
  18. package/browser/Enums/Modes/AnimationMode.js +7 -1
  19. package/browser/Enums/Modes/CollisionMode.js +6 -1
  20. package/browser/Enums/Modes/LimitMode.js +5 -1
  21. package/browser/Enums/Modes/OutMode.js +8 -1
  22. package/browser/Enums/Modes/PixelMode.js +5 -1
  23. package/browser/Enums/Modes/ResponsiveMode.js +5 -1
  24. package/browser/Enums/Modes/ThemeMode.js +6 -1
  25. package/browser/Enums/Types/AlterType.js +5 -1
  26. package/browser/Enums/Types/DestroyType.js +6 -1
  27. package/browser/Enums/Types/DivType.js +5 -1
  28. package/browser/Enums/Types/EasingType.js +30 -1
  29. package/browser/Enums/Types/EventType.js +15 -1
  30. package/browser/Enums/Types/GradientType.js +6 -1
  31. package/browser/Enums/Types/InteractorType.js +5 -1
  32. package/browser/Enums/Types/ParticleOutType.js +6 -1
  33. package/browser/Enums/Types/StartValueType.js +6 -1
  34. package/browser/Options/Classes/AnimationOptions.js +4 -2
  35. package/browser/Options/Classes/Interactivity/Events/DivEvent.js +2 -1
  36. package/browser/Options/Classes/Interactivity/Events/Events.js +1 -1
  37. package/browser/Options/Classes/Interactivity/Interactivity.js +2 -1
  38. package/browser/Options/Classes/ManualParticle.js +2 -1
  39. package/browser/Options/Classes/Options.js +14 -12
  40. package/browser/Options/Classes/Particles/Collisions/Collisions.js +2 -1
  41. package/browser/Options/Classes/Particles/Move/Move.js +2 -1
  42. package/browser/Options/Classes/Particles/Move/MoveCenter.js +2 -1
  43. package/browser/Options/Classes/Particles/Move/OutModes.js +2 -1
  44. package/browser/Options/Classes/Particles/Number/ParticlesNumberLimit.js +2 -1
  45. package/browser/Options/Classes/Particles/Opacity/OpacityAnimation.js +2 -1
  46. package/browser/Options/Classes/Particles/ParticlesOptions.js +1 -1
  47. package/browser/Options/Classes/Particles/Size/SizeAnimation.js +2 -1
  48. package/browser/Options/Classes/Responsive.js +5 -4
  49. package/browser/Options/Classes/Theme/ThemeDefault.js +2 -1
  50. package/browser/Types/RangeType.js +5 -1
  51. package/browser/Utils/CanvasUtils.js +13 -7
  52. package/browser/Utils/ColorUtils.js +17 -9
  53. package/browser/Utils/EventDispatcher.js +1 -1
  54. package/browser/Utils/HslColorManager.js +11 -4
  55. package/browser/Utils/NumberUtils.js +28 -14
  56. package/browser/Utils/RgbColorManager.js +11 -4
  57. package/browser/Utils/Utils.js +37 -31
  58. package/cjs/Core/Canvas.js +27 -22
  59. package/cjs/Core/Container.js +57 -44
  60. package/cjs/Core/Engine.js +82 -74
  61. package/cjs/Core/Particle.js +29 -15
  62. package/cjs/Core/Particles.js +23 -24
  63. package/cjs/Core/Utils/EventListeners.js +18 -17
  64. package/cjs/Core/Utils/ExternalInteractorBase.js +2 -1
  65. package/cjs/Core/Utils/InteractionManager.js +3 -2
  66. package/cjs/Core/Utils/ParticlesInteractorBase.js +2 -1
  67. package/cjs/Core/Utils/QuadTree.js +1 -1
  68. package/cjs/Core/Utils/Ranges.js +5 -4
  69. package/cjs/Enums/AnimationStatus.js +6 -0
  70. package/cjs/Enums/Directions/MoveDirection.js +15 -0
  71. package/cjs/Enums/Directions/OutModeDirection.js +8 -0
  72. package/cjs/Enums/Directions/RotateDirection.js +7 -0
  73. package/cjs/Enums/InteractivityDetect.js +7 -0
  74. package/cjs/Enums/Modes/AnimationMode.js +8 -0
  75. package/cjs/Enums/Modes/CollisionMode.js +7 -0
  76. package/cjs/Enums/Modes/LimitMode.js +6 -0
  77. package/cjs/Enums/Modes/OutMode.js +9 -0
  78. package/cjs/Enums/Modes/PixelMode.js +6 -0
  79. package/cjs/Enums/Modes/ResponsiveMode.js +6 -0
  80. package/cjs/Enums/Modes/ThemeMode.js +7 -0
  81. package/cjs/Enums/Types/AlterType.js +6 -0
  82. package/cjs/Enums/Types/DestroyType.js +7 -0
  83. package/cjs/Enums/Types/DivType.js +6 -0
  84. package/cjs/Enums/Types/EasingType.js +31 -0
  85. package/cjs/Enums/Types/EventType.js +16 -0
  86. package/cjs/Enums/Types/GradientType.js +7 -0
  87. package/cjs/Enums/Types/InteractorType.js +6 -0
  88. package/cjs/Enums/Types/ParticleOutType.js +7 -0
  89. package/cjs/Enums/Types/StartValueType.js +7 -0
  90. package/cjs/Options/Classes/AnimationOptions.js +4 -2
  91. package/cjs/Options/Classes/Interactivity/Events/DivEvent.js +2 -1
  92. package/cjs/Options/Classes/Interactivity/Events/Events.js +1 -1
  93. package/cjs/Options/Classes/Interactivity/Interactivity.js +2 -1
  94. package/cjs/Options/Classes/ManualParticle.js +2 -1
  95. package/cjs/Options/Classes/Options.js +14 -12
  96. package/cjs/Options/Classes/Particles/Collisions/Collisions.js +2 -1
  97. package/cjs/Options/Classes/Particles/Move/Move.js +2 -1
  98. package/cjs/Options/Classes/Particles/Move/MoveCenter.js +2 -1
  99. package/cjs/Options/Classes/Particles/Move/OutModes.js +2 -1
  100. package/cjs/Options/Classes/Particles/Number/ParticlesNumberLimit.js +2 -1
  101. package/cjs/Options/Classes/Particles/Opacity/OpacityAnimation.js +2 -1
  102. package/cjs/Options/Classes/Particles/ParticlesOptions.js +1 -1
  103. package/cjs/Options/Classes/Particles/Size/SizeAnimation.js +2 -1
  104. package/cjs/Options/Classes/Responsive.js +5 -4
  105. package/cjs/Options/Classes/Theme/ThemeDefault.js +2 -1
  106. package/cjs/Types/RangeType.js +6 -0
  107. package/cjs/Utils/CanvasUtils.js +24 -19
  108. package/cjs/Utils/ColorUtils.js +37 -30
  109. package/cjs/Utils/EventDispatcher.js +1 -1
  110. package/cjs/Utils/HslColorManager.js +11 -4
  111. package/cjs/Utils/NumberUtils.js +54 -38
  112. package/cjs/Utils/OptionsUtils.js +2 -3
  113. package/cjs/Utils/RgbColorManager.js +11 -4
  114. package/cjs/Utils/TypeUtils.js +6 -7
  115. package/cjs/Utils/Utils.js +66 -61
  116. package/cjs/init.js +1 -2
  117. package/esm/Core/Canvas.js +27 -22
  118. package/esm/Core/Container.js +57 -44
  119. package/esm/Core/Engine.js +82 -74
  120. package/esm/Core/Particle.js +29 -15
  121. package/esm/Core/Particles.js +23 -24
  122. package/esm/Core/Utils/EventListeners.js +18 -17
  123. package/esm/Core/Utils/ExternalInteractorBase.js +2 -1
  124. package/esm/Core/Utils/InteractionManager.js +3 -2
  125. package/esm/Core/Utils/ParticlesInteractorBase.js +2 -1
  126. package/esm/Core/Utils/QuadTree.js +1 -1
  127. package/esm/Core/Utils/Ranges.js +5 -4
  128. package/esm/Enums/AnimationStatus.js +5 -1
  129. package/esm/Enums/Directions/MoveDirection.js +14 -1
  130. package/esm/Enums/Directions/OutModeDirection.js +7 -1
  131. package/esm/Enums/Directions/RotateDirection.js +6 -1
  132. package/esm/Enums/InteractivityDetect.js +6 -1
  133. package/esm/Enums/Modes/AnimationMode.js +7 -1
  134. package/esm/Enums/Modes/CollisionMode.js +6 -1
  135. package/esm/Enums/Modes/LimitMode.js +5 -1
  136. package/esm/Enums/Modes/OutMode.js +8 -1
  137. package/esm/Enums/Modes/PixelMode.js +5 -1
  138. package/esm/Enums/Modes/ResponsiveMode.js +5 -1
  139. package/esm/Enums/Modes/ThemeMode.js +6 -1
  140. package/esm/Enums/Types/AlterType.js +5 -1
  141. package/esm/Enums/Types/DestroyType.js +6 -1
  142. package/esm/Enums/Types/DivType.js +5 -1
  143. package/esm/Enums/Types/EasingType.js +30 -1
  144. package/esm/Enums/Types/EventType.js +15 -1
  145. package/esm/Enums/Types/GradientType.js +6 -1
  146. package/esm/Enums/Types/InteractorType.js +5 -1
  147. package/esm/Enums/Types/ParticleOutType.js +6 -1
  148. package/esm/Enums/Types/StartValueType.js +6 -1
  149. package/esm/Options/Classes/AnimationOptions.js +4 -2
  150. package/esm/Options/Classes/Interactivity/Events/DivEvent.js +2 -1
  151. package/esm/Options/Classes/Interactivity/Events/Events.js +1 -1
  152. package/esm/Options/Classes/Interactivity/Interactivity.js +2 -1
  153. package/esm/Options/Classes/ManualParticle.js +2 -1
  154. package/esm/Options/Classes/Options.js +14 -12
  155. package/esm/Options/Classes/Particles/Collisions/Collisions.js +2 -1
  156. package/esm/Options/Classes/Particles/Move/Move.js +2 -1
  157. package/esm/Options/Classes/Particles/Move/MoveCenter.js +2 -1
  158. package/esm/Options/Classes/Particles/Move/OutModes.js +2 -1
  159. package/esm/Options/Classes/Particles/Number/ParticlesNumberLimit.js +2 -1
  160. package/esm/Options/Classes/Particles/Opacity/OpacityAnimation.js +2 -1
  161. package/esm/Options/Classes/Particles/ParticlesOptions.js +1 -1
  162. package/esm/Options/Classes/Particles/Size/SizeAnimation.js +2 -1
  163. package/esm/Options/Classes/Responsive.js +5 -4
  164. package/esm/Options/Classes/Theme/ThemeDefault.js +2 -1
  165. package/esm/Types/RangeType.js +5 -1
  166. package/esm/Utils/CanvasUtils.js +13 -7
  167. package/esm/Utils/ColorUtils.js +17 -9
  168. package/esm/Utils/EventDispatcher.js +1 -1
  169. package/esm/Utils/HslColorManager.js +11 -4
  170. package/esm/Utils/NumberUtils.js +28 -14
  171. package/esm/Utils/RgbColorManager.js +11 -4
  172. package/esm/Utils/Utils.js +37 -31
  173. package/package.json +1 -1
  174. package/report.html +1 -1
  175. package/tsparticles.engine.js +327 -225
  176. package/tsparticles.engine.min.js +1 -1
  177. package/tsparticles.engine.min.js.LICENSE.txt +1 -1
  178. package/types/Core/Container.d.ts +4 -2
  179. package/types/Core/Engine.d.ts +6 -5
  180. package/types/Core/Interfaces/IPlugin.d.ts +3 -4
  181. package/types/Core/Interfaces/IShapeDrawer.d.ts +1 -0
  182. package/types/Core/Particle.d.ts +1 -0
  183. package/types/Enums/AnimationStatus.d.ts +1 -1
  184. package/types/Enums/Directions/MoveDirection.d.ts +1 -1
  185. package/types/Enums/Directions/OutModeDirection.d.ts +1 -1
  186. package/types/Enums/Directions/RotateDirection.d.ts +1 -1
  187. package/types/Enums/InteractivityDetect.d.ts +1 -1
  188. package/types/Enums/Modes/AnimationMode.d.ts +1 -1
  189. package/types/Enums/Modes/CollisionMode.d.ts +1 -1
  190. package/types/Enums/Modes/LimitMode.d.ts +1 -1
  191. package/types/Enums/Modes/OutMode.d.ts +1 -1
  192. package/types/Enums/Modes/PixelMode.d.ts +1 -1
  193. package/types/Enums/Modes/ResponsiveMode.d.ts +1 -1
  194. package/types/Enums/Modes/ThemeMode.d.ts +1 -1
  195. package/types/Enums/Types/AlterType.d.ts +1 -1
  196. package/types/Enums/Types/DestroyType.d.ts +1 -1
  197. package/types/Enums/Types/DivType.d.ts +1 -1
  198. package/types/Enums/Types/EasingType.d.ts +1 -1
  199. package/types/Enums/Types/EventType.d.ts +1 -1
  200. package/types/Enums/Types/GradientType.d.ts +1 -1
  201. package/types/Enums/Types/InteractorType.d.ts +1 -1
  202. package/types/Enums/Types/ParticleOutType.d.ts +1 -1
  203. package/types/Enums/Types/StartValueType.d.ts +1 -1
  204. package/types/Options/Classes/Options.d.ts +2 -1
  205. package/types/Options/Classes/Responsive.d.ts +2 -2
  206. package/types/Options/Classes/Theme/Theme.d.ts +2 -2
  207. package/types/Options/Interfaces/IResponsive.d.ts +2 -3
  208. package/types/Options/Interfaces/Theme/ITheme.d.ts +2 -3
  209. package/types/Types/RangeType.d.ts +1 -1
  210. package/types/Utils/NumberUtils.d.ts +3 -0
  211. package/umd/Core/Canvas.js +27 -22
  212. package/umd/Core/Container.js +58 -45
  213. package/umd/Core/Engine.js +83 -99
  214. package/umd/Core/Particle.js +30 -16
  215. package/umd/Core/Particles.js +24 -25
  216. package/umd/Core/Utils/EventListeners.js +19 -18
  217. package/umd/Core/Utils/ExternalInteractorBase.js +3 -2
  218. package/umd/Core/Utils/InteractionManager.js +4 -3
  219. package/umd/Core/Utils/ParticlesInteractorBase.js +3 -2
  220. package/umd/Core/Utils/QuadTree.js +1 -1
  221. package/umd/Core/Utils/Ranges.js +6 -5
  222. package/umd/Enums/AnimationStatus.js +6 -0
  223. package/umd/Enums/Directions/MoveDirection.js +15 -0
  224. package/umd/Enums/Directions/OutModeDirection.js +8 -0
  225. package/umd/Enums/Directions/RotateDirection.js +7 -0
  226. package/umd/Enums/InteractivityDetect.js +7 -0
  227. package/umd/Enums/Modes/AnimationMode.js +8 -0
  228. package/umd/Enums/Modes/CollisionMode.js +7 -0
  229. package/umd/Enums/Modes/LimitMode.js +6 -0
  230. package/umd/Enums/Modes/OutMode.js +9 -0
  231. package/umd/Enums/Modes/PixelMode.js +6 -0
  232. package/umd/Enums/Modes/ResponsiveMode.js +6 -0
  233. package/umd/Enums/Modes/ThemeMode.js +7 -0
  234. package/umd/Enums/Types/AlterType.js +6 -0
  235. package/umd/Enums/Types/DestroyType.js +7 -0
  236. package/umd/Enums/Types/DivType.js +6 -0
  237. package/umd/Enums/Types/EasingType.js +31 -0
  238. package/umd/Enums/Types/EventType.js +16 -0
  239. package/umd/Enums/Types/GradientType.js +7 -0
  240. package/umd/Enums/Types/InteractorType.js +6 -0
  241. package/umd/Enums/Types/ParticleOutType.js +7 -0
  242. package/umd/Enums/Types/StartValueType.js +7 -0
  243. package/umd/Options/Classes/AnimationOptions.js +5 -3
  244. package/umd/Options/Classes/Interactivity/Events/DivEvent.js +3 -2
  245. package/umd/Options/Classes/Interactivity/Events/Events.js +1 -1
  246. package/umd/Options/Classes/Interactivity/Interactivity.js +3 -2
  247. package/umd/Options/Classes/ManualParticle.js +3 -2
  248. package/umd/Options/Classes/Options.js +15 -13
  249. package/umd/Options/Classes/Particles/Collisions/Collisions.js +3 -2
  250. package/umd/Options/Classes/Particles/Move/Move.js +3 -2
  251. package/umd/Options/Classes/Particles/Move/MoveCenter.js +3 -2
  252. package/umd/Options/Classes/Particles/Move/OutModes.js +3 -2
  253. package/umd/Options/Classes/Particles/Number/ParticlesNumberLimit.js +3 -2
  254. package/umd/Options/Classes/Particles/Opacity/OpacityAnimation.js +3 -2
  255. package/umd/Options/Classes/Particles/ParticlesOptions.js +1 -1
  256. package/umd/Options/Classes/Particles/Size/SizeAnimation.js +3 -2
  257. package/umd/Options/Classes/Responsive.js +6 -5
  258. package/umd/Options/Classes/Theme/ThemeDefault.js +3 -2
  259. package/umd/Types/RangeType.js +6 -0
  260. package/umd/Utils/CanvasUtils.js +25 -20
  261. package/umd/Utils/ColorUtils.js +38 -31
  262. package/umd/Utils/EventDispatcher.js +1 -1
  263. package/umd/Utils/HslColorManager.js +11 -4
  264. package/umd/Utils/NumberUtils.js +55 -39
  265. package/umd/Utils/OptionsUtils.js +2 -3
  266. package/umd/Utils/RgbColorManager.js +11 -4
  267. package/umd/Utils/TypeUtils.js +6 -7
  268. package/umd/Utils/Utils.js +67 -62
  269. package/umd/init.js +1 -2
  270. package/174.min.js +0 -2
  271. package/174.min.js.LICENSE.txt +0 -1
  272. package/dist_browser_Core_Container_js.js +0 -102
@@ -1,6 +1,7 @@
1
+ import { InteractorType } from "../../Enums/Types/InteractorType.js";
1
2
  export class ParticlesInteractorBase {
2
3
  constructor(container) {
3
- this.type = "particles";
4
+ this.type = InteractorType.particles;
4
5
  this.container = container;
5
6
  }
6
7
  }
@@ -28,7 +28,7 @@ export class QuadTree {
28
28
  if (!this._divided) {
29
29
  this._subdivide();
30
30
  }
31
- return this._subs.some((sub) => sub.insert(point));
31
+ return this._subs.some(sub => sub.insert(point));
32
32
  }
33
33
  query(range, check) {
34
34
  const res = [];
@@ -1,3 +1,4 @@
1
+ import { RangeType } from "../../Types/RangeType.js";
1
2
  import { getDistance } from "../../Utils/NumberUtils.js";
2
3
  const squareExp = 2;
3
4
  export class BaseRange {
@@ -11,7 +12,7 @@ export class BaseRange {
11
12
  }
12
13
  export class Circle extends BaseRange {
13
14
  constructor(x, y, radius) {
14
- super(x, y, "circle");
15
+ super(x, y, RangeType.circle);
15
16
  this.radius = radius;
16
17
  }
17
18
  contains(point) {
@@ -19,11 +20,11 @@ export class Circle extends BaseRange {
19
20
  }
20
21
  intersects(range) {
21
22
  const pos1 = this.position, pos2 = range.position, distPos = { x: Math.abs(pos2.x - pos1.x), y: Math.abs(pos2.y - pos1.y) }, r = this.radius;
22
- if (range instanceof Circle || range.type === "circle") {
23
+ if (range instanceof Circle || range.type === RangeType.circle) {
23
24
  const circleRange = range, rSum = r + circleRange.radius, dist = Math.sqrt(distPos.x ** squareExp + distPos.y ** squareExp);
24
25
  return rSum > dist;
25
26
  }
26
- else if (range instanceof Rectangle || range.type === "rectangle") {
27
+ else if (range instanceof Rectangle || range.type === RangeType.rectangle) {
27
28
  const rectRange = range, { width, height } = rectRange.size, edges = Math.pow(distPos.x - width, squareExp) + Math.pow(distPos.y - height, squareExp);
28
29
  return (edges <= r ** squareExp ||
29
30
  (distPos.x <= r + width && distPos.y <= r + height) ||
@@ -35,7 +36,7 @@ export class Circle extends BaseRange {
35
36
  }
36
37
  export class Rectangle extends BaseRange {
37
38
  constructor(x, y, width, height) {
38
- super(x, y, "rectangle");
39
+ super(x, y, RangeType.rectangle);
39
40
  this.size = {
40
41
  height: height,
41
42
  width: width,
@@ -1 +1,5 @@
1
- export {};
1
+ export var AnimationStatus;
2
+ (function (AnimationStatus) {
3
+ AnimationStatus["increasing"] = "increasing";
4
+ AnimationStatus["decreasing"] = "decreasing";
5
+ })(AnimationStatus || (AnimationStatus = {}));
@@ -1 +1,14 @@
1
- export {};
1
+ export var MoveDirection;
2
+ (function (MoveDirection) {
3
+ MoveDirection["bottom"] = "bottom";
4
+ MoveDirection["bottomLeft"] = "bottom-left";
5
+ MoveDirection["bottomRight"] = "bottom-right";
6
+ MoveDirection["left"] = "left";
7
+ MoveDirection["none"] = "none";
8
+ MoveDirection["right"] = "right";
9
+ MoveDirection["top"] = "top";
10
+ MoveDirection["topLeft"] = "top-left";
11
+ MoveDirection["topRight"] = "top-right";
12
+ MoveDirection["outside"] = "outside";
13
+ MoveDirection["inside"] = "inside";
14
+ })(MoveDirection || (MoveDirection = {}));
@@ -1 +1,7 @@
1
- export {};
1
+ export var OutModeDirection;
2
+ (function (OutModeDirection) {
3
+ OutModeDirection["bottom"] = "bottom";
4
+ OutModeDirection["left"] = "left";
5
+ OutModeDirection["right"] = "right";
6
+ OutModeDirection["top"] = "top";
7
+ })(OutModeDirection || (OutModeDirection = {}));
@@ -1 +1,6 @@
1
- export {};
1
+ export var RotateDirection;
2
+ (function (RotateDirection) {
3
+ RotateDirection["clockwise"] = "clockwise";
4
+ RotateDirection["counterClockwise"] = "counter-clockwise";
5
+ RotateDirection["random"] = "random";
6
+ })(RotateDirection || (RotateDirection = {}));
@@ -1 +1,6 @@
1
- export {};
1
+ export var InteractivityDetect;
2
+ (function (InteractivityDetect) {
3
+ InteractivityDetect["canvas"] = "canvas";
4
+ InteractivityDetect["parent"] = "parent";
5
+ InteractivityDetect["window"] = "window";
6
+ })(InteractivityDetect || (InteractivityDetect = {}));
@@ -1 +1,7 @@
1
- export {};
1
+ export var AnimationMode;
2
+ (function (AnimationMode) {
3
+ AnimationMode["auto"] = "auto";
4
+ AnimationMode["increase"] = "increase";
5
+ AnimationMode["decrease"] = "decrease";
6
+ AnimationMode["random"] = "random";
7
+ })(AnimationMode || (AnimationMode = {}));
@@ -1 +1,6 @@
1
- export {};
1
+ export var CollisionMode;
2
+ (function (CollisionMode) {
3
+ CollisionMode["absorb"] = "absorb";
4
+ CollisionMode["bounce"] = "bounce";
5
+ CollisionMode["destroy"] = "destroy";
6
+ })(CollisionMode || (CollisionMode = {}));
@@ -1 +1,5 @@
1
- export {};
1
+ export var LimitMode;
2
+ (function (LimitMode) {
3
+ LimitMode["delete"] = "delete";
4
+ LimitMode["wait"] = "wait";
5
+ })(LimitMode || (LimitMode = {}));
@@ -1 +1,8 @@
1
- export {};
1
+ export var OutMode;
2
+ (function (OutMode) {
3
+ OutMode["bounce"] = "bounce";
4
+ OutMode["none"] = "none";
5
+ OutMode["out"] = "out";
6
+ OutMode["destroy"] = "destroy";
7
+ OutMode["split"] = "split";
8
+ })(OutMode || (OutMode = {}));
@@ -1 +1,5 @@
1
- export {};
1
+ export var PixelMode;
2
+ (function (PixelMode) {
3
+ PixelMode["precise"] = "precise";
4
+ PixelMode["percent"] = "percent";
5
+ })(PixelMode || (PixelMode = {}));
@@ -1 +1,5 @@
1
- export {};
1
+ export var ResponsiveMode;
2
+ (function (ResponsiveMode) {
3
+ ResponsiveMode["screen"] = "screen";
4
+ ResponsiveMode["canvas"] = "canvas";
5
+ })(ResponsiveMode || (ResponsiveMode = {}));
@@ -1 +1,6 @@
1
- export {};
1
+ export var ThemeMode;
2
+ (function (ThemeMode) {
3
+ ThemeMode["any"] = "any";
4
+ ThemeMode["dark"] = "dark";
5
+ ThemeMode["light"] = "light";
6
+ })(ThemeMode || (ThemeMode = {}));
@@ -1 +1,5 @@
1
- export {};
1
+ export var AlterType;
2
+ (function (AlterType) {
3
+ AlterType["darken"] = "darken";
4
+ AlterType["enlighten"] = "enlighten";
5
+ })(AlterType || (AlterType = {}));
@@ -1 +1,6 @@
1
- export {};
1
+ export var DestroyType;
2
+ (function (DestroyType) {
3
+ DestroyType["none"] = "none";
4
+ DestroyType["max"] = "max";
5
+ DestroyType["min"] = "min";
6
+ })(DestroyType || (DestroyType = {}));
@@ -1 +1,5 @@
1
- export {};
1
+ export var DivType;
2
+ (function (DivType) {
3
+ DivType["circle"] = "circle";
4
+ DivType["rectangle"] = "rectangle";
5
+ })(DivType || (DivType = {}));
@@ -1 +1,30 @@
1
- export {};
1
+ export var EasingType;
2
+ (function (EasingType) {
3
+ EasingType["easeInBack"] = "ease-in-back";
4
+ EasingType["easeInCirc"] = "ease-in-circ";
5
+ EasingType["easeInCubic"] = "ease-in-cubic";
6
+ EasingType["easeInLinear"] = "ease-in-linear";
7
+ EasingType["easeInQuad"] = "ease-in-quad";
8
+ EasingType["easeInQuart"] = "ease-in-quart";
9
+ EasingType["easeInQuint"] = "ease-in-quint";
10
+ EasingType["easeInExpo"] = "ease-in-expo";
11
+ EasingType["easeInSine"] = "ease-in-sine";
12
+ EasingType["easeOutBack"] = "ease-out-back";
13
+ EasingType["easeOutCirc"] = "ease-out-circ";
14
+ EasingType["easeOutCubic"] = "ease-out-cubic";
15
+ EasingType["easeOutLinear"] = "ease-out-linear";
16
+ EasingType["easeOutQuad"] = "ease-out-quad";
17
+ EasingType["easeOutQuart"] = "ease-out-quart";
18
+ EasingType["easeOutQuint"] = "ease-out-quint";
19
+ EasingType["easeOutExpo"] = "ease-out-expo";
20
+ EasingType["easeOutSine"] = "ease-out-sine";
21
+ EasingType["easeInOutBack"] = "ease-in-out-back";
22
+ EasingType["easeInOutCirc"] = "ease-in-out-circ";
23
+ EasingType["easeInOutCubic"] = "ease-in-out-cubic";
24
+ EasingType["easeInOutLinear"] = "ease-in-out-linear";
25
+ EasingType["easeInOutQuad"] = "ease-in-out-quad";
26
+ EasingType["easeInOutQuart"] = "ease-in-out-quart";
27
+ EasingType["easeInOutQuint"] = "ease-in-out-quint";
28
+ EasingType["easeInOutExpo"] = "ease-in-out-expo";
29
+ EasingType["easeInOutSine"] = "ease-in-out-sine";
30
+ })(EasingType || (EasingType = {}));
@@ -1 +1,15 @@
1
- export {};
1
+ export var EventType;
2
+ (function (EventType) {
3
+ EventType["configAdded"] = "configAdded";
4
+ EventType["containerInit"] = "containerInit";
5
+ EventType["particlesSetup"] = "particlesSetup";
6
+ EventType["containerStarted"] = "containerStarted";
7
+ EventType["containerStopped"] = "containerStopped";
8
+ EventType["containerDestroyed"] = "containerDestroyed";
9
+ EventType["containerPaused"] = "containerPaused";
10
+ EventType["containerPlay"] = "containerPlay";
11
+ EventType["containerBuilt"] = "containerBuilt";
12
+ EventType["particleAdded"] = "particleAdded";
13
+ EventType["particleDestroyed"] = "particleDestroyed";
14
+ EventType["particleRemoved"] = "particleRemoved";
15
+ })(EventType || (EventType = {}));
@@ -1 +1,6 @@
1
- export {};
1
+ export var GradientType;
2
+ (function (GradientType) {
3
+ GradientType["linear"] = "linear";
4
+ GradientType["radial"] = "radial";
5
+ GradientType["random"] = "random";
6
+ })(GradientType || (GradientType = {}));
@@ -1 +1,5 @@
1
- export {};
1
+ export var InteractorType;
2
+ (function (InteractorType) {
3
+ InteractorType["external"] = "external";
4
+ InteractorType["particles"] = "particles";
5
+ })(InteractorType || (InteractorType = {}));
@@ -1 +1,6 @@
1
- export {};
1
+ export var ParticleOutType;
2
+ (function (ParticleOutType) {
3
+ ParticleOutType["normal"] = "normal";
4
+ ParticleOutType["inside"] = "inside";
5
+ ParticleOutType["outside"] = "outside";
6
+ })(ParticleOutType || (ParticleOutType = {}));
@@ -1 +1,6 @@
1
- export {};
1
+ export var StartValueType;
2
+ (function (StartValueType) {
3
+ StartValueType["max"] = "max";
4
+ StartValueType["min"] = "min";
5
+ StartValueType["random"] = "random";
6
+ })(StartValueType || (StartValueType = {}));
@@ -1,3 +1,5 @@
1
+ import { AnimationMode } from "../../Enums/Modes/AnimationMode.js";
2
+ import { StartValueType } from "../../Enums/Types/StartValueType.js";
1
3
  import { setRangeValue } from "../../Utils/NumberUtils.js";
2
4
  export class AnimationOptions {
3
5
  constructor() {
@@ -35,8 +37,8 @@ export class AnimationOptions {
35
37
  export class RangedAnimationOptions extends AnimationOptions {
36
38
  constructor() {
37
39
  super();
38
- this.mode = "auto";
39
- this.startValue = "random";
40
+ this.mode = AnimationMode.auto;
41
+ this.startValue = StartValueType.random;
40
42
  }
41
43
  load(data) {
42
44
  super.load(data);
@@ -1,9 +1,10 @@
1
+ import { DivType } from "../../../../Enums/Types/DivType.js";
1
2
  export class DivEvent {
2
3
  constructor() {
3
4
  this.selectors = [];
4
5
  this.enable = false;
5
6
  this.mode = [];
6
- this.type = "circle";
7
+ this.type = DivType.circle;
7
8
  }
8
9
  load(data) {
9
10
  if (!data) {
@@ -17,7 +17,7 @@ export class Events {
17
17
  this.onClick.load(data.onClick);
18
18
  const onDiv = data.onDiv;
19
19
  if (onDiv !== undefined) {
20
- this.onDiv = executeOnSingleOrMultiple(onDiv, (t) => {
20
+ this.onDiv = executeOnSingleOrMultiple(onDiv, t => {
21
21
  const tmp = new DivEvent();
22
22
  tmp.load(t);
23
23
  return tmp;
@@ -1,8 +1,9 @@
1
1
  import { Events } from "./Events/Events.js";
2
+ import { InteractivityDetect } from "../../../Enums/InteractivityDetect.js";
2
3
  import { Modes } from "./Modes/Modes.js";
3
4
  export class Interactivity {
4
5
  constructor(engine, container) {
5
- this.detectsOn = "window";
6
+ this.detectsOn = InteractivityDetect.window;
6
7
  this.events = new Events();
7
8
  this.modes = new Modes(engine, container);
8
9
  }
@@ -1,3 +1,4 @@
1
+ import { PixelMode } from "../../Enums/Modes/PixelMode.js";
1
2
  import { deepExtend } from "../../Utils/Utils.js";
2
3
  const defaultPosition = 50;
3
4
  export class ManualParticle {
@@ -9,7 +10,7 @@ export class ManualParticle {
9
10
  this.position = {
10
11
  x: data.position.x ?? defaultPosition,
11
12
  y: data.position.y ?? defaultPosition,
12
- mode: data.position.mode ?? "percent",
13
+ mode: data.position.mode ?? PixelMode.percent,
13
14
  };
14
15
  }
15
16
  if (data.options) {
@@ -5,17 +5,19 @@ import { FullScreen } from "./FullScreen/FullScreen.js";
5
5
  import { Interactivity } from "./Interactivity/Interactivity.js";
6
6
  import { ManualParticle } from "./ManualParticle.js";
7
7
  import { Responsive } from "./Responsive.js";
8
+ import { ResponsiveMode } from "../../Enums/Modes/ResponsiveMode.js";
8
9
  import { Theme } from "./Theme/Theme.js";
10
+ import { ThemeMode } from "../../Enums/Modes/ThemeMode.js";
9
11
  import { isBoolean } from "../../Utils/TypeUtils.js";
10
12
  import { loadParticlesOptions } from "../../Utils/OptionsUtils.js";
11
13
  import { setRangeValue } from "../../Utils/NumberUtils.js";
12
14
  export class Options {
13
15
  constructor(engine, container) {
14
- this._findDefaultTheme = (mode) => {
15
- return (this.themes.find((theme) => theme.default.value && theme.default.mode === mode) ??
16
- this.themes.find((theme) => theme.default.value && theme.default.mode === "any"));
16
+ this._findDefaultTheme = mode => {
17
+ return (this.themes.find(theme => theme.default.value && theme.default.mode === mode) ??
18
+ this.themes.find(theme => theme.default.value && theme.default.mode === ThemeMode.any));
17
19
  };
18
- this._importPreset = (preset) => {
20
+ this._importPreset = preset => {
19
21
  this.load(this._engine.getPreset(preset));
20
22
  };
21
23
  this._engine = engine;
@@ -46,7 +48,7 @@ export class Options {
46
48
  return;
47
49
  }
48
50
  if (data.preset !== undefined) {
49
- executeOnSingleOrMultiple(data.preset, (preset) => this._importPreset(preset));
51
+ executeOnSingleOrMultiple(data.preset, preset => this._importPreset(preset));
50
52
  }
51
53
  if (data.autoPlay !== undefined) {
52
54
  this.autoPlay = data.autoPlay;
@@ -94,7 +96,7 @@ export class Options {
94
96
  this.backgroundMask.load(data.backgroundMask);
95
97
  this.interactivity.load(data.interactivity);
96
98
  if (data.manualParticles) {
97
- this.manualParticles = data.manualParticles.map((t) => {
99
+ this.manualParticles = data.manualParticles.map(t => {
98
100
  const tmp = new ManualParticle();
99
101
  tmp.load(t);
100
102
  return tmp;
@@ -124,7 +126,7 @@ export class Options {
124
126
  this.responsive.sort((a, b) => a.maxWidth - b.maxWidth);
125
127
  if (data.themes !== undefined) {
126
128
  for (const theme of data.themes) {
127
- const existingTheme = this.themes.find((t) => t.name === theme.name);
129
+ const existingTheme = this.themes.find(t => t.name === theme.name);
128
130
  if (!existingTheme) {
129
131
  const optTheme = new Theme();
130
132
  optTheme.load(theme);
@@ -135,24 +137,24 @@ export class Options {
135
137
  }
136
138
  }
137
139
  }
138
- this.defaultThemes.dark = this._findDefaultTheme("dark")?.name;
139
- this.defaultThemes.light = this._findDefaultTheme("light")?.name;
140
+ this.defaultThemes.dark = this._findDefaultTheme(ThemeMode.dark)?.name;
141
+ this.defaultThemes.light = this._findDefaultTheme(ThemeMode.light)?.name;
140
142
  }
141
143
  setResponsive(width, pxRatio, defaultOptions) {
142
144
  this.load(defaultOptions);
143
- const responsiveOptions = this.responsive.find((t) => t.mode === "screen" && screen ? t.maxWidth > screen.availWidth : t.maxWidth * pxRatio > width);
145
+ const responsiveOptions = this.responsive.find(t => t.mode === ResponsiveMode.screen && screen ? t.maxWidth > screen.availWidth : t.maxWidth * pxRatio > width);
144
146
  this.load(responsiveOptions?.options);
145
147
  return responsiveOptions?.maxWidth;
146
148
  }
147
149
  setTheme(name) {
148
150
  if (name) {
149
- const chosenTheme = this.themes.find((theme) => theme.name === name);
151
+ const chosenTheme = this.themes.find(theme => theme.name === name);
150
152
  if (chosenTheme) {
151
153
  this.load(chosenTheme.options);
152
154
  }
153
155
  }
154
156
  else {
155
- const mediaMatch = safeMatchMedia("(prefers-color-scheme: dark)"), clientDarkMode = mediaMatch && mediaMatch.matches, defaultTheme = this._findDefaultTheme(clientDarkMode ? "dark" : "light");
157
+ const mediaMatch = safeMatchMedia("(prefers-color-scheme: dark)"), clientDarkMode = mediaMatch?.matches, defaultTheme = this._findDefaultTheme(clientDarkMode ? ThemeMode.dark : ThemeMode.light);
156
158
  if (defaultTheme) {
157
159
  this.load(defaultTheme.options);
158
160
  }
@@ -1,3 +1,4 @@
1
+ import { CollisionMode } from "../../../../Enums/Modes/CollisionMode.js";
1
2
  import { CollisionsAbsorb } from "./CollisionsAbsorb.js";
2
3
  import { CollisionsOverlap } from "./CollisionsOverlap.js";
3
4
  import { ParticlesBounce } from "../Bounce/ParticlesBounce.js";
@@ -8,7 +9,7 @@ export class Collisions {
8
9
  this.bounce = new ParticlesBounce();
9
10
  this.enable = false;
10
11
  this.maxSpeed = 50;
11
- this.mode = "bounce";
12
+ this.mode = CollisionMode.bounce;
12
13
  this.overlap = new CollisionsOverlap();
13
14
  }
14
15
  load(data) {
@@ -1,3 +1,4 @@
1
+ import { MoveDirection } from "../../../../Enums/Directions/MoveDirection.js";
1
2
  import { isNumber, isObject } from "../../../../Utils/TypeUtils.js";
2
3
  import { MoveAngle } from "./MoveAngle.js";
3
4
  import { MoveAttract } from "./MoveAttract.js";
@@ -15,7 +16,7 @@ export class Move {
15
16
  this.center = new MoveCenter();
16
17
  this.decay = 0;
17
18
  this.distance = {};
18
- this.direction = "none";
19
+ this.direction = MoveDirection.none;
19
20
  this.drift = 0;
20
21
  this.enable = false;
21
22
  this.gravity = new MoveGravity();
@@ -1,8 +1,9 @@
1
+ import { PixelMode } from "../../../../Enums/Modes/PixelMode.js";
1
2
  export class MoveCenter {
2
3
  constructor() {
3
4
  this.x = 50;
4
5
  this.y = 50;
5
- this.mode = "percent";
6
+ this.mode = PixelMode.percent;
6
7
  this.radius = 0;
7
8
  }
8
9
  load(data) {
@@ -1,6 +1,7 @@
1
+ import { OutMode } from "../../../../Enums/Modes/OutMode.js";
1
2
  export class OutModes {
2
3
  constructor() {
3
- this.default = "out";
4
+ this.default = OutMode.out;
4
5
  }
5
6
  load(data) {
6
7
  if (!data) {
@@ -1,6 +1,7 @@
1
+ import { LimitMode } from "../../../../Enums/Modes/LimitMode.js";
1
2
  export class ParticlesNumberLimit {
2
3
  constructor() {
3
- this.mode = "delete";
4
+ this.mode = LimitMode.delete;
4
5
  this.value = 0;
5
6
  }
6
7
  load(data) {
@@ -1,8 +1,9 @@
1
+ import { DestroyType } from "../../../../Enums/Types/DestroyType.js";
1
2
  import { RangedAnimationOptions } from "../../AnimationOptions.js";
2
3
  export class OpacityAnimation extends RangedAnimationOptions {
3
4
  constructor() {
4
5
  super();
5
- this.destroy = "none";
6
+ this.destroy = DestroyType.none;
6
7
  this.speed = 2;
7
8
  }
8
9
  load(data) {
@@ -65,7 +65,7 @@ export class ParticlesOptions {
65
65
  }
66
66
  const strokeToLoad = data.stroke;
67
67
  if (strokeToLoad) {
68
- this.stroke = executeOnSingleOrMultiple(strokeToLoad, (t) => {
68
+ this.stroke = executeOnSingleOrMultiple(strokeToLoad, t => {
69
69
  const tmp = new Stroke();
70
70
  tmp.load(t);
71
71
  return tmp;
@@ -1,8 +1,9 @@
1
+ import { DestroyType } from "../../../../Enums/Types/DestroyType.js";
1
2
  import { RangedAnimationOptions } from "../../AnimationOptions.js";
2
3
  export class SizeAnimation extends RangedAnimationOptions {
3
4
  constructor() {
4
5
  super();
5
- this.destroy = "none";
6
+ this.destroy = DestroyType.none;
6
7
  this.speed = 5;
7
8
  }
8
9
  load(data) {
@@ -1,9 +1,10 @@
1
+ import { ResponsiveMode } from "../../Enums/Modes/ResponsiveMode.js";
1
2
  import { deepExtend } from "../../Utils/Utils.js";
2
3
  export class Responsive {
3
4
  constructor() {
4
5
  this.maxWidth = Infinity;
5
6
  this.options = {};
6
- this.mode = "canvas";
7
+ this.mode = ResponsiveMode.canvas;
7
8
  }
8
9
  load(data) {
9
10
  if (!data) {
@@ -13,11 +14,11 @@ export class Responsive {
13
14
  this.maxWidth = data.maxWidth;
14
15
  }
15
16
  if (data.mode !== undefined) {
16
- if (data.mode === "screen") {
17
- this.mode = "screen";
17
+ if (data.mode === ResponsiveMode.screen) {
18
+ this.mode = ResponsiveMode.screen;
18
19
  }
19
20
  else {
20
- this.mode = "canvas";
21
+ this.mode = ResponsiveMode.canvas;
21
22
  }
22
23
  }
23
24
  if (data.options !== undefined) {
@@ -1,7 +1,8 @@
1
+ import { ThemeMode } from "../../../Enums/Modes/ThemeMode.js";
1
2
  export class ThemeDefault {
2
3
  constructor() {
3
4
  this.auto = false;
4
- this.mode = "any";
5
+ this.mode = ThemeMode.any;
5
6
  this.value = false;
6
7
  }
7
8
  load(data) {
@@ -1 +1,5 @@
1
- export {};
1
+ export var RangeType;
2
+ (function (RangeType) {
3
+ RangeType["circle"] = "circle";
4
+ RangeType["rectangle"] = "rectangle";
5
+ })(RangeType || (RangeType = {}));
@@ -1,5 +1,11 @@
1
+ import { AlterType } from "../Enums/Types/AlterType.js";
1
2
  import { getStyleFromRgb } from "./ColorUtils.js";
2
- const origin = { x: 0, y: 0 };
3
+ const origin = { x: 0, y: 0 }, defaultTransform = {
4
+ a: 1,
5
+ b: 0,
6
+ c: 0,
7
+ d: 1,
8
+ };
3
9
  export function drawLine(context, begin, end) {
4
10
  context.beginPath();
5
11
  context.moveTo(begin.x, begin.y);
@@ -25,11 +31,11 @@ export function drawParticle(data) {
25
31
  const { container, context, particle, delta, colorStyles, backgroundMask, composite, radius, opacity, shadow, transform, } = data, pos = particle.getPosition(), defaultAngle = 0, angle = particle.rotation + (particle.pathRotation ? particle.velocity.angle : defaultAngle), rotateData = {
26
32
  sin: Math.sin(angle),
27
33
  cos: Math.cos(angle),
28
- }, defaultTransformFactor = 1, transformData = {
29
- a: rotateData.cos * (transform.a ?? defaultTransformFactor),
30
- b: rotateData.sin * (transform.b ?? defaultTransformFactor),
31
- c: -rotateData.sin * (transform.c ?? defaultTransformFactor),
32
- d: rotateData.cos * (transform.d ?? defaultTransformFactor),
34
+ }, rotating = !!angle, identity = 1, transformData = {
35
+ a: rotateData.cos * (transform.a ?? defaultTransform.a),
36
+ b: rotating ? rotateData.sin * (transform.b ?? identity) : transform.b ?? defaultTransform.b,
37
+ c: rotating ? -rotateData.sin * (transform.c ?? identity) : transform.c ?? defaultTransform.c,
38
+ d: rotateData.cos * (transform.d ?? defaultTransform.d),
33
39
  };
34
40
  context.setTransform(transformData.a, transformData.b, transformData.c, transformData.d, pos.x, pos.y);
35
41
  if (backgroundMask) {
@@ -150,6 +156,6 @@ export function alterHsl(color, type, value) {
150
156
  return {
151
157
  h: color.h,
152
158
  s: color.s,
153
- l: color.l + (type === "darken" ? -lFactor : lFactor) * value,
159
+ l: color.l + (type === AlterType.darken ? -lFactor : lFactor) * value,
154
160
  };
155
161
  }