@tsparticles/engine 4.0.0-alpha.26 → 4.0.0-alpha.27

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 (101) hide show
  1. package/164.min.js +1 -0
  2. package/README.md +1 -1
  3. package/browser/Core/Canvas.js +7 -4
  4. package/browser/Core/Engine.js +8 -1
  5. package/browser/Core/Interfaces/IPalette.js +1 -0
  6. package/browser/Core/Particle.js +8 -12
  7. package/browser/Core/Utils/Constants.js +1 -1
  8. package/browser/Options/Classes/ColorAnimation.js +11 -1
  9. package/browser/Options/Classes/HslAnimation.js +4 -3
  10. package/browser/Options/Classes/Options.js +38 -1
  11. package/browser/Options/Classes/Particles/Effect/Effect.js +0 -5
  12. package/browser/Options/Classes/Particles/Fill.js +28 -0
  13. package/browser/Options/Classes/Particles/ParticlesOptions.js +12 -6
  14. package/browser/Options/Classes/Particles/Shape/Shape.js +0 -5
  15. package/browser/Options/Interfaces/Particles/IFill.js +1 -0
  16. package/browser/Utils/CanvasUtils.js +5 -5
  17. package/browser/Utils/ColorUtils.js +22 -19
  18. package/browser/Utils/Utils.js +86 -13
  19. package/browser/exports.js +1 -0
  20. package/cjs/Core/Canvas.js +7 -4
  21. package/cjs/Core/Engine.js +8 -1
  22. package/cjs/Core/Interfaces/IPalette.js +1 -0
  23. package/cjs/Core/Particle.js +8 -12
  24. package/cjs/Core/Utils/Constants.js +1 -1
  25. package/cjs/Options/Classes/ColorAnimation.js +11 -1
  26. package/cjs/Options/Classes/HslAnimation.js +4 -3
  27. package/cjs/Options/Classes/Options.js +38 -1
  28. package/cjs/Options/Classes/Particles/Effect/Effect.js +0 -5
  29. package/cjs/Options/Classes/Particles/Fill.js +28 -0
  30. package/cjs/Options/Classes/Particles/ParticlesOptions.js +12 -6
  31. package/cjs/Options/Classes/Particles/Shape/Shape.js +0 -5
  32. package/cjs/Options/Interfaces/Particles/IFill.js +1 -0
  33. package/cjs/Utils/CanvasUtils.js +5 -5
  34. package/cjs/Utils/ColorUtils.js +22 -19
  35. package/cjs/Utils/Utils.js +86 -13
  36. package/cjs/exports.js +1 -0
  37. package/dist_browser_Core_Container_js.js +3 -3
  38. package/esm/Core/Canvas.js +7 -4
  39. package/esm/Core/Engine.js +8 -1
  40. package/esm/Core/Interfaces/IPalette.js +1 -0
  41. package/esm/Core/Particle.js +8 -12
  42. package/esm/Core/Utils/Constants.js +1 -1
  43. package/esm/Options/Classes/ColorAnimation.js +11 -1
  44. package/esm/Options/Classes/HslAnimation.js +4 -3
  45. package/esm/Options/Classes/Options.js +38 -1
  46. package/esm/Options/Classes/Particles/Effect/Effect.js +0 -5
  47. package/esm/Options/Classes/Particles/Fill.js +28 -0
  48. package/esm/Options/Classes/Particles/ParticlesOptions.js +12 -6
  49. package/esm/Options/Classes/Particles/Shape/Shape.js +0 -5
  50. package/esm/Options/Interfaces/Particles/IFill.js +1 -0
  51. package/esm/Utils/CanvasUtils.js +5 -5
  52. package/esm/Utils/ColorUtils.js +22 -19
  53. package/esm/Utils/Utils.js +86 -13
  54. package/esm/exports.js +1 -0
  55. package/package.json +1 -1
  56. package/report.html +1 -1
  57. package/scripts/install.js +2 -18
  58. package/tsparticles.engine.js +30 -20
  59. package/tsparticles.engine.min.js +2 -2
  60. package/types/Core/Engine.d.ts +4 -0
  61. package/types/Core/Interfaces/IPalette.d.ts +7 -0
  62. package/types/Core/Interfaces/IParticleOpacityData.d.ts +1 -0
  63. package/types/Core/Interfaces/IParticleValueAnimation.d.ts +3 -3
  64. package/types/Core/Interfaces/IShapeValues.d.ts +0 -1
  65. package/types/Core/Particle.d.ts +3 -3
  66. package/types/Core/Utils/Constants.d.ts +1 -1
  67. package/types/Options/Classes/ColorAnimation.d.ts +3 -1
  68. package/types/Options/Classes/Options.d.ts +2 -0
  69. package/types/Options/Classes/Particles/Effect/Effect.d.ts +0 -1
  70. package/types/Options/Classes/Particles/Fill.d.ts +12 -0
  71. package/types/Options/Classes/Particles/ParticlesOptions.d.ts +2 -2
  72. package/types/Options/Classes/Particles/Shape/Shape.d.ts +0 -1
  73. package/types/Options/Interfaces/IColorAnimation.d.ts +2 -0
  74. package/types/Options/Interfaces/IOptions.d.ts +1 -0
  75. package/types/Options/Interfaces/Particles/Effect/IEffect.d.ts +0 -1
  76. package/types/Options/Interfaces/Particles/IFill.d.ts +9 -0
  77. package/types/Options/Interfaces/Particles/IParticlesOptions.d.ts +2 -2
  78. package/types/Options/Interfaces/Particles/IStroke.d.ts +2 -2
  79. package/types/Options/Interfaces/Particles/Shape/IShape.d.ts +0 -1
  80. package/types/Utils/ColorUtils.d.ts +1 -2
  81. package/types/Utils/Utils.d.ts +7 -0
  82. package/types/export-types.d.ts +2 -1
  83. package/types/exports.d.ts +1 -0
  84. package/umd/Core/Canvas.js +6 -3
  85. package/umd/Core/Engine.js +8 -1
  86. package/umd/Core/Interfaces/IPalette.js +12 -0
  87. package/umd/Core/Particle.js +8 -12
  88. package/umd/Core/Utils/Constants.js +2 -2
  89. package/umd/Options/Classes/ColorAnimation.js +11 -1
  90. package/umd/Options/Classes/HslAnimation.js +5 -4
  91. package/umd/Options/Classes/Options.js +38 -1
  92. package/umd/Options/Classes/Particles/Effect/Effect.js +0 -5
  93. package/umd/Options/Classes/Particles/Fill.js +42 -0
  94. package/umd/Options/Classes/Particles/ParticlesOptions.js +13 -7
  95. package/umd/Options/Classes/Particles/Shape/Shape.js +0 -5
  96. package/umd/Options/Interfaces/Particles/IFill.js +12 -0
  97. package/umd/Utils/CanvasUtils.js +5 -5
  98. package/umd/Utils/ColorUtils.js +21 -18
  99. package/umd/Utils/Utils.js +87 -13
  100. package/umd/exports.js +2 -1
  101. package/622.min.js +0 -1
@@ -12,14 +12,12 @@ function loadEffectData(effect, effectOptions, id, reduceDuplicates) {
12
12
  const effectData = effectOptions.options[effect];
13
13
  return deepExtend({
14
14
  close: effectOptions.close,
15
- fill: effectOptions.fill,
16
15
  }, itemFromSingleOrMultiple(effectData, id, reduceDuplicates));
17
16
  }
18
17
  function loadShapeData(shape, shapeOptions, id, reduceDuplicates) {
19
18
  const shapeData = shapeOptions.options[shape];
20
19
  return deepExtend({
21
20
  close: shapeOptions.close,
22
- fill: shapeOptions.fill,
23
21
  }, itemFromSingleOrMultiple(shapeData, id, reduceDuplicates));
24
22
  }
25
23
  function fixOutMode(data) {
@@ -38,13 +36,14 @@ export class Particle {
38
36
  container;
39
37
  backColor;
40
38
  bubble;
41
- color;
42
39
  destroyed;
43
40
  direction;
44
41
  effect;
45
42
  effectClose;
46
43
  effectData;
47
- effectFill;
44
+ fillColor;
45
+ fillEnabled;
46
+ fillOpacity;
48
47
  group;
49
48
  id;
50
49
  ignoresResizeRatio;
@@ -67,7 +66,6 @@ export class Particle {
67
66
  shape;
68
67
  shapeClose;
69
68
  shapeData;
70
- shapeFill;
71
69
  sides;
72
70
  size;
73
71
  slow;
@@ -79,6 +77,7 @@ export class Particle {
79
77
  velocity;
80
78
  zIndexFactor;
81
79
  _cachedOpacityData = {
80
+ fillOpacity: defaultOpacity,
82
81
  opacity: defaultOpacity,
83
82
  strokeOpacity: defaultOpacity,
84
83
  };
@@ -126,15 +125,16 @@ export class Particle {
126
125
  return this.rotation + (this.pathRotation ? this.velocity.angle : defaultAngle);
127
126
  }
128
127
  getFillColor() {
129
- return this._getRollColor(this.bubble.color ?? getHslFromAnimation(this.color));
128
+ return this._getRollColor(this.bubble.color ?? getHslFromAnimation(this.fillColor));
130
129
  }
131
130
  getMass() {
132
131
  return this.getRadius() ** squareExp * Math.PI * half;
133
132
  }
134
133
  getOpacity() {
135
- const zIndexOptions = this.options.zIndex, zIndexFactor = zIndexFactorOffset - this.zIndexFactor, zOpacityFactor = zIndexFactor ** zIndexOptions.opacityRate, opacity = this.bubble.opacity ?? getRangeValue(this.opacity?.value ?? defaultOpacity), strokeOpacity = this.strokeOpacity ?? opacity;
134
+ const zIndexOptions = this.options.zIndex, zIndexFactor = zIndexFactorOffset - this.zIndexFactor, zOpacityFactor = zIndexFactor ** zIndexOptions.opacityRate, opacity = this.bubble.opacity ?? getRangeValue(this.opacity?.value ?? defaultOpacity), fillOpacity = this.fillOpacity ?? defaultOpacity, strokeOpacity = this.strokeOpacity ?? defaultOpacity;
135
+ this._cachedOpacityData.fillOpacity = opacity * fillOpacity * zOpacityFactor;
136
136
  this._cachedOpacityData.opacity = opacity * zOpacityFactor;
137
- this._cachedOpacityData.strokeOpacity = strokeOpacity * zOpacityFactor;
137
+ this._cachedOpacityData.strokeOpacity = opacity * strokeOpacity * zOpacityFactor;
138
138
  return this._cachedOpacityData;
139
139
  }
140
140
  getPosition() {
@@ -172,9 +172,7 @@ export class Particle {
172
172
  this.id = id;
173
173
  this.group = group;
174
174
  this.effectClose = true;
175
- this.effectFill = true;
176
175
  this.shapeClose = true;
177
- this.shapeFill = true;
178
176
  this.pathRotation = false;
179
177
  this.lastPathTime = 0;
180
178
  this.destroyed = false;
@@ -226,9 +224,7 @@ export class Particle {
226
224
  if (shapeData) {
227
225
  particlesOptions.load(shapeData.particles);
228
226
  }
229
- this.effectFill = effectData?.fill ?? particlesOptions.effect.fill;
230
227
  this.effectClose = effectData?.close ?? particlesOptions.effect.close;
231
- this.shapeFill = shapeData?.fill ?? particlesOptions.shape.fill;
232
228
  this.shapeClose = shapeData?.close ?? particlesOptions.shape.close;
233
229
  this.options = particlesOptions;
234
230
  container.retina.initParticle(this);
@@ -1,4 +1,4 @@
1
- export const generatedAttribute = "generated", resizeEvent = "resize", visibilityChangeEvent = "visibilitychange", percentDenominator = 100, half = 0.5, millisecondsToSeconds = 1000, originPoint = {
1
+ export const generatedAttribute = "generated", defaultCompositeValue = "source-over", resizeEvent = "resize", visibilityChangeEvent = "visibilitychange", percentDenominator = 100, half = 0.5, millisecondsToSeconds = 1000, originPoint = {
2
2
  x: 0,
3
3
  y: 0,
4
4
  z: 0,
@@ -2,9 +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
+ max;
6
+ min;
5
7
  offset;
6
- constructor() {
8
+ constructor(min, max) {
7
9
  super();
10
+ this.min = min;
11
+ this.max = max;
8
12
  this.offset = 0;
9
13
  this.sync = true;
10
14
  }
@@ -13,6 +17,12 @@ export class ColorAnimation extends AnimationOptions {
13
17
  if (isNull(data)) {
14
18
  return;
15
19
  }
20
+ if (data.max !== undefined) {
21
+ this.max = data.max;
22
+ }
23
+ if (data.min !== undefined) {
24
+ this.min = data.min;
25
+ }
16
26
  if (data.offset !== undefined) {
17
27
  this.offset = setRangeValue(data.offset);
18
28
  }
@@ -1,9 +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
- h = new ColorAnimation();
5
- l = new ColorAnimation();
6
- s = new ColorAnimation();
5
+ h = new ColorAnimation(hMin, hMax);
6
+ l = new ColorAnimation(lMin, lMax);
7
+ s = new ColorAnimation(sMin, sMax);
7
8
  load(data) {
8
9
  if (isNull(data)) {
9
10
  return;
@@ -18,6 +18,7 @@ export class Options {
18
18
  hdr;
19
19
  key;
20
20
  name;
21
+ palette;
21
22
  particles;
22
23
  pauseOnBlur;
23
24
  pauseOnOutsideViewport;
@@ -54,10 +55,15 @@ export class Options {
54
55
  return;
55
56
  }
56
57
  if (data.preset !== undefined) {
57
- executeOnSingleOrMultiple(data.preset, preset => {
58
+ this.preset = data.preset;
59
+ executeOnSingleOrMultiple(this.preset, preset => {
58
60
  this._importPreset(preset);
59
61
  });
60
62
  }
63
+ if (data.palette !== undefined) {
64
+ this.palette = data.palette;
65
+ this._importPalette(this.palette);
66
+ }
61
67
  if (data.autoPlay !== undefined) {
62
68
  this.autoPlay = data.autoPlay;
63
69
  }
@@ -114,6 +120,37 @@ export class Options {
114
120
  plugin.loadOptions(this._container, this, data);
115
121
  });
116
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
+ };
117
154
  _importPreset = preset => {
118
155
  this.load(this._engine.getPreset(preset));
119
156
  };
@@ -2,12 +2,10 @@ import { deepExtend } from "../../../../Utils/Utils.js";
2
2
  import { isNull } from "../../../../Utils/TypeUtils.js";
3
3
  export class Effect {
4
4
  close;
5
- fill;
6
5
  options;
7
6
  type;
8
7
  constructor() {
9
8
  this.close = true;
10
- this.fill = true;
11
9
  this.options = {};
12
10
  this.type = [];
13
11
  }
@@ -27,9 +25,6 @@ export class Effect {
27
25
  if (data.close !== undefined) {
28
26
  this.close = data.close;
29
27
  }
30
- if (data.fill !== undefined) {
31
- this.fill = data.fill;
32
- }
33
28
  if (data.type !== undefined) {
34
29
  this.type = data.type;
35
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,6 +1,6 @@
1
1
  import { deepExtend, executeOnSingleOrMultiple } from "../../../Utils/Utils.js";
2
- import { AnimatableColor } from "../AnimatableColor.js";
3
2
  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
6
  import { ParticlesBounce } from "./Bounce/ParticlesBounce.js";
@@ -12,8 +12,8 @@ import { ZIndex } from "./ZIndex/ZIndex.js";
12
12
  import { isNull } from "../../../Utils/TypeUtils.js";
13
13
  export class ParticlesOptions {
14
14
  bounce;
15
- color;
16
15
  effect;
16
+ fill;
17
17
  groups;
18
18
  move;
19
19
  number;
@@ -29,9 +29,8 @@ export class ParticlesOptions {
29
29
  this._engine = engine;
30
30
  this._container = container;
31
31
  this.bounce = new ParticlesBounce();
32
- this.color = new AnimatableColor();
33
- this.color.value = "#fff";
34
32
  this.effect = new Effect();
33
+ this.fill = new Fill();
35
34
  this.groups = {};
36
35
  this.move = new Move();
37
36
  this.number = new ParticlesNumber();
@@ -48,7 +47,7 @@ export class ParticlesOptions {
48
47
  }
49
48
  if (data.groups !== undefined) {
50
49
  for (const group of Object.keys(data.groups)) {
51
- if (!Object.hasOwn(data.groups, group)) {
50
+ if (!(group in data.groups)) {
52
51
  continue;
53
52
  }
54
53
  const item = data.groups[group];
@@ -61,7 +60,6 @@ export class ParticlesOptions {
61
60
  this.reduceDuplicates = data.reduceDuplicates;
62
61
  }
63
62
  this.bounce.load(data.bounce);
64
- this.color.load(AnimatableColor.create(this.color, data.color));
65
63
  this.effect.load(data.effect);
66
64
  this.move.load(data.move);
67
65
  this.number.load(data.number);
@@ -69,6 +67,14 @@ export class ParticlesOptions {
69
67
  this.shape.load(data.shape);
70
68
  this.size.load(data.size);
71
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
+ }
72
78
  const strokeToLoad = data.stroke;
73
79
  if (strokeToLoad) {
74
80
  this.stroke = executeOnSingleOrMultiple(strokeToLoad, t => {
@@ -2,12 +2,10 @@ import { deepExtend } from "../../../../Utils/Utils.js";
2
2
  import { isNull } from "../../../../Utils/TypeUtils.js";
3
3
  export class Shape {
4
4
  close;
5
- fill;
6
5
  options;
7
6
  type;
8
7
  constructor() {
9
8
  this.close = true;
10
- this.fill = true;
11
9
  this.options = {};
12
10
  this.type = "circle";
13
11
  }
@@ -27,9 +25,6 @@ export class Shape {
27
25
  if (data.close !== undefined) {
28
26
  this.close = data.close;
29
27
  }
30
- if (data.fill !== undefined) {
31
- this.fill = data.fill;
32
- }
33
28
  if (data.type !== undefined) {
34
29
  this.type = data.type;
35
30
  }
@@ -0,0 +1 @@
1
+ export {};
@@ -24,7 +24,7 @@ export function drawParticle(data) {
24
24
  if (colorStyles.fill) {
25
25
  context.fillStyle = colorStyles.fill;
26
26
  }
27
- const strokeWidth = particle.strokeWidth ?? minStrokeWidth;
27
+ const fillEnabled = !!particle.fillEnabled, strokeWidth = particle.strokeWidth ?? minStrokeWidth;
28
28
  context.lineWidth = strokeWidth;
29
29
  if (colorStyles.stroke) {
30
30
  context.strokeStyle = colorStyles.stroke;
@@ -37,8 +37,8 @@ export function drawParticle(data) {
37
37
  opacity,
38
38
  delta,
39
39
  pixelRatio: container.retina.pixelRatio,
40
- fill: particle.shapeFill,
41
- stroke: strokeWidth > minStrokeWidth || !particle.shapeFill,
40
+ fill: fillEnabled,
41
+ stroke: strokeWidth > minStrokeWidth,
42
42
  transformData,
43
43
  position: { ...pos },
44
44
  drawPosition,
@@ -79,7 +79,7 @@ export function drawShape(drawer, data) {
79
79
  if (!drawer) {
80
80
  return;
81
81
  }
82
- const { context, particle, stroke } = data;
82
+ const { context, fill, particle, stroke } = data;
83
83
  if (!particle.shape) {
84
84
  return;
85
85
  }
@@ -91,7 +91,7 @@ export function drawShape(drawer, data) {
91
91
  if (stroke) {
92
92
  context.stroke();
93
93
  }
94
- if (particle.shapeFill) {
94
+ if (fill) {
95
95
  context.fill();
96
96
  }
97
97
  }
@@ -1,4 +1,4 @@
1
- import { clamp, getRandom, getRandomInRange, getRangeMax, getRangeMin, getRangeValue, mix, randomInRangeValue, setRangeValue, } from "./MathUtils.js";
1
+ import { clamp, getRandom, getRandomInRange, getRangeValue, mix, randomInRangeValue, setRangeValue, } from "./MathUtils.js";
2
2
  import { decayOffset, defaultLoops, defaultOpacity, defaultRgbMin, defaultTime, defaultVelocity, double, hMax, hMin, hPhase, half, identity, lFactor, lMax, lMin, midColorValue, millisecondsToSeconds, percentDenominator, phaseNumerator, randomColorValue, rgbMax, sMax, sMin, sNormalizedOffset, sextuple, triple, } from "../Core/Utils/Constants.js";
3
3
  import { isArray, isString } from "./TypeUtils.js";
4
4
  import { AlterType } from "../Enums/Types/AlterType.js";
@@ -190,10 +190,10 @@ function getSdrStyleFromHsl(color, opacity) {
190
190
  }
191
191
  export function colorMix(color1, color2, size1, size2) {
192
192
  let rgb1 = color1, rgb2 = color2;
193
- if (!Object.hasOwn(rgb1, "r")) {
193
+ if (!("r" in rgb1)) {
194
194
  rgb1 = hslToRgb(color1);
195
195
  }
196
- if (!Object.hasOwn(rgb2, "r")) {
196
+ if (!("r" in rgb2)) {
197
197
  rgb2 = hslToRgb(color2);
198
198
  }
199
199
  return {
@@ -246,27 +246,33 @@ export function getLinkRandomColor(engine, optColor, blink, consent) {
246
246
  }
247
247
  }
248
248
  export function getHslFromAnimation(animation) {
249
- return animation !== undefined
250
- ? {
249
+ return animation === undefined
250
+ ? undefined
251
+ : {
251
252
  h: animation.h.value,
252
253
  s: animation.s.value,
253
254
  l: animation.l.value,
254
- }
255
- : undefined;
255
+ };
256
256
  }
257
257
  export function getHslAnimationFromHsl(hsl, animationOptions, reduceFactor) {
258
258
  const resColor = {
259
259
  h: {
260
260
  enable: false,
261
261
  value: hsl.h,
262
+ min: hMin,
263
+ max: hMax,
262
264
  },
263
265
  s: {
264
266
  enable: false,
265
267
  value: hsl.s,
268
+ min: sMin,
269
+ max: sMax,
266
270
  },
267
271
  l: {
268
272
  enable: false,
269
273
  value: hsl.l,
274
+ min: lMin,
275
+ max: lMax,
270
276
  },
271
277
  };
272
278
  if (animationOptions) {
@@ -278,6 +284,8 @@ export function getHslAnimationFromHsl(hsl, animationOptions, reduceFactor) {
278
284
  }
279
285
  function setColorAnimation(colorValue, colorAnimation, reduceFactor) {
280
286
  colorValue.enable = colorAnimation.enable;
287
+ colorValue.min = colorAnimation.min;
288
+ colorValue.max = colorAnimation.max;
281
289
  if (colorValue.enable) {
282
290
  colorValue.velocity = (getRangeValue(colorAnimation.speed) / percentDenominator) * reduceFactor;
283
291
  colorValue.decay = decayOffset - getRangeValue(colorAnimation.decay);
@@ -297,7 +305,7 @@ function setColorAnimation(colorValue, colorAnimation, reduceFactor) {
297
305
  colorValue.velocity = defaultVelocity;
298
306
  }
299
307
  }
300
- export function updateColorValue(data, range, decrease, delta) {
308
+ export function updateColorValue(data, decrease, delta) {
301
309
  const minLoops = 0, minDelay = 0, identity = 1, minVelocity = 0, minOffset = 0, velocityFactor = 3.6;
302
310
  if (!data.enable ||
303
311
  ((data.maxLoops ?? minLoops) > minLoops && (data.loops ?? minLoops) > (data.maxLoops ?? minLoops))) {
@@ -310,7 +318,7 @@ export function updateColorValue(data, range, decrease, delta) {
310
318
  if ((data.delayTime ?? minDelay) > minDelay && data.time < (data.delayTime ?? minDelay)) {
311
319
  return;
312
320
  }
313
- const offset = data.offset ? randomInRangeValue(data.offset) : minOffset, velocity = (data.velocity ?? minVelocity) * delta.factor + offset * velocityFactor, decay = data.decay ?? identity, max = getRangeMax(range), min = getRangeMin(range);
321
+ const offset = data.offset ? randomInRangeValue(data.offset) : minOffset, velocity = (data.velocity ?? minVelocity) * delta.factor + offset * velocityFactor, decay = data.decay ?? identity, max = data.max, min = data.min;
314
322
  if (!decrease || data.status === AnimationStatus.increasing) {
315
323
  data.value += velocity;
316
324
  if (data.value > max) {
@@ -326,8 +334,7 @@ export function updateColorValue(data, range, decrease, delta) {
326
334
  }
327
335
  else {
328
336
  data.value -= velocity;
329
- const minValue = 0;
330
- if (data.value < minValue) {
337
+ if (data.value < min) {
331
338
  data.loops ??= 0;
332
339
  data.loops++;
333
340
  data.status = AnimationStatus.increasing;
@@ -342,14 +349,10 @@ export function updateColor(color, delta) {
342
349
  if (!color) {
343
350
  return;
344
351
  }
345
- const { h, s, l } = color, ranges = {
346
- h: { min: hMin, max: hMax },
347
- s: { min: sMin, max: sMax },
348
- l: { min: lMin, max: lMax },
349
- };
350
- updateColorValue(h, ranges.h, false, delta);
351
- updateColorValue(s, ranges.s, true, delta);
352
- updateColorValue(l, ranges.l, true, delta);
352
+ const { h, s, l } = color;
353
+ updateColorValue(h, false, delta);
354
+ updateColorValue(s, true, delta);
355
+ updateColorValue(l, true, delta);
353
356
  }
354
357
  export function alterHsl(color, type, value) {
355
358
  return {
@@ -8,16 +8,70 @@ import { OutModeDirection } from "../Enums/Directions/OutModeDirection.js";
8
8
  import { PixelMode } from "../Enums/Modes/PixelMode.js";
9
9
  import { StartValueType } from "../Enums/Types/StartValueType.js";
10
10
  import { Vector } from "../Core/Utils/Vectors.js";
11
- const minRadius = 0;
12
- function memoize(fn) {
13
- const cache = new Map();
11
+ const minRadius = 0, minMemoizeSize = 0;
12
+ export function memoize(fn, options) {
13
+ const cache = new Map(), maxSize = options?.maxSize, ttlMs = options?.ttlMs, keyFn = options?.keyFn, stableStringify = (obj, seen = new WeakSet()) => {
14
+ if (obj === null) {
15
+ return "null";
16
+ }
17
+ const t = typeof obj;
18
+ if (t === "undefined") {
19
+ return "undefined";
20
+ }
21
+ if (t === "number" || t === "boolean" || t === "string") {
22
+ return JSON.stringify(obj);
23
+ }
24
+ if (t === "function") {
25
+ try {
26
+ const fn = obj;
27
+ return fn.toString();
28
+ }
29
+ catch {
30
+ return '"[Function]"';
31
+ }
32
+ }
33
+ if (t === "symbol") {
34
+ try {
35
+ return obj.toString();
36
+ }
37
+ catch {
38
+ return '"[Symbol]"';
39
+ }
40
+ }
41
+ if (Array.isArray(obj)) {
42
+ return `[${obj.map(i => stableStringify(i, seen)).join(",")}]`;
43
+ }
44
+ if (seen.has(obj)) {
45
+ return '"[Circular]"';
46
+ }
47
+ seen.add(obj);
48
+ const keys = Object.keys(obj).sort();
49
+ return `{${keys.map(k => `${JSON.stringify(k)}:${stableStringify(obj[k], seen)}`).join(",")}}`;
50
+ }, defaultKeyer = (args) => stableStringify(args), makeKey = (args) => (keyFn ? keyFn(args) : defaultKeyer(args)), ensureBounds = () => {
51
+ if (typeof maxSize === "number" && maxSize >= minMemoizeSize) {
52
+ while (cache.size > maxSize) {
53
+ const firstKey = cache.keys().next().value;
54
+ if (firstKey === undefined)
55
+ break;
56
+ cache.delete(firstKey);
57
+ }
58
+ }
59
+ };
14
60
  return (...args) => {
15
- const key = JSON.stringify(args);
16
- if (cache.has(key)) {
17
- return cache.get(key);
61
+ const key = makeKey(args), now = Date.now(), entry = cache.get(key);
62
+ if (entry !== undefined) {
63
+ if (ttlMs && now - entry.ts > ttlMs) {
64
+ cache.delete(key);
65
+ }
66
+ else {
67
+ cache.delete(key);
68
+ cache.set(key, { value: entry.value, ts: entry.ts });
69
+ return entry.value;
70
+ }
18
71
  }
19
72
  const result = fn(...args);
20
- cache.set(key, result);
73
+ cache.set(key, { value: result, ts: now });
74
+ ensureBounds();
21
75
  return result;
22
76
  };
23
77
  }
@@ -98,8 +152,27 @@ export function deepExtend(destination, ...sources) {
98
152
  else if (!isObject(destination) || Array.isArray(destination)) {
99
153
  destination = {};
100
154
  }
101
- for (const key of Object.keys(source)) {
102
- if (key === "__proto__" || key === "constructor" || key === "prototype") {
155
+ const sourceKeys = Object.keys(source), dangerousKeys = new Set(["__proto__", "constructor", "prototype"]), hasNested = sourceKeys.some(k => {
156
+ const v = source[k];
157
+ return isObject(v) || Array.isArray(v);
158
+ });
159
+ if (!hasNested) {
160
+ const sourceDict = source, destDict = destination;
161
+ for (const key of sourceKeys) {
162
+ if (dangerousKeys.has(key)) {
163
+ continue;
164
+ }
165
+ if (key in sourceDict) {
166
+ const v = sourceDict[key];
167
+ if (v !== undefined) {
168
+ destDict[key] = v;
169
+ }
170
+ }
171
+ }
172
+ continue;
173
+ }
174
+ for (const key of sourceKeys) {
175
+ if (dangerousKeys.has(key)) {
103
176
  continue;
104
177
  }
105
178
  const sourceDict = source, destDict = destination, value = sourceDict[key];
@@ -297,7 +370,7 @@ export function cloneStyle(style) {
297
370
  const clonedStyle = safeDocument().createElement("div").style;
298
371
  for (const key in style) {
299
372
  const styleKey = style[key];
300
- if (!Object.hasOwn(style, key) || isNull(styleKey)) {
373
+ if (!(key in style) || isNull(styleKey)) {
301
374
  continue;
302
375
  }
303
376
  const styleValue = style.getPropertyValue?.(styleKey);
@@ -305,11 +378,11 @@ export function cloneStyle(style) {
305
378
  continue;
306
379
  }
307
380
  const stylePriority = style.getPropertyPriority?.(styleKey);
308
- if (!stylePriority) {
309
- clonedStyle.setProperty(styleKey, styleValue);
381
+ if (stylePriority) {
382
+ clonedStyle.setProperty(styleKey, styleValue, stylePriority);
310
383
  }
311
384
  else {
312
- clonedStyle.setProperty(styleKey, styleValue, stylePriority);
385
+ clonedStyle.setProperty(styleKey, styleValue);
313
386
  }
314
387
  }
315
388
  return clonedStyle;
package/esm/exports.js CHANGED
@@ -27,6 +27,7 @@ export * from "./Options/Classes/OptionsColor.js";
27
27
  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
+ export * from "./Options/Classes/Particles/Fill.js";
30
31
  export * from "./Options/Classes/Particles/Stroke.js";
31
32
  export * from "./Options/Classes/Particles/Move/Move.js";
32
33
  export * from "./Options/Classes/Particles/Move/MoveAngle.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsparticles/engine",
3
- "version": "4.0.0-alpha.26",
3
+ "version": "4.0.0-alpha.27",
4
4
  "description": "Easily create highly customizable particle, confetti and fireworks animations and use them as animated backgrounds for your website. Ready to use components available also for React, Vue.js (2.x and 3.x), Angular, Svelte, jQuery, Preact, Riot.js, Inferno.",
5
5
  "homepage": "https://particles.js.org",
6
6
  "scripts": {
package/report.html CHANGED
@@ -3,7 +3,7 @@
3
3
  <head>
4
4
  <meta charset="UTF-8"/>
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1"/>
6
- <title>@tsparticles/engine [26 Feb 2026 at 17:54]</title>
6
+ <title>@tsparticles/engine [9 Mar 2026 at 17:21]</title>
7
7
  <link rel="shortcut icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAABrVBMVEUAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+O1foceMD///+J0/qK1Pr7/v8Xdr/9///W8P4UdL7L7P0Scr2r4Pyj3vwad8D5/f/2/f+55f3E6f34+/2H0/ojfMKpzOd0rNgQcb3F3O/j9f7c8v6g3Pz0/P/w+v/q+P7n9v6T1/uQ1vuE0vqLut/y+v+Z2fvt+f+15Pzv9fuc2/vR7v2V2Pvd6/bg9P7I6/285/2y4/yp3/zp8vk8i8kqgMT7/P31+fyv4vxGkcz6/P6/6P3j7vfS5PNnpNUxhcbO7f7F6v3O4vHK3/DA2u631Ouy0eqXweKJud5wqthfoNMMbLvY8f73+v2dxeR8sNtTmdDx9/zX6PSjyeaCtd1YnNGX2PuQveCGt95Nls42h8dLlM3F4vBtAAAAM3RSTlMAAyOx0/sKBvik8opWGBMOAe3l1snDm2E9LSb06eHcu5JpHbarfHZCN9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