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

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 +39 -5
  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
@@ -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/cjs/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";
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * tsParticles Engine v4.0.0-alpha.26
2
+ * tsParticles Engine v4.0.0-alpha.28
3
3
  * Author: Matteo Bruni
4
4
  * MIT license: https://opensource.org/licenses/MIT
5
5
  * Website: https://particles.js.org/
@@ -25,7 +25,7 @@
25
25
  \*************************************/
26
26
  (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
27
27
 
28
- eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Canvas: () => (/* binding */ Canvas)\n/* harmony export */ });\n/* harmony import */ var _Utils_CanvasUtils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Utils/CanvasUtils.js */ \"./dist/browser/Utils/CanvasUtils.js\");\n/* harmony import */ var _Utils_Utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Utils/Utils.js */ \"./dist/browser/Utils/Utils.js\");\n/* harmony import */ var _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Utils/Constants.js */ \"./dist/browser/Core/Utils/Constants.js\");\n/* harmony import */ var _Utils_ColorUtils_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Utils/ColorUtils.js */ \"./dist/browser/Utils/ColorUtils.js\");\n\n\n\n\nconst fColorIndex = 0, sColorIndex = 1;\nfunction setTransformValue(factor, newFactor, key) {\n const newValue = newFactor[key];\n if (newValue !== undefined) {\n factor[key] = (factor[key] ?? _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_2__.defaultTransformValue) * newValue;\n }\n}\nfunction setStyle(canvas, style, important = false) {\n if (!style) {\n return;\n }\n const element = canvas, elementStyle = element.style, keys = new Set();\n for(let i = 0; i < elementStyle.length; i++){\n const key = elementStyle.item(i);\n if (!key) {\n continue;\n }\n keys.add(key);\n }\n for(let i = 0; i < style.length; i++){\n const key = style.item(i);\n if (!key) {\n continue;\n }\n keys.add(key);\n }\n for (const key of keys){\n const value = style.getPropertyValue(key);\n if (value) {\n elementStyle.setProperty(key, value, important ? \"important\" : \"\");\n } else {\n elementStyle.removeProperty(key);\n }\n }\n}\nclass Canvas {\n container;\n element;\n size;\n zoom = _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_2__.defaultZoom;\n _canvasClearPlugins;\n _canvasPaintPlugins;\n _canvasSettings;\n _clearDrawPlugins;\n _colorPlugins;\n _context;\n _drawParticlePlugins;\n _drawParticlesCleanupPlugins;\n _drawParticlesSetupPlugins;\n _drawPlugins;\n _drawSettingsCleanupPlugins;\n _drawSettingsSetupPlugins;\n _engine;\n _generated;\n _mutationObserver;\n _originalStyle;\n _pointerEvents;\n _postDrawUpdaters;\n _preDrawUpdaters;\n _resizePlugins;\n _reusableColorStyles = {};\n _reusablePluginColors = [\n undefined,\n undefined\n ];\n _reusableTransform = {};\n _standardSize;\n _zoomCenter;\n constructor(container, engine){\n this.container = container;\n this._engine = engine;\n this._standardSize = {\n height: 0,\n width: 0\n };\n const pxRatio = container.retina.pixelRatio, stdSize = this._standardSize;\n this.size = {\n height: stdSize.height * pxRatio,\n width: stdSize.width * pxRatio\n };\n this._context = null;\n this._generated = false;\n this._preDrawUpdaters = [];\n this._postDrawUpdaters = [];\n this._resizePlugins = [];\n this._colorPlugins = [];\n this._canvasClearPlugins = [];\n this._canvasPaintPlugins = [];\n this._clearDrawPlugins = [];\n this._drawParticlePlugins = [];\n this._drawParticlesCleanupPlugins = [];\n this._drawParticlesSetupPlugins = [];\n this._drawPlugins = [];\n this._drawSettingsSetupPlugins = [];\n this._drawSettingsCleanupPlugins = [];\n this._pointerEvents = \"none\";\n }\n get settings() {\n return this._canvasSettings;\n }\n get _fullScreen() {\n return this.container.actualOptions.fullScreen.enable;\n }\n canvasClear() {\n if (!this.container.actualOptions.clear) {\n return;\n }\n this.draw((ctx)=>{\n (0,_Utils_CanvasUtils_js__WEBPACK_IMPORTED_MODULE_0__.clear)(ctx, this.size);\n });\n }\n clear() {\n let pluginHandled = false;\n for (const plugin of this._canvasClearPlugins){\n pluginHandled = plugin.canvasClear?.() ?? false;\n if (pluginHandled) {\n break;\n }\n }\n if (pluginHandled) {\n return;\n }\n this.canvasClear();\n }\n destroy() {\n this.stop();\n if (this._generated) {\n const element = this.element;\n element?.remove();\n this.element = undefined;\n } else {\n this._resetOriginalStyle();\n }\n this._preDrawUpdaters = [];\n this._postDrawUpdaters = [];\n this._resizePlugins = [];\n this._colorPlugins = [];\n this._canvasClearPlugins = [];\n this._canvasPaintPlugins = [];\n this._clearDrawPlugins = [];\n this._drawParticlePlugins = [];\n this._drawParticlesCleanupPlugins = [];\n this._drawParticlesSetupPlugins = [];\n this._drawPlugins = [];\n this._drawSettingsSetupPlugins = [];\n this._drawSettingsCleanupPlugins = [];\n }\n draw(cb) {\n const ctx = this._context;\n if (!ctx) {\n return;\n }\n return cb(ctx);\n }\n drawParticle(particle, delta) {\n if (particle.spawning || particle.destroyed) {\n return;\n }\n const radius = particle.getRadius();\n if (radius <= _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_2__.minimumSize) {\n return;\n }\n const pfColor = particle.getFillColor(), psColor = particle.getStrokeColor() ?? pfColor;\n let [fColor, sColor] = this._getPluginParticleColors(particle);\n fColor ??= pfColor;\n sColor ??= psColor;\n if (!fColor && !sColor) {\n return;\n }\n const container = this.container, zIndexOptions = particle.options.zIndex, zIndexFactor = _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_2__.zIndexFactorOffset - particle.zIndexFactor, { opacity, strokeOpacity } = particle.getOpacity(), transform = this._reusableTransform, colorStyles = this._reusableColorStyles, fill = fColor ? (0,_Utils_ColorUtils_js__WEBPACK_IMPORTED_MODULE_3__.getStyleFromHsl)(fColor, container.hdr, opacity) : undefined, stroke = sColor ? (0,_Utils_ColorUtils_js__WEBPACK_IMPORTED_MODULE_3__.getStyleFromHsl)(sColor, container.hdr, strokeOpacity) : fill;\n transform.a = transform.b = transform.c = transform.d = undefined;\n colorStyles.fill = fill;\n colorStyles.stroke = stroke;\n this.draw((context)=>{\n for (const plugin of this._drawParticlesSetupPlugins){\n plugin.drawParticleSetup?.(context, particle, delta);\n }\n this._applyPreDrawUpdaters(context, particle, radius, opacity, colorStyles, transform);\n (0,_Utils_CanvasUtils_js__WEBPACK_IMPORTED_MODULE_0__.drawParticle)({\n container,\n context,\n particle,\n delta,\n colorStyles,\n radius: radius * zIndexFactor ** zIndexOptions.sizeRate,\n opacity: opacity,\n transform\n });\n this._applyPostDrawUpdaters(particle);\n for (const plugin of this._drawParticlesCleanupPlugins){\n plugin.drawParticleCleanup?.(context, particle, delta);\n }\n });\n }\n drawParticlePlugins(particle, delta) {\n this.draw((ctx)=>{\n for (const plugin of this._drawParticlePlugins){\n (0,_Utils_CanvasUtils_js__WEBPACK_IMPORTED_MODULE_0__.drawParticlePlugin)(ctx, plugin, particle, delta);\n }\n });\n }\n drawParticles(delta) {\n const { particles } = this.container;\n this.clear();\n particles.update(delta);\n this.draw((ctx)=>{\n for (const plugin of this._drawSettingsSetupPlugins){\n plugin.drawSettingsSetup?.(ctx, delta);\n }\n for (const plugin of this._drawPlugins){\n plugin.draw?.(ctx, delta);\n }\n particles.drawParticles(delta);\n for (const plugin of this._clearDrawPlugins){\n plugin.clearDraw?.(ctx, delta);\n }\n for (const plugin of this._drawSettingsCleanupPlugins){\n plugin.drawSettingsCleanup?.(ctx, delta);\n }\n });\n }\n getZoomCenter() {\n const pxRatio = this.container.retina.pixelRatio, { width, height } = this.size;\n if (this._zoomCenter) {\n return this._zoomCenter;\n }\n return {\n x: width * _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_2__.half / pxRatio,\n y: height * _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_2__.half / pxRatio\n };\n }\n init() {\n this._safeMutationObserver((obs)=>{\n obs.disconnect();\n });\n this._mutationObserver = (0,_Utils_Utils_js__WEBPACK_IMPORTED_MODULE_1__.safeMutationObserver)((records)=>{\n for (const record of records){\n if (record.type === \"attributes\" && record.attributeName === \"style\") {\n this._repairStyle();\n }\n }\n });\n this.resize();\n this._initStyle();\n this.initBackground();\n this._safeMutationObserver((obs)=>{\n if (!this.element || !(this.element instanceof Node)) {\n return;\n }\n obs.observe(this.element, {\n attributes: true\n });\n });\n this.initUpdaters();\n this.initPlugins();\n this.paint();\n }\n initBackground() {\n const { container } = this, options = container.actualOptions, background = options.background, element = this.element;\n if (!element) {\n return;\n }\n const elementStyle = element.style, color = (0,_Utils_ColorUtils_js__WEBPACK_IMPORTED_MODULE_3__.rangeColorToRgb)(this._engine, background.color);\n if (color) {\n elementStyle.backgroundColor = (0,_Utils_ColorUtils_js__WEBPACK_IMPORTED_MODULE_3__.getStyleFromRgb)(color, container.hdr, background.opacity);\n } else {\n elementStyle.backgroundColor = \"\";\n }\n elementStyle.backgroundImage = background.image || \"\";\n elementStyle.backgroundPosition = background.position || \"\";\n elementStyle.backgroundRepeat = background.repeat || \"\";\n elementStyle.backgroundSize = background.size || \"\";\n }\n initPlugins() {\n this._resizePlugins = [];\n this._colorPlugins = [];\n this._canvasClearPlugins = [];\n this._canvasPaintPlugins = [];\n this._clearDrawPlugins = [];\n this._drawParticlePlugins = [];\n this._drawParticlesSetupPlugins = [];\n this._drawParticlesCleanupPlugins = [];\n this._drawPlugins = [];\n this._drawSettingsSetupPlugins = [];\n this._drawSettingsCleanupPlugins = [];\n for (const plugin of this.container.plugins){\n if (plugin.resize) {\n this._resizePlugins.push(plugin);\n }\n if (plugin.particleFillColor ?? plugin.particleStrokeColor) {\n this._colorPlugins.push(plugin);\n }\n if (plugin.canvasClear) {\n this._canvasClearPlugins.push(plugin);\n }\n if (plugin.canvasPaint) {\n this._canvasPaintPlugins.push(plugin);\n }\n if (plugin.drawParticle) {\n this._drawParticlePlugins.push(plugin);\n }\n if (plugin.drawParticleSetup) {\n this._drawParticlesSetupPlugins.push(plugin);\n }\n if (plugin.drawParticleCleanup) {\n this._drawParticlesCleanupPlugins.push(plugin);\n }\n if (plugin.draw) {\n this._drawPlugins.push(plugin);\n }\n if (plugin.drawSettingsSetup) {\n this._drawSettingsSetupPlugins.push(plugin);\n }\n if (plugin.drawSettingsCleanup) {\n this._drawSettingsCleanupPlugins.push(plugin);\n }\n if (plugin.clearDraw) {\n this._clearDrawPlugins.push(plugin);\n }\n }\n }\n initUpdaters() {\n this._preDrawUpdaters = [];\n this._postDrawUpdaters = [];\n for (const updater of this.container.particles.updaters){\n if (updater.afterDraw) {\n this._postDrawUpdaters.push(updater);\n }\n if (updater.getColorStyles ?? updater.getTransformValues ?? updater.beforeDraw) {\n this._preDrawUpdaters.push(updater);\n }\n }\n }\n loadCanvas(canvas) {\n if (this._generated && this.element) {\n this.element.remove();\n }\n const container = this.container;\n this._generated = _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_2__.generatedAttribute in canvas.dataset ? canvas.dataset[_Utils_Constants_js__WEBPACK_IMPORTED_MODULE_2__.generatedAttribute] === \"true\" : this._generated;\n this.element = canvas;\n this.element.ariaHidden = \"true\";\n this._originalStyle = (0,_Utils_Utils_js__WEBPACK_IMPORTED_MODULE_1__.cloneStyle)(this.element.style);\n const standardSize = this._standardSize;\n standardSize.height = canvas.offsetHeight;\n standardSize.width = canvas.offsetWidth;\n const pxRatio = this.container.retina.pixelRatio, retinaSize = this.size;\n canvas.height = retinaSize.height = standardSize.height * pxRatio;\n canvas.width = retinaSize.width = standardSize.width * pxRatio;\n const canSupportHdrQuery = (0,_Utils_Utils_js__WEBPACK_IMPORTED_MODULE_1__.safeMatchMedia)(\"(color-gamut: p3)\");\n this._canvasSettings = {\n alpha: true,\n colorSpace: canSupportHdrQuery?.matches && container.hdr ? \"display-p3\" : \"srgb\",\n desynchronized: true,\n willReadFrequently: false\n };\n this._context = this.element.getContext(\"2d\", this._canvasSettings);\n this._safeMutationObserver((obs)=>{\n obs.disconnect();\n });\n container.retina.init();\n this.initBackground();\n this._safeMutationObserver((obs)=>{\n if (!this.element || !(this.element instanceof Node)) {\n return;\n }\n obs.observe(this.element, {\n attributes: true\n });\n });\n }\n paint() {\n let handled = false;\n for (const plugin of this._canvasPaintPlugins){\n handled = plugin.canvasPaint?.() ?? false;\n if (handled) {\n break;\n }\n }\n if (handled) {\n return;\n }\n this.paintBase();\n }\n paintBase(baseColor) {\n this.draw((ctx)=>{\n (0,_Utils_CanvasUtils_js__WEBPACK_IMPORTED_MODULE_0__.paintBase)(ctx, this.size, baseColor);\n });\n }\n paintImage(image, opacity) {\n this.draw((ctx)=>{\n (0,_Utils_CanvasUtils_js__WEBPACK_IMPORTED_MODULE_0__.paintImage)(ctx, this.size, image, opacity);\n });\n }\n resize() {\n if (!this.element) {\n return false;\n }\n const container = this.container, currentSize = container.canvas._standardSize, newSize = {\n width: this.element.offsetWidth,\n height: this.element.offsetHeight\n }, pxRatio = container.retina.pixelRatio, retinaSize = {\n width: newSize.width * pxRatio,\n height: newSize.height * pxRatio\n };\n if (newSize.height === currentSize.height && newSize.width === currentSize.width && retinaSize.height === this.element.height && retinaSize.width === this.element.width) {\n return false;\n }\n const oldSize = {\n ...currentSize\n };\n currentSize.height = newSize.height;\n currentSize.width = newSize.width;\n const canvasSize = this.size;\n this.element.width = canvasSize.width = retinaSize.width;\n this.element.height = canvasSize.height = retinaSize.height;\n if (this.container.started) {\n container.particles.setResizeFactor({\n width: currentSize.width / oldSize.width,\n height: currentSize.height / oldSize.height\n });\n }\n return true;\n }\n setPointerEvents(type) {\n const element = this.element;\n if (!element) {\n return;\n }\n this._pointerEvents = type;\n this._repairStyle();\n }\n setZoom(zoomLevel, center) {\n this.zoom = zoomLevel;\n this._zoomCenter = center;\n }\n stop() {\n this._safeMutationObserver((obs)=>{\n obs.disconnect();\n });\n this._mutationObserver = undefined;\n this.draw((ctx)=>{\n (0,_Utils_CanvasUtils_js__WEBPACK_IMPORTED_MODULE_0__.clear)(ctx, this.size);\n });\n }\n async windowResize() {\n if (!this.element || !this.resize()) {\n return;\n }\n const container = this.container, needsRefresh = container.updateActualOptions();\n container.particles.setDensity();\n this._applyResizePlugins();\n if (needsRefresh) {\n await container.refresh();\n }\n }\n _applyPostDrawUpdaters = (particle)=>{\n for (const updater of this._postDrawUpdaters){\n updater.afterDraw?.(particle);\n }\n };\n _applyPreDrawUpdaters = (ctx, particle, radius, zOpacity, colorStyles, transform)=>{\n for (const updater of this._preDrawUpdaters){\n if (updater.getColorStyles) {\n const { fill, stroke } = updater.getColorStyles(particle, ctx, radius, zOpacity);\n if (fill) {\n colorStyles.fill = fill;\n }\n if (stroke) {\n colorStyles.stroke = stroke;\n }\n }\n if (updater.getTransformValues) {\n const updaterTransform = updater.getTransformValues(particle);\n for(const key in updaterTransform){\n setTransformValue(transform, updaterTransform, key);\n }\n }\n updater.beforeDraw?.(particle);\n }\n };\n _applyResizePlugins = ()=>{\n for (const plugin of this._resizePlugins){\n plugin.resize?.();\n }\n };\n _getPluginParticleColors = (particle)=>{\n let fColor, sColor;\n for (const plugin of this._colorPlugins){\n if (!fColor && plugin.particleFillColor) {\n fColor = (0,_Utils_ColorUtils_js__WEBPACK_IMPORTED_MODULE_3__.rangeColorToHsl)(this._engine, plugin.particleFillColor(particle));\n }\n if (!sColor && plugin.particleStrokeColor) {\n sColor = (0,_Utils_ColorUtils_js__WEBPACK_IMPORTED_MODULE_3__.rangeColorToHsl)(this._engine, plugin.particleStrokeColor(particle));\n }\n if (fColor && sColor) {\n break;\n }\n }\n this._reusablePluginColors[fColorIndex] = fColor;\n this._reusablePluginColors[sColorIndex] = sColor;\n return this._reusablePluginColors;\n };\n _initStyle = ()=>{\n const element = this.element, options = this.container.actualOptions;\n if (!element) {\n return;\n }\n if (this._fullScreen) {\n this._setFullScreenStyle();\n } else {\n this._resetOriginalStyle();\n }\n for(const key in options.style){\n if (!key || !Object.hasOwn(options.style, key)) {\n continue;\n }\n const value = options.style[key];\n if (!value) {\n continue;\n }\n element.style.setProperty(key, value, \"important\");\n }\n };\n _repairStyle = ()=>{\n const element = this.element;\n if (!element) {\n return;\n }\n this._safeMutationObserver((observer)=>{\n observer.disconnect();\n });\n this._initStyle();\n this.initBackground();\n const pointerEvents = this._pointerEvents;\n element.style.pointerEvents = pointerEvents;\n element.setAttribute(\"pointer-events\", pointerEvents);\n this._safeMutationObserver((observer)=>{\n if (!(element instanceof Node)) {\n return;\n }\n observer.observe(element, {\n attributes: true\n });\n });\n };\n _resetOriginalStyle = ()=>{\n const element = this.element, originalStyle = this._originalStyle;\n if (!element || !originalStyle) {\n return;\n }\n setStyle(element, originalStyle, true);\n };\n _safeMutationObserver = (callback)=>{\n if (!this._mutationObserver) {\n return;\n }\n callback(this._mutationObserver);\n };\n _setFullScreenStyle = ()=>{\n const element = this.element;\n if (!element) {\n return;\n }\n setStyle(element, (0,_Utils_Utils_js__WEBPACK_IMPORTED_MODULE_1__.getFullScreenStyle)(this.container.actualOptions.fullScreen.zIndex), true);\n };\n}\n\n\n//# sourceURL=webpack://@tsparticles/engine/./dist/browser/Core/Canvas.js?\n}");
28
+ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Canvas: () => (/* binding */ Canvas)\n/* harmony export */ });\n/* harmony import */ var _Utils_CanvasUtils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Utils/CanvasUtils.js */ \"./dist/browser/Utils/CanvasUtils.js\");\n/* harmony import */ var _Utils_Utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Utils/Utils.js */ \"./dist/browser/Utils/Utils.js\");\n/* harmony import */ var _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Utils/Constants.js */ \"./dist/browser/Core/Utils/Constants.js\");\n/* harmony import */ var _Utils_ColorUtils_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Utils/ColorUtils.js */ \"./dist/browser/Utils/ColorUtils.js\");\n\n\n\n\nconst fColorIndex = 0, sColorIndex = 1;\nfunction setTransformValue(factor, newFactor, key) {\n const newValue = newFactor[key];\n if (newValue !== undefined) {\n factor[key] = (factor[key] ?? _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_2__.defaultTransformValue) * newValue;\n }\n}\nfunction setStyle(canvas, style, important = false) {\n if (!style) {\n return;\n }\n const element = canvas, elementStyle = element.style, keys = new Set();\n for(let i = 0; i < elementStyle.length; i++){\n const key = elementStyle.item(i);\n if (!key) {\n continue;\n }\n keys.add(key);\n }\n for(let i = 0; i < style.length; i++){\n const key = style.item(i);\n if (!key) {\n continue;\n }\n keys.add(key);\n }\n for (const key of keys){\n const value = style.getPropertyValue(key);\n if (value) {\n elementStyle.setProperty(key, value, important ? \"important\" : \"\");\n } else {\n elementStyle.removeProperty(key);\n }\n }\n}\nclass Canvas {\n container;\n element;\n size;\n zoom = _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_2__.defaultZoom;\n _canvasClearPlugins;\n _canvasPaintPlugins;\n _canvasSettings;\n _clearDrawPlugins;\n _colorPlugins;\n _context;\n _drawParticlePlugins;\n _drawParticlesCleanupPlugins;\n _drawParticlesSetupPlugins;\n _drawPlugins;\n _drawSettingsCleanupPlugins;\n _drawSettingsSetupPlugins;\n _engine;\n _generated;\n _mutationObserver;\n _originalStyle;\n _pointerEvents;\n _postDrawUpdaters;\n _preDrawUpdaters;\n _resizePlugins;\n _reusableColorStyles = {};\n _reusablePluginColors = [\n undefined,\n undefined\n ];\n _reusableTransform = {};\n _standardSize;\n _zoomCenter;\n constructor(container, engine){\n this.container = container;\n this._engine = engine;\n this._standardSize = {\n height: 0,\n width: 0\n };\n const pxRatio = container.retina.pixelRatio, stdSize = this._standardSize;\n this.size = {\n height: stdSize.height * pxRatio,\n width: stdSize.width * pxRatio\n };\n this._context = null;\n this._generated = false;\n this._preDrawUpdaters = [];\n this._postDrawUpdaters = [];\n this._resizePlugins = [];\n this._colorPlugins = [];\n this._canvasClearPlugins = [];\n this._canvasPaintPlugins = [];\n this._clearDrawPlugins = [];\n this._drawParticlePlugins = [];\n this._drawParticlesCleanupPlugins = [];\n this._drawParticlesSetupPlugins = [];\n this._drawPlugins = [];\n this._drawSettingsSetupPlugins = [];\n this._drawSettingsCleanupPlugins = [];\n this._pointerEvents = \"none\";\n }\n get settings() {\n return this._canvasSettings;\n }\n get _fullScreen() {\n return this.container.actualOptions.fullScreen.enable;\n }\n canvasClear() {\n if (!this.container.actualOptions.clear) {\n return;\n }\n this.draw((ctx)=>{\n (0,_Utils_CanvasUtils_js__WEBPACK_IMPORTED_MODULE_0__.clear)(ctx, this.size);\n });\n }\n clear() {\n let pluginHandled = false;\n for (const plugin of this._canvasClearPlugins){\n pluginHandled = plugin.canvasClear?.() ?? false;\n if (pluginHandled) {\n break;\n }\n }\n if (pluginHandled) {\n return;\n }\n this.canvasClear();\n }\n destroy() {\n this.stop();\n if (this._generated) {\n const element = this.element;\n element?.remove();\n this.element = undefined;\n } else {\n this._resetOriginalStyle();\n }\n this._preDrawUpdaters = [];\n this._postDrawUpdaters = [];\n this._resizePlugins = [];\n this._colorPlugins = [];\n this._canvasClearPlugins = [];\n this._canvasPaintPlugins = [];\n this._clearDrawPlugins = [];\n this._drawParticlePlugins = [];\n this._drawParticlesCleanupPlugins = [];\n this._drawParticlesSetupPlugins = [];\n this._drawPlugins = [];\n this._drawSettingsSetupPlugins = [];\n this._drawSettingsCleanupPlugins = [];\n }\n draw(cb) {\n const ctx = this._context;\n if (!ctx) {\n return;\n }\n return cb(ctx);\n }\n drawParticle(particle, delta) {\n if (particle.spawning || particle.destroyed) {\n return;\n }\n const radius = particle.getRadius();\n if (radius <= _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_2__.minimumSize) {\n return;\n }\n const pfColor = particle.getFillColor(), psColor = particle.getStrokeColor();\n let [fColor, sColor] = this._getPluginParticleColors(particle);\n fColor ??= pfColor;\n sColor ??= psColor;\n if (!fColor && !sColor) {\n return;\n }\n const container = this.container, zIndexOptions = particle.options.zIndex, zIndexFactor = _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_2__.zIndexFactorOffset - particle.zIndexFactor, { fillOpacity, opacity, strokeOpacity } = particle.getOpacity(), transform = this._reusableTransform, colorStyles = this._reusableColorStyles, fill = fColor ? (0,_Utils_ColorUtils_js__WEBPACK_IMPORTED_MODULE_3__.getStyleFromHsl)(fColor, container.hdr, fillOpacity * opacity) : undefined, stroke = sColor ? (0,_Utils_ColorUtils_js__WEBPACK_IMPORTED_MODULE_3__.getStyleFromHsl)(sColor, container.hdr, strokeOpacity * opacity) : fill;\n transform.a = transform.b = transform.c = transform.d = undefined;\n colorStyles.fill = fill;\n colorStyles.stroke = stroke;\n this.draw((context)=>{\n for (const plugin of this._drawParticlesSetupPlugins){\n plugin.drawParticleSetup?.(context, particle, delta);\n }\n this._applyPreDrawUpdaters(context, particle, radius, opacity, colorStyles, transform);\n (0,_Utils_CanvasUtils_js__WEBPACK_IMPORTED_MODULE_0__.drawParticle)({\n container,\n context,\n particle,\n delta,\n colorStyles,\n radius: radius * zIndexFactor ** zIndexOptions.sizeRate,\n opacity: opacity,\n transform\n });\n this._applyPostDrawUpdaters(particle);\n for (const plugin of this._drawParticlesCleanupPlugins){\n plugin.drawParticleCleanup?.(context, particle, delta);\n }\n });\n }\n drawParticlePlugins(particle, delta) {\n this.draw((ctx)=>{\n for (const plugin of this._drawParticlePlugins){\n (0,_Utils_CanvasUtils_js__WEBPACK_IMPORTED_MODULE_0__.drawParticlePlugin)(ctx, plugin, particle, delta);\n }\n });\n }\n drawParticles(delta) {\n const { particles } = this.container;\n this.clear();\n particles.update(delta);\n this.draw((ctx)=>{\n for (const plugin of this._drawSettingsSetupPlugins){\n plugin.drawSettingsSetup?.(ctx, delta);\n }\n for (const plugin of this._drawPlugins){\n plugin.draw?.(ctx, delta);\n }\n particles.drawParticles(delta);\n for (const plugin of this._clearDrawPlugins){\n plugin.clearDraw?.(ctx, delta);\n }\n for (const plugin of this._drawSettingsCleanupPlugins){\n plugin.drawSettingsCleanup?.(ctx, delta);\n }\n });\n }\n getZoomCenter() {\n const pxRatio = this.container.retina.pixelRatio, { width, height } = this.size;\n if (this._zoomCenter) {\n return this._zoomCenter;\n }\n return {\n x: width * _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_2__.half / pxRatio,\n y: height * _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_2__.half / pxRatio\n };\n }\n init() {\n this._safeMutationObserver((obs)=>{\n obs.disconnect();\n });\n this._mutationObserver = (0,_Utils_Utils_js__WEBPACK_IMPORTED_MODULE_1__.safeMutationObserver)((records)=>{\n for (const record of records){\n if (record.type === \"attributes\" && record.attributeName === \"style\") {\n this._repairStyle();\n }\n }\n });\n this.resize();\n this._initStyle();\n this.initBackground();\n this._safeMutationObserver((obs)=>{\n if (!this.element || !(this.element instanceof Node)) {\n return;\n }\n obs.observe(this.element, {\n attributes: true\n });\n });\n this.initUpdaters();\n this.initPlugins();\n this.paint();\n }\n initBackground() {\n const { container } = this, options = container.actualOptions, background = options.background, element = this.element;\n if (!element) {\n return;\n }\n const elementStyle = element.style, color = (0,_Utils_ColorUtils_js__WEBPACK_IMPORTED_MODULE_3__.rangeColorToRgb)(this._engine, background.color);\n if (color) {\n elementStyle.backgroundColor = (0,_Utils_ColorUtils_js__WEBPACK_IMPORTED_MODULE_3__.getStyleFromRgb)(color, container.hdr, background.opacity);\n } else {\n elementStyle.backgroundColor = \"\";\n }\n elementStyle.backgroundImage = background.image || \"\";\n elementStyle.backgroundPosition = background.position || \"\";\n elementStyle.backgroundRepeat = background.repeat || \"\";\n elementStyle.backgroundSize = background.size || \"\";\n }\n initPlugins() {\n this._resizePlugins = [];\n this._colorPlugins = [];\n this._canvasClearPlugins = [];\n this._canvasPaintPlugins = [];\n this._clearDrawPlugins = [];\n this._drawParticlePlugins = [];\n this._drawParticlesSetupPlugins = [];\n this._drawParticlesCleanupPlugins = [];\n this._drawPlugins = [];\n this._drawSettingsSetupPlugins = [];\n this._drawSettingsCleanupPlugins = [];\n for (const plugin of this.container.plugins){\n if (plugin.resize) {\n this._resizePlugins.push(plugin);\n }\n if (plugin.particleFillColor ?? plugin.particleStrokeColor) {\n this._colorPlugins.push(plugin);\n }\n if (plugin.canvasClear) {\n this._canvasClearPlugins.push(plugin);\n }\n if (plugin.canvasPaint) {\n this._canvasPaintPlugins.push(plugin);\n }\n if (plugin.drawParticle) {\n this._drawParticlePlugins.push(plugin);\n }\n if (plugin.drawParticleSetup) {\n this._drawParticlesSetupPlugins.push(plugin);\n }\n if (plugin.drawParticleCleanup) {\n this._drawParticlesCleanupPlugins.push(plugin);\n }\n if (plugin.draw) {\n this._drawPlugins.push(plugin);\n }\n if (plugin.drawSettingsSetup) {\n this._drawSettingsSetupPlugins.push(plugin);\n }\n if (plugin.drawSettingsCleanup) {\n this._drawSettingsCleanupPlugins.push(plugin);\n }\n if (plugin.clearDraw) {\n this._clearDrawPlugins.push(plugin);\n }\n }\n }\n initUpdaters() {\n this._preDrawUpdaters = [];\n this._postDrawUpdaters = [];\n for (const updater of this.container.particles.updaters){\n if (updater.afterDraw) {\n this._postDrawUpdaters.push(updater);\n }\n if (updater.getColorStyles ?? updater.getTransformValues ?? updater.beforeDraw) {\n this._preDrawUpdaters.push(updater);\n }\n }\n }\n loadCanvas(canvas) {\n if (this._generated && this.element) {\n this.element.remove();\n }\n const container = this.container;\n this._generated = _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_2__.generatedAttribute in canvas.dataset ? canvas.dataset[_Utils_Constants_js__WEBPACK_IMPORTED_MODULE_2__.generatedAttribute] === \"true\" : this._generated;\n this.element = canvas;\n this.element.ariaHidden = \"true\";\n this._originalStyle = (0,_Utils_Utils_js__WEBPACK_IMPORTED_MODULE_1__.cloneStyle)(this.element.style);\n const standardSize = this._standardSize;\n standardSize.height = canvas.offsetHeight;\n standardSize.width = canvas.offsetWidth;\n const pxRatio = this.container.retina.pixelRatio, retinaSize = this.size;\n canvas.height = retinaSize.height = standardSize.height * pxRatio;\n canvas.width = retinaSize.width = standardSize.width * pxRatio;\n const canSupportHdrQuery = (0,_Utils_Utils_js__WEBPACK_IMPORTED_MODULE_1__.safeMatchMedia)(\"(color-gamut: p3)\");\n this._canvasSettings = {\n alpha: true,\n colorSpace: canSupportHdrQuery?.matches && container.hdr ? \"display-p3\" : \"srgb\",\n desynchronized: true,\n willReadFrequently: false\n };\n this._context = this.element.getContext(\"2d\", this._canvasSettings);\n if (this._context) {\n this._context.globalCompositeOperation = _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_2__.defaultCompositeValue;\n }\n this._safeMutationObserver((obs)=>{\n obs.disconnect();\n });\n container.retina.init();\n this.initBackground();\n this._safeMutationObserver((obs)=>{\n if (!this.element || !(this.element instanceof Node)) {\n return;\n }\n obs.observe(this.element, {\n attributes: true\n });\n });\n }\n paint() {\n let handled = false;\n for (const plugin of this._canvasPaintPlugins){\n handled = plugin.canvasPaint?.() ?? false;\n if (handled) {\n break;\n }\n }\n if (handled) {\n return;\n }\n this.paintBase();\n }\n paintBase(baseColor) {\n this.draw((ctx)=>{\n (0,_Utils_CanvasUtils_js__WEBPACK_IMPORTED_MODULE_0__.paintBase)(ctx, this.size, baseColor);\n });\n }\n paintImage(image, opacity) {\n this.draw((ctx)=>{\n (0,_Utils_CanvasUtils_js__WEBPACK_IMPORTED_MODULE_0__.paintImage)(ctx, this.size, image, opacity);\n });\n }\n resize() {\n if (!this.element) {\n return false;\n }\n const container = this.container, currentSize = container.canvas._standardSize, newSize = {\n width: this.element.offsetWidth,\n height: this.element.offsetHeight\n }, pxRatio = container.retina.pixelRatio, retinaSize = {\n width: newSize.width * pxRatio,\n height: newSize.height * pxRatio\n };\n if (newSize.height === currentSize.height && newSize.width === currentSize.width && retinaSize.height === this.element.height && retinaSize.width === this.element.width) {\n return false;\n }\n const oldSize = {\n ...currentSize\n };\n currentSize.height = newSize.height;\n currentSize.width = newSize.width;\n const canvasSize = this.size;\n this.element.width = canvasSize.width = retinaSize.width;\n this.element.height = canvasSize.height = retinaSize.height;\n if (this.container.started) {\n container.particles.setResizeFactor({\n width: currentSize.width / oldSize.width,\n height: currentSize.height / oldSize.height\n });\n }\n return true;\n }\n setPointerEvents(type) {\n const element = this.element;\n if (!element) {\n return;\n }\n this._pointerEvents = type;\n this._repairStyle();\n }\n setZoom(zoomLevel, center) {\n this.zoom = zoomLevel;\n this._zoomCenter = center;\n }\n stop() {\n this._safeMutationObserver((obs)=>{\n obs.disconnect();\n });\n this._mutationObserver = undefined;\n this.draw((ctx)=>{\n (0,_Utils_CanvasUtils_js__WEBPACK_IMPORTED_MODULE_0__.clear)(ctx, this.size);\n });\n }\n async windowResize() {\n if (!this.element || !this.resize()) {\n return;\n }\n const container = this.container, needsRefresh = container.updateActualOptions();\n container.particles.setDensity();\n this._applyResizePlugins();\n if (needsRefresh) {\n await container.refresh();\n }\n }\n _applyPostDrawUpdaters = (particle)=>{\n for (const updater of this._postDrawUpdaters){\n updater.afterDraw?.(particle);\n }\n };\n _applyPreDrawUpdaters = (ctx, particle, radius, zOpacity, colorStyles, transform)=>{\n for (const updater of this._preDrawUpdaters){\n if (updater.getColorStyles) {\n const { fill, stroke } = updater.getColorStyles(particle, ctx, radius, zOpacity);\n if (fill) {\n colorStyles.fill = fill;\n }\n if (stroke) {\n colorStyles.stroke = stroke;\n }\n }\n if (updater.getTransformValues) {\n const updaterTransform = updater.getTransformValues(particle);\n for(const key in updaterTransform){\n setTransformValue(transform, updaterTransform, key);\n }\n }\n updater.beforeDraw?.(particle);\n }\n };\n _applyResizePlugins = ()=>{\n for (const plugin of this._resizePlugins){\n plugin.resize?.();\n }\n };\n _getPluginParticleColors = (particle)=>{\n let fColor, sColor;\n for (const plugin of this._colorPlugins){\n if (!fColor && plugin.particleFillColor) {\n fColor = (0,_Utils_ColorUtils_js__WEBPACK_IMPORTED_MODULE_3__.rangeColorToHsl)(this._engine, plugin.particleFillColor(particle));\n }\n if (!sColor && plugin.particleStrokeColor) {\n sColor = (0,_Utils_ColorUtils_js__WEBPACK_IMPORTED_MODULE_3__.rangeColorToHsl)(this._engine, plugin.particleStrokeColor(particle));\n }\n if (fColor && sColor) {\n break;\n }\n }\n this._reusablePluginColors[fColorIndex] = fColor;\n this._reusablePluginColors[sColorIndex] = sColor;\n return this._reusablePluginColors;\n };\n _initStyle = ()=>{\n const element = this.element, options = this.container.actualOptions;\n if (!element) {\n return;\n }\n if (this._fullScreen) {\n this._setFullScreenStyle();\n } else {\n this._resetOriginalStyle();\n }\n for(const key in options.style){\n if (!key || !(key in options.style)) {\n continue;\n }\n const value = options.style[key];\n if (!value) {\n continue;\n }\n element.style.setProperty(key, value, \"important\");\n }\n };\n _repairStyle = ()=>{\n const element = this.element;\n if (!element) {\n return;\n }\n this._safeMutationObserver((observer)=>{\n observer.disconnect();\n });\n this._initStyle();\n this.initBackground();\n const pointerEvents = this._pointerEvents;\n element.style.pointerEvents = pointerEvents;\n element.setAttribute(\"pointer-events\", pointerEvents);\n this._safeMutationObserver((observer)=>{\n if (!(element instanceof Node)) {\n return;\n }\n observer.observe(element, {\n attributes: true\n });\n });\n };\n _resetOriginalStyle = ()=>{\n const element = this.element, originalStyle = this._originalStyle;\n if (!element || !originalStyle) {\n return;\n }\n setStyle(element, originalStyle, true);\n };\n _safeMutationObserver = (callback)=>{\n if (!this._mutationObserver) {\n return;\n }\n callback(this._mutationObserver);\n };\n _setFullScreenStyle = ()=>{\n const element = this.element;\n if (!element) {\n return;\n }\n setStyle(element, (0,_Utils_Utils_js__WEBPACK_IMPORTED_MODULE_1__.getFullScreenStyle)(this.container.actualOptions.fullScreen.zIndex), true);\n };\n}\n\n\n//# sourceURL=webpack://@tsparticles/engine/./dist/browser/Core/Canvas.js?\n}");
29
29
 
30
30
  /***/ },
31
31
 
@@ -45,7 +45,7 @@ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpa
45
45
  \***************************************/
46
46
  (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
47
47
 
48
- eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Particle: () => (/* binding */ Particle)\n/* harmony export */ });\n/* harmony import */ var _Utils_Vectors_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Utils/Vectors.js */ \"./dist/browser/Core/Utils/Vectors.js\");\n/* harmony import */ var _Utils_ColorUtils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Utils/ColorUtils.js */ \"./dist/browser/Utils/ColorUtils.js\");\n/* harmony import */ var _Utils_MathUtils_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Utils/MathUtils.js */ \"./dist/browser/Utils/MathUtils.js\");\n/* harmony import */ var _Utils_Utils_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Utils/Utils.js */ \"./dist/browser/Utils/Utils.js\");\n/* harmony import */ var _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Utils/Constants.js */ \"./dist/browser/Core/Utils/Constants.js\");\n/* harmony import */ var _Enums_Types_EventType_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Enums/Types/EventType.js */ \"./dist/browser/Enums/Types/EventType.js\");\n/* harmony import */ var _Enums_Directions_MoveDirection_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Enums/Directions/MoveDirection.js */ \"./dist/browser/Enums/Directions/MoveDirection.js\");\n/* harmony import */ var _Enums_Modes_OutMode_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Enums/Modes/OutMode.js */ \"./dist/browser/Enums/Modes/OutMode.js\");\n/* harmony import */ var _Enums_Types_ParticleOutType_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Enums/Types/ParticleOutType.js */ \"./dist/browser/Enums/Types/ParticleOutType.js\");\n/* harmony import */ var _Utils_OptionsUtils_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Utils/OptionsUtils.js */ \"./dist/browser/Utils/OptionsUtils.js\");\n\n\n\n\n\n\n\n\n\n\nfunction loadEffectData(effect, effectOptions, id, reduceDuplicates) {\n const effectData = effectOptions.options[effect];\n return (0,_Utils_Utils_js__WEBPACK_IMPORTED_MODULE_3__.deepExtend)({\n close: effectOptions.close,\n fill: effectOptions.fill\n }, (0,_Utils_Utils_js__WEBPACK_IMPORTED_MODULE_3__.itemFromSingleOrMultiple)(effectData, id, reduceDuplicates));\n}\nfunction loadShapeData(shape, shapeOptions, id, reduceDuplicates) {\n const shapeData = shapeOptions.options[shape];\n return (0,_Utils_Utils_js__WEBPACK_IMPORTED_MODULE_3__.deepExtend)({\n close: shapeOptions.close,\n fill: shapeOptions.fill\n }, (0,_Utils_Utils_js__WEBPACK_IMPORTED_MODULE_3__.itemFromSingleOrMultiple)(shapeData, id, reduceDuplicates));\n}\nfunction fixOutMode(data) {\n if (!(0,_Utils_Utils_js__WEBPACK_IMPORTED_MODULE_3__.isInArray)(data.outMode, data.checkModes)) {\n return;\n }\n const diameter = data.radius * _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.double;\n if (data.coord > data.maxCoord - diameter) {\n data.setCb(-data.radius);\n } else if (data.coord < diameter) {\n data.setCb(data.radius);\n }\n}\nclass Particle {\n container;\n backColor;\n bubble;\n color;\n destroyed;\n direction;\n effect;\n effectClose;\n effectData;\n effectFill;\n group;\n id;\n ignoresResizeRatio;\n initialPosition;\n initialVelocity;\n isRotating;\n lastPathTime;\n misplaced;\n moveCenter;\n offset;\n opacity;\n options;\n outType;\n pathRotation;\n position;\n randomIndexData;\n retina;\n roll;\n rotation;\n shape;\n shapeClose;\n shapeData;\n shapeFill;\n sides;\n size;\n slow;\n spawning;\n strokeColor;\n strokeOpacity;\n strokeWidth;\n unbreakable;\n velocity;\n zIndexFactor;\n _cachedOpacityData = {\n opacity: _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.defaultOpacity,\n strokeOpacity: _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.defaultOpacity\n };\n _cachedPosition = _Utils_Vectors_js__WEBPACK_IMPORTED_MODULE_0__.Vector3d.origin;\n _cachedRotateData = {\n sin: 0,\n cos: 0\n };\n _cachedTransform = {\n a: 1,\n b: 0,\n c: 0,\n d: 1\n };\n _engine;\n constructor(engine, container){\n this.container = container;\n this._engine = engine;\n }\n destroy(override) {\n if (this.unbreakable || this.destroyed) {\n return;\n }\n this.destroyed = true;\n this.bubble.inRange = false;\n this.slow.inRange = false;\n const container = this.container, shapeDrawer = this.shape ? container.particles.shapeDrawers.get(this.shape) : undefined;\n shapeDrawer?.particleDestroy?.(this);\n for (const plugin of container.particleDestroyedPlugins){\n plugin.particleDestroyed?.(this, override);\n }\n for (const updater of container.particles.updaters){\n updater.particleDestroyed?.(this, override);\n }\n this._engine.dispatchEvent(_Enums_Types_EventType_js__WEBPACK_IMPORTED_MODULE_5__.EventType.particleDestroyed, {\n container: this.container,\n data: {\n particle: this\n }\n });\n }\n draw(delta) {\n const container = this.container, canvas = container.canvas;\n canvas.drawParticlePlugins(this, delta);\n canvas.drawParticle(this, delta);\n }\n getAngle() {\n return this.rotation + (this.pathRotation ? this.velocity.angle : _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.defaultAngle);\n }\n getFillColor() {\n return this._getRollColor(this.bubble.color ?? (0,_Utils_ColorUtils_js__WEBPACK_IMPORTED_MODULE_1__.getHslFromAnimation)(this.color));\n }\n getMass() {\n return this.getRadius() ** _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.squareExp * Math.PI * _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.half;\n }\n getOpacity() {\n const zIndexOptions = this.options.zIndex, zIndexFactor = _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.zIndexFactorOffset - this.zIndexFactor, zOpacityFactor = zIndexFactor ** zIndexOptions.opacityRate, opacity = this.bubble.opacity ?? (0,_Utils_MathUtils_js__WEBPACK_IMPORTED_MODULE_2__.getRangeValue)(this.opacity?.value ?? _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.defaultOpacity), strokeOpacity = this.strokeOpacity ?? opacity;\n this._cachedOpacityData.opacity = opacity * zOpacityFactor;\n this._cachedOpacityData.strokeOpacity = strokeOpacity * zOpacityFactor;\n return this._cachedOpacityData;\n }\n getPosition() {\n this._cachedPosition.x = this.position.x + this.offset.x;\n this._cachedPosition.y = this.position.y + this.offset.y;\n this._cachedPosition.z = this.position.z;\n return this._cachedPosition;\n }\n getRadius() {\n return this.bubble.radius ?? this.size.value;\n }\n getRotateData() {\n const angle = this.getAngle();\n this._cachedRotateData.sin = Math.sin(angle);\n this._cachedRotateData.cos = Math.cos(angle);\n return this._cachedRotateData;\n }\n getStrokeColor() {\n return this._getRollColor(this.bubble.color ?? (0,_Utils_ColorUtils_js__WEBPACK_IMPORTED_MODULE_1__.getHslFromAnimation)(this.strokeColor));\n }\n getTransformData(externalTransform) {\n const rotateData = this.getRotateData(), rotating = this.isRotating;\n this._cachedTransform.a = rotateData.cos * (externalTransform.a ?? _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.defaultTransform.a);\n this._cachedTransform.b = rotating ? rotateData.sin * (externalTransform.b ?? _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.identity) : externalTransform.b ?? _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.defaultTransform.b;\n this._cachedTransform.c = rotating ? -rotateData.sin * (externalTransform.c ?? _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.identity) : externalTransform.c ?? _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.defaultTransform.c;\n this._cachedTransform.d = rotateData.cos * (externalTransform.d ?? _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.defaultTransform.d);\n return this._cachedTransform;\n }\n init(id, position, overrideOptions, group) {\n const container = this.container;\n this.id = id;\n this.group = group;\n this.effectClose = true;\n this.effectFill = true;\n this.shapeClose = true;\n this.shapeFill = true;\n this.pathRotation = false;\n this.lastPathTime = 0;\n this.destroyed = false;\n this.unbreakable = false;\n this.isRotating = false;\n this.rotation = 0;\n this.misplaced = false;\n this.retina = {\n maxDistance: {}\n };\n this.outType = _Enums_Types_ParticleOutType_js__WEBPACK_IMPORTED_MODULE_8__.ParticleOutType.normal;\n this.ignoresResizeRatio = true;\n const pxRatio = container.retina.pixelRatio, mainOptions = container.actualOptions, particlesOptions = (0,_Utils_OptionsUtils_js__WEBPACK_IMPORTED_MODULE_9__.loadParticlesOptions)(this._engine, container, mainOptions.particles), reduceDuplicates = particlesOptions.reduceDuplicates, effectType = particlesOptions.effect.type, shapeType = particlesOptions.shape.type;\n this.effect = (0,_Utils_Utils_js__WEBPACK_IMPORTED_MODULE_3__.itemFromSingleOrMultiple)(effectType, this.id, reduceDuplicates);\n this.shape = (0,_Utils_Utils_js__WEBPACK_IMPORTED_MODULE_3__.itemFromSingleOrMultiple)(shapeType, this.id, reduceDuplicates);\n const effectOptions = particlesOptions.effect, shapeOptions = particlesOptions.shape;\n if (overrideOptions) {\n if (overrideOptions.effect?.type) {\n const overrideEffectType = overrideOptions.effect.type, effect = (0,_Utils_Utils_js__WEBPACK_IMPORTED_MODULE_3__.itemFromSingleOrMultiple)(overrideEffectType, this.id, reduceDuplicates);\n if (effect) {\n this.effect = effect;\n effectOptions.load(overrideOptions.effect);\n }\n }\n if (overrideOptions.shape?.type) {\n const overrideShapeType = overrideOptions.shape.type, shape = (0,_Utils_Utils_js__WEBPACK_IMPORTED_MODULE_3__.itemFromSingleOrMultiple)(overrideShapeType, this.id, reduceDuplicates);\n if (shape) {\n this.shape = shape;\n shapeOptions.load(overrideOptions.shape);\n }\n }\n }\n if (this.effect === _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.randomColorValue) {\n const availableEffects = [\n ...this.container.particles.effectDrawers.keys()\n ];\n this.effect = availableEffects[Math.floor((0,_Utils_MathUtils_js__WEBPACK_IMPORTED_MODULE_2__.getRandom)() * availableEffects.length)];\n }\n if (this.shape === _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.randomColorValue) {\n const availableShapes = [\n ...this.container.particles.shapeDrawers.keys()\n ];\n this.shape = availableShapes[Math.floor((0,_Utils_MathUtils_js__WEBPACK_IMPORTED_MODULE_2__.getRandom)() * availableShapes.length)];\n }\n this.effectData = this.effect ? loadEffectData(this.effect, effectOptions, this.id, reduceDuplicates) : undefined;\n this.shapeData = this.shape ? loadShapeData(this.shape, shapeOptions, this.id, reduceDuplicates) : undefined;\n particlesOptions.load(overrideOptions);\n const effectData = this.effectData;\n if (effectData) {\n particlesOptions.load(effectData.particles);\n }\n const shapeData = this.shapeData;\n if (shapeData) {\n particlesOptions.load(shapeData.particles);\n }\n this.effectFill = effectData?.fill ?? particlesOptions.effect.fill;\n this.effectClose = effectData?.close ?? particlesOptions.effect.close;\n this.shapeFill = shapeData?.fill ?? particlesOptions.shape.fill;\n this.shapeClose = shapeData?.close ?? particlesOptions.shape.close;\n this.options = particlesOptions;\n container.retina.initParticle(this);\n this.size = (0,_Utils_Utils_js__WEBPACK_IMPORTED_MODULE_3__.initParticleNumericAnimationValue)(this.options.size, pxRatio);\n this.bubble = {\n inRange: false\n };\n this.slow = {\n inRange: false,\n factor: 1\n };\n this._initPosition(position);\n this.initialVelocity = this._calculateVelocity();\n this.velocity = this.initialVelocity.copy();\n const particles = container.particles;\n particles.setLastZIndex(this.position.z);\n this.zIndexFactor = this.position.z / container.zLayers;\n this.sides = 24;\n let effectDrawer, shapeDrawer;\n if (this.effect) {\n effectDrawer = container.particles.effectDrawers.get(this.effect);\n }\n if (effectDrawer?.loadEffect) {\n effectDrawer.loadEffect(this);\n }\n if (this.shape) {\n shapeDrawer = container.particles.shapeDrawers.get(this.shape);\n }\n if (shapeDrawer?.loadShape) {\n shapeDrawer.loadShape(this);\n }\n const sideCountFunc = shapeDrawer?.getSidesCount;\n if (sideCountFunc) {\n this.sides = sideCountFunc(this);\n }\n this.spawning = false;\n for (const updater of particles.updaters){\n updater.init(this);\n }\n effectDrawer?.particleInit?.(container, this);\n shapeDrawer?.particleInit?.(container, this);\n for (const plugin of container.particleCreatedPlugins){\n plugin.particleCreated?.(this);\n }\n }\n isInsideCanvas() {\n const radius = this.getRadius(), canvasSize = this.container.canvas.size, position = this.position;\n return position.x >= -radius && position.y >= -radius && position.y <= canvasSize.height + radius && position.x <= canvasSize.width + radius;\n }\n isShowingBack() {\n if (!this.roll) {\n return false;\n }\n const angle = this.roll.angle;\n if (this.roll.horizontal && this.roll.vertical) {\n const normalizedAngle = angle % _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.doublePI, adjustedAngle = normalizedAngle < _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.defaultAngle ? normalizedAngle + _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.doublePI : normalizedAngle;\n return adjustedAngle >= Math.PI * _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.half && adjustedAngle < Math.PI * _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.triple * _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.half;\n }\n if (this.roll.horizontal) {\n const normalizedAngle = (angle + Math.PI * _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.half) % (Math.PI * _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.double), adjustedAngle = normalizedAngle < _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.defaultAngle ? normalizedAngle + Math.PI * _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.double : normalizedAngle;\n return adjustedAngle >= Math.PI && adjustedAngle < Math.PI * _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.double;\n }\n if (this.roll.vertical) {\n const normalizedAngle = angle % (Math.PI * _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.double), adjustedAngle = normalizedAngle < _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.defaultAngle ? normalizedAngle + Math.PI * _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.double : normalizedAngle;\n return adjustedAngle >= Math.PI && adjustedAngle < Math.PI * _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.double;\n }\n return false;\n }\n isVisible() {\n return !this.destroyed && !this.spawning && this.isInsideCanvas();\n }\n reset() {\n for (const updater of this.container.particles.updaters){\n updater.reset?.(this);\n }\n }\n _calcPosition = (position, zIndex)=>{\n let tryCount = _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.defaultRetryCount, posVec = position ? _Utils_Vectors_js__WEBPACK_IMPORTED_MODULE_0__.Vector3d.create(position.x, position.y, zIndex) : undefined;\n const container = this.container, plugins = container.particlePositionPlugins, outModes = this.options.move.outModes, radius = this.getRadius(), canvasSize = container.canvas.size, abortController = new AbortController(), { signal } = abortController;\n while(!signal.aborted){\n for (const plugin of plugins){\n const pluginPos = plugin.particlePosition?.(posVec, this);\n if (pluginPos) {\n return _Utils_Vectors_js__WEBPACK_IMPORTED_MODULE_0__.Vector3d.create(pluginPos.x, pluginPos.y, zIndex);\n }\n }\n const exactPosition = (0,_Utils_MathUtils_js__WEBPACK_IMPORTED_MODULE_2__.calcExactPositionOrRandomFromSize)({\n size: canvasSize,\n position: posVec\n }), pos = _Utils_Vectors_js__WEBPACK_IMPORTED_MODULE_0__.Vector3d.create(exactPosition.x, exactPosition.y, zIndex);\n this._fixHorizontal(pos, radius, outModes.left ?? outModes.default);\n this._fixHorizontal(pos, radius, outModes.right ?? outModes.default);\n this._fixVertical(pos, radius, outModes.top ?? outModes.default);\n this._fixVertical(pos, radius, outModes.bottom ?? outModes.default);\n let isValidPosition = true;\n for (const plugin of container.particles.checkParticlePositionPlugins){\n isValidPosition = plugin.checkParticlePosition?.(this, pos, tryCount) ?? true;\n if (!isValidPosition) {\n break;\n }\n }\n if (isValidPosition) {\n return pos;\n }\n tryCount += _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.tryCountIncrement;\n posVec = undefined;\n }\n return posVec;\n };\n _calculateVelocity = ()=>{\n const baseVelocity = (0,_Utils_MathUtils_js__WEBPACK_IMPORTED_MODULE_2__.getParticleBaseVelocity)(this.direction), res = baseVelocity.copy(), moveOptions = this.options.move;\n if (moveOptions.direction === _Enums_Directions_MoveDirection_js__WEBPACK_IMPORTED_MODULE_6__.MoveDirection.inside || moveOptions.direction === _Enums_Directions_MoveDirection_js__WEBPACK_IMPORTED_MODULE_6__.MoveDirection.outside) {\n return res;\n }\n const rad = (0,_Utils_MathUtils_js__WEBPACK_IMPORTED_MODULE_2__.degToRad)((0,_Utils_MathUtils_js__WEBPACK_IMPORTED_MODULE_2__.getRangeValue)(moveOptions.angle.value)), radOffset = (0,_Utils_MathUtils_js__WEBPACK_IMPORTED_MODULE_2__.degToRad)((0,_Utils_MathUtils_js__WEBPACK_IMPORTED_MODULE_2__.getRangeValue)(moveOptions.angle.offset)), range = {\n left: radOffset - rad * _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.half,\n right: radOffset + rad * _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.half\n };\n if (!moveOptions.straight) {\n res.angle += (0,_Utils_MathUtils_js__WEBPACK_IMPORTED_MODULE_2__.randomInRangeValue)((0,_Utils_MathUtils_js__WEBPACK_IMPORTED_MODULE_2__.setRangeValue)(range.left, range.right));\n }\n if (moveOptions.random && typeof moveOptions.speed === \"number\") {\n res.length *= (0,_Utils_MathUtils_js__WEBPACK_IMPORTED_MODULE_2__.getRandom)();\n }\n return res;\n };\n _fixHorizontal = (pos, radius, outMode)=>{\n fixOutMode({\n outMode,\n checkModes: [\n _Enums_Modes_OutMode_js__WEBPACK_IMPORTED_MODULE_7__.OutMode.bounce\n ],\n coord: pos.x,\n maxCoord: this.container.canvas.size.width,\n setCb: (value)=>pos.x += value,\n radius\n });\n };\n _fixVertical = (pos, radius, outMode)=>{\n fixOutMode({\n outMode,\n checkModes: [\n _Enums_Modes_OutMode_js__WEBPACK_IMPORTED_MODULE_7__.OutMode.bounce\n ],\n coord: pos.y,\n maxCoord: this.container.canvas.size.height,\n setCb: (value)=>pos.y += value,\n radius\n });\n };\n _getRollColor = (color)=>{\n if (!color || !this.roll || !this.backColor && !this.roll.alter) {\n return color;\n }\n if (!this.isShowingBack()) {\n return color;\n }\n if (this.backColor) {\n return this.backColor;\n }\n if (this.roll.alter) {\n return (0,_Utils_ColorUtils_js__WEBPACK_IMPORTED_MODULE_1__.alterHsl)(color, this.roll.alter.type, this.roll.alter.value);\n }\n return color;\n };\n _initPosition = (position)=>{\n const container = this.container, zIndexValue = (0,_Utils_MathUtils_js__WEBPACK_IMPORTED_MODULE_2__.getRangeValue)(this.options.zIndex.value), initialPosition = this._calcPosition(position, (0,_Utils_MathUtils_js__WEBPACK_IMPORTED_MODULE_2__.clamp)(zIndexValue, _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.minZ, container.zLayers));\n if (!initialPosition) {\n throw new Error(\"a valid position cannot be found for particle\");\n }\n this.position = initialPosition;\n this.initialPosition = this.position.copy();\n const canvasSize = container.canvas.size;\n this.moveCenter = {\n ...(0,_Utils_Utils_js__WEBPACK_IMPORTED_MODULE_3__.getPosition)(this.options.move.center, canvasSize),\n radius: this.options.move.center.radius,\n mode: this.options.move.center.mode\n };\n this.direction = (0,_Utils_MathUtils_js__WEBPACK_IMPORTED_MODULE_2__.getParticleDirectionAngle)(this.options.move.direction, this.position, this.moveCenter);\n switch(this.options.move.direction){\n case _Enums_Directions_MoveDirection_js__WEBPACK_IMPORTED_MODULE_6__.MoveDirection.inside:\n this.outType = _Enums_Types_ParticleOutType_js__WEBPACK_IMPORTED_MODULE_8__.ParticleOutType.inside;\n break;\n case _Enums_Directions_MoveDirection_js__WEBPACK_IMPORTED_MODULE_6__.MoveDirection.outside:\n this.outType = _Enums_Types_ParticleOutType_js__WEBPACK_IMPORTED_MODULE_8__.ParticleOutType.outside;\n break;\n default:\n break;\n }\n this.offset = _Utils_Vectors_js__WEBPACK_IMPORTED_MODULE_0__.Vector.origin;\n };\n}\n\n\n//# sourceURL=webpack://@tsparticles/engine/./dist/browser/Core/Particle.js?\n}");
48
+ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Particle: () => (/* binding */ Particle)\n/* harmony export */ });\n/* harmony import */ var _Utils_Vectors_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Utils/Vectors.js */ \"./dist/browser/Core/Utils/Vectors.js\");\n/* harmony import */ var _Utils_ColorUtils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Utils/ColorUtils.js */ \"./dist/browser/Utils/ColorUtils.js\");\n/* harmony import */ var _Utils_MathUtils_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Utils/MathUtils.js */ \"./dist/browser/Utils/MathUtils.js\");\n/* harmony import */ var _Utils_Utils_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Utils/Utils.js */ \"./dist/browser/Utils/Utils.js\");\n/* harmony import */ var _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Utils/Constants.js */ \"./dist/browser/Core/Utils/Constants.js\");\n/* harmony import */ var _Enums_Types_EventType_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Enums/Types/EventType.js */ \"./dist/browser/Enums/Types/EventType.js\");\n/* harmony import */ var _Enums_Directions_MoveDirection_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Enums/Directions/MoveDirection.js */ \"./dist/browser/Enums/Directions/MoveDirection.js\");\n/* harmony import */ var _Enums_Modes_OutMode_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Enums/Modes/OutMode.js */ \"./dist/browser/Enums/Modes/OutMode.js\");\n/* harmony import */ var _Enums_Types_ParticleOutType_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Enums/Types/ParticleOutType.js */ \"./dist/browser/Enums/Types/ParticleOutType.js\");\n/* harmony import */ var _Utils_OptionsUtils_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Utils/OptionsUtils.js */ \"./dist/browser/Utils/OptionsUtils.js\");\n\n\n\n\n\n\n\n\n\n\nfunction loadEffectData(effect, effectOptions, id, reduceDuplicates) {\n const effectData = effectOptions.options[effect];\n return (0,_Utils_Utils_js__WEBPACK_IMPORTED_MODULE_3__.deepExtend)({\n close: effectOptions.close\n }, (0,_Utils_Utils_js__WEBPACK_IMPORTED_MODULE_3__.itemFromSingleOrMultiple)(effectData, id, reduceDuplicates));\n}\nfunction loadShapeData(shape, shapeOptions, id, reduceDuplicates) {\n const shapeData = shapeOptions.options[shape];\n return (0,_Utils_Utils_js__WEBPACK_IMPORTED_MODULE_3__.deepExtend)({\n close: shapeOptions.close\n }, (0,_Utils_Utils_js__WEBPACK_IMPORTED_MODULE_3__.itemFromSingleOrMultiple)(shapeData, id, reduceDuplicates));\n}\nfunction fixOutMode(data) {\n if (!(0,_Utils_Utils_js__WEBPACK_IMPORTED_MODULE_3__.isInArray)(data.outMode, data.checkModes)) {\n return;\n }\n const diameter = data.radius * _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.double;\n if (data.coord > data.maxCoord - diameter) {\n data.setCb(-data.radius);\n } else if (data.coord < diameter) {\n data.setCb(data.radius);\n }\n}\nclass Particle {\n container;\n backColor;\n bubble;\n destroyed;\n direction;\n effect;\n effectClose;\n effectData;\n fillColor;\n fillEnabled;\n fillOpacity;\n group;\n id;\n ignoresResizeRatio;\n initialPosition;\n initialVelocity;\n isRotating;\n lastPathTime;\n misplaced;\n moveCenter;\n offset;\n opacity;\n options;\n outType;\n pathRotation;\n position;\n randomIndexData;\n retina;\n roll;\n rotation;\n shape;\n shapeClose;\n shapeData;\n sides;\n size;\n slow;\n spawning;\n strokeColor;\n strokeOpacity;\n strokeWidth;\n unbreakable;\n velocity;\n zIndexFactor;\n _cachedOpacityData = {\n fillOpacity: _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.defaultOpacity,\n opacity: _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.defaultOpacity,\n strokeOpacity: _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.defaultOpacity\n };\n _cachedPosition = _Utils_Vectors_js__WEBPACK_IMPORTED_MODULE_0__.Vector3d.origin;\n _cachedRotateData = {\n sin: 0,\n cos: 0\n };\n _cachedTransform = {\n a: 1,\n b: 0,\n c: 0,\n d: 1\n };\n _engine;\n constructor(engine, container){\n this.container = container;\n this._engine = engine;\n }\n destroy(override) {\n if (this.unbreakable || this.destroyed) {\n return;\n }\n this.destroyed = true;\n this.bubble.inRange = false;\n this.slow.inRange = false;\n const container = this.container, shapeDrawer = this.shape ? container.particles.shapeDrawers.get(this.shape) : undefined;\n shapeDrawer?.particleDestroy?.(this);\n for (const plugin of container.particleDestroyedPlugins){\n plugin.particleDestroyed?.(this, override);\n }\n for (const updater of container.particles.updaters){\n updater.particleDestroyed?.(this, override);\n }\n this._engine.dispatchEvent(_Enums_Types_EventType_js__WEBPACK_IMPORTED_MODULE_5__.EventType.particleDestroyed, {\n container: this.container,\n data: {\n particle: this\n }\n });\n }\n draw(delta) {\n const container = this.container, canvas = container.canvas;\n canvas.drawParticlePlugins(this, delta);\n canvas.drawParticle(this, delta);\n }\n getAngle() {\n return this.rotation + (this.pathRotation ? this.velocity.angle : _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.defaultAngle);\n }\n getFillColor() {\n return this._getRollColor(this.bubble.color ?? (0,_Utils_ColorUtils_js__WEBPACK_IMPORTED_MODULE_1__.getHslFromAnimation)(this.fillColor));\n }\n getMass() {\n return this.getRadius() ** _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.squareExp * Math.PI * _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.half;\n }\n getOpacity() {\n const zIndexOptions = this.options.zIndex, zIndexFactor = _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.zIndexFactorOffset - this.zIndexFactor, zOpacityFactor = zIndexFactor ** zIndexOptions.opacityRate, opacity = this.bubble.opacity ?? (0,_Utils_MathUtils_js__WEBPACK_IMPORTED_MODULE_2__.getRangeValue)(this.opacity?.value ?? _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.defaultOpacity), fillOpacity = this.fillOpacity ?? _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.defaultOpacity, strokeOpacity = this.strokeOpacity ?? _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.defaultOpacity;\n this._cachedOpacityData.fillOpacity = opacity * fillOpacity * zOpacityFactor;\n this._cachedOpacityData.opacity = opacity * zOpacityFactor;\n this._cachedOpacityData.strokeOpacity = opacity * strokeOpacity * zOpacityFactor;\n return this._cachedOpacityData;\n }\n getPosition() {\n this._cachedPosition.x = this.position.x + this.offset.x;\n this._cachedPosition.y = this.position.y + this.offset.y;\n this._cachedPosition.z = this.position.z;\n return this._cachedPosition;\n }\n getRadius() {\n return this.bubble.radius ?? this.size.value;\n }\n getRotateData() {\n const angle = this.getAngle();\n this._cachedRotateData.sin = Math.sin(angle);\n this._cachedRotateData.cos = Math.cos(angle);\n return this._cachedRotateData;\n }\n getStrokeColor() {\n return this._getRollColor(this.bubble.color ?? (0,_Utils_ColorUtils_js__WEBPACK_IMPORTED_MODULE_1__.getHslFromAnimation)(this.strokeColor));\n }\n getTransformData(externalTransform) {\n const rotateData = this.getRotateData(), rotating = this.isRotating;\n this._cachedTransform.a = rotateData.cos * (externalTransform.a ?? _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.defaultTransform.a);\n this._cachedTransform.b = rotating ? rotateData.sin * (externalTransform.b ?? _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.identity) : externalTransform.b ?? _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.defaultTransform.b;\n this._cachedTransform.c = rotating ? -rotateData.sin * (externalTransform.c ?? _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.identity) : externalTransform.c ?? _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.defaultTransform.c;\n this._cachedTransform.d = rotateData.cos * (externalTransform.d ?? _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.defaultTransform.d);\n return this._cachedTransform;\n }\n init(id, position, overrideOptions, group) {\n const container = this.container;\n this.id = id;\n this.group = group;\n this.effectClose = true;\n this.shapeClose = true;\n this.pathRotation = false;\n this.lastPathTime = 0;\n this.destroyed = false;\n this.unbreakable = false;\n this.isRotating = false;\n this.rotation = 0;\n this.misplaced = false;\n this.retina = {\n maxDistance: {}\n };\n this.outType = _Enums_Types_ParticleOutType_js__WEBPACK_IMPORTED_MODULE_8__.ParticleOutType.normal;\n this.ignoresResizeRatio = true;\n const pxRatio = container.retina.pixelRatio, mainOptions = container.actualOptions, particlesOptions = (0,_Utils_OptionsUtils_js__WEBPACK_IMPORTED_MODULE_9__.loadParticlesOptions)(this._engine, container, mainOptions.particles), reduceDuplicates = particlesOptions.reduceDuplicates, effectType = particlesOptions.effect.type, shapeType = particlesOptions.shape.type;\n this.effect = (0,_Utils_Utils_js__WEBPACK_IMPORTED_MODULE_3__.itemFromSingleOrMultiple)(effectType, this.id, reduceDuplicates);\n this.shape = (0,_Utils_Utils_js__WEBPACK_IMPORTED_MODULE_3__.itemFromSingleOrMultiple)(shapeType, this.id, reduceDuplicates);\n const effectOptions = particlesOptions.effect, shapeOptions = particlesOptions.shape;\n if (overrideOptions) {\n if (overrideOptions.effect?.type) {\n const overrideEffectType = overrideOptions.effect.type, effect = (0,_Utils_Utils_js__WEBPACK_IMPORTED_MODULE_3__.itemFromSingleOrMultiple)(overrideEffectType, this.id, reduceDuplicates);\n if (effect) {\n this.effect = effect;\n effectOptions.load(overrideOptions.effect);\n }\n }\n if (overrideOptions.shape?.type) {\n const overrideShapeType = overrideOptions.shape.type, shape = (0,_Utils_Utils_js__WEBPACK_IMPORTED_MODULE_3__.itemFromSingleOrMultiple)(overrideShapeType, this.id, reduceDuplicates);\n if (shape) {\n this.shape = shape;\n shapeOptions.load(overrideOptions.shape);\n }\n }\n }\n if (this.effect === _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.randomColorValue) {\n const availableEffects = [\n ...this.container.particles.effectDrawers.keys()\n ];\n this.effect = availableEffects[Math.floor((0,_Utils_MathUtils_js__WEBPACK_IMPORTED_MODULE_2__.getRandom)() * availableEffects.length)];\n }\n if (this.shape === _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.randomColorValue) {\n const availableShapes = [\n ...this.container.particles.shapeDrawers.keys()\n ];\n this.shape = availableShapes[Math.floor((0,_Utils_MathUtils_js__WEBPACK_IMPORTED_MODULE_2__.getRandom)() * availableShapes.length)];\n }\n this.effectData = this.effect ? loadEffectData(this.effect, effectOptions, this.id, reduceDuplicates) : undefined;\n this.shapeData = this.shape ? loadShapeData(this.shape, shapeOptions, this.id, reduceDuplicates) : undefined;\n particlesOptions.load(overrideOptions);\n const effectData = this.effectData;\n if (effectData) {\n particlesOptions.load(effectData.particles);\n }\n const shapeData = this.shapeData;\n if (shapeData) {\n particlesOptions.load(shapeData.particles);\n }\n this.effectClose = effectData?.close ?? particlesOptions.effect.close;\n this.shapeClose = shapeData?.close ?? particlesOptions.shape.close;\n this.options = particlesOptions;\n container.retina.initParticle(this);\n this.size = (0,_Utils_Utils_js__WEBPACK_IMPORTED_MODULE_3__.initParticleNumericAnimationValue)(this.options.size, pxRatio);\n this.bubble = {\n inRange: false\n };\n this.slow = {\n inRange: false,\n factor: 1\n };\n this._initPosition(position);\n this.initialVelocity = this._calculateVelocity();\n this.velocity = this.initialVelocity.copy();\n const particles = container.particles;\n particles.setLastZIndex(this.position.z);\n this.zIndexFactor = this.position.z / container.zLayers;\n this.sides = 24;\n let effectDrawer, shapeDrawer;\n if (this.effect) {\n effectDrawer = container.particles.effectDrawers.get(this.effect);\n }\n if (effectDrawer?.loadEffect) {\n effectDrawer.loadEffect(this);\n }\n if (this.shape) {\n shapeDrawer = container.particles.shapeDrawers.get(this.shape);\n }\n if (shapeDrawer?.loadShape) {\n shapeDrawer.loadShape(this);\n }\n const sideCountFunc = shapeDrawer?.getSidesCount;\n if (sideCountFunc) {\n this.sides = sideCountFunc(this);\n }\n this.spawning = false;\n for (const updater of particles.updaters){\n updater.init(this);\n }\n effectDrawer?.particleInit?.(container, this);\n shapeDrawer?.particleInit?.(container, this);\n for (const plugin of container.particleCreatedPlugins){\n plugin.particleCreated?.(this);\n }\n }\n isInsideCanvas() {\n const radius = this.getRadius(), canvasSize = this.container.canvas.size, position = this.position;\n return position.x >= -radius && position.y >= -radius && position.y <= canvasSize.height + radius && position.x <= canvasSize.width + radius;\n }\n isShowingBack() {\n if (!this.roll) {\n return false;\n }\n const angle = this.roll.angle;\n if (this.roll.horizontal && this.roll.vertical) {\n const normalizedAngle = angle % _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.doublePI, adjustedAngle = normalizedAngle < _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.defaultAngle ? normalizedAngle + _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.doublePI : normalizedAngle;\n return adjustedAngle >= Math.PI * _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.half && adjustedAngle < Math.PI * _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.triple * _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.half;\n }\n if (this.roll.horizontal) {\n const normalizedAngle = (angle + Math.PI * _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.half) % (Math.PI * _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.double), adjustedAngle = normalizedAngle < _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.defaultAngle ? normalizedAngle + Math.PI * _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.double : normalizedAngle;\n return adjustedAngle >= Math.PI && adjustedAngle < Math.PI * _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.double;\n }\n if (this.roll.vertical) {\n const normalizedAngle = angle % (Math.PI * _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.double), adjustedAngle = normalizedAngle < _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.defaultAngle ? normalizedAngle + Math.PI * _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.double : normalizedAngle;\n return adjustedAngle >= Math.PI && adjustedAngle < Math.PI * _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.double;\n }\n return false;\n }\n isVisible() {\n return !this.destroyed && !this.spawning && this.isInsideCanvas();\n }\n reset() {\n for (const updater of this.container.particles.updaters){\n updater.reset?.(this);\n }\n }\n _calcPosition = (position, zIndex)=>{\n let tryCount = _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.defaultRetryCount, posVec = position ? _Utils_Vectors_js__WEBPACK_IMPORTED_MODULE_0__.Vector3d.create(position.x, position.y, zIndex) : undefined;\n const container = this.container, plugins = container.particlePositionPlugins, outModes = this.options.move.outModes, radius = this.getRadius(), canvasSize = container.canvas.size, abortController = new AbortController(), { signal } = abortController;\n while(!signal.aborted){\n for (const plugin of plugins){\n const pluginPos = plugin.particlePosition?.(posVec, this);\n if (pluginPos) {\n return _Utils_Vectors_js__WEBPACK_IMPORTED_MODULE_0__.Vector3d.create(pluginPos.x, pluginPos.y, zIndex);\n }\n }\n const exactPosition = (0,_Utils_MathUtils_js__WEBPACK_IMPORTED_MODULE_2__.calcExactPositionOrRandomFromSize)({\n size: canvasSize,\n position: posVec\n }), pos = _Utils_Vectors_js__WEBPACK_IMPORTED_MODULE_0__.Vector3d.create(exactPosition.x, exactPosition.y, zIndex);\n this._fixHorizontal(pos, radius, outModes.left ?? outModes.default);\n this._fixHorizontal(pos, radius, outModes.right ?? outModes.default);\n this._fixVertical(pos, radius, outModes.top ?? outModes.default);\n this._fixVertical(pos, radius, outModes.bottom ?? outModes.default);\n let isValidPosition = true;\n for (const plugin of container.particles.checkParticlePositionPlugins){\n isValidPosition = plugin.checkParticlePosition?.(this, pos, tryCount) ?? true;\n if (!isValidPosition) {\n break;\n }\n }\n if (isValidPosition) {\n return pos;\n }\n tryCount += _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.tryCountIncrement;\n posVec = undefined;\n }\n return posVec;\n };\n _calculateVelocity = ()=>{\n const baseVelocity = (0,_Utils_MathUtils_js__WEBPACK_IMPORTED_MODULE_2__.getParticleBaseVelocity)(this.direction), res = baseVelocity.copy(), moveOptions = this.options.move;\n if (moveOptions.direction === _Enums_Directions_MoveDirection_js__WEBPACK_IMPORTED_MODULE_6__.MoveDirection.inside || moveOptions.direction === _Enums_Directions_MoveDirection_js__WEBPACK_IMPORTED_MODULE_6__.MoveDirection.outside) {\n return res;\n }\n const rad = (0,_Utils_MathUtils_js__WEBPACK_IMPORTED_MODULE_2__.degToRad)((0,_Utils_MathUtils_js__WEBPACK_IMPORTED_MODULE_2__.getRangeValue)(moveOptions.angle.value)), radOffset = (0,_Utils_MathUtils_js__WEBPACK_IMPORTED_MODULE_2__.degToRad)((0,_Utils_MathUtils_js__WEBPACK_IMPORTED_MODULE_2__.getRangeValue)(moveOptions.angle.offset)), range = {\n left: radOffset - rad * _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.half,\n right: radOffset + rad * _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.half\n };\n if (!moveOptions.straight) {\n res.angle += (0,_Utils_MathUtils_js__WEBPACK_IMPORTED_MODULE_2__.randomInRangeValue)((0,_Utils_MathUtils_js__WEBPACK_IMPORTED_MODULE_2__.setRangeValue)(range.left, range.right));\n }\n if (moveOptions.random && typeof moveOptions.speed === \"number\") {\n res.length *= (0,_Utils_MathUtils_js__WEBPACK_IMPORTED_MODULE_2__.getRandom)();\n }\n return res;\n };\n _fixHorizontal = (pos, radius, outMode)=>{\n fixOutMode({\n outMode,\n checkModes: [\n _Enums_Modes_OutMode_js__WEBPACK_IMPORTED_MODULE_7__.OutMode.bounce\n ],\n coord: pos.x,\n maxCoord: this.container.canvas.size.width,\n setCb: (value)=>pos.x += value,\n radius\n });\n };\n _fixVertical = (pos, radius, outMode)=>{\n fixOutMode({\n outMode,\n checkModes: [\n _Enums_Modes_OutMode_js__WEBPACK_IMPORTED_MODULE_7__.OutMode.bounce\n ],\n coord: pos.y,\n maxCoord: this.container.canvas.size.height,\n setCb: (value)=>pos.y += value,\n radius\n });\n };\n _getRollColor = (color)=>{\n if (!color || !this.roll || !this.backColor && !this.roll.alter) {\n return color;\n }\n if (!this.isShowingBack()) {\n return color;\n }\n if (this.backColor) {\n return this.backColor;\n }\n if (this.roll.alter) {\n return (0,_Utils_ColorUtils_js__WEBPACK_IMPORTED_MODULE_1__.alterHsl)(color, this.roll.alter.type, this.roll.alter.value);\n }\n return color;\n };\n _initPosition = (position)=>{\n const container = this.container, zIndexValue = (0,_Utils_MathUtils_js__WEBPACK_IMPORTED_MODULE_2__.getRangeValue)(this.options.zIndex.value), initialPosition = this._calcPosition(position, (0,_Utils_MathUtils_js__WEBPACK_IMPORTED_MODULE_2__.clamp)(zIndexValue, _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_4__.minZ, container.zLayers));\n if (!initialPosition) {\n throw new Error(\"a valid position cannot be found for particle\");\n }\n this.position = initialPosition;\n this.initialPosition = this.position.copy();\n const canvasSize = container.canvas.size;\n this.moveCenter = {\n ...(0,_Utils_Utils_js__WEBPACK_IMPORTED_MODULE_3__.getPosition)(this.options.move.center, canvasSize),\n radius: this.options.move.center.radius,\n mode: this.options.move.center.mode\n };\n this.direction = (0,_Utils_MathUtils_js__WEBPACK_IMPORTED_MODULE_2__.getParticleDirectionAngle)(this.options.move.direction, this.position, this.moveCenter);\n switch(this.options.move.direction){\n case _Enums_Directions_MoveDirection_js__WEBPACK_IMPORTED_MODULE_6__.MoveDirection.inside:\n this.outType = _Enums_Types_ParticleOutType_js__WEBPACK_IMPORTED_MODULE_8__.ParticleOutType.inside;\n break;\n case _Enums_Directions_MoveDirection_js__WEBPACK_IMPORTED_MODULE_6__.MoveDirection.outside:\n this.outType = _Enums_Types_ParticleOutType_js__WEBPACK_IMPORTED_MODULE_8__.ParticleOutType.outside;\n break;\n default:\n break;\n }\n this.offset = _Utils_Vectors_js__WEBPACK_IMPORTED_MODULE_0__.Vector.origin;\n };\n}\n\n\n//# sourceURL=webpack://@tsparticles/engine/./dist/browser/Core/Particle.js?\n}");
49
49
 
50
50
  /***/ },
51
51