@tsparticles/engine 4.0.0-alpha.5 → 4.0.0-beta.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 (279) hide show
  1. package/164.min.js +1 -0
  2. package/README.md +41 -7
  3. package/browser/Core/Canvas.js +250 -143
  4. package/browser/Core/Container.js +80 -74
  5. package/browser/Core/Engine.js +44 -67
  6. package/browser/Core/Particle.js +202 -173
  7. package/browser/Core/Particles.js +187 -138
  8. package/browser/Core/Retina.js +5 -0
  9. package/browser/Core/Utils/Constants.js +2 -2
  10. package/browser/Core/Utils/EventListeners.js +67 -63
  11. package/browser/Core/Utils/Ranges.js +29 -10
  12. package/browser/Core/Utils/SpatialHashGrid.js +102 -0
  13. package/browser/Core/Utils/Vectors.js +17 -18
  14. package/browser/Enums/Types/EasingType.js +18 -3
  15. package/browser/Options/Classes/AnimatableColor.js +1 -0
  16. package/browser/Options/Classes/AnimationOptions.js +8 -0
  17. package/browser/Options/Classes/Background/Background.js +6 -0
  18. package/browser/Options/Classes/ColorAnimation.js +12 -1
  19. package/browser/Options/Classes/FullScreen/FullScreen.js +2 -0
  20. package/browser/Options/Classes/HslAnimation.js +4 -5
  21. package/browser/Options/Classes/Options.js +63 -4
  22. package/browser/Options/Classes/OptionsColor.js +1 -0
  23. package/browser/Options/Classes/Particles/Bounce/ParticlesBounce.js +2 -0
  24. package/browser/Options/Classes/Particles/Effect/Effect.js +3 -4
  25. package/browser/Options/Classes/Particles/Fill.js +28 -0
  26. package/browser/Options/Classes/Particles/Move/Move.js +17 -3
  27. package/browser/Options/Classes/Particles/Move/MoveAngle.js +2 -0
  28. package/browser/Options/Classes/Particles/Move/MoveCenter.js +4 -0
  29. package/browser/Options/Classes/Particles/Move/MoveGravity.js +4 -0
  30. package/browser/Options/Classes/Particles/Move/OutModes.js +5 -0
  31. package/browser/Options/Classes/Particles/Move/Path/MovePath.js +5 -0
  32. package/browser/Options/Classes/Particles/Move/Spin.js +3 -0
  33. package/browser/Options/Classes/Particles/Number/ParticlesDensity.js +3 -0
  34. package/browser/Options/Classes/Particles/Number/ParticlesNumber.js +3 -0
  35. package/browser/Options/Classes/Particles/Number/ParticlesNumberLimit.js +2 -0
  36. package/browser/Options/Classes/Particles/Opacity/Opacity.js +1 -0
  37. package/browser/Options/Classes/Particles/Opacity/OpacityAnimation.js +1 -0
  38. package/browser/Options/Classes/Particles/ParticlesOptions.js +25 -5
  39. package/browser/Options/Classes/Particles/Shape/Shape.js +3 -4
  40. package/browser/Options/Classes/Particles/Size/Size.js +1 -0
  41. package/browser/Options/Classes/Particles/Size/SizeAnimation.js +1 -0
  42. package/browser/Options/Classes/Particles/Stroke.js +3 -0
  43. package/browser/Options/Classes/Particles/ZIndex/ZIndex.js +3 -0
  44. package/browser/Options/Classes/ResizeEvent.js +2 -0
  45. package/browser/Options/Classes/ValueWithRandom.js +3 -4
  46. package/browser/Utils/CanvasUtils.js +43 -62
  47. package/browser/Utils/ColorUtils.js +30 -19
  48. package/browser/Utils/EventDispatcher.js +1 -0
  49. package/browser/Utils/MathUtils.js +12 -7
  50. package/browser/Utils/Utils.js +109 -31
  51. package/browser/exports.js +1 -2
  52. package/cjs/Core/Canvas.js +250 -143
  53. package/cjs/Core/Container.js +80 -74
  54. package/cjs/Core/Engine.js +44 -67
  55. package/cjs/Core/Particle.js +202 -173
  56. package/cjs/Core/Particles.js +187 -138
  57. package/cjs/Core/Retina.js +5 -0
  58. package/cjs/Core/Utils/Constants.js +2 -2
  59. package/cjs/Core/Utils/EventListeners.js +67 -63
  60. package/cjs/Core/Utils/Ranges.js +29 -10
  61. package/cjs/Core/Utils/SpatialHashGrid.js +102 -0
  62. package/cjs/Core/Utils/Vectors.js +17 -18
  63. package/cjs/Enums/Types/EasingType.js +18 -3
  64. package/cjs/Options/Classes/AnimatableColor.js +1 -0
  65. package/cjs/Options/Classes/AnimationOptions.js +8 -0
  66. package/cjs/Options/Classes/Background/Background.js +6 -0
  67. package/cjs/Options/Classes/ColorAnimation.js +12 -1
  68. package/cjs/Options/Classes/FullScreen/FullScreen.js +2 -0
  69. package/cjs/Options/Classes/HslAnimation.js +4 -5
  70. package/cjs/Options/Classes/Options.js +63 -4
  71. package/cjs/Options/Classes/OptionsColor.js +1 -0
  72. package/cjs/Options/Classes/Particles/Bounce/ParticlesBounce.js +2 -0
  73. package/cjs/Options/Classes/Particles/Effect/Effect.js +3 -4
  74. package/cjs/Options/Classes/Particles/Fill.js +28 -0
  75. package/cjs/Options/Classes/Particles/Move/Move.js +17 -3
  76. package/cjs/Options/Classes/Particles/Move/MoveAngle.js +2 -0
  77. package/cjs/Options/Classes/Particles/Move/MoveCenter.js +4 -0
  78. package/cjs/Options/Classes/Particles/Move/MoveGravity.js +4 -0
  79. package/cjs/Options/Classes/Particles/Move/OutModes.js +5 -0
  80. package/cjs/Options/Classes/Particles/Move/Path/MovePath.js +5 -0
  81. package/cjs/Options/Classes/Particles/Move/Spin.js +3 -0
  82. package/cjs/Options/Classes/Particles/Number/ParticlesDensity.js +3 -0
  83. package/cjs/Options/Classes/Particles/Number/ParticlesNumber.js +3 -0
  84. package/cjs/Options/Classes/Particles/Number/ParticlesNumberLimit.js +2 -0
  85. package/cjs/Options/Classes/Particles/Opacity/Opacity.js +1 -0
  86. package/cjs/Options/Classes/Particles/Opacity/OpacityAnimation.js +1 -0
  87. package/cjs/Options/Classes/Particles/ParticlesOptions.js +25 -5
  88. package/cjs/Options/Classes/Particles/Shape/Shape.js +3 -4
  89. package/cjs/Options/Classes/Particles/Size/Size.js +1 -0
  90. package/cjs/Options/Classes/Particles/Size/SizeAnimation.js +1 -0
  91. package/cjs/Options/Classes/Particles/Stroke.js +3 -0
  92. package/cjs/Options/Classes/Particles/ZIndex/ZIndex.js +3 -0
  93. package/cjs/Options/Classes/ResizeEvent.js +2 -0
  94. package/cjs/Options/Classes/ValueWithRandom.js +3 -4
  95. package/cjs/Utils/CanvasUtils.js +43 -62
  96. package/cjs/Utils/ColorUtils.js +30 -19
  97. package/cjs/Utils/EventDispatcher.js +1 -0
  98. package/cjs/Utils/MathUtils.js +12 -7
  99. package/cjs/Utils/Utils.js +109 -31
  100. package/cjs/exports.js +1 -2
  101. package/dist_browser_Core_Container_js.js +12 -12
  102. package/esm/Core/Canvas.js +250 -143
  103. package/esm/Core/Container.js +80 -74
  104. package/esm/Core/Engine.js +44 -67
  105. package/esm/Core/Particle.js +202 -173
  106. package/esm/Core/Particles.js +187 -138
  107. package/esm/Core/Retina.js +5 -0
  108. package/esm/Core/Utils/Constants.js +2 -2
  109. package/esm/Core/Utils/EventListeners.js +67 -63
  110. package/esm/Core/Utils/Ranges.js +29 -10
  111. package/esm/Core/Utils/SpatialHashGrid.js +102 -0
  112. package/esm/Core/Utils/Vectors.js +17 -18
  113. package/esm/Enums/Types/EasingType.js +18 -3
  114. package/esm/Options/Classes/AnimatableColor.js +1 -0
  115. package/esm/Options/Classes/AnimationOptions.js +8 -0
  116. package/esm/Options/Classes/Background/Background.js +6 -0
  117. package/esm/Options/Classes/ColorAnimation.js +12 -1
  118. package/esm/Options/Classes/FullScreen/FullScreen.js +2 -0
  119. package/esm/Options/Classes/HslAnimation.js +4 -5
  120. package/esm/Options/Classes/Options.js +63 -4
  121. package/esm/Options/Classes/OptionsColor.js +1 -0
  122. package/esm/Options/Classes/Particles/Bounce/ParticlesBounce.js +2 -0
  123. package/esm/Options/Classes/Particles/Effect/Effect.js +3 -4
  124. package/esm/Options/Classes/Particles/Fill.js +28 -0
  125. package/esm/Options/Classes/Particles/Move/Move.js +17 -3
  126. package/esm/Options/Classes/Particles/Move/MoveAngle.js +2 -0
  127. package/esm/Options/Classes/Particles/Move/MoveCenter.js +4 -0
  128. package/esm/Options/Classes/Particles/Move/MoveGravity.js +4 -0
  129. package/esm/Options/Classes/Particles/Move/OutModes.js +5 -0
  130. package/esm/Options/Classes/Particles/Move/Path/MovePath.js +5 -0
  131. package/esm/Options/Classes/Particles/Move/Spin.js +3 -0
  132. package/esm/Options/Classes/Particles/Number/ParticlesDensity.js +3 -0
  133. package/esm/Options/Classes/Particles/Number/ParticlesNumber.js +3 -0
  134. package/esm/Options/Classes/Particles/Number/ParticlesNumberLimit.js +2 -0
  135. package/esm/Options/Classes/Particles/Opacity/Opacity.js +1 -0
  136. package/esm/Options/Classes/Particles/Opacity/OpacityAnimation.js +1 -0
  137. package/esm/Options/Classes/Particles/ParticlesOptions.js +25 -5
  138. package/esm/Options/Classes/Particles/Shape/Shape.js +3 -4
  139. package/esm/Options/Classes/Particles/Size/Size.js +1 -0
  140. package/esm/Options/Classes/Particles/Size/SizeAnimation.js +1 -0
  141. package/esm/Options/Classes/Particles/Stroke.js +3 -0
  142. package/esm/Options/Classes/Particles/ZIndex/ZIndex.js +3 -0
  143. package/esm/Options/Classes/ResizeEvent.js +2 -0
  144. package/esm/Options/Classes/ValueWithRandom.js +3 -4
  145. package/esm/Utils/CanvasUtils.js +43 -62
  146. package/esm/Utils/ColorUtils.js +30 -19
  147. package/esm/Utils/EventDispatcher.js +1 -0
  148. package/esm/Utils/MathUtils.js +12 -7
  149. package/esm/Utils/Utils.js +109 -31
  150. package/esm/exports.js +1 -2
  151. package/package.json +1 -1
  152. package/report.html +3 -3
  153. package/scripts/install.js +4 -20
  154. package/tsparticles.engine.js +93 -91
  155. package/tsparticles.engine.min.js +2 -2
  156. package/types/Core/Canvas.d.ts +17 -4
  157. package/types/Core/Container.d.ts +3 -7
  158. package/types/Core/Engine.d.ts +13 -20
  159. package/types/Core/Interfaces/IColorManager.d.ts +0 -1
  160. package/types/Core/Interfaces/IContainerPlugin.d.ts +6 -1
  161. package/types/Core/Interfaces/IPalette.d.ts +7 -0
  162. package/types/Core/Interfaces/IParticleOpacityData.d.ts +1 -0
  163. package/types/Core/Interfaces/IParticleValueAnimation.d.ts +3 -3
  164. package/types/Core/Interfaces/IShapeDrawData.d.ts +8 -0
  165. package/types/Core/Interfaces/IShapeDrawer.d.ts +0 -1
  166. package/types/Core/Interfaces/IShapeValues.d.ts +0 -1
  167. package/types/Core/Particle.d.ts +4 -7
  168. package/types/Core/Particles.d.ts +15 -7
  169. package/types/Core/Utils/Constants.d.ts +2 -2
  170. package/types/Core/Utils/Ranges.d.ts +4 -1
  171. package/types/Core/Utils/SpatialHashGrid.d.ts +25 -0
  172. package/types/Core/Utils/Vectors.d.ts +8 -10
  173. package/types/Enums/Types/EasingType.d.ts +20 -5
  174. package/types/Options/Classes/ColorAnimation.d.ts +3 -1
  175. package/types/Options/Classes/HslAnimation.d.ts +3 -4
  176. package/types/Options/Classes/Options.d.ts +2 -0
  177. package/types/Options/Classes/Particles/Effect/Effect.d.ts +0 -1
  178. package/types/Options/Classes/Particles/Fill.d.ts +12 -0
  179. package/types/Options/Classes/Particles/Move/Move.d.ts +0 -2
  180. package/types/Options/Classes/Particles/ParticlesOptions.d.ts +2 -2
  181. package/types/Options/Classes/Particles/Shape/Shape.d.ts +0 -1
  182. package/types/Options/Classes/ValueWithRandom.d.ts +0 -1
  183. package/types/Options/Interfaces/IColorAnimation.d.ts +2 -0
  184. package/types/Options/Interfaces/IOptions.d.ts +1 -0
  185. package/types/Options/Interfaces/Particles/Effect/IEffect.d.ts +0 -1
  186. package/types/Options/Interfaces/Particles/IFill.d.ts +9 -0
  187. package/types/Options/Interfaces/Particles/IParticlesOptions.d.ts +2 -2
  188. package/types/Options/Interfaces/Particles/IStroke.d.ts +2 -2
  189. package/types/Options/Interfaces/Particles/Move/IMove.d.ts +0 -2
  190. package/types/Options/Interfaces/Particles/Shape/IShape.d.ts +0 -1
  191. package/types/Types/EngineInitializers.d.ts +6 -3
  192. package/types/Utils/CanvasUtils.d.ts +6 -14
  193. package/types/Utils/ColorUtils.d.ts +3 -2
  194. package/types/Utils/MathUtils.d.ts +2 -0
  195. package/types/Utils/Utils.d.ts +8 -1
  196. package/types/export-types.d.ts +3 -5
  197. package/types/exports.d.ts +1 -2
  198. package/umd/Core/Canvas.js +248 -141
  199. package/umd/Core/Container.js +80 -74
  200. package/umd/Core/Engine.js +43 -66
  201. package/umd/Core/Particle.js +203 -174
  202. package/umd/Core/Particles.js +187 -138
  203. package/umd/Core/Retina.js +5 -0
  204. package/umd/Core/Utils/Constants.js +3 -3
  205. package/umd/Core/Utils/EventListeners.js +67 -63
  206. package/umd/Core/Utils/Ranges.js +28 -9
  207. package/umd/Core/Utils/SpatialHashGrid.js +116 -0
  208. package/umd/Core/Utils/Vectors.js +17 -18
  209. package/umd/Enums/Types/EasingType.js +18 -3
  210. package/umd/Options/Classes/AnimatableColor.js +1 -0
  211. package/umd/Options/Classes/AnimationOptions.js +8 -0
  212. package/umd/Options/Classes/Background/Background.js +6 -0
  213. package/umd/Options/Classes/ColorAnimation.js +12 -1
  214. package/umd/Options/Classes/FullScreen/FullScreen.js +2 -0
  215. package/umd/Options/Classes/HslAnimation.js +5 -6
  216. package/umd/Options/Classes/Options.js +63 -4
  217. package/umd/Options/Classes/OptionsColor.js +1 -0
  218. package/umd/Options/Classes/Particles/Bounce/ParticlesBounce.js +2 -0
  219. package/umd/Options/Classes/Particles/Effect/Effect.js +3 -4
  220. package/umd/Options/Classes/Particles/Fill.js +42 -0
  221. package/umd/Options/Classes/Particles/Move/Move.js +18 -4
  222. package/umd/Options/Classes/Particles/Move/MoveAngle.js +2 -0
  223. package/umd/Options/Classes/Particles/Move/MoveCenter.js +4 -0
  224. package/umd/Options/Classes/Particles/Move/MoveGravity.js +4 -0
  225. package/umd/Options/Classes/Particles/Move/OutModes.js +5 -0
  226. package/umd/Options/Classes/Particles/Move/Path/MovePath.js +5 -0
  227. package/umd/Options/Classes/Particles/Move/Spin.js +3 -0
  228. package/umd/Options/Classes/Particles/Number/ParticlesDensity.js +3 -0
  229. package/umd/Options/Classes/Particles/Number/ParticlesNumber.js +3 -0
  230. package/umd/Options/Classes/Particles/Number/ParticlesNumberLimit.js +2 -0
  231. package/umd/Options/Classes/Particles/Opacity/Opacity.js +1 -0
  232. package/umd/Options/Classes/Particles/Opacity/OpacityAnimation.js +1 -0
  233. package/umd/Options/Classes/Particles/ParticlesOptions.js +26 -6
  234. package/umd/Options/Classes/Particles/Shape/Shape.js +3 -4
  235. package/umd/Options/Classes/Particles/Size/Size.js +1 -0
  236. package/umd/Options/Classes/Particles/Size/SizeAnimation.js +1 -0
  237. package/umd/Options/Classes/Particles/Stroke.js +3 -0
  238. package/umd/Options/Classes/Particles/ZIndex/ZIndex.js +3 -0
  239. package/umd/Options/Classes/ResizeEvent.js +2 -0
  240. package/umd/Options/Classes/ValueWithRandom.js +3 -4
  241. package/umd/Utils/CanvasUtils.js +43 -66
  242. package/umd/Utils/ColorUtils.js +30 -18
  243. package/umd/Utils/EventDispatcher.js +1 -0
  244. package/umd/Utils/MathUtils.js +14 -7
  245. package/umd/Utils/Utils.js +111 -32
  246. package/umd/exports.js +2 -3
  247. package/794.min.js +0 -2
  248. package/794.min.js.LICENSE.txt +0 -1
  249. package/browser/Core/Utils/Point.js +0 -6
  250. package/browser/Core/Utils/QuadTree.js +0 -59
  251. package/browser/Options/Classes/Particles/Move/MoveAttract.js +0 -33
  252. package/cjs/Core/Utils/Point.js +0 -6
  253. package/cjs/Core/Utils/QuadTree.js +0 -59
  254. package/cjs/Options/Classes/Particles/Move/MoveAttract.js +0 -33
  255. package/esm/Core/Interfaces/IMovePathGenerator.js +0 -1
  256. package/esm/Core/Interfaces/IParticleMover.js +0 -1
  257. package/esm/Core/Utils/Point.js +0 -6
  258. package/esm/Core/Utils/QuadTree.js +0 -59
  259. package/esm/Options/Classes/Particles/Move/MoveAttract.js +0 -33
  260. package/esm/Options/Interfaces/Particles/Move/IMoveAttract.js +0 -1
  261. package/tsparticles.engine.min.js.LICENSE.txt +0 -1
  262. package/types/Core/Interfaces/IMovePathGenerator.d.ts +0 -10
  263. package/types/Core/Interfaces/IParticleMover.d.ts +0 -7
  264. package/types/Core/Utils/Point.d.ts +0 -7
  265. package/types/Core/Utils/QuadTree.d.ts +0 -18
  266. package/types/Options/Classes/Particles/Move/MoveAttract.d.ts +0 -12
  267. package/types/Options/Interfaces/Particles/Move/IMoveAttract.d.ts +0 -7
  268. package/umd/Core/Utils/Point.js +0 -20
  269. package/umd/Core/Utils/QuadTree.js +0 -73
  270. package/umd/Options/Classes/Particles/Move/MoveAttract.js +0 -47
  271. package/umd/Options/Interfaces/Particles/Move/IMoveAttract.js +0 -12
  272. /package/browser/Core/Interfaces/{IMovePathGenerator.js → IPalette.js} +0 -0
  273. /package/browser/{Core/Interfaces/IParticleMover.js → Options/Interfaces/Particles/IFill.js} +0 -0
  274. /package/{browser/Options/Interfaces/Particles/Move/IMoveAttract.js → cjs/Core/Interfaces/IPalette.js} +0 -0
  275. /package/cjs/{Core/Interfaces/IMovePathGenerator.js → Options/Interfaces/Particles/IFill.js} +0 -0
  276. /package/{cjs/Core/Interfaces/IParticleMover.js → esm/Core/Interfaces/IPalette.js} +0 -0
  277. /package/{cjs/Options/Interfaces/Particles/Move/IMoveAttract.js → esm/Options/Interfaces/Particles/IFill.js} +0 -0
  278. /package/umd/Core/Interfaces/{IMovePathGenerator.js → IPalette.js} +0 -0
  279. /package/umd/{Core/Interfaces/IParticleMover.js → Options/Interfaces/Particles/IFill.js} +0 -0
@@ -0,0 +1,102 @@
1
+ import { Circle, Rectangle } from "./Ranges.js";
2
+ export class SpatialHashGrid {
3
+ _cellSize;
4
+ _cells = new Map();
5
+ _circlePool = [];
6
+ _circlePoolIdx;
7
+ _pendingCellSize;
8
+ _rectanglePool = [];
9
+ _rectanglePoolIdx;
10
+ constructor(cellSize) {
11
+ this._cellSize = cellSize;
12
+ this._circlePoolIdx = 0;
13
+ this._rectanglePoolIdx = 0;
14
+ }
15
+ clear() {
16
+ this._cells.clear();
17
+ const pendingCellSize = this._pendingCellSize;
18
+ if (pendingCellSize) {
19
+ this._cellSize = pendingCellSize;
20
+ }
21
+ this._pendingCellSize = undefined;
22
+ }
23
+ insert(particle) {
24
+ const { x, y } = particle.getPosition(), key = this._cellKeyFromCoords(x, y);
25
+ if (!this._cells.has(key)) {
26
+ this._cells.set(key, []);
27
+ }
28
+ this._cells.get(key)?.push(particle);
29
+ }
30
+ query(range, check, out = []) {
31
+ const bounds = this._getRangeBounds(range);
32
+ if (!bounds) {
33
+ return out;
34
+ }
35
+ const minCellX = Math.floor(bounds.minX / this._cellSize), maxCellX = Math.floor(bounds.maxX / this._cellSize), minCellY = Math.floor(bounds.minY / this._cellSize), maxCellY = Math.floor(bounds.maxY / this._cellSize);
36
+ for (let cx = minCellX; cx <= maxCellX; cx++) {
37
+ for (let cy = minCellY; cy <= maxCellY; cy++) {
38
+ const key = `${cx}_${cy}`, cellParticles = this._cells.get(key);
39
+ if (!cellParticles) {
40
+ continue;
41
+ }
42
+ for (const p of cellParticles) {
43
+ if (check && !check(p)) {
44
+ continue;
45
+ }
46
+ if (range.contains(p.getPosition())) {
47
+ out.push(p);
48
+ }
49
+ }
50
+ }
51
+ }
52
+ return out;
53
+ }
54
+ queryCircle(position, radius, check, out = []) {
55
+ const circle = this._acquireCircle(position.x, position.y, radius), result = this.query(circle, check, out);
56
+ this._releaseShapes();
57
+ return result;
58
+ }
59
+ queryRectangle(position, size, check, out = []) {
60
+ const rect = this._acquireRectangle(position.x, position.y, size.width, size.height), result = this.query(rect, check, out);
61
+ this._releaseShapes();
62
+ return result;
63
+ }
64
+ setCellSize(cellSize) {
65
+ this._pendingCellSize = cellSize;
66
+ }
67
+ _acquireCircle(x, y, r) {
68
+ return (this._circlePool[this._circlePoolIdx++] ??= new Circle(x, y, r)).reset(x, y, r);
69
+ }
70
+ _acquireRectangle(x, y, w, h) {
71
+ return (this._rectanglePool[this._rectanglePoolIdx++] ??= new Rectangle(x, y, w, h)).reset(x, y, w, h);
72
+ }
73
+ _cellKeyFromCoords(x, y) {
74
+ const cellX = Math.floor(x / this._cellSize), cellY = Math.floor(y / this._cellSize);
75
+ return `${cellX}_${cellY}`;
76
+ }
77
+ _getRangeBounds(range) {
78
+ if (range instanceof Circle) {
79
+ const r = range.radius, { x, y } = range.position;
80
+ return {
81
+ minX: x - r,
82
+ maxX: x + r,
83
+ minY: y - r,
84
+ maxY: y + r,
85
+ };
86
+ }
87
+ if (range instanceof Rectangle) {
88
+ const { x, y } = range.position, { width, height } = range.size;
89
+ return {
90
+ minX: x,
91
+ maxX: x + width,
92
+ minY: y,
93
+ maxY: y + height,
94
+ };
95
+ }
96
+ return null;
97
+ }
98
+ _releaseShapes() {
99
+ this._circlePoolIdx = 0;
100
+ this._rectanglePoolIdx = 0;
101
+ }
102
+ }
@@ -1,10 +1,12 @@
1
1
  import { inverseFactorNumerator, none, originPoint, squareExp } from "./Constants.js";
2
+ function getZ(source) {
3
+ return "z" in source ? source.z : originPoint.z;
4
+ }
2
5
  export class Vector3d {
6
+ x;
7
+ y;
8
+ z;
3
9
  constructor(x = originPoint.x, y = originPoint.y, z = originPoint.z) {
4
- this._updateFromAngle = (angle, length) => {
5
- this.x = Math.cos(angle) * length;
6
- this.y = Math.sin(angle) * length;
7
- };
8
10
  this.x = x;
9
11
  this.y = y;
10
12
  this.z = z;
@@ -25,31 +27,25 @@ export class Vector3d {
25
27
  this._updateFromAngle(this.angle, length);
26
28
  }
27
29
  static clone(source) {
28
- return Vector3d.create(source.x, source.y, source.z);
30
+ return Vector3d.create(source.x, source.y, getZ(source));
29
31
  }
30
32
  static create(x, y, z) {
31
33
  if (typeof x === "number") {
32
34
  return new Vector3d(x, y ?? originPoint.y, z ?? originPoint.z);
33
35
  }
34
- return new Vector3d(x.x, x.y, Object.hasOwn(x, "z") ? x.z : originPoint.z);
36
+ return new Vector3d(x.x, x.y, getZ(x));
35
37
  }
36
38
  add(v) {
37
- return Vector3d.create(this.x + v.x, this.y + v.y, this.z + v.z);
39
+ return Vector3d.create(this.x + v.x, this.y + v.y, this.z + getZ(v));
38
40
  }
39
41
  addTo(v) {
40
42
  this.x += v.x;
41
43
  this.y += v.y;
42
- this.z += v.z;
44
+ this.z += getZ(v);
43
45
  }
44
46
  copy() {
45
47
  return Vector3d.clone(this);
46
48
  }
47
- distanceTo(v) {
48
- return this.sub(v).length;
49
- }
50
- distanceToSq(v) {
51
- return this.sub(v).getLengthSq();
52
- }
53
49
  div(n) {
54
50
  return Vector3d.create(this.x / n, this.y / n, this.z / n);
55
51
  }
@@ -81,16 +77,19 @@ export class Vector3d {
81
77
  setTo(c) {
82
78
  this.x = c.x;
83
79
  this.y = c.y;
84
- const v3d = c;
85
- this.z = v3d.z ? v3d.z : originPoint.z;
80
+ this.z = getZ(c);
86
81
  }
87
82
  sub(v) {
88
- return Vector3d.create(this.x - v.x, this.y - v.y, this.z - v.z);
83
+ return Vector3d.create(this.x - v.x, this.y - v.y, this.z - getZ(v));
89
84
  }
90
85
  subFrom(v) {
91
86
  this.x -= v.x;
92
87
  this.y -= v.y;
93
- this.z -= v.z;
88
+ this.z -= getZ(v);
89
+ }
90
+ _updateFromAngle(angle, length) {
91
+ this.x = Math.cos(angle) * length;
92
+ this.y = Math.sin(angle) * length;
94
93
  }
95
94
  }
96
95
  export class Vector extends Vector3d {
@@ -1,30 +1,45 @@
1
1
  export var EasingType;
2
2
  (function (EasingType) {
3
3
  EasingType["easeInBack"] = "ease-in-back";
4
+ EasingType["easeInBounce"] = "ease-in-bounce";
4
5
  EasingType["easeInCirc"] = "ease-in-circ";
5
6
  EasingType["easeInCubic"] = "ease-in-cubic";
7
+ EasingType["easeInElastic"] = "ease-in-elastic";
8
+ EasingType["easeInExpo"] = "ease-in-expo";
9
+ EasingType["easeInGaussian"] = "ease-in-gaussian";
6
10
  EasingType["easeInLinear"] = "ease-in-linear";
7
11
  EasingType["easeInQuad"] = "ease-in-quad";
8
12
  EasingType["easeInQuart"] = "ease-in-quart";
9
13
  EasingType["easeInQuint"] = "ease-in-quint";
10
- EasingType["easeInExpo"] = "ease-in-expo";
14
+ EasingType["easeInSigmoid"] = "ease-in-sigmoid";
11
15
  EasingType["easeInSine"] = "ease-in-sine";
16
+ EasingType["easeInSmoothstep"] = "ease-in-smoothstep";
12
17
  EasingType["easeOutBack"] = "ease-out-back";
18
+ EasingType["easeOutBounce"] = "ease-out-bounce";
13
19
  EasingType["easeOutCirc"] = "ease-out-circ";
14
20
  EasingType["easeOutCubic"] = "ease-out-cubic";
21
+ EasingType["easeOutElastic"] = "ease-out-elastic";
22
+ EasingType["easeOutExpo"] = "ease-out-expo";
23
+ EasingType["easeOutGaussian"] = "ease-out-gaussian";
15
24
  EasingType["easeOutLinear"] = "ease-out-linear";
16
25
  EasingType["easeOutQuad"] = "ease-out-quad";
17
26
  EasingType["easeOutQuart"] = "ease-out-quart";
18
27
  EasingType["easeOutQuint"] = "ease-out-quint";
19
- EasingType["easeOutExpo"] = "ease-out-expo";
28
+ EasingType["easeOutSigmoid"] = "ease-out-sigmoid";
20
29
  EasingType["easeOutSine"] = "ease-out-sine";
30
+ EasingType["easeOutSmoothstep"] = "ease-out-smoothstep";
21
31
  EasingType["easeInOutBack"] = "ease-in-out-back";
32
+ EasingType["easeInOutBounce"] = "ease-in-out-bounce";
22
33
  EasingType["easeInOutCirc"] = "ease-in-out-circ";
23
34
  EasingType["easeInOutCubic"] = "ease-in-out-cubic";
35
+ EasingType["easeInOutElastic"] = "ease-in-out-elastic";
36
+ EasingType["easeInOutExpo"] = "ease-in-out-expo";
37
+ EasingType["easeInOutGaussian"] = "ease-in-out-gaussian";
24
38
  EasingType["easeInOutLinear"] = "ease-in-out-linear";
25
39
  EasingType["easeInOutQuad"] = "ease-in-out-quad";
26
40
  EasingType["easeInOutQuart"] = "ease-in-out-quart";
27
41
  EasingType["easeInOutQuint"] = "ease-in-out-quint";
28
- EasingType["easeInOutExpo"] = "ease-in-out-expo";
42
+ EasingType["easeInOutSigmoid"] = "ease-in-out-sigmoid";
29
43
  EasingType["easeInOutSine"] = "ease-in-out-sine";
44
+ EasingType["easeInOutSmoothstep"] = "ease-in-out-smoothstep";
30
45
  })(EasingType || (EasingType = {}));
@@ -2,6 +2,7 @@ import { isArray, isNull, isString } from "../../Utils/TypeUtils.js";
2
2
  import { HslAnimation } from "./HslAnimation.js";
3
3
  import { OptionsColor } from "./OptionsColor.js";
4
4
  export class AnimatableColor extends OptionsColor {
5
+ animation;
5
6
  constructor() {
6
7
  super();
7
8
  this.animation = new HslAnimation();
@@ -3,6 +3,12 @@ import { StartValueType } from "../../Enums/Types/StartValueType.js";
3
3
  import { isNull } from "../../Utils/TypeUtils.js";
4
4
  import { setRangeValue } from "../../Utils/MathUtils.js";
5
5
  export class AnimationOptions {
6
+ count;
7
+ decay;
8
+ delay;
9
+ enable;
10
+ speed;
11
+ sync;
6
12
  constructor() {
7
13
  this.count = 0;
8
14
  this.enable = false;
@@ -36,6 +42,8 @@ export class AnimationOptions {
36
42
  }
37
43
  }
38
44
  export class RangedAnimationOptions extends AnimationOptions {
45
+ mode;
46
+ startValue;
39
47
  constructor() {
40
48
  super();
41
49
  this.mode = AnimationMode.auto;
@@ -1,6 +1,12 @@
1
1
  import { OptionsColor } from "../OptionsColor.js";
2
2
  import { isNull } from "../../../Utils/TypeUtils.js";
3
3
  export class Background {
4
+ color;
5
+ image;
6
+ opacity;
7
+ position;
8
+ repeat;
9
+ size;
4
10
  constructor() {
5
11
  this.color = new OptionsColor();
6
12
  this.color.value = "";
@@ -2,8 +2,13 @@ import { AnimationOptions } from "./AnimationOptions.js";
2
2
  import { isNull } from "../../Utils/TypeUtils.js";
3
3
  import { setRangeValue } from "../../Utils/MathUtils.js";
4
4
  export class ColorAnimation extends AnimationOptions {
5
- constructor() {
5
+ max;
6
+ min;
7
+ offset;
8
+ constructor(min, max) {
6
9
  super();
10
+ this.min = min;
11
+ this.max = max;
7
12
  this.offset = 0;
8
13
  this.sync = true;
9
14
  }
@@ -12,6 +17,12 @@ export class ColorAnimation extends AnimationOptions {
12
17
  if (isNull(data)) {
13
18
  return;
14
19
  }
20
+ if (data.max !== undefined) {
21
+ this.max = data.max;
22
+ }
23
+ if (data.min !== undefined) {
24
+ this.min = data.min;
25
+ }
15
26
  if (data.offset !== undefined) {
16
27
  this.offset = setRangeValue(data.offset);
17
28
  }
@@ -1,5 +1,7 @@
1
1
  import { isNull } from "../../../Utils/TypeUtils.js";
2
2
  export class FullScreen {
3
+ enable;
4
+ zIndex;
3
5
  constructor() {
4
6
  this.enable = true;
5
7
  this.zIndex = 0;
@@ -1,11 +1,10 @@
1
+ import { hMax, hMin, lMax, lMin, sMax, sMin } from "../../Core/Utils/Constants.js";
1
2
  import { ColorAnimation } from "./ColorAnimation.js";
2
3
  import { isNull } from "../../Utils/TypeUtils.js";
3
4
  export class HslAnimation {
4
- constructor() {
5
- this.h = new ColorAnimation();
6
- this.s = new ColorAnimation();
7
- this.l = new ColorAnimation();
8
- }
5
+ h = new ColorAnimation(hMin, hMax);
6
+ l = new ColorAnimation(lMin, lMax);
7
+ s = new ColorAnimation(sMin, sMax);
9
8
  load(data) {
10
9
  if (isNull(data)) {
11
10
  return;
@@ -6,10 +6,30 @@ import { ResizeEvent } from "./ResizeEvent.js";
6
6
  import { loadParticlesOptions } from "../../Utils/OptionsUtils.js";
7
7
  import { setRangeValue } from "../../Utils/MathUtils.js";
8
8
  export class Options {
9
+ autoPlay;
10
+ background;
11
+ clear;
12
+ defaultThemes;
13
+ delay;
14
+ detectRetina;
15
+ duration;
16
+ fpsLimit;
17
+ fullScreen;
18
+ hdr;
19
+ key;
20
+ name;
21
+ palette;
22
+ particles;
23
+ pauseOnBlur;
24
+ pauseOnOutsideViewport;
25
+ preset;
26
+ resize;
27
+ smooth;
28
+ style;
29
+ zLayers;
30
+ _container;
31
+ _engine;
9
32
  constructor(engine, container) {
10
- this._importPreset = preset => {
11
- this.load(this._engine.getPreset(preset));
12
- };
13
33
  this._engine = engine;
14
34
  this._container = container;
15
35
  this.autoPlay = true;
@@ -35,10 +55,15 @@ export class Options {
35
55
  return;
36
56
  }
37
57
  if (data.preset !== undefined) {
38
- executeOnSingleOrMultiple(data.preset, preset => {
58
+ this.preset = data.preset;
59
+ executeOnSingleOrMultiple(this.preset, preset => {
39
60
  this._importPreset(preset);
40
61
  });
41
62
  }
63
+ if (data.palette !== undefined) {
64
+ this.palette = data.palette;
65
+ this._importPalette(this.palette);
66
+ }
42
67
  if (data.autoPlay !== undefined) {
43
68
  this.autoPlay = data.autoPlay;
44
69
  }
@@ -95,4 +120,38 @@ export class Options {
95
120
  plugin.loadOptions(this._container, this, data);
96
121
  });
97
122
  }
123
+ _importPalette = palette => {
124
+ const paletteData = this._engine.getPalette(palette);
125
+ if (!paletteData) {
126
+ return;
127
+ }
128
+ this.load({
129
+ background: {
130
+ color: paletteData.background,
131
+ },
132
+ blend: {
133
+ enable: true,
134
+ mode: paletteData.blendMode,
135
+ },
136
+ particles: {
137
+ fill: {
138
+ color: paletteData.fill
139
+ ? {
140
+ value: paletteData.colors,
141
+ }
142
+ : undefined,
143
+ enable: paletteData.fill,
144
+ },
145
+ stroke: !paletteData.fill
146
+ ? paletteData.colors.map(color => ({
147
+ color: { value: color },
148
+ width: 1,
149
+ }))
150
+ : undefined,
151
+ },
152
+ });
153
+ };
154
+ _importPreset = preset => {
155
+ this.load(this._engine.getPreset(preset));
156
+ };
98
157
  }
@@ -1,5 +1,6 @@
1
1
  import { isArray, isNull, isString } from "../../Utils/TypeUtils.js";
2
2
  export class OptionsColor {
3
+ value;
3
4
  constructor() {
4
5
  this.value = "";
5
6
  }
@@ -1,6 +1,8 @@
1
1
  import { ParticlesBounceFactor } from "./ParticlesBounceFactor.js";
2
2
  import { isNull } from "../../../../Utils/TypeUtils.js";
3
3
  export class ParticlesBounce {
4
+ horizontal;
5
+ vertical;
4
6
  constructor() {
5
7
  this.horizontal = new ParticlesBounceFactor();
6
8
  this.vertical = new ParticlesBounceFactor();
@@ -1,9 +1,11 @@
1
1
  import { deepExtend } from "../../../../Utils/Utils.js";
2
2
  import { isNull } from "../../../../Utils/TypeUtils.js";
3
3
  export class Effect {
4
+ close;
5
+ options;
6
+ type;
4
7
  constructor() {
5
8
  this.close = true;
6
- this.fill = true;
7
9
  this.options = {};
8
10
  this.type = [];
9
11
  }
@@ -23,9 +25,6 @@ export class Effect {
23
25
  if (data.close !== undefined) {
24
26
  this.close = data.close;
25
27
  }
26
- if (data.fill !== undefined) {
27
- this.fill = data.fill;
28
- }
29
28
  if (data.type !== undefined) {
30
29
  this.type = data.type;
31
30
  }
@@ -0,0 +1,28 @@
1
+ import { AnimatableColor } from "../AnimatableColor.js";
2
+ import { isNull } from "../../../Utils/TypeUtils.js";
3
+ import { setRangeValue } from "../../../Utils/MathUtils.js";
4
+ export class Fill {
5
+ color;
6
+ enable;
7
+ opacity;
8
+ constructor() {
9
+ this.enable = true;
10
+ this.color = new AnimatableColor();
11
+ this.color.value = "#fff";
12
+ this.opacity = 1;
13
+ }
14
+ load(data) {
15
+ if (isNull(data)) {
16
+ return;
17
+ }
18
+ if (data.color !== undefined) {
19
+ this.color = AnimatableColor.create(this.color, data.color);
20
+ }
21
+ if (data.enable !== undefined) {
22
+ this.enable = data.enable;
23
+ }
24
+ if (data.opacity !== undefined) {
25
+ this.opacity = setRangeValue(data.opacity);
26
+ }
27
+ }
28
+ }
@@ -1,7 +1,6 @@
1
1
  import { MoveDirection } from "../../../../Enums/Directions/MoveDirection.js";
2
2
  import { isNull, isNumber, isObject } from "../../../../Utils/TypeUtils.js";
3
3
  import { MoveAngle } from "./MoveAngle.js";
4
- import { MoveAttract } from "./MoveAttract.js";
5
4
  import { MoveCenter } from "./MoveCenter.js";
6
5
  import { MoveGravity } from "./MoveGravity.js";
7
6
  import { MovePath } from "./Path/MovePath.js";
@@ -9,9 +8,25 @@ import { OutModes } from "./OutModes.js";
9
8
  import { Spin } from "./Spin.js";
10
9
  import { setRangeValue } from "../../../../Utils/MathUtils.js";
11
10
  export class Move {
11
+ angle;
12
+ center;
13
+ decay;
14
+ direction;
15
+ distance;
16
+ drift;
17
+ enable;
18
+ gravity;
19
+ outModes;
20
+ path;
21
+ random;
22
+ size;
23
+ speed;
24
+ spin;
25
+ straight;
26
+ vibrate;
27
+ warp;
12
28
  constructor() {
13
29
  this.angle = new MoveAngle();
14
- this.attract = new MoveAttract();
15
30
  this.center = new MoveCenter();
16
31
  this.decay = 0;
17
32
  this.distance = {};
@@ -34,7 +49,6 @@ export class Move {
34
49
  return;
35
50
  }
36
51
  this.angle.load(isNumber(data.angle) ? { value: data.angle } : data.angle);
37
- this.attract.load(data.attract);
38
52
  this.center.load(data.center);
39
53
  if (data.decay !== undefined) {
40
54
  this.decay = setRangeValue(data.decay);
@@ -1,6 +1,8 @@
1
1
  import { isNull } from "../../../../Utils/TypeUtils.js";
2
2
  import { setRangeValue } from "../../../../Utils/MathUtils.js";
3
3
  export class MoveAngle {
4
+ offset;
5
+ value;
4
6
  constructor() {
5
7
  this.offset = 0;
6
8
  this.value = 90;
@@ -1,6 +1,10 @@
1
1
  import { PixelMode } from "../../../../Enums/Modes/PixelMode.js";
2
2
  import { isNull } from "../../../../Utils/TypeUtils.js";
3
3
  export class MoveCenter {
4
+ mode;
5
+ radius;
6
+ x;
7
+ y;
4
8
  constructor() {
5
9
  this.x = 50;
6
10
  this.y = 50;
@@ -1,6 +1,10 @@
1
1
  import { isNull } from "../../../../Utils/TypeUtils.js";
2
2
  import { setRangeValue } from "../../../../Utils/MathUtils.js";
3
3
  export class MoveGravity {
4
+ acceleration;
5
+ enable;
6
+ inverse;
7
+ maxSpeed;
4
8
  constructor() {
5
9
  this.acceleration = 9.81;
6
10
  this.enable = false;
@@ -1,6 +1,11 @@
1
1
  import { OutMode } from "../../../../Enums/Modes/OutMode.js";
2
2
  import { isNull } from "../../../../Utils/TypeUtils.js";
3
3
  export class OutModes {
4
+ bottom;
5
+ default;
6
+ left;
7
+ right;
8
+ top;
4
9
  constructor() {
5
10
  this.default = OutMode.out;
6
11
  }
@@ -2,6 +2,11 @@ import { ValueWithRandom } from "../../../ValueWithRandom.js";
2
2
  import { deepExtend } from "../../../../../Utils/Utils.js";
3
3
  import { isNull } from "../../../../../Utils/TypeUtils.js";
4
4
  export class MovePath {
5
+ clamp;
6
+ delay;
7
+ enable;
8
+ generator;
9
+ options;
5
10
  constructor() {
6
11
  this.clamp = true;
7
12
  this.delay = new ValueWithRandom();
@@ -2,6 +2,9 @@ import { deepExtend } from "../../../../Utils/Utils.js";
2
2
  import { isNull } from "../../../../Utils/TypeUtils.js";
3
3
  import { setRangeValue } from "../../../../Utils/MathUtils.js";
4
4
  export class Spin {
5
+ acceleration;
6
+ enable;
7
+ position;
5
8
  constructor() {
6
9
  this.acceleration = 0;
7
10
  this.enable = false;
@@ -1,5 +1,8 @@
1
1
  import { isNull } from "../../../../Utils/TypeUtils.js";
2
2
  export class ParticlesDensity {
3
+ enable;
4
+ height;
5
+ width;
3
6
  constructor() {
4
7
  this.enable = false;
5
8
  this.width = 1920;
@@ -2,6 +2,9 @@ import { ParticlesDensity } from "./ParticlesDensity.js";
2
2
  import { ParticlesNumberLimit } from "./ParticlesNumberLimit.js";
3
3
  import { isNull } from "../../../../Utils/TypeUtils.js";
4
4
  export class ParticlesNumber {
5
+ density;
6
+ limit;
7
+ value;
5
8
  constructor() {
6
9
  this.density = new ParticlesDensity();
7
10
  this.limit = new ParticlesNumberLimit();
@@ -1,6 +1,8 @@
1
1
  import { LimitMode } from "../../../../Enums/Modes/LimitMode.js";
2
2
  import { isNull } from "../../../../Utils/TypeUtils.js";
3
3
  export class ParticlesNumberLimit {
4
+ mode;
5
+ value;
4
6
  constructor() {
5
7
  this.mode = LimitMode.delete;
6
8
  this.value = 0;
@@ -2,6 +2,7 @@ import { OpacityAnimation } from "./OpacityAnimation.js";
2
2
  import { RangedAnimationValueWithRandom } from "../../ValueWithRandom.js";
3
3
  import { isNull } from "../../../../Utils/TypeUtils.js";
4
4
  export class Opacity extends RangedAnimationValueWithRandom {
5
+ animation;
5
6
  constructor() {
6
7
  super();
7
8
  this.animation = new OpacityAnimation();
@@ -2,6 +2,7 @@ import { DestroyType } from "../../../../Enums/Types/DestroyType.js";
2
2
  import { RangedAnimationOptions } from "../../AnimationOptions.js";
3
3
  import { isNull } from "../../../../Utils/TypeUtils.js";
4
4
  export class OpacityAnimation extends RangedAnimationOptions {
5
+ destroy;
5
6
  constructor() {
6
7
  super();
7
8
  this.destroy = DestroyType.none;