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