@tsparticles/engine 4.0.0-beta.0 → 4.0.0-beta.10

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 (242) hide show
  1. package/67.min.js +1 -0
  2. package/README.md +53 -965
  3. package/browser/Core/CanvasManager.js +303 -0
  4. package/browser/Core/Container.js +61 -34
  5. package/browser/Core/Engine.js +26 -138
  6. package/browser/Core/Particle.js +29 -28
  7. package/{cjs/Core/Particles.js → browser/Core/ParticlesManager.js} +27 -57
  8. package/browser/Core/RenderManager.js +303 -0
  9. package/browser/Core/Retina.js +3 -8
  10. package/browser/Core/Utils/PluginManager.js +145 -0
  11. package/browser/Options/Classes/Options.js +8 -21
  12. package/browser/Options/Classes/Particles/Paint.js +20 -0
  13. package/browser/Options/Classes/Particles/ParticlesOptions.js +65 -27
  14. package/browser/Options/Interfaces/Particles/IPaint.js +1 -0
  15. package/browser/Types/CanvasContextType.js +1 -0
  16. package/browser/Utils/CanvasUtils.js +4 -4
  17. package/browser/Utils/ColorUtils.js +21 -21
  18. package/browser/Utils/LogUtils.js +1 -0
  19. package/browser/Utils/OptionsUtils.js +2 -2
  20. package/browser/Utils/Utils.js +16 -10
  21. package/browser/exports.js +1 -0
  22. package/cjs/Core/CanvasManager.js +303 -0
  23. package/cjs/Core/Container.js +61 -34
  24. package/cjs/Core/Engine.js +26 -138
  25. package/cjs/Core/Particle.js +29 -28
  26. package/{esm/Core/Particles.js → cjs/Core/ParticlesManager.js} +27 -57
  27. package/cjs/Core/RenderManager.js +303 -0
  28. package/cjs/Core/Retina.js +3 -8
  29. package/cjs/Core/Utils/PluginManager.js +145 -0
  30. package/cjs/Options/Classes/Options.js +8 -21
  31. package/cjs/Options/Classes/Particles/Paint.js +20 -0
  32. package/cjs/Options/Classes/Particles/ParticlesOptions.js +65 -27
  33. package/cjs/Options/Interfaces/Particles/IPaint.js +1 -0
  34. package/cjs/Types/CanvasContextType.js +1 -0
  35. package/cjs/Utils/CanvasUtils.js +4 -4
  36. package/cjs/Utils/ColorUtils.js +21 -21
  37. package/cjs/Utils/LogUtils.js +1 -0
  38. package/cjs/Utils/OptionsUtils.js +2 -2
  39. package/cjs/Utils/Utils.js +16 -10
  40. package/cjs/exports.js +1 -0
  41. package/dist_browser_Core_Container_js.js +24 -14
  42. package/esm/Core/CanvasManager.js +303 -0
  43. package/esm/Core/Container.js +61 -34
  44. package/esm/Core/Engine.js +26 -138
  45. package/esm/Core/Particle.js +29 -28
  46. package/{browser/Core/Particles.js → esm/Core/ParticlesManager.js} +27 -57
  47. package/esm/Core/RenderManager.js +303 -0
  48. package/esm/Core/Retina.js +3 -8
  49. package/esm/Core/Utils/PluginManager.js +145 -0
  50. package/esm/Options/Classes/Options.js +8 -21
  51. package/esm/Options/Classes/Particles/Paint.js +20 -0
  52. package/esm/Options/Classes/Particles/ParticlesOptions.js +65 -27
  53. package/esm/Options/Interfaces/Particles/IPaint.js +1 -0
  54. package/esm/Types/CanvasContextType.js +1 -0
  55. package/esm/Utils/CanvasUtils.js +4 -4
  56. package/esm/Utils/ColorUtils.js +21 -21
  57. package/esm/Utils/LogUtils.js +1 -0
  58. package/esm/Utils/OptionsUtils.js +2 -2
  59. package/esm/Utils/Utils.js +16 -10
  60. package/esm/exports.js +1 -0
  61. package/package.json +2 -3
  62. package/report.html +84 -29
  63. package/tsparticles.engine.js +31 -11
  64. package/tsparticles.engine.min.js +2 -2
  65. package/types/Core/CanvasManager.d.ts +39 -0
  66. package/types/Core/Container.d.ts +26 -7
  67. package/types/Core/Engine.d.ts +2 -54
  68. package/types/Core/Interfaces/IContainerPlugin.d.ts +8 -7
  69. package/types/Core/Interfaces/IDrawParticleParams.d.ts +2 -1
  70. package/types/Core/Interfaces/IPalette.d.ts +15 -2
  71. package/types/Core/Interfaces/IParticleRetinaProps.d.ts +4 -4
  72. package/types/Core/Interfaces/IParticleUpdater.d.ts +2 -1
  73. package/types/Core/Interfaces/IShapeDrawData.d.ts +2 -1
  74. package/types/Core/Particle.d.ts +4 -4
  75. package/types/Core/{Particles.d.ts → ParticlesManager.d.ts} +4 -11
  76. package/types/Core/{Canvas.d.ts → RenderManager.d.ts} +12 -33
  77. package/types/Core/Retina.d.ts +0 -2
  78. package/types/Core/Utils/PluginManager.d.ts +62 -0
  79. package/types/Options/Classes/Options.d.ts +3 -3
  80. package/types/Options/Classes/Particles/Paint.d.ts +10 -0
  81. package/types/Options/Classes/Particles/ParticlesOptions.d.ts +7 -7
  82. package/types/Options/Interfaces/Particles/IPaint.d.ts +6 -0
  83. package/types/Options/Interfaces/Particles/IParticlesOptions.d.ts +3 -4
  84. package/types/Types/CanvasContextType.d.ts +1 -0
  85. package/types/Utils/CanvasUtils.d.ts +8 -5
  86. package/types/Utils/ColorUtils.d.ts +8 -8
  87. package/types/Utils/LogUtils.d.ts +1 -0
  88. package/types/Utils/OptionsUtils.d.ts +2 -2
  89. package/types/export-types.d.ts +5 -2
  90. package/types/exports.d.ts +1 -0
  91. package/164.min.js +0 -1
  92. package/browser/Core/Canvas.js +0 -570
  93. package/cjs/Core/Canvas.js +0 -570
  94. package/esm/Core/Canvas.js +0 -570
  95. package/umd/Core/Canvas.js +0 -584
  96. package/umd/Core/Container.js +0 -356
  97. package/umd/Core/Engine.js +0 -295
  98. package/umd/Core/Interfaces/Colors.js +0 -12
  99. package/umd/Core/Interfaces/IBounds.js +0 -12
  100. package/umd/Core/Interfaces/IBubbleParticleData.js +0 -12
  101. package/umd/Core/Interfaces/ICircleBouncer.js +0 -12
  102. package/umd/Core/Interfaces/IColorManager.js +0 -12
  103. package/umd/Core/Interfaces/IContainerPlugin.js +0 -12
  104. package/umd/Core/Interfaces/ICoordinates.js +0 -12
  105. package/umd/Core/Interfaces/IDelta.js +0 -12
  106. package/umd/Core/Interfaces/IDimension.js +0 -12
  107. package/umd/Core/Interfaces/IDistance.js +0 -12
  108. package/umd/Core/Interfaces/IDrawParticleParams.js +0 -12
  109. package/umd/Core/Interfaces/IEffectDrawer.js +0 -12
  110. package/umd/Core/Interfaces/ILoadParams.js +0 -12
  111. package/umd/Core/Interfaces/IPalette.js +0 -12
  112. package/umd/Core/Interfaces/IParticleColorStyle.js +0 -12
  113. package/umd/Core/Interfaces/IParticleHslAnimation.js +0 -12
  114. package/umd/Core/Interfaces/IParticleLife.js +0 -12
  115. package/umd/Core/Interfaces/IParticleOpacityData.js +0 -12
  116. package/umd/Core/Interfaces/IParticleRetinaProps.js +0 -12
  117. package/umd/Core/Interfaces/IParticleRoll.js +0 -12
  118. package/umd/Core/Interfaces/IParticleRotateData.js +0 -12
  119. package/umd/Core/Interfaces/IParticleTransformValues.js +0 -12
  120. package/umd/Core/Interfaces/IParticleUpdater.js +0 -12
  121. package/umd/Core/Interfaces/IParticleValueAnimation.js +0 -12
  122. package/umd/Core/Interfaces/IPlugin.js +0 -12
  123. package/umd/Core/Interfaces/IPositionFromSizeParams.js +0 -12
  124. package/umd/Core/Interfaces/IRangeValue.js +0 -12
  125. package/umd/Core/Interfaces/IShapeDrawData.js +0 -12
  126. package/umd/Core/Interfaces/IShapeDrawer.js +0 -12
  127. package/umd/Core/Interfaces/IShapeValues.js +0 -12
  128. package/umd/Core/Interfaces/ISlowParticleData.js +0 -12
  129. package/umd/Core/Particle.js +0 -432
  130. package/umd/Core/Particles.js +0 -407
  131. package/umd/Core/Retina.js +0 -52
  132. package/umd/Core/Utils/Constants.js +0 -23
  133. package/umd/Core/Utils/EventListeners.js +0 -102
  134. package/umd/Core/Utils/Ranges.js +0 -91
  135. package/umd/Core/Utils/SpatialHashGrid.js +0 -116
  136. package/umd/Core/Utils/Vectors.js +0 -126
  137. package/umd/Enums/AnimationStatus.js +0 -18
  138. package/umd/Enums/Directions/MoveDirection.js +0 -27
  139. package/umd/Enums/Directions/OutModeDirection.js +0 -20
  140. package/umd/Enums/Directions/RotateDirection.js +0 -19
  141. package/umd/Enums/Modes/AnimationMode.js +0 -20
  142. package/umd/Enums/Modes/LimitMode.js +0 -18
  143. package/umd/Enums/Modes/OutMode.js +0 -21
  144. package/umd/Enums/Modes/PixelMode.js +0 -18
  145. package/umd/Enums/RangeType.js +0 -18
  146. package/umd/Enums/Types/AlterType.js +0 -18
  147. package/umd/Enums/Types/DestroyType.js +0 -19
  148. package/umd/Enums/Types/EasingType.js +0 -58
  149. package/umd/Enums/Types/EventType.js +0 -28
  150. package/umd/Enums/Types/GradientType.js +0 -19
  151. package/umd/Enums/Types/ParticleOutType.js +0 -19
  152. package/umd/Enums/Types/StartValueType.js +0 -19
  153. package/umd/Options/Classes/AnimatableColor.js +0 -52
  154. package/umd/Options/Classes/AnimationOptions.js +0 -79
  155. package/umd/Options/Classes/Background/Background.js +0 -56
  156. package/umd/Options/Classes/ColorAnimation.js +0 -44
  157. package/umd/Options/Classes/FullScreen/FullScreen.js +0 -34
  158. package/umd/Options/Classes/HslAnimation.js +0 -30
  159. package/umd/Options/Classes/Options.js +0 -171
  160. package/umd/Options/Classes/OptionsColor.js +0 -42
  161. package/umd/Options/Classes/Particles/Bounce/ParticlesBounce.js +0 -31
  162. package/umd/Options/Classes/Particles/Bounce/ParticlesBounceFactor.js +0 -21
  163. package/umd/Options/Classes/Particles/Effect/Effect.js +0 -46
  164. package/umd/Options/Classes/Particles/Fill.js +0 -42
  165. package/umd/Options/Classes/Particles/Move/Move.js +0 -120
  166. package/umd/Options/Classes/Particles/Move/MoveAngle.js +0 -35
  167. package/umd/Options/Classes/Particles/Move/MoveCenter.js +0 -45
  168. package/umd/Options/Classes/Particles/Move/MoveGravity.js +0 -45
  169. package/umd/Options/Classes/Particles/Move/OutModes.js +0 -38
  170. package/umd/Options/Classes/Particles/Move/Path/MovePath.js +0 -46
  171. package/umd/Options/Classes/Particles/Move/Spin.js +0 -40
  172. package/umd/Options/Classes/Particles/Number/ParticlesDensity.js +0 -41
  173. package/umd/Options/Classes/Particles/Number/ParticlesNumber.js +0 -37
  174. package/umd/Options/Classes/Particles/Number/ParticlesNumberLimit.js +0 -35
  175. package/umd/Options/Classes/Particles/Opacity/Opacity.js +0 -35
  176. package/umd/Options/Classes/Particles/Opacity/OpacityAnimation.js +0 -34
  177. package/umd/Options/Classes/Particles/ParticlesOptions.js +0 -116
  178. package/umd/Options/Classes/Particles/Shape/Shape.js +0 -46
  179. package/umd/Options/Classes/Particles/Size/Size.js +0 -35
  180. package/umd/Options/Classes/Particles/Size/SizeAnimation.js +0 -34
  181. package/umd/Options/Classes/Particles/Stroke.js +0 -39
  182. package/umd/Options/Classes/Particles/ZIndex/ZIndex.js +0 -42
  183. package/umd/Options/Classes/ResizeEvent.js +0 -34
  184. package/umd/Options/Classes/ValueWithRandom.js +0 -56
  185. package/umd/Options/Interfaces/Background/IBackground.js +0 -12
  186. package/umd/Options/Interfaces/FullScreen/IFullScreen.js +0 -12
  187. package/umd/Options/Interfaces/IAnimatable.js +0 -12
  188. package/umd/Options/Interfaces/IAnimatableColor.js +0 -12
  189. package/umd/Options/Interfaces/IAnimation.js +0 -12
  190. package/umd/Options/Interfaces/IColorAnimation.js +0 -12
  191. package/umd/Options/Interfaces/IHslAnimation.js +0 -12
  192. package/umd/Options/Interfaces/IOptionLoader.js +0 -12
  193. package/umd/Options/Interfaces/IOptions.js +0 -12
  194. package/umd/Options/Interfaces/IOptionsColor.js +0 -12
  195. package/umd/Options/Interfaces/IResizeEvent.js +0 -12
  196. package/umd/Options/Interfaces/IValueWithRandom.js +0 -12
  197. package/umd/Options/Interfaces/Particles/Bounce/IParticlesBounce.js +0 -12
  198. package/umd/Options/Interfaces/Particles/Effect/IEffect.js +0 -12
  199. package/umd/Options/Interfaces/Particles/IFill.js +0 -12
  200. package/umd/Options/Interfaces/Particles/IParticlesOptions.js +0 -12
  201. package/umd/Options/Interfaces/Particles/IStroke.js +0 -12
  202. package/umd/Options/Interfaces/Particles/Move/IMove.js +0 -12
  203. package/umd/Options/Interfaces/Particles/Move/IMoveAngle.js +0 -12
  204. package/umd/Options/Interfaces/Particles/Move/IMoveCenter.js +0 -12
  205. package/umd/Options/Interfaces/Particles/Move/IMoveGravity.js +0 -12
  206. package/umd/Options/Interfaces/Particles/Move/IOutModes.js +0 -12
  207. package/umd/Options/Interfaces/Particles/Move/ISpin.js +0 -12
  208. package/umd/Options/Interfaces/Particles/Move/Path/IMovePath.js +0 -12
  209. package/umd/Options/Interfaces/Particles/Number/IParticlesDensity.js +0 -12
  210. package/umd/Options/Interfaces/Particles/Number/IParticlesNumber.js +0 -12
  211. package/umd/Options/Interfaces/Particles/Number/IParticlesNumberLimit.js +0 -12
  212. package/umd/Options/Interfaces/Particles/Opacity/IOpacity.js +0 -12
  213. package/umd/Options/Interfaces/Particles/Opacity/IOpacityAnimation.js +0 -12
  214. package/umd/Options/Interfaces/Particles/Shape/IShape.js +0 -12
  215. package/umd/Options/Interfaces/Particles/Size/ISize.js +0 -12
  216. package/umd/Options/Interfaces/Particles/Size/ISizeAnimation.js +0 -12
  217. package/umd/Options/Interfaces/Particles/ZIndex/IZIndex.js +0 -12
  218. package/umd/Types/CustomEventArgs.js +0 -12
  219. package/umd/Types/CustomEventListener.js +0 -12
  220. package/umd/Types/EasingFunction.js +0 -12
  221. package/umd/Types/EngineInitializers.js +0 -12
  222. package/umd/Types/ExportResult.js +0 -12
  223. package/umd/Types/ISourceOptions.js +0 -12
  224. package/umd/Types/ParticlesGroups.js +0 -12
  225. package/umd/Types/PathOptions.js +0 -12
  226. package/umd/Types/RangeValue.js +0 -12
  227. package/umd/Types/RecursivePartial.js +0 -12
  228. package/umd/Types/ShapeData.js +0 -12
  229. package/umd/Types/SingleOrMultiple.js +0 -12
  230. package/umd/Utils/CanvasUtils.js +0 -145
  231. package/umd/Utils/ColorUtils.js +0 -395
  232. package/umd/Utils/EventDispatcher.js +0 -63
  233. package/umd/Utils/LogUtils.js +0 -36
  234. package/umd/Utils/MathUtils.js +0 -203
  235. package/umd/Utils/OptionsUtils.js +0 -25
  236. package/umd/Utils/TypeUtils.js +0 -40
  237. package/umd/Utils/Utils.js +0 -484
  238. package/umd/bundle.js +0 -32
  239. package/umd/export-types.js +0 -12
  240. package/umd/exports.js +0 -82
  241. package/umd/index.js +0 -32
  242. package/umd/initEngine.js +0 -17
@@ -1,50 +1,52 @@
1
1
  import { deepExtend, executeOnSingleOrMultiple } from "../../../Utils/Utils.js";
2
+ import { isArray, isNull } from "../../../Utils/TypeUtils.js";
2
3
  import { Effect } from "./Effect/Effect.js";
3
- import { Fill } from "./Fill.js";
4
4
  import { Move } from "./Move/Move.js";
5
5
  import { Opacity } from "./Opacity/Opacity.js";
6
+ import { Paint } from "./Paint.js";
6
7
  import { ParticlesBounce } from "./Bounce/ParticlesBounce.js";
7
8
  import { ParticlesNumber } from "./Number/ParticlesNumber.js";
8
9
  import { Shape } from "./Shape/Shape.js";
9
10
  import { Size } from "./Size/Size.js";
10
- import { Stroke } from "./Stroke.js";
11
11
  import { ZIndex } from "./ZIndex/ZIndex.js";
12
- import { isNull } from "../../../Utils/TypeUtils.js";
13
12
  export class ParticlesOptions {
14
13
  bounce;
15
14
  effect;
16
- fill;
17
15
  groups;
18
16
  move;
19
17
  number;
20
18
  opacity;
19
+ paint;
20
+ palette;
21
21
  reduceDuplicates;
22
22
  shape;
23
23
  size;
24
- stroke;
25
24
  zIndex;
26
25
  _container;
27
- _engine;
28
- constructor(engine, container) {
29
- this._engine = engine;
26
+ _pluginManager;
27
+ constructor(pluginManager, container) {
28
+ this._pluginManager = pluginManager;
30
29
  this._container = container;
31
30
  this.bounce = new ParticlesBounce();
32
31
  this.effect = new Effect();
33
- this.fill = new Fill();
34
32
  this.groups = {};
35
33
  this.move = new Move();
36
34
  this.number = new ParticlesNumber();
37
35
  this.opacity = new Opacity();
36
+ this.paint = new Paint();
38
37
  this.reduceDuplicates = false;
39
38
  this.shape = new Shape();
40
39
  this.size = new Size();
41
- this.stroke = new Stroke();
42
40
  this.zIndex = new ZIndex();
43
41
  }
44
42
  load(data) {
45
43
  if (isNull(data)) {
46
44
  return;
47
45
  }
46
+ if (data.palette) {
47
+ this.palette = data.palette;
48
+ this._importPalette(this.palette);
49
+ }
48
50
  if (data.groups !== undefined) {
49
51
  for (const group of Object.keys(data.groups)) {
50
52
  if (!(group in data.groups)) {
@@ -64,32 +66,24 @@ export class ParticlesOptions {
64
66
  this.move.load(data.move);
65
67
  this.number.load(data.number);
66
68
  this.opacity.load(data.opacity);
67
- this.shape.load(data.shape);
68
- this.size.load(data.size);
69
- this.zIndex.load(data.zIndex);
70
- const fillToLoad = data.fill;
71
- if (fillToLoad) {
72
- this.fill = executeOnSingleOrMultiple(fillToLoad, t => {
73
- const tmp = new Fill();
74
- tmp.load(t);
75
- return tmp;
76
- });
77
- }
78
- const strokeToLoad = data.stroke;
79
- if (strokeToLoad) {
80
- this.stroke = executeOnSingleOrMultiple(strokeToLoad, t => {
81
- const tmp = new Stroke();
69
+ const paintToLoad = data.paint;
70
+ if (paintToLoad) {
71
+ this.paint = executeOnSingleOrMultiple(paintToLoad, t => {
72
+ const tmp = new Paint();
82
73
  tmp.load(t);
83
74
  return tmp;
84
75
  });
85
76
  }
77
+ this.shape.load(data.shape);
78
+ this.size.load(data.size);
79
+ this.zIndex.load(data.zIndex);
86
80
  if (this._container) {
87
- for (const plugin of this._engine.plugins) {
81
+ for (const plugin of this._pluginManager.plugins) {
88
82
  if (plugin.loadParticlesOptions) {
89
83
  plugin.loadParticlesOptions(this._container, this, data);
90
84
  }
91
85
  }
92
- const updaters = this._engine.updaters.get(this._container);
86
+ const updaters = this._pluginManager.updaters.get(this._container);
93
87
  if (updaters) {
94
88
  for (const updater of updaters) {
95
89
  if (updater.loadOptions) {
@@ -99,4 +93,48 @@ export class ParticlesOptions {
99
93
  }
100
94
  }
101
95
  }
96
+ _importPalette = (palette) => {
97
+ const paletteData = this._pluginManager.getPalette(palette);
98
+ if (!paletteData) {
99
+ return;
100
+ }
101
+ const paletteColors = paletteData.colors, paletteFill = paletteColors.fill, paletteStroke = paletteColors.stroke, defaultPaintStrokeIndex = 0, defaultPaintStrokeWidth = 0, palettePaint = {
102
+ fill: paletteFill
103
+ ? {
104
+ color: {
105
+ value: paletteFill.value,
106
+ },
107
+ enable: paletteFill.enable,
108
+ }
109
+ : undefined,
110
+ };
111
+ if (paletteStroke) {
112
+ if (isArray(paletteStroke)) {
113
+ const firstStroke = paletteStroke[defaultPaintStrokeIndex];
114
+ if (firstStroke) {
115
+ palettePaint.stroke = {
116
+ color: {
117
+ value: firstStroke.value,
118
+ },
119
+ width: firstStroke.width || defaultPaintStrokeWidth,
120
+ };
121
+ }
122
+ }
123
+ else {
124
+ palettePaint.stroke = {
125
+ color: {
126
+ value: paletteStroke.value,
127
+ },
128
+ width: paletteStroke.width,
129
+ };
130
+ }
131
+ }
132
+ this.load({
133
+ paint: palettePaint,
134
+ blend: {
135
+ enable: true,
136
+ mode: paletteData.blendMode,
137
+ },
138
+ });
139
+ };
102
140
  }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -16,7 +16,7 @@ export function clear(context, dimension) {
16
16
  context.clearRect(originPoint.x, originPoint.y, dimension.width, dimension.height);
17
17
  }
18
18
  export function drawParticle(data) {
19
- const { container, context, particle, delta, colorStyles, radius, opacity, transform } = data, { effectDrawers, shapeDrawers } = container.particles, pos = particle.getPosition(), transformData = particle.getTransformData(transform), drawScale = defaultZoom, drawPosition = {
19
+ const { container, context, particle, delta, colorStyles, radius, opacity, transform } = data, { effectDrawers, shapeDrawers } = container, pos = particle.getPosition(), transformData = particle.getTransformData(transform), drawScale = defaultZoom, drawPosition = {
20
20
  x: pos.x,
21
21
  y: pos.y,
22
22
  };
@@ -88,12 +88,12 @@ export function drawShape(drawer, data) {
88
88
  if (particle.shapeClose) {
89
89
  context.closePath();
90
90
  }
91
- if (stroke) {
92
- context.stroke();
93
- }
94
91
  if (fill) {
95
92
  context.fill();
96
93
  }
94
+ if (stroke) {
95
+ context.stroke();
96
+ }
97
97
  }
98
98
  export function drawShapeAfterDraw(drawer, data) {
99
99
  if (!drawer?.afterDraw) {
@@ -17,35 +17,35 @@ function getCachedStyle(key, generator) {
17
17
  }
18
18
  return cached;
19
19
  }
20
- function stringToRgba(engine, input) {
20
+ function stringToRgba(pluginManager, input) {
21
21
  if (!input) {
22
22
  return;
23
23
  }
24
- for (const manager of engine.colorManagers.values()) {
24
+ for (const manager of pluginManager.colorManagers.values()) {
25
25
  if (manager.accepts(input)) {
26
26
  return manager.parseString(input);
27
27
  }
28
28
  }
29
29
  return undefined;
30
30
  }
31
- export function rangeColorToRgb(engine, input, index, useIndex = true) {
31
+ export function rangeColorToRgb(pluginManager, input, index, useIndex = true) {
32
32
  if (!input) {
33
33
  return;
34
34
  }
35
35
  const color = isString(input) ? { value: input } : input;
36
36
  if (isString(color.value)) {
37
- return colorToRgb(engine, color.value, index, useIndex);
37
+ return colorToRgb(pluginManager, color.value, index, useIndex);
38
38
  }
39
39
  if (isArray(color.value)) {
40
40
  const value = itemFromArray(color.value, index, useIndex);
41
41
  if (!value) {
42
42
  return;
43
43
  }
44
- return rangeColorToRgb(engine, {
44
+ return rangeColorToRgb(pluginManager, {
45
45
  value,
46
46
  });
47
47
  }
48
- for (const manager of engine.colorManagers.values()) {
48
+ for (const manager of pluginManager.colorManagers.values()) {
49
49
  const res = manager.handleRangeColor(color);
50
50
  if (res) {
51
51
  return res;
@@ -53,24 +53,24 @@ export function rangeColorToRgb(engine, input, index, useIndex = true) {
53
53
  }
54
54
  return undefined;
55
55
  }
56
- export function colorToRgb(engine, input, index, useIndex = true) {
56
+ export function colorToRgb(pluginManager, input, index, useIndex = true) {
57
57
  if (!input) {
58
58
  return;
59
59
  }
60
60
  const color = isString(input) ? { value: input } : input;
61
61
  if (isString(color.value)) {
62
- return color.value === randomColorValue ? getRandomRgbColor() : stringToRgb(engine, color.value);
62
+ return color.value === randomColorValue ? getRandomRgbColor() : stringToRgb(pluginManager, color.value);
63
63
  }
64
64
  if (isArray(color.value)) {
65
65
  const value = itemFromArray(color.value, index, useIndex);
66
66
  if (!value) {
67
67
  return;
68
68
  }
69
- return colorToRgb(engine, {
69
+ return colorToRgb(pluginManager, {
70
70
  value,
71
71
  });
72
72
  }
73
- for (const manager of engine.colorManagers.values()) {
73
+ for (const manager of pluginManager.colorManagers.values()) {
74
74
  const res = manager.handleColor(color);
75
75
  if (res) {
76
76
  return res;
@@ -78,12 +78,12 @@ export function colorToRgb(engine, input, index, useIndex = true) {
78
78
  }
79
79
  return undefined;
80
80
  }
81
- export function colorToHsl(engine, color, index, useIndex = true) {
82
- const rgb = colorToRgb(engine, color, index, useIndex);
81
+ export function colorToHsl(pluginManager, color, index, useIndex = true) {
82
+ const rgb = colorToRgb(pluginManager, color, index, useIndex);
83
83
  return rgb ? rgbToHsl(rgb) : undefined;
84
84
  }
85
- export function rangeColorToHsl(engine, color, index, useIndex = true) {
86
- const rgb = rangeColorToRgb(engine, color, index, useIndex);
85
+ export function rangeColorToHsl(pluginManager, color, index, useIndex = true) {
86
+ const rgb = rangeColorToRgb(pluginManager, color, index, useIndex);
87
87
  return rgb ? rgbToHsl(rgb) : undefined;
88
88
  }
89
89
  export function rgbToHsl(color) {
@@ -115,11 +115,11 @@ export function rgbToHsl(color) {
115
115
  }
116
116
  return res;
117
117
  }
118
- export function stringToAlpha(engine, input) {
119
- return stringToRgba(engine, input)?.a;
118
+ export function stringToAlpha(pluginManager, input) {
119
+ return stringToRgba(pluginManager, input)?.a;
120
120
  }
121
- export function stringToRgb(engine, input) {
122
- return stringToRgba(engine, input);
121
+ export function stringToRgb(pluginManager, input) {
122
+ return stringToRgba(pluginManager, input);
123
123
  }
124
124
  export function hslToRgb(hsl) {
125
125
  const h = ((hsl.h % hMax) + hMax) % hMax, s = Math.max(sMin, Math.min(sMax, hsl.s)), l = Math.max(lMin, Math.min(lMax, hsl.l)), hNormalized = h / hMax, sNormalized = s / sMax, lNormalized = l / lMax;
@@ -223,11 +223,11 @@ export function getLinkColor(p1, p2, linkColor) {
223
223
  }
224
224
  return undefined;
225
225
  }
226
- export function getLinkRandomColor(engine, optColor, blink, consent) {
226
+ export function getLinkRandomColor(pluginManager, optColor, blink, consent) {
227
227
  const color = isString(optColor) ? optColor : optColor.value;
228
228
  if (color === randomColorValue) {
229
229
  if (consent) {
230
- return rangeColorToRgb(engine, {
230
+ return rangeColorToRgb(pluginManager, {
231
231
  value: color,
232
232
  });
233
233
  }
@@ -240,7 +240,7 @@ export function getLinkRandomColor(engine, optColor, blink, consent) {
240
240
  return midColorValue;
241
241
  }
242
242
  else {
243
- return rangeColorToRgb(engine, {
243
+ return rangeColorToRgb(pluginManager, {
244
244
  value: color,
245
245
  });
246
246
  }
@@ -6,6 +6,7 @@ const _logger = {
6
6
  },
7
7
  info: console.info,
8
8
  log: console.log,
9
+ trace: console.trace,
9
10
  verbose: console.log,
10
11
  warning: console.warn,
11
12
  };
@@ -4,8 +4,8 @@ export function loadOptions(options, ...sourceOptionsArr) {
4
4
  options.load(sourceOptions);
5
5
  }
6
6
  }
7
- export function loadParticlesOptions(engine, container, ...sourceOptionsArr) {
8
- const options = new ParticlesOptions(engine, container);
7
+ export function loadParticlesOptions(pluginManager, container, ...sourceOptionsArr) {
8
+ const options = new ParticlesOptions(pluginManager, container);
9
9
  loadOptions(options, ...sourceOptionsArr);
10
10
  return options;
11
11
  }
@@ -326,6 +326,19 @@ export function updateAnimation(particle, data, changeDirection, destroyType, de
326
326
  if ((data.delayTime ?? minDelay) > minDelay && data.time < (data.delayTime ?? minDelay)) {
327
327
  return;
328
328
  }
329
+ switch (data.status) {
330
+ case AnimationStatus.increasing:
331
+ data.value += velocity;
332
+ break;
333
+ case AnimationStatus.decreasing:
334
+ data.value -= velocity;
335
+ break;
336
+ default:
337
+ break;
338
+ }
339
+ if (data.velocity && decay !== identity) {
340
+ data.velocity *= decay;
341
+ }
329
342
  switch (data.status) {
330
343
  case AnimationStatus.increasing:
331
344
  if (data.value >= maxValue) {
@@ -338,9 +351,6 @@ export function updateAnimation(particle, data, changeDirection, destroyType, de
338
351
  data.loops ??= minLoops;
339
352
  data.loops++;
340
353
  }
341
- else {
342
- data.value += velocity;
343
- }
344
354
  break;
345
355
  case AnimationStatus.decreasing:
346
356
  if (data.value <= minValue) {
@@ -353,18 +363,14 @@ export function updateAnimation(particle, data, changeDirection, destroyType, de
353
363
  data.loops ??= minLoops;
354
364
  data.loops++;
355
365
  }
356
- else {
357
- data.value -= velocity;
358
- }
359
366
  break;
360
367
  default:
361
368
  break;
362
369
  }
363
- if (data.velocity && decay !== identity) {
364
- data.velocity *= decay;
365
- }
366
370
  checkDestroy(particle, destroyType, data.value, minValue, maxValue);
367
- data.value = clamp(data.value, minValue, maxValue);
371
+ if (!particle.destroyed) {
372
+ data.value = clamp(data.value, minValue, maxValue);
373
+ }
368
374
  }
369
375
  export function cloneStyle(style) {
370
376
  const clonedStyle = safeDocument().createElement("div").style;
package/cjs/exports.js CHANGED
@@ -28,6 +28,7 @@ export * from "./Options/Classes/Particles/Bounce/ParticlesBounce.js";
28
28
  export * from "./Options/Classes/Particles/Bounce/ParticlesBounceFactor.js";
29
29
  export * from "./Options/Classes/Particles/ParticlesOptions.js";
30
30
  export * from "./Options/Classes/Particles/Fill.js";
31
+ export * from "./Options/Classes/Particles/Paint.js";
31
32
  export * from "./Options/Classes/Particles/Stroke.js";
32
33
  export * from "./Options/Classes/Particles/Move/Move.js";
33
34
  export * from "./Options/Classes/Particles/Move/MoveAngle.js";