@tsparticles/engine 3.4.0 → 3.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,7 +9,26 @@
9
9
  })(function (require, exports) {
10
10
  "use strict";
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.updateColor = exports.updateColorValue = exports.getHslAnimationFromHsl = exports.getHslFromAnimation = exports.getLinkRandomColor = exports.getLinkColor = exports.colorMix = exports.getStyleFromHsl = exports.getStyleFromRgb = exports.getRandomRgbColor = exports.hslaToRgba = exports.hslToRgb = exports.stringToRgb = exports.stringToAlpha = exports.rgbToHsl = exports.rangeColorToHsl = exports.colorToHsl = exports.colorToRgb = exports.rangeColorToRgb = exports.addColorManager = void 0;
12
+ exports.addColorManager = addColorManager;
13
+ exports.rangeColorToRgb = rangeColorToRgb;
14
+ exports.colorToRgb = colorToRgb;
15
+ exports.colorToHsl = colorToHsl;
16
+ exports.rangeColorToHsl = rangeColorToHsl;
17
+ exports.rgbToHsl = rgbToHsl;
18
+ exports.stringToAlpha = stringToAlpha;
19
+ exports.stringToRgb = stringToRgb;
20
+ exports.hslToRgb = hslToRgb;
21
+ exports.hslaToRgba = hslaToRgba;
22
+ exports.getRandomRgbColor = getRandomRgbColor;
23
+ exports.getStyleFromRgb = getStyleFromRgb;
24
+ exports.getStyleFromHsl = getStyleFromHsl;
25
+ exports.colorMix = colorMix;
26
+ exports.getLinkColor = getLinkColor;
27
+ exports.getLinkRandomColor = getLinkRandomColor;
28
+ exports.getHslFromAnimation = getHslFromAnimation;
29
+ exports.getHslAnimationFromHsl = getHslAnimationFromHsl;
30
+ exports.updateColorValue = updateColorValue;
31
+ exports.updateColor = updateColor;
13
32
  const NumberUtils_js_1 = require("./NumberUtils.js");
14
33
  const TypeUtils_js_1 = require("./TypeUtils.js");
15
34
  const Constants_js_1 = require("../Core/Utils/Constants.js");
@@ -26,7 +45,6 @@
26
45
  function addColorManager(manager) {
27
46
  colorManagers.set(manager.key, manager);
28
47
  }
29
- exports.addColorManager = addColorManager;
30
48
  function stringToRgba(input) {
31
49
  for (const [, manager] of colorManagers) {
32
50
  if (input.startsWith(manager.stringPrefix)) {
@@ -67,7 +85,6 @@
67
85
  }
68
86
  }
69
87
  }
70
- exports.rangeColorToRgb = rangeColorToRgb;
71
88
  function colorToRgb(input, index, useIndex = true) {
72
89
  if (!input) {
73
90
  return;
@@ -88,17 +105,14 @@
88
105
  }
89
106
  }
90
107
  }
91
- exports.colorToRgb = colorToRgb;
92
108
  function colorToHsl(color, index, useIndex = true) {
93
109
  const rgb = colorToRgb(color, index, useIndex);
94
110
  return rgb ? rgbToHsl(rgb) : undefined;
95
111
  }
96
- exports.colorToHsl = colorToHsl;
97
112
  function rangeColorToHsl(color, index, useIndex = true) {
98
113
  const rgb = rangeColorToRgb(color, index, useIndex);
99
114
  return rgb ? rgbToHsl(rgb) : undefined;
100
115
  }
101
- exports.rangeColorToHsl = rangeColorToHsl;
102
116
  function rgbToHsl(color) {
103
117
  const rgbMax = 255, hMax = 360, sMax = 100, lMax = 100, hMin = 0, sMin = 0, hPhase = 60, half = 0.5, double = 2, r1 = color.r / rgbMax, g1 = color.g / rgbMax, b1 = color.b / rgbMax, max = Math.max(r1, g1, b1), min = Math.min(r1, g1, b1), res = {
104
118
  h: hMin,
@@ -123,15 +137,12 @@
123
137
  }
124
138
  return res;
125
139
  }
126
- exports.rgbToHsl = rgbToHsl;
127
140
  function stringToAlpha(input) {
128
141
  return stringToRgba(input)?.a;
129
142
  }
130
- exports.stringToAlpha = stringToAlpha;
131
143
  function stringToRgb(input) {
132
144
  return stringToRgba(input);
133
145
  }
134
- exports.stringToRgb = stringToRgb;
135
146
  function hslToRgb(hsl) {
136
147
  const hMax = 360, sMax = 100, lMax = 100, sMin = 0, lMin = 0, h = ((hsl.h % hMax) + hMax) % hMax, s = Math.max(sMin, Math.min(sMax, hsl.s)), l = Math.max(lMin, Math.min(lMax, hsl.l)), hNormalized = h / hMax, sNormalized = s / sMax, lNormalized = l / lMax, rgbFactor = 255, triple = 3;
137
148
  if (s === sMin) {
@@ -162,7 +173,6 @@
162
173
  : lNormalized + sNormalized - lNormalized * sNormalized, temp2 = double * lNormalized - temp1, phaseNumerator = 1, phaseThird = phaseNumerator / triple, red = Math.min(rgbFactor, rgbFactor * channel(temp2, temp1, hNormalized + phaseThird)), green = Math.min(rgbFactor, rgbFactor * channel(temp2, temp1, hNormalized)), blue = Math.min(rgbFactor, rgbFactor * channel(temp2, temp1, hNormalized - phaseThird));
163
174
  return { r: Math.round(red), g: Math.round(green), b: Math.round(blue) };
164
175
  }
165
- exports.hslToRgb = hslToRgb;
166
176
  function hslaToRgba(hsla) {
167
177
  const rgbResult = hslToRgb(hsla);
168
178
  return {
@@ -172,7 +182,6 @@
172
182
  r: rgbResult.r,
173
183
  };
174
184
  }
175
- exports.hslaToRgba = hslaToRgba;
176
185
  function getRandomRgbColor(min) {
177
186
  const defaultMin = 0, fixedMin = min ?? defaultMin, rgbMax = 256;
178
187
  return {
@@ -181,17 +190,14 @@
181
190
  r: Math.floor((0, NumberUtils_js_1.randomInRange)((0, NumberUtils_js_1.setRangeValue)(fixedMin, rgbMax))),
182
191
  };
183
192
  }
184
- exports.getRandomRgbColor = getRandomRgbColor;
185
193
  function getStyleFromRgb(color, opacity) {
186
194
  const defaultOpacity = 1;
187
195
  return `rgba(${color.r}, ${color.g}, ${color.b}, ${opacity ?? defaultOpacity})`;
188
196
  }
189
- exports.getStyleFromRgb = getStyleFromRgb;
190
197
  function getStyleFromHsl(color, opacity) {
191
198
  const defaultOpacity = 1;
192
199
  return `hsla(${color.h}, ${color.s}%, ${color.l}%, ${opacity ?? defaultOpacity})`;
193
200
  }
194
- exports.getStyleFromHsl = getStyleFromHsl;
195
201
  function colorMix(color1, color2, size1, size2) {
196
202
  let rgb1 = color1, rgb2 = color2;
197
203
  if (rgb1.r === undefined) {
@@ -206,7 +212,6 @@
206
212
  r: (0, NumberUtils_js_1.mix)(rgb1.r, rgb2.r, size1, size2),
207
213
  };
208
214
  }
209
- exports.colorMix = colorMix;
210
215
  function getLinkColor(p1, p2, linkColor) {
211
216
  if (linkColor === randomColorValue) {
212
217
  return getRandomRgbColor();
@@ -227,7 +232,6 @@
227
232
  return linkColor;
228
233
  }
229
234
  }
230
- exports.getLinkColor = getLinkColor;
231
235
  function getLinkRandomColor(optColor, blink, consent) {
232
236
  const color = (0, TypeUtils_js_1.isString)(optColor) ? optColor : optColor.value;
233
237
  if (color === randomColorValue) {
@@ -250,7 +254,6 @@
250
254
  });
251
255
  }
252
256
  }
253
- exports.getLinkRandomColor = getLinkRandomColor;
254
257
  function getHslFromAnimation(animation) {
255
258
  return animation !== undefined
256
259
  ? {
@@ -260,7 +263,6 @@
260
263
  }
261
264
  : undefined;
262
265
  }
263
- exports.getHslFromAnimation = getHslFromAnimation;
264
266
  function getHslAnimationFromHsl(hsl, animationOptions, reduceFactor) {
265
267
  const resColor = {
266
268
  h: {
@@ -283,7 +285,6 @@
283
285
  }
284
286
  return resColor;
285
287
  }
286
- exports.getHslAnimationFromHsl = getHslAnimationFromHsl;
287
288
  function setColorAnimation(colorValue, colorAnimation, reduceFactor) {
288
289
  colorValue.enable = colorAnimation.enable;
289
290
  const defaultVelocity = 0, decayOffset = 1, defaultLoops = 0, defaultTime = 0;
@@ -354,7 +355,6 @@
354
355
  }
355
356
  data.value = (0, NumberUtils_js_1.clamp)(data.value, min, max);
356
357
  }
357
- exports.updateColorValue = updateColorValue;
358
358
  function updateColor(color, delta) {
359
359
  if (!color) {
360
360
  return;
@@ -375,5 +375,4 @@
375
375
  updateColorValue(l, ranges.l, true, delta);
376
376
  }
377
377
  }
378
- exports.updateColor = updateColor;
379
378
  });
@@ -9,41 +9,73 @@
9
9
  })(function (require, exports) {
10
10
  "use strict";
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.parseAlpha = exports.calcExactPositionOrRandomFromSizeRanged = exports.calcExactPositionOrRandomFromSize = exports.calcPositionOrRandomFromSizeRanged = exports.calcPositionOrRandomFromSize = exports.calcPositionFromSize = exports.collisionVelocity = exports.getParticleBaseVelocity = exports.getParticleDirectionAngle = exports.degToRad = exports.getDistance = exports.getDistances = exports.setRangeValue = exports.getRangeMax = exports.getRangeMin = exports.getRangeValue = exports.randomInRange = exports.mix = exports.clamp = exports.getRandom = exports.setRandom = exports.getEasing = exports.addEasing = void 0;
12
+ exports.addEasing = addEasing;
13
+ exports.getEasing = getEasing;
14
+ exports.setRandom = setRandom;
15
+ exports.getRandom = getRandom;
16
+ exports.setAnimationFunctions = setAnimationFunctions;
17
+ exports.animate = animate;
18
+ exports.cancelAnimation = cancelAnimation;
19
+ exports.clamp = clamp;
20
+ exports.mix = mix;
21
+ exports.randomInRange = randomInRange;
22
+ exports.getRangeValue = getRangeValue;
23
+ exports.getRangeMin = getRangeMin;
24
+ exports.getRangeMax = getRangeMax;
25
+ exports.setRangeValue = setRangeValue;
26
+ exports.getDistances = getDistances;
27
+ exports.getDistance = getDistance;
28
+ exports.degToRad = degToRad;
29
+ exports.getParticleDirectionAngle = getParticleDirectionAngle;
30
+ exports.getParticleBaseVelocity = getParticleBaseVelocity;
31
+ exports.collisionVelocity = collisionVelocity;
32
+ exports.calcPositionFromSize = calcPositionFromSize;
33
+ exports.calcPositionOrRandomFromSize = calcPositionOrRandomFromSize;
34
+ exports.calcPositionOrRandomFromSizeRanged = calcPositionOrRandomFromSizeRanged;
35
+ exports.calcExactPositionOrRandomFromSize = calcExactPositionOrRandomFromSize;
36
+ exports.calcExactPositionOrRandomFromSizeRanged = calcExactPositionOrRandomFromSizeRanged;
37
+ exports.parseAlpha = parseAlpha;
13
38
  const MoveDirection_js_1 = require("../Enums/Directions/MoveDirection.js");
14
39
  const Vectors_js_1 = require("../Core/Utils/Vectors.js");
15
40
  const TypeUtils_js_1 = require("./TypeUtils.js");
16
41
  const Constants_js_1 = require("../Core/Utils/Constants.js");
17
42
  let _random = Math.random;
18
- const easings = new Map(), double = 2, doublePI = Math.PI * double;
43
+ const _animationLoop = {
44
+ nextFrame: (cb) => requestAnimationFrame(cb),
45
+ cancel: (idx) => cancelAnimationFrame(idx),
46
+ }, easingFunctions = new Map(), double = 2, doublePI = Math.PI * double;
19
47
  function addEasing(name, easing) {
20
- if (easings.get(name)) {
48
+ if (easingFunctions.get(name)) {
21
49
  return;
22
50
  }
23
- easings.set(name, easing);
51
+ easingFunctions.set(name, easing);
24
52
  }
25
- exports.addEasing = addEasing;
26
53
  function getEasing(name) {
27
- return easings.get(name) ?? ((value) => value);
54
+ return easingFunctions.get(name) ?? ((value) => value);
28
55
  }
29
- exports.getEasing = getEasing;
30
56
  function setRandom(rnd = Math.random) {
31
57
  _random = rnd;
32
58
  }
33
- exports.setRandom = setRandom;
34
59
  function getRandom() {
35
60
  const min = 0, max = 1;
36
61
  return clamp(_random(), min, max - Number.EPSILON);
37
62
  }
38
- exports.getRandom = getRandom;
63
+ function setAnimationFunctions(nextFrame, cancel) {
64
+ _animationLoop.nextFrame = (callback) => nextFrame(callback);
65
+ _animationLoop.cancel = (handle) => cancel(handle);
66
+ }
67
+ function animate(fn) {
68
+ return _animationLoop.nextFrame(fn);
69
+ }
70
+ function cancelAnimation(handle) {
71
+ _animationLoop.cancel(handle);
72
+ }
39
73
  function clamp(num, min, max) {
40
74
  return Math.min(Math.max(num, min), max);
41
75
  }
42
- exports.clamp = clamp;
43
76
  function mix(comp1, comp2, weight1, weight2) {
44
77
  return Math.floor((comp1 * weight1 + comp2 * weight2) / (weight1 + weight2));
45
78
  }
46
- exports.mix = mix;
47
79
  function randomInRange(r) {
48
80
  const max = getRangeMax(r), minOffset = 0;
49
81
  let min = getRangeMin(r);
@@ -52,19 +84,15 @@
52
84
  }
53
85
  return getRandom() * (max - min) + min;
54
86
  }
55
- exports.randomInRange = randomInRange;
56
87
  function getRangeValue(value) {
57
88
  return (0, TypeUtils_js_1.isNumber)(value) ? value : randomInRange(value);
58
89
  }
59
- exports.getRangeValue = getRangeValue;
60
90
  function getRangeMin(value) {
61
91
  return (0, TypeUtils_js_1.isNumber)(value) ? value : value.min;
62
92
  }
63
- exports.getRangeMin = getRangeMin;
64
93
  function getRangeMax(value) {
65
94
  return (0, TypeUtils_js_1.isNumber)(value) ? value : value.max;
66
95
  }
67
- exports.getRangeMax = getRangeMax;
68
96
  function setRangeValue(source, value) {
69
97
  if (source === value || (value === undefined && (0, TypeUtils_js_1.isNumber)(source))) {
70
98
  return source;
@@ -77,21 +105,17 @@
77
105
  }
78
106
  : setRangeValue(min, max);
79
107
  }
80
- exports.setRangeValue = setRangeValue;
81
108
  function getDistances(pointA, pointB) {
82
109
  const dx = pointA.x - pointB.x, dy = pointA.y - pointB.y, squareExp = 2;
83
110
  return { dx: dx, dy: dy, distance: Math.sqrt(dx ** squareExp + dy ** squareExp) };
84
111
  }
85
- exports.getDistances = getDistances;
86
112
  function getDistance(pointA, pointB) {
87
113
  return getDistances(pointA, pointB).distance;
88
114
  }
89
- exports.getDistance = getDistance;
90
115
  function degToRad(degrees) {
91
116
  const PIDeg = 180;
92
117
  return (degrees * Math.PI) / PIDeg;
93
118
  }
94
- exports.degToRad = degToRad;
95
119
  function getParticleDirectionAngle(direction, position, center) {
96
120
  if ((0, TypeUtils_js_1.isNumber)(direction)) {
97
121
  return degToRad(direction);
@@ -122,19 +146,16 @@
122
146
  return getRandom() * doublePI;
123
147
  }
124
148
  }
125
- exports.getParticleDirectionAngle = getParticleDirectionAngle;
126
149
  function getParticleBaseVelocity(direction) {
127
150
  const baseVelocity = Vectors_js_1.Vector.origin;
128
151
  baseVelocity.length = 1;
129
152
  baseVelocity.angle = direction;
130
153
  return baseVelocity;
131
154
  }
132
- exports.getParticleBaseVelocity = getParticleBaseVelocity;
133
155
  function collisionVelocity(v1, v2, m1, m2) {
134
156
  const double = 2;
135
157
  return Vectors_js_1.Vector.create((v1.x * (m1 - m2)) / (m1 + m2) + (v2.x * double * m2) / (m1 + m2), v1.y);
136
158
  }
137
- exports.collisionVelocity = collisionVelocity;
138
159
  function calcPositionFromSize(data) {
139
160
  return data.position?.x !== undefined && data.position.y !== undefined
140
161
  ? {
@@ -143,14 +164,12 @@
143
164
  }
144
165
  : undefined;
145
166
  }
146
- exports.calcPositionFromSize = calcPositionFromSize;
147
167
  function calcPositionOrRandomFromSize(data) {
148
168
  return {
149
169
  x: ((data.position?.x ?? getRandom() * Constants_js_1.percentDenominator) * data.size.width) / Constants_js_1.percentDenominator,
150
170
  y: ((data.position?.y ?? getRandom() * Constants_js_1.percentDenominator) * data.size.height) / Constants_js_1.percentDenominator,
151
171
  };
152
172
  }
153
- exports.calcPositionOrRandomFromSize = calcPositionOrRandomFromSize;
154
173
  function calcPositionOrRandomFromSizeRanged(data) {
155
174
  const position = {
156
175
  x: data.position?.x !== undefined ? getRangeValue(data.position.x) : undefined,
@@ -158,14 +177,12 @@
158
177
  };
159
178
  return calcPositionOrRandomFromSize({ size: data.size, position });
160
179
  }
161
- exports.calcPositionOrRandomFromSizeRanged = calcPositionOrRandomFromSizeRanged;
162
180
  function calcExactPositionOrRandomFromSize(data) {
163
181
  return {
164
182
  x: data.position?.x ?? getRandom() * data.size.width,
165
183
  y: data.position?.y ?? getRandom() * data.size.height,
166
184
  };
167
185
  }
168
- exports.calcExactPositionOrRandomFromSize = calcExactPositionOrRandomFromSize;
169
186
  function calcExactPositionOrRandomFromSizeRanged(data) {
170
187
  const position = {
171
188
  x: data.position?.x !== undefined ? getRangeValue(data.position.x) : undefined,
@@ -173,7 +190,6 @@
173
190
  };
174
191
  return calcExactPositionOrRandomFromSize({ size: data.size, position });
175
192
  }
176
- exports.calcExactPositionOrRandomFromSizeRanged = calcExactPositionOrRandomFromSizeRanged;
177
193
  function parseAlpha(input) {
178
194
  const defaultAlpha = 1;
179
195
  if (!input) {
@@ -181,5 +197,4 @@
181
197
  }
182
198
  return input.endsWith("%") ? parseFloat(input) / Constants_js_1.percentDenominator : parseFloat(input);
183
199
  }
184
- exports.parseAlpha = parseAlpha;
185
200
  });
@@ -9,18 +9,17 @@
9
9
  })(function (require, exports) {
10
10
  "use strict";
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.loadParticlesOptions = exports.loadOptions = void 0;
12
+ exports.loadOptions = loadOptions;
13
+ exports.loadParticlesOptions = loadParticlesOptions;
13
14
  const ParticlesOptions_js_1 = require("../Options/Classes/Particles/ParticlesOptions.js");
14
15
  function loadOptions(options, ...sourceOptionsArr) {
15
16
  for (const sourceOptions of sourceOptionsArr) {
16
17
  options.load(sourceOptions);
17
18
  }
18
19
  }
19
- exports.loadOptions = loadOptions;
20
20
  function loadParticlesOptions(engine, container, ...sourceOptionsArr) {
21
21
  const options = new ParticlesOptions_js_1.ParticlesOptions(engine, container);
22
22
  loadOptions(options, ...sourceOptionsArr);
23
23
  return options;
24
24
  }
25
- exports.loadParticlesOptions = loadParticlesOptions;
26
25
  });
@@ -9,29 +9,28 @@
9
9
  })(function (require, exports) {
10
10
  "use strict";
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.isArray = exports.isObject = exports.isFunction = exports.isNumber = exports.isString = exports.isBoolean = void 0;
12
+ exports.isBoolean = isBoolean;
13
+ exports.isString = isString;
14
+ exports.isNumber = isNumber;
15
+ exports.isFunction = isFunction;
16
+ exports.isObject = isObject;
17
+ exports.isArray = isArray;
13
18
  function isBoolean(arg) {
14
19
  return typeof arg === "boolean";
15
20
  }
16
- exports.isBoolean = isBoolean;
17
21
  function isString(arg) {
18
22
  return typeof arg === "string";
19
23
  }
20
- exports.isString = isString;
21
24
  function isNumber(arg) {
22
25
  return typeof arg === "number";
23
26
  }
24
- exports.isNumber = isNumber;
25
27
  function isFunction(arg) {
26
28
  return typeof arg === "function";
27
29
  }
28
- exports.isFunction = isFunction;
29
30
  function isObject(arg) {
30
31
  return typeof arg === "object" && arg !== null;
31
32
  }
32
- exports.isObject = isObject;
33
33
  function isArray(arg) {
34
34
  return Array.isArray(arg);
35
35
  }
36
- exports.isArray = isArray;
37
36
  });
@@ -9,7 +9,35 @@
9
9
  })(function (require, exports) {
10
10
  "use strict";
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.updateAnimation = exports.getSize = exports.getPosition = exports.initParticleNumericAnimationValue = exports.findItemFromSingleOrMultiple = exports.itemFromSingleOrMultiple = exports.executeOnSingleOrMultiple = exports.rectBounce = exports.circleBounce = exports.circleBounceDataFromParticle = exports.divMode = exports.singleDivModeExecute = exports.divModeExecute = exports.isDivModeEnabled = exports.deepExtend = exports.calculateBounds = exports.areBoundsInside = exports.isPointInside = exports.itemFromArray = exports.arrayRandomIndex = exports.loadFont = exports.isInArray = exports.safeMutationObserver = exports.safeIntersectionObserver = exports.safeMatchMedia = exports.hasMatchMedia = exports.isSsr = exports.getLogger = exports.setLogger = void 0;
12
+ exports.setLogger = setLogger;
13
+ exports.getLogger = getLogger;
14
+ exports.isSsr = isSsr;
15
+ exports.hasMatchMedia = hasMatchMedia;
16
+ exports.safeMatchMedia = safeMatchMedia;
17
+ exports.safeIntersectionObserver = safeIntersectionObserver;
18
+ exports.safeMutationObserver = safeMutationObserver;
19
+ exports.isInArray = isInArray;
20
+ exports.loadFont = loadFont;
21
+ exports.arrayRandomIndex = arrayRandomIndex;
22
+ exports.itemFromArray = itemFromArray;
23
+ exports.isPointInside = isPointInside;
24
+ exports.areBoundsInside = areBoundsInside;
25
+ exports.calculateBounds = calculateBounds;
26
+ exports.deepExtend = deepExtend;
27
+ exports.isDivModeEnabled = isDivModeEnabled;
28
+ exports.divModeExecute = divModeExecute;
29
+ exports.singleDivModeExecute = singleDivModeExecute;
30
+ exports.divMode = divMode;
31
+ exports.circleBounceDataFromParticle = circleBounceDataFromParticle;
32
+ exports.circleBounce = circleBounce;
33
+ exports.rectBounce = rectBounce;
34
+ exports.executeOnSingleOrMultiple = executeOnSingleOrMultiple;
35
+ exports.itemFromSingleOrMultiple = itemFromSingleOrMultiple;
36
+ exports.findItemFromSingleOrMultiple = findItemFromSingleOrMultiple;
37
+ exports.initParticleNumericAnimationValue = initParticleNumericAnimationValue;
38
+ exports.getPosition = getPosition;
39
+ exports.getSize = getSize;
40
+ exports.updateAnimation = updateAnimation;
13
41
  const NumberUtils_js_1 = require("./NumberUtils.js");
14
42
  const Constants_js_1 = require("../Core/Utils/Constants.js");
15
43
  const TypeUtils_js_1 = require("./TypeUtils.js");
@@ -36,11 +64,9 @@
36
64
  _logger.verbose = logger.verbose || _logger.verbose;
37
65
  _logger.warning = logger.warning || _logger.warning;
38
66
  }
39
- exports.setLogger = setLogger;
40
67
  function getLogger() {
41
68
  return _logger;
42
69
  }
43
- exports.getLogger = getLogger;
44
70
  function rectSideBounce(data) {
45
71
  const res = { bounced: false }, { pSide, pOtherSide, rectSide, rectOtherSide, velocity, factor } = data, half = 0.5, minVelocity = 0;
46
72
  if (pOtherSide.min < rectOtherSide.min ||
@@ -65,37 +91,31 @@
65
91
  function isSsr() {
66
92
  return typeof window === "undefined" || !window || typeof window.document === "undefined" || !window.document;
67
93
  }
68
- exports.isSsr = isSsr;
69
94
  function hasMatchMedia() {
70
95
  return !isSsr() && typeof matchMedia !== "undefined";
71
96
  }
72
- exports.hasMatchMedia = hasMatchMedia;
73
97
  function safeMatchMedia(query) {
74
98
  if (!hasMatchMedia()) {
75
99
  return;
76
100
  }
77
101
  return matchMedia(query);
78
102
  }
79
- exports.safeMatchMedia = safeMatchMedia;
80
103
  function safeIntersectionObserver(callback) {
81
104
  if (isSsr() || typeof IntersectionObserver === "undefined") {
82
105
  return;
83
106
  }
84
107
  return new IntersectionObserver(callback);
85
108
  }
86
- exports.safeIntersectionObserver = safeIntersectionObserver;
87
109
  function safeMutationObserver(callback) {
88
110
  if (isSsr() || typeof MutationObserver === "undefined") {
89
111
  return;
90
112
  }
91
113
  return new MutationObserver(callback);
92
114
  }
93
- exports.safeMutationObserver = safeMutationObserver;
94
115
  function isInArray(value, array) {
95
116
  const invalidIndex = -1;
96
117
  return value === array || ((0, TypeUtils_js_1.isArray)(array) && array.indexOf(value) > invalidIndex);
97
118
  }
98
- exports.isInArray = isInArray;
99
119
  async function loadFont(font, weight) {
100
120
  try {
101
121
  await document.fonts.load(`${weight ?? "400"} 36px '${font ?? "Verdana"}'`);
@@ -103,20 +123,16 @@
103
123
  catch {
104
124
  }
105
125
  }
106
- exports.loadFont = loadFont;
107
126
  function arrayRandomIndex(array) {
108
127
  return Math.floor((0, NumberUtils_js_1.getRandom)() * array.length);
109
128
  }
110
- exports.arrayRandomIndex = arrayRandomIndex;
111
129
  function itemFromArray(array, index, useIndex = true) {
112
130
  return array[index !== undefined && useIndex ? index % array.length : arrayRandomIndex(array)];
113
131
  }
114
- exports.itemFromArray = itemFromArray;
115
132
  function isPointInside(point, size, offset, radius, direction) {
116
133
  const minRadius = 0;
117
134
  return areBoundsInside(calculateBounds(point, radius ?? minRadius), size, offset, direction);
118
135
  }
119
- exports.isPointInside = isPointInside;
120
136
  function areBoundsInside(bounds, size, offset, direction) {
121
137
  let inside = true;
122
138
  if (!direction || direction === OutModeDirection_js_1.OutModeDirection.bottom) {
@@ -133,7 +149,6 @@
133
149
  }
134
150
  return inside;
135
151
  }
136
- exports.areBoundsInside = areBoundsInside;
137
152
  function calculateBounds(point, radius) {
138
153
  return {
139
154
  bottom: point.y + radius,
@@ -142,7 +157,6 @@
142
157
  top: point.y - radius,
143
158
  };
144
159
  }
145
- exports.calculateBounds = calculateBounds;
146
160
  function deepExtend(destination, ...sources) {
147
161
  for (const source of sources) {
148
162
  if (source === undefined || source === null) {
@@ -172,11 +186,9 @@
172
186
  }
173
187
  return destination;
174
188
  }
175
- exports.deepExtend = deepExtend;
176
189
  function isDivModeEnabled(mode, divs) {
177
190
  return !!findItemFromSingleOrMultiple(divs, t => t.enable && isInArray(mode, t.mode));
178
191
  }
179
- exports.isDivModeEnabled = isDivModeEnabled;
180
192
  function divModeExecute(mode, divs, callback) {
181
193
  executeOnSingleOrMultiple(divs, div => {
182
194
  const divMode = div.mode, divEnabled = div.enable;
@@ -185,14 +197,12 @@
185
197
  }
186
198
  });
187
199
  }
188
- exports.divModeExecute = divModeExecute;
189
200
  function singleDivModeExecute(div, callback) {
190
201
  const selectors = div.selectors;
191
202
  executeOnSingleOrMultiple(selectors, selector => {
192
203
  callback(selector, div);
193
204
  });
194
205
  }
195
- exports.singleDivModeExecute = singleDivModeExecute;
196
206
  function divMode(divs, element) {
197
207
  if (!element || !divs) {
198
208
  return;
@@ -201,7 +211,6 @@
201
211
  return checkSelector(element, div.selectors);
202
212
  });
203
213
  }
204
- exports.divMode = divMode;
205
214
  function circleBounceDataFromParticle(p) {
206
215
  return {
207
216
  position: p.getPosition(),
@@ -211,7 +220,6 @@
211
220
  factor: Vectors_js_1.Vector.create((0, NumberUtils_js_1.getRangeValue)(p.options.bounce.horizontal.value), (0, NumberUtils_js_1.getRangeValue)(p.options.bounce.vertical.value)),
212
221
  };
213
222
  }
214
- exports.circleBounceDataFromParticle = circleBounceDataFromParticle;
215
223
  function circleBounce(p1, p2) {
216
224
  const { x: xVelocityDiff, y: yVelocityDiff } = p1.velocity.sub(p2.velocity), [pos1, pos2] = [p1.position, p2.position], { dx: xDist, dy: yDist } = (0, NumberUtils_js_1.getDistances)(pos2, pos1), minimumDistance = 0;
217
225
  if (xVelocityDiff * xDist + yVelocityDiff * yDist < minimumDistance) {
@@ -223,7 +231,6 @@
223
231
  p2.velocity.x = vFinal2.x * p2.factor.x;
224
232
  p2.velocity.y = vFinal2.y * p2.factor.y;
225
233
  }
226
- exports.circleBounce = circleBounce;
227
234
  function rectBounce(particle, divBounds) {
228
235
  const pPos = particle.getPosition(), size = particle.getRadius(), bounds = calculateBounds(pPos, size), bounceOptions = particle.options.bounce, resH = rectSideBounce({
229
236
  pSide: {
@@ -282,16 +289,13 @@
282
289
  }
283
290
  }
284
291
  }
285
- exports.rectBounce = rectBounce;
286
292
  function executeOnSingleOrMultiple(obj, callback) {
287
293
  const defaultIndex = 0;
288
294
  return (0, TypeUtils_js_1.isArray)(obj) ? obj.map((item, index) => callback(item, index)) : callback(obj, defaultIndex);
289
295
  }
290
- exports.executeOnSingleOrMultiple = executeOnSingleOrMultiple;
291
296
  function itemFromSingleOrMultiple(obj, index, useIndex) {
292
297
  return (0, TypeUtils_js_1.isArray)(obj) ? itemFromArray(obj, index, useIndex) : obj;
293
298
  }
294
- exports.itemFromSingleOrMultiple = itemFromSingleOrMultiple;
295
299
  function findItemFromSingleOrMultiple(obj, callback) {
296
300
  if ((0, TypeUtils_js_1.isArray)(obj)) {
297
301
  return obj.find((t, index) => callback(t, index));
@@ -299,7 +303,6 @@
299
303
  const defaultIndex = 0;
300
304
  return callback(obj, defaultIndex) ? obj : undefined;
301
305
  }
302
- exports.findItemFromSingleOrMultiple = findItemFromSingleOrMultiple;
303
306
  function initParticleNumericAnimationValue(options, pxRatio) {
304
307
  const valueRange = options.value, animationOptions = options.animation, res = {
305
308
  delayTime: (0, NumberUtils_js_1.getRangeValue)(animationOptions.delay) * Constants_js_1.millisecondsToSeconds,
@@ -350,7 +353,6 @@
350
353
  res.initialValue = res.value;
351
354
  return res;
352
355
  }
353
- exports.initParticleNumericAnimationValue = initParticleNumericAnimationValue;
354
356
  function getPositionOrSize(positionOrSize, canvasSize) {
355
357
  const isPercent = positionOrSize.mode === PixelMode_js_1.PixelMode.percent;
356
358
  if (!isPercent) {
@@ -374,11 +376,9 @@
374
376
  function getPosition(position, canvasSize) {
375
377
  return getPositionOrSize(position, canvasSize);
376
378
  }
377
- exports.getPosition = getPosition;
378
379
  function getSize(size, canvasSize) {
379
380
  return getPositionOrSize(size, canvasSize);
380
381
  }
381
- exports.getSize = getSize;
382
382
  function checkDestroy(particle, destroyType, value, minValue, maxValue) {
383
383
  switch (destroyType) {
384
384
  case DestroyType_js_1.DestroyType.max:
@@ -454,5 +454,4 @@
454
454
  data.value = (0, NumberUtils_js_1.clamp)(data.value, minValue, maxValue);
455
455
  }
456
456
  }
457
- exports.updateAnimation = updateAnimation;
458
457
  });
package/umd/init.js CHANGED
@@ -9,7 +9,7 @@
9
9
  })(function (require, exports) {
10
10
  "use strict";
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.init = void 0;
12
+ exports.init = init;
13
13
  const Engine_js_1 = require("./Core/Engine.js");
14
14
  const HslColorManager_js_1 = require("./Utils/HslColorManager.js");
15
15
  const RgbColorManager_js_1 = require("./Utils/RgbColorManager.js");
@@ -22,5 +22,4 @@
22
22
  engine.init();
23
23
  return engine;
24
24
  }
25
- exports.init = init;
26
25
  });