tsparticles 1.37.2 → 1.37.3

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 (33) hide show
  1. package/Plugins/Absorbers/AbsorberInstance.d.ts +2 -1
  2. package/Plugins/Absorbers/AbsorberInstance.js +21 -9
  3. package/Plugins/Absorbers/Options/Classes/AbsorberSize.d.ts +2 -1
  4. package/Plugins/Absorbers/Options/Classes/AbsorberSize.js +6 -4
  5. package/Plugins/Absorbers/Options/Classes/AbsorberSizeLimit.d.ts +9 -0
  6. package/Plugins/Absorbers/Options/Classes/AbsorberSizeLimit.js +21 -0
  7. package/Plugins/Absorbers/Options/Interfaces/IAbsorberSize.d.ts +3 -2
  8. package/Plugins/Absorbers/Options/Interfaces/IAbsorberSizeLimit.d.ts +4 -0
  9. package/Plugins/Absorbers/Options/Interfaces/IAbsorberSizeLimit.js +2 -0
  10. package/browser/Plugins/Absorbers/AbsorberInstance.d.ts +2 -1
  11. package/browser/Plugins/Absorbers/AbsorberInstance.js +21 -9
  12. package/browser/Plugins/Absorbers/Options/Classes/AbsorberSize.d.ts +2 -1
  13. package/browser/Plugins/Absorbers/Options/Classes/AbsorberSize.js +6 -4
  14. package/browser/Plugins/Absorbers/Options/Classes/AbsorberSizeLimit.d.ts +9 -0
  15. package/browser/Plugins/Absorbers/Options/Classes/AbsorberSizeLimit.js +17 -0
  16. package/browser/Plugins/Absorbers/Options/Interfaces/IAbsorberSize.d.ts +3 -2
  17. package/browser/Plugins/Absorbers/Options/Interfaces/IAbsorberSizeLimit.d.ts +4 -0
  18. package/browser/Plugins/Absorbers/Options/Interfaces/IAbsorberSizeLimit.js +1 -0
  19. package/esm/Plugins/Absorbers/AbsorberInstance.d.ts +2 -1
  20. package/esm/Plugins/Absorbers/AbsorberInstance.js +21 -9
  21. package/esm/Plugins/Absorbers/Options/Classes/AbsorberSize.d.ts +2 -1
  22. package/esm/Plugins/Absorbers/Options/Classes/AbsorberSize.js +6 -4
  23. package/esm/Plugins/Absorbers/Options/Classes/AbsorberSizeLimit.d.ts +9 -0
  24. package/esm/Plugins/Absorbers/Options/Classes/AbsorberSizeLimit.js +17 -0
  25. package/esm/Plugins/Absorbers/Options/Interfaces/IAbsorberSize.d.ts +3 -2
  26. package/esm/Plugins/Absorbers/Options/Interfaces/IAbsorberSizeLimit.d.ts +4 -0
  27. package/esm/Plugins/Absorbers/Options/Interfaces/IAbsorberSizeLimit.js +1 -0
  28. package/package.json +1 -1
  29. package/report.html +2 -2
  30. package/report.slim.html +2 -2
  31. package/tsparticles.js +40 -14
  32. package/tsparticles.min.js +2 -2
  33. package/tsparticles.slim.min.js +1 -1
@@ -5,6 +5,7 @@ import type { IAbsorber } from "./Options/Interfaces/IAbsorber";
5
5
  import type { Absorbers } from "./Absorbers";
6
6
  import { Vector } from "../../Core/Particle/Vector";
7
7
  import { RotateDirection } from "../../Enums";
8
+ import { IAbsorberSizeLimit } from "./Options/Interfaces/IAbsorberSizeLimit";
8
9
  declare type OrbitingParticle = Particle & {
9
10
  absorberOrbit?: Vector;
10
11
  absorberOrbitDirection?: RotateDirection;
@@ -17,7 +18,7 @@ export declare class AbsorberInstance {
17
18
  opacity: number;
18
19
  size: number;
19
20
  color: IRgb;
20
- limit?: number;
21
+ limit: IAbsorberSizeLimit;
21
22
  readonly name?: string;
22
23
  position: Vector;
23
24
  private dragging;
@@ -6,7 +6,7 @@ const Vector_1 = require("../../Core/Particle/Vector");
6
6
  const Enums_1 = require("../../Enums");
7
7
  class AbsorberInstance {
8
8
  constructor(absorbers, container, options, position) {
9
- var _a, _b, _c;
9
+ var _a, _b, _c, _d, _e;
10
10
  this.absorbers = absorbers;
11
11
  this.container = container;
12
12
  this.initialPosition = position ? Vector_1.Vector.create(position.x, position.y) : undefined;
@@ -17,14 +17,23 @@ class AbsorberInstance {
17
17
  this.size = (0, Utils_1.getRangeValue)(options.size.value) * container.retina.pixelRatio;
18
18
  this.mass = this.size * options.size.density * container.retina.reduceFactor;
19
19
  const limit = options.size.limit;
20
- this.limit = limit !== undefined ? limit * container.retina.pixelRatio * container.retina.reduceFactor : limit;
20
+ this.limit =
21
+ typeof limit === "number"
22
+ ? {
23
+ radius: limit * container.retina.pixelRatio * container.retina.reduceFactor,
24
+ mass: 0,
25
+ }
26
+ : {
27
+ radius: ((_a = limit === null || limit === void 0 ? void 0 : limit.radius) !== null && _a !== void 0 ? _a : 0) * container.retina.pixelRatio * container.retina.reduceFactor,
28
+ mass: (_b = limit === null || limit === void 0 ? void 0 : limit.mass) !== null && _b !== void 0 ? _b : 0,
29
+ };
21
30
  const color = typeof options.color === "string" ? { value: options.color } : options.color;
22
- this.color = (_a = (0, Utils_1.colorToRgb)(color)) !== null && _a !== void 0 ? _a : {
31
+ this.color = (_c = (0, Utils_1.colorToRgb)(color)) !== null && _c !== void 0 ? _c : {
23
32
  b: 0,
24
33
  g: 0,
25
34
  r: 0,
26
35
  };
27
- this.position = (_c = (_b = this.initialPosition) === null || _b === void 0 ? void 0 : _b.copy()) !== null && _c !== void 0 ? _c : this.calcPosition();
36
+ this.position = (_e = (_d = this.initialPosition) === null || _d === void 0 ? void 0 : _d.copy()) !== null && _e !== void 0 ? _e : this.calcPosition();
28
37
  }
29
38
  attract(particle) {
30
39
  const container = this.container;
@@ -67,10 +76,12 @@ class AbsorberInstance {
67
76
  }
68
77
  this.updateParticlePosition(particle, v);
69
78
  }
70
- if (this.limit === undefined || this.size < this.limit) {
79
+ if (this.limit.radius <= 0 || this.size < this.limit.radius) {
71
80
  this.size += sizeFactor;
72
81
  }
73
- this.mass += sizeFactor * this.options.size.density * container.retina.reduceFactor;
82
+ if (this.limit.mass <= 0 || this.mass < this.limit.mass) {
83
+ this.mass += sizeFactor * this.options.size.density * container.retina.reduceFactor;
84
+ }
74
85
  }
75
86
  else {
76
87
  this.updateParticlePosition(particle, v);
@@ -105,9 +116,10 @@ class AbsorberInstance {
105
116
  const container = this.container;
106
117
  const canvasSize = container.canvas.size;
107
118
  if (particle.needsNewPosition) {
108
- const pSize = particle.getRadius();
109
- particle.position.x = (canvasSize.width - pSize * 2) * (1 + (Math.random() * 0.2 - 0.1)) + pSize;
110
- particle.position.y = (canvasSize.height - pSize * 2) * (1 + (Math.random() * 0.2 - 0.1)) + pSize;
119
+ particle.position.x = Math.floor(Math.random() * canvasSize.width);
120
+ particle.position.y = Math.floor(Math.random() * canvasSize.height);
121
+ particle.velocity.setTo(particle.initialVelocity);
122
+ particle.absorberOrbit = undefined;
111
123
  particle.needsNewPosition = false;
112
124
  }
113
125
  if (this.options.orbits) {
@@ -2,9 +2,10 @@ import type { IAbsorberSize } from "../Interfaces/IAbsorberSize";
2
2
  import type { RecursivePartial } from "../../../../Types";
3
3
  import type { IOptionLoader } from "../../../../Options/Interfaces/IOptionLoader";
4
4
  import { ValueWithRandom } from "../../../../Options/Classes/ValueWithRandom";
5
+ import { AbsorberSizeLimit } from "./AbsorberSizeLimit";
5
6
  export declare class AbsorberSize extends ValueWithRandom implements IAbsorberSize, IOptionLoader<IAbsorberSize> {
6
7
  density: number;
7
- limit?: number;
8
+ limit: AbsorberSizeLimit;
8
9
  constructor();
9
10
  load(data?: RecursivePartial<IAbsorberSize>): void;
10
11
  }
@@ -2,12 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AbsorberSize = void 0;
4
4
  const ValueWithRandom_1 = require("../../../../Options/Classes/ValueWithRandom");
5
+ const AbsorberSizeLimit_1 = require("./AbsorberSizeLimit");
5
6
  class AbsorberSize extends ValueWithRandom_1.ValueWithRandom {
6
7
  constructor() {
7
8
  super();
8
9
  this.density = 5;
9
10
  this.random.minimumValue = 1;
10
11
  this.value = 50;
12
+ this.limit = new AbsorberSizeLimit_1.AbsorberSizeLimit();
11
13
  }
12
14
  load(data) {
13
15
  if (!data) {
@@ -17,11 +19,11 @@ class AbsorberSize extends ValueWithRandom_1.ValueWithRandom {
17
19
  if (data.density !== undefined) {
18
20
  this.density = data.density;
19
21
  }
20
- if (data.limit !== undefined) {
21
- this.limit = data.limit;
22
+ if (typeof data.limit === "number") {
23
+ this.limit.radius = data.limit;
22
24
  }
23
- if (data.limit !== undefined) {
24
- this.limit = data.limit;
25
+ else {
26
+ this.limit.load(data.limit);
25
27
  }
26
28
  }
27
29
  }
@@ -0,0 +1,9 @@
1
+ import type { RecursivePartial } from "../../../../Types";
2
+ import type { IOptionLoader } from "../../../../Options/Interfaces/IOptionLoader";
3
+ import type { IAbsorberSizeLimit } from "../Interfaces/IAbsorberSizeLimit";
4
+ export declare class AbsorberSizeLimit implements IAbsorberSizeLimit, IOptionLoader<IAbsorberSizeLimit> {
5
+ radius: number;
6
+ mass: number;
7
+ constructor();
8
+ load(data?: RecursivePartial<IAbsorberSizeLimit>): void;
9
+ }
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AbsorberSizeLimit = void 0;
4
+ class AbsorberSizeLimit {
5
+ constructor() {
6
+ this.radius = 0;
7
+ this.mass = 0;
8
+ }
9
+ load(data) {
10
+ if (!data) {
11
+ return;
12
+ }
13
+ if (data.mass !== undefined) {
14
+ this.mass = data.mass;
15
+ }
16
+ if (data.radius !== undefined) {
17
+ this.radius = data.radius;
18
+ }
19
+ }
20
+ }
21
+ exports.AbsorberSizeLimit = AbsorberSizeLimit;
@@ -1,5 +1,6 @@
1
- import { IValueWithRandom } from "../../../../Options/Interfaces/IValueWithRandom";
1
+ import type { IValueWithRandom } from "../../../../Options/Interfaces/IValueWithRandom";
2
+ import type { IAbsorberSizeLimit } from "./IAbsorberSizeLimit";
2
3
  export interface IAbsorberSize extends IValueWithRandom {
3
- limit?: number;
4
+ limit?: number | IAbsorberSizeLimit;
4
5
  density: number;
5
6
  }
@@ -0,0 +1,4 @@
1
+ export interface IAbsorberSizeLimit {
2
+ radius: number;
3
+ mass: number;
4
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -5,6 +5,7 @@ import type { IAbsorber } from "./Options/Interfaces/IAbsorber";
5
5
  import type { Absorbers } from "./Absorbers";
6
6
  import { Vector } from "../../Core/Particle/Vector";
7
7
  import { RotateDirection } from "../../Enums";
8
+ import { IAbsorberSizeLimit } from "./Options/Interfaces/IAbsorberSizeLimit";
8
9
  declare type OrbitingParticle = Particle & {
9
10
  absorberOrbit?: Vector;
10
11
  absorberOrbitDirection?: RotateDirection;
@@ -20,7 +21,7 @@ export declare class AbsorberInstance {
20
21
  opacity: number;
21
22
  size: number;
22
23
  color: IRgb;
23
- limit?: number;
24
+ limit: IAbsorberSizeLimit;
24
25
  readonly name?: string;
25
26
  position: Vector;
26
27
  private dragging;
@@ -6,7 +6,7 @@ import { RotateDirection } from "../../Enums";
6
6
  */
7
7
  export class AbsorberInstance {
8
8
  constructor(absorbers, container, options, position) {
9
- var _a, _b, _c;
9
+ var _a, _b, _c, _d, _e;
10
10
  this.absorbers = absorbers;
11
11
  this.container = container;
12
12
  this.initialPosition = position ? Vector.create(position.x, position.y) : undefined;
@@ -17,14 +17,23 @@ export class AbsorberInstance {
17
17
  this.size = getRangeValue(options.size.value) * container.retina.pixelRatio;
18
18
  this.mass = this.size * options.size.density * container.retina.reduceFactor;
19
19
  const limit = options.size.limit;
20
- this.limit = limit !== undefined ? limit * container.retina.pixelRatio * container.retina.reduceFactor : limit;
20
+ this.limit =
21
+ typeof limit === "number"
22
+ ? {
23
+ radius: limit * container.retina.pixelRatio * container.retina.reduceFactor,
24
+ mass: 0,
25
+ }
26
+ : {
27
+ radius: ((_a = limit === null || limit === void 0 ? void 0 : limit.radius) !== null && _a !== void 0 ? _a : 0) * container.retina.pixelRatio * container.retina.reduceFactor,
28
+ mass: (_b = limit === null || limit === void 0 ? void 0 : limit.mass) !== null && _b !== void 0 ? _b : 0,
29
+ };
21
30
  const color = typeof options.color === "string" ? { value: options.color } : options.color;
22
- this.color = (_a = colorToRgb(color)) !== null && _a !== void 0 ? _a : {
31
+ this.color = (_c = colorToRgb(color)) !== null && _c !== void 0 ? _c : {
23
32
  b: 0,
24
33
  g: 0,
25
34
  r: 0,
26
35
  };
27
- this.position = (_c = (_b = this.initialPosition) === null || _b === void 0 ? void 0 : _b.copy()) !== null && _c !== void 0 ? _c : this.calcPosition();
36
+ this.position = (_e = (_d = this.initialPosition) === null || _d === void 0 ? void 0 : _d.copy()) !== null && _e !== void 0 ? _e : this.calcPosition();
28
37
  }
29
38
  attract(particle) {
30
39
  const container = this.container;
@@ -67,10 +76,12 @@ export class AbsorberInstance {
67
76
  }
68
77
  this.updateParticlePosition(particle, v);
69
78
  }
70
- if (this.limit === undefined || this.size < this.limit) {
79
+ if (this.limit.radius <= 0 || this.size < this.limit.radius) {
71
80
  this.size += sizeFactor;
72
81
  }
73
- this.mass += sizeFactor * this.options.size.density * container.retina.reduceFactor;
82
+ if (this.limit.mass <= 0 || this.mass < this.limit.mass) {
83
+ this.mass += sizeFactor * this.options.size.density * container.retina.reduceFactor;
84
+ }
74
85
  }
75
86
  else {
76
87
  this.updateParticlePosition(particle, v);
@@ -105,9 +116,10 @@ export class AbsorberInstance {
105
116
  const container = this.container;
106
117
  const canvasSize = container.canvas.size;
107
118
  if (particle.needsNewPosition) {
108
- const pSize = particle.getRadius();
109
- particle.position.x = (canvasSize.width - pSize * 2) * (1 + (Math.random() * 0.2 - 0.1)) + pSize;
110
- particle.position.y = (canvasSize.height - pSize * 2) * (1 + (Math.random() * 0.2 - 0.1)) + pSize;
119
+ particle.position.x = Math.floor(Math.random() * canvasSize.width);
120
+ particle.position.y = Math.floor(Math.random() * canvasSize.height);
121
+ particle.velocity.setTo(particle.initialVelocity);
122
+ particle.absorberOrbit = undefined;
111
123
  particle.needsNewPosition = false;
112
124
  }
113
125
  if (this.options.orbits) {
@@ -2,9 +2,10 @@ import type { IAbsorberSize } from "../Interfaces/IAbsorberSize";
2
2
  import type { RecursivePartial } from "../../../../Types";
3
3
  import type { IOptionLoader } from "../../../../Options/Interfaces/IOptionLoader";
4
4
  import { ValueWithRandom } from "../../../../Options/Classes/ValueWithRandom";
5
+ import { AbsorberSizeLimit } from "./AbsorberSizeLimit";
5
6
  export declare class AbsorberSize extends ValueWithRandom implements IAbsorberSize, IOptionLoader<IAbsorberSize> {
6
7
  density: number;
7
- limit?: number;
8
+ limit: AbsorberSizeLimit;
8
9
  constructor();
9
10
  load(data?: RecursivePartial<IAbsorberSize>): void;
10
11
  }
@@ -1,10 +1,12 @@
1
1
  import { ValueWithRandom } from "../../../../Options/Classes/ValueWithRandom";
2
+ import { AbsorberSizeLimit } from "./AbsorberSizeLimit";
2
3
  export class AbsorberSize extends ValueWithRandom {
3
4
  constructor() {
4
5
  super();
5
6
  this.density = 5;
6
7
  this.random.minimumValue = 1;
7
8
  this.value = 50;
9
+ this.limit = new AbsorberSizeLimit();
8
10
  }
9
11
  load(data) {
10
12
  if (!data) {
@@ -14,11 +16,11 @@ export class AbsorberSize extends ValueWithRandom {
14
16
  if (data.density !== undefined) {
15
17
  this.density = data.density;
16
18
  }
17
- if (data.limit !== undefined) {
18
- this.limit = data.limit;
19
+ if (typeof data.limit === "number") {
20
+ this.limit.radius = data.limit;
19
21
  }
20
- if (data.limit !== undefined) {
21
- this.limit = data.limit;
22
+ else {
23
+ this.limit.load(data.limit);
22
24
  }
23
25
  }
24
26
  }
@@ -0,0 +1,9 @@
1
+ import type { RecursivePartial } from "../../../../Types";
2
+ import type { IOptionLoader } from "../../../../Options/Interfaces/IOptionLoader";
3
+ import type { IAbsorberSizeLimit } from "../Interfaces/IAbsorberSizeLimit";
4
+ export declare class AbsorberSizeLimit implements IAbsorberSizeLimit, IOptionLoader<IAbsorberSizeLimit> {
5
+ radius: number;
6
+ mass: number;
7
+ constructor();
8
+ load(data?: RecursivePartial<IAbsorberSizeLimit>): void;
9
+ }
@@ -0,0 +1,17 @@
1
+ export class AbsorberSizeLimit {
2
+ constructor() {
3
+ this.radius = 0;
4
+ this.mass = 0;
5
+ }
6
+ load(data) {
7
+ if (!data) {
8
+ return;
9
+ }
10
+ if (data.mass !== undefined) {
11
+ this.mass = data.mass;
12
+ }
13
+ if (data.radius !== undefined) {
14
+ this.radius = data.radius;
15
+ }
16
+ }
17
+ }
@@ -1,5 +1,6 @@
1
- import { IValueWithRandom } from "../../../../Options/Interfaces/IValueWithRandom";
1
+ import type { IValueWithRandom } from "../../../../Options/Interfaces/IValueWithRandom";
2
+ import type { IAbsorberSizeLimit } from "./IAbsorberSizeLimit";
2
3
  export interface IAbsorberSize extends IValueWithRandom {
3
- limit?: number;
4
+ limit?: number | IAbsorberSizeLimit;
4
5
  density: number;
5
6
  }
@@ -0,0 +1,4 @@
1
+ export interface IAbsorberSizeLimit {
2
+ radius: number;
3
+ mass: number;
4
+ }
@@ -5,6 +5,7 @@ import type { IAbsorber } from "./Options/Interfaces/IAbsorber";
5
5
  import type { Absorbers } from "./Absorbers";
6
6
  import { Vector } from "../../Core/Particle/Vector";
7
7
  import { RotateDirection } from "../../Enums";
8
+ import { IAbsorberSizeLimit } from "./Options/Interfaces/IAbsorberSizeLimit";
8
9
  declare type OrbitingParticle = Particle & {
9
10
  absorberOrbit?: Vector;
10
11
  absorberOrbitDirection?: RotateDirection;
@@ -17,7 +18,7 @@ export declare class AbsorberInstance {
17
18
  opacity: number;
18
19
  size: number;
19
20
  color: IRgb;
20
- limit?: number;
21
+ limit: IAbsorberSizeLimit;
21
22
  readonly name?: string;
22
23
  position: Vector;
23
24
  private dragging;
@@ -3,7 +3,7 @@ import { Vector } from "../../Core/Particle/Vector";
3
3
  import { RotateDirection } from "../../Enums";
4
4
  export class AbsorberInstance {
5
5
  constructor(absorbers, container, options, position) {
6
- var _a, _b, _c;
6
+ var _a, _b, _c, _d, _e;
7
7
  this.absorbers = absorbers;
8
8
  this.container = container;
9
9
  this.initialPosition = position ? Vector.create(position.x, position.y) : undefined;
@@ -14,14 +14,23 @@ export class AbsorberInstance {
14
14
  this.size = getRangeValue(options.size.value) * container.retina.pixelRatio;
15
15
  this.mass = this.size * options.size.density * container.retina.reduceFactor;
16
16
  const limit = options.size.limit;
17
- this.limit = limit !== undefined ? limit * container.retina.pixelRatio * container.retina.reduceFactor : limit;
17
+ this.limit =
18
+ typeof limit === "number"
19
+ ? {
20
+ radius: limit * container.retina.pixelRatio * container.retina.reduceFactor,
21
+ mass: 0,
22
+ }
23
+ : {
24
+ radius: ((_a = limit === null || limit === void 0 ? void 0 : limit.radius) !== null && _a !== void 0 ? _a : 0) * container.retina.pixelRatio * container.retina.reduceFactor,
25
+ mass: (_b = limit === null || limit === void 0 ? void 0 : limit.mass) !== null && _b !== void 0 ? _b : 0,
26
+ };
18
27
  const color = typeof options.color === "string" ? { value: options.color } : options.color;
19
- this.color = (_a = colorToRgb(color)) !== null && _a !== void 0 ? _a : {
28
+ this.color = (_c = colorToRgb(color)) !== null && _c !== void 0 ? _c : {
20
29
  b: 0,
21
30
  g: 0,
22
31
  r: 0,
23
32
  };
24
- this.position = (_c = (_b = this.initialPosition) === null || _b === void 0 ? void 0 : _b.copy()) !== null && _c !== void 0 ? _c : this.calcPosition();
33
+ this.position = (_e = (_d = this.initialPosition) === null || _d === void 0 ? void 0 : _d.copy()) !== null && _e !== void 0 ? _e : this.calcPosition();
25
34
  }
26
35
  attract(particle) {
27
36
  const container = this.container;
@@ -64,10 +73,12 @@ export class AbsorberInstance {
64
73
  }
65
74
  this.updateParticlePosition(particle, v);
66
75
  }
67
- if (this.limit === undefined || this.size < this.limit) {
76
+ if (this.limit.radius <= 0 || this.size < this.limit.radius) {
68
77
  this.size += sizeFactor;
69
78
  }
70
- this.mass += sizeFactor * this.options.size.density * container.retina.reduceFactor;
79
+ if (this.limit.mass <= 0 || this.mass < this.limit.mass) {
80
+ this.mass += sizeFactor * this.options.size.density * container.retina.reduceFactor;
81
+ }
71
82
  }
72
83
  else {
73
84
  this.updateParticlePosition(particle, v);
@@ -102,9 +113,10 @@ export class AbsorberInstance {
102
113
  const container = this.container;
103
114
  const canvasSize = container.canvas.size;
104
115
  if (particle.needsNewPosition) {
105
- const pSize = particle.getRadius();
106
- particle.position.x = (canvasSize.width - pSize * 2) * (1 + (Math.random() * 0.2 - 0.1)) + pSize;
107
- particle.position.y = (canvasSize.height - pSize * 2) * (1 + (Math.random() * 0.2 - 0.1)) + pSize;
116
+ particle.position.x = Math.floor(Math.random() * canvasSize.width);
117
+ particle.position.y = Math.floor(Math.random() * canvasSize.height);
118
+ particle.velocity.setTo(particle.initialVelocity);
119
+ particle.absorberOrbit = undefined;
108
120
  particle.needsNewPosition = false;
109
121
  }
110
122
  if (this.options.orbits) {
@@ -2,9 +2,10 @@ import type { IAbsorberSize } from "../Interfaces/IAbsorberSize";
2
2
  import type { RecursivePartial } from "../../../../Types";
3
3
  import type { IOptionLoader } from "../../../../Options/Interfaces/IOptionLoader";
4
4
  import { ValueWithRandom } from "../../../../Options/Classes/ValueWithRandom";
5
+ import { AbsorberSizeLimit } from "./AbsorberSizeLimit";
5
6
  export declare class AbsorberSize extends ValueWithRandom implements IAbsorberSize, IOptionLoader<IAbsorberSize> {
6
7
  density: number;
7
- limit?: number;
8
+ limit: AbsorberSizeLimit;
8
9
  constructor();
9
10
  load(data?: RecursivePartial<IAbsorberSize>): void;
10
11
  }
@@ -1,10 +1,12 @@
1
1
  import { ValueWithRandom } from "../../../../Options/Classes/ValueWithRandom";
2
+ import { AbsorberSizeLimit } from "./AbsorberSizeLimit";
2
3
  export class AbsorberSize extends ValueWithRandom {
3
4
  constructor() {
4
5
  super();
5
6
  this.density = 5;
6
7
  this.random.minimumValue = 1;
7
8
  this.value = 50;
9
+ this.limit = new AbsorberSizeLimit();
8
10
  }
9
11
  load(data) {
10
12
  if (!data) {
@@ -14,11 +16,11 @@ export class AbsorberSize extends ValueWithRandom {
14
16
  if (data.density !== undefined) {
15
17
  this.density = data.density;
16
18
  }
17
- if (data.limit !== undefined) {
18
- this.limit = data.limit;
19
+ if (typeof data.limit === "number") {
20
+ this.limit.radius = data.limit;
19
21
  }
20
- if (data.limit !== undefined) {
21
- this.limit = data.limit;
22
+ else {
23
+ this.limit.load(data.limit);
22
24
  }
23
25
  }
24
26
  }
@@ -0,0 +1,9 @@
1
+ import type { RecursivePartial } from "../../../../Types";
2
+ import type { IOptionLoader } from "../../../../Options/Interfaces/IOptionLoader";
3
+ import type { IAbsorberSizeLimit } from "../Interfaces/IAbsorberSizeLimit";
4
+ export declare class AbsorberSizeLimit implements IAbsorberSizeLimit, IOptionLoader<IAbsorberSizeLimit> {
5
+ radius: number;
6
+ mass: number;
7
+ constructor();
8
+ load(data?: RecursivePartial<IAbsorberSizeLimit>): void;
9
+ }
@@ -0,0 +1,17 @@
1
+ export class AbsorberSizeLimit {
2
+ constructor() {
3
+ this.radius = 0;
4
+ this.mass = 0;
5
+ }
6
+ load(data) {
7
+ if (!data) {
8
+ return;
9
+ }
10
+ if (data.mass !== undefined) {
11
+ this.mass = data.mass;
12
+ }
13
+ if (data.radius !== undefined) {
14
+ this.radius = data.radius;
15
+ }
16
+ }
17
+ }
@@ -1,5 +1,6 @@
1
- import { IValueWithRandom } from "../../../../Options/Interfaces/IValueWithRandom";
1
+ import type { IValueWithRandom } from "../../../../Options/Interfaces/IValueWithRandom";
2
+ import type { IAbsorberSizeLimit } from "./IAbsorberSizeLimit";
2
3
  export interface IAbsorberSize extends IValueWithRandom {
3
- limit?: number;
4
+ limit?: number | IAbsorberSizeLimit;
4
5
  density: number;
5
6
  }
@@ -0,0 +1,4 @@
1
+ export interface IAbsorberSizeLimit {
2
+ radius: number;
3
+ mass: number;
4
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tsparticles",
3
- "version": "1.37.2",
3
+ "version": "1.37.3",
4
4
  "description": "Easily create highly customizable particle animations and use them as animated backgrounds for your website. Ready to use components available also for React, Vue.js (2.x and 3.x), Angular, Svelte, jQuery, Preact, Riot.js, Inferno.",
5
5
  "homepage": "https://particles.js.org/",
6
6
  "scripts": {