tsparticles 1.39.2 → 1.40.2
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.
- package/Core/Container.d.ts +3 -1
- package/Core/Container.js +30 -15
- package/Core/Loader.d.ts +12 -9
- package/Core/Loader.js +35 -19
- package/Core/Particle.d.ts +3 -1
- package/Core/Particle.js +17 -2
- package/Core/Particles.d.ts +3 -1
- package/Core/Particles.js +20 -5
- package/Core/Utils/InteractionManager.d.ts +5 -3
- package/Core/Utils/InteractionManager.js +19 -3
- package/Core/Utils/Plugins.d.ts +29 -15
- package/Core/Utils/Plugins.js +58 -46
- package/Options/Classes/Options.d.ts +2 -1
- package/Options/Classes/Options.js +14 -7
- package/Plugins/Emitters/EmitterInstance.d.ts +6 -3
- package/Plugins/Emitters/EmitterInstance.js +46 -16
- package/Plugins/Emitters/Emitters.d.ts +3 -1
- package/Plugins/Emitters/Emitters.js +17 -2
- package/Plugins/Emitters/{EmittersMain.d.ts → EmittersEngine.d.ts} +3 -1
- package/Plugins/Emitters/{EmittersMain.js → EmittersEngine.js} +0 -0
- package/Plugins/Emitters/IEmitterShape.d.ts +2 -2
- package/Plugins/Emitters/Options/Classes/Emitter.d.ts +1 -0
- package/Plugins/Emitters/Options/Classes/Emitter.js +1 -0
- package/Plugins/Emitters/Options/Interfaces/IEmitter.d.ts +1 -0
- package/Plugins/Emitters/ShapeManager.d.ts +6 -3
- package/Plugins/Emitters/ShapeManager.js +16 -4
- package/Plugins/Emitters/Shapes/Circle/CircleShape.d.ts +2 -2
- package/Plugins/Emitters/Shapes/Circle/CircleShape.js +2 -2
- package/Plugins/Emitters/Shapes/Square/SquareShape.d.ts +2 -2
- package/Plugins/Emitters/Shapes/Square/SquareShape.js +4 -4
- package/Plugins/Emitters/index.d.ts +3 -3
- package/Plugins/Emitters/index.js +25 -6
- package/README.md +1 -1
- package/browser/Core/Container.d.ts +4 -1
- package/browser/Core/Container.js +32 -16
- package/browser/Core/Loader.d.ts +12 -9
- package/browser/Core/Loader.js +35 -19
- package/browser/Core/Particle.d.ts +3 -1
- package/browser/Core/Particle.js +18 -3
- package/browser/Core/Particles.d.ts +3 -1
- package/browser/Core/Particles.js +21 -6
- package/browser/Core/Utils/InteractionManager.d.ts +5 -3
- package/browser/Core/Utils/InteractionManager.js +19 -3
- package/browser/Core/Utils/Plugins.d.ts +29 -15
- package/browser/Core/Utils/Plugins.js +58 -46
- package/browser/Options/Classes/Options.d.ts +2 -1
- package/browser/Options/Classes/Options.js +14 -7
- package/browser/Plugins/Emitters/EmitterInstance.d.ts +6 -3
- package/browser/Plugins/Emitters/EmitterInstance.js +46 -16
- package/browser/Plugins/Emitters/Emitters.d.ts +3 -1
- package/browser/Plugins/Emitters/Emitters.js +17 -2
- package/{esm/Plugins/Emitters/EmittersMain.d.ts → browser/Plugins/Emitters/EmittersEngine.d.ts} +3 -1
- package/browser/Plugins/Emitters/{EmittersMain.js → EmittersEngine.js} +0 -0
- package/browser/Plugins/Emitters/IEmitterShape.d.ts +2 -2
- package/browser/Plugins/Emitters/Options/Classes/Emitter.d.ts +1 -0
- package/browser/Plugins/Emitters/Options/Classes/Emitter.js +1 -0
- package/browser/Plugins/Emitters/Options/Interfaces/IEmitter.d.ts +4 -0
- package/browser/Plugins/Emitters/ShapeManager.d.ts +6 -3
- package/browser/Plugins/Emitters/ShapeManager.js +16 -4
- package/browser/Plugins/Emitters/Shapes/Circle/CircleShape.d.ts +2 -2
- package/browser/Plugins/Emitters/Shapes/Circle/CircleShape.js +2 -2
- package/browser/Plugins/Emitters/Shapes/Square/SquareShape.d.ts +2 -2
- package/browser/Plugins/Emitters/Shapes/Square/SquareShape.js +4 -4
- package/browser/Plugins/Emitters/index.d.ts +3 -3
- package/browser/Plugins/Emitters/index.js +25 -6
- package/browser/engine.d.ts +5 -1
- package/browser/engine.js +22 -17
- package/engine.d.ts +3 -0
- package/engine.js +20 -16
- package/esm/Core/Container.d.ts +3 -1
- package/esm/Core/Container.js +31 -16
- package/esm/Core/Loader.d.ts +12 -9
- package/esm/Core/Loader.js +35 -19
- package/esm/Core/Particle.d.ts +3 -1
- package/esm/Core/Particle.js +18 -3
- package/esm/Core/Particles.d.ts +3 -1
- package/esm/Core/Particles.js +21 -6
- package/esm/Core/Utils/InteractionManager.d.ts +5 -3
- package/esm/Core/Utils/InteractionManager.js +19 -3
- package/esm/Core/Utils/Plugins.d.ts +29 -15
- package/esm/Core/Utils/Plugins.js +58 -46
- package/esm/Options/Classes/Options.d.ts +2 -1
- package/esm/Options/Classes/Options.js +14 -7
- package/esm/Plugins/Emitters/EmitterInstance.d.ts +6 -3
- package/esm/Plugins/Emitters/EmitterInstance.js +46 -16
- package/esm/Plugins/Emitters/Emitters.d.ts +3 -1
- package/esm/Plugins/Emitters/Emitters.js +17 -2
- package/{browser/Plugins/Emitters/EmittersMain.d.ts → esm/Plugins/Emitters/EmittersEngine.d.ts} +3 -1
- package/esm/Plugins/Emitters/{EmittersMain.js → EmittersEngine.js} +0 -0
- package/esm/Plugins/Emitters/IEmitterShape.d.ts +2 -2
- package/esm/Plugins/Emitters/Options/Classes/Emitter.d.ts +1 -0
- package/esm/Plugins/Emitters/Options/Classes/Emitter.js +1 -0
- package/esm/Plugins/Emitters/Options/Interfaces/IEmitter.d.ts +1 -0
- package/esm/Plugins/Emitters/ShapeManager.d.ts +6 -3
- package/esm/Plugins/Emitters/ShapeManager.js +16 -4
- package/esm/Plugins/Emitters/Shapes/Circle/CircleShape.d.ts +2 -2
- package/esm/Plugins/Emitters/Shapes/Circle/CircleShape.js +2 -2
- package/esm/Plugins/Emitters/Shapes/Square/SquareShape.d.ts +2 -2
- package/esm/Plugins/Emitters/Shapes/Square/SquareShape.js +4 -4
- package/esm/Plugins/Emitters/index.d.ts +3 -3
- package/esm/Plugins/Emitters/index.js +25 -6
- package/esm/engine.d.ts +3 -0
- package/esm/engine.js +20 -16
- package/package.json +11 -6
- package/report.html +2 -2
- package/report.slim.html +2 -2
- package/tsparticles.engine.js +227 -118
- package/tsparticles.engine.min.js +2 -2
- package/tsparticles.interaction.external.attract.js +205 -100
- package/tsparticles.interaction.external.attract.min.js +2 -2
- package/tsparticles.interaction.external.bounce.js +205 -100
- package/tsparticles.interaction.external.bounce.min.js +2 -2
- package/tsparticles.interaction.external.bubble.js +205 -100
- package/tsparticles.interaction.external.bubble.min.js +2 -2
- package/tsparticles.interaction.external.connect.js +205 -100
- package/tsparticles.interaction.external.connect.min.js +2 -2
- package/tsparticles.interaction.external.grab.js +205 -100
- package/tsparticles.interaction.external.grab.min.js +2 -2
- package/tsparticles.interaction.external.repulse.js +205 -100
- package/tsparticles.interaction.external.repulse.min.js +2 -2
- package/tsparticles.interaction.external.trail.js +205 -100
- package/tsparticles.interaction.external.trail.min.js +2 -2
- package/tsparticles.interaction.particles.attract.js +205 -100
- package/tsparticles.interaction.particles.attract.min.js +2 -2
- package/tsparticles.interaction.particles.collisions.js +205 -100
- package/tsparticles.interaction.particles.collisions.min.js +2 -2
- package/tsparticles.interaction.particles.links.js +205 -100
- package/tsparticles.interaction.particles.links.min.js +2 -2
- package/tsparticles.js +347 -156
- package/tsparticles.min.js +2 -2
- package/tsparticles.pathseg.min.js +1 -1
- package/tsparticles.plugins.absorbers.js +205 -100
- package/tsparticles.plugins.absorbers.min.js +2 -2
- package/tsparticles.plugins.emitters.js +330 -143
- package/tsparticles.plugins.emitters.min.js +2 -2
- package/tsparticles.plugins.polygonMask.js +205 -100
- package/tsparticles.plugins.polygonMask.min.js +2 -2
- package/tsparticles.shape.circle.min.js +1 -1
- package/tsparticles.shape.image.js +208 -103
- package/tsparticles.shape.image.min.js +2 -2
- package/tsparticles.shape.line.min.js +1 -1
- package/tsparticles.shape.polygon.min.js +1 -1
- package/tsparticles.shape.square.min.js +1 -1
- package/tsparticles.shape.star.min.js +1 -1
- package/tsparticles.shape.text.js +205 -100
- package/tsparticles.shape.text.min.js +2 -2
- package/tsparticles.slim.js +227 -118
- package/tsparticles.slim.min.js +2 -2
- package/tsparticles.updater.angle.js +205 -100
- package/tsparticles.updater.angle.min.js +2 -2
- package/tsparticles.updater.color.js +205 -100
- package/tsparticles.updater.color.min.js +2 -2
- package/tsparticles.updater.life.js +205 -100
- package/tsparticles.updater.life.min.js +2 -2
- package/tsparticles.updater.opacity.js +205 -100
- package/tsparticles.updater.opacity.min.js +2 -2
- package/tsparticles.updater.outModes.js +205 -100
- package/tsparticles.updater.outModes.min.js +2 -2
- package/tsparticles.updater.roll.js +205 -100
- package/tsparticles.updater.roll.min.js +2 -2
- package/tsparticles.updater.size.js +205 -100
- package/tsparticles.updater.size.min.js +2 -2
- package/tsparticles.updater.strokeColor.js +205 -100
- package/tsparticles.updater.strokeColor.min.js +2 -2
- package/tsparticles.updater.tilt.js +205 -100
- package/tsparticles.updater.tilt.min.js +2 -2
- package/tsparticles.updater.wobble.js +205 -100
- package/tsparticles.updater.wobble.min.js +2 -2
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { Container, ICoordinates, IDelta, IHsl } from "../../Core";
|
|
1
|
+
import type { Container, ICoordinates, IDelta, IDimension, IHsl } from "../../Core";
|
|
2
2
|
import { Emitter } from "./Options/Classes/Emitter";
|
|
3
3
|
import type { Emitters } from "./Emitters";
|
|
4
|
+
import type { EmittersEngine } from "./EmittersEngine";
|
|
4
5
|
import type { IEmitter } from "./Options/Interfaces/IEmitter";
|
|
5
6
|
import type { IEmitterSize } from "./Options/Interfaces/IEmitterSize";
|
|
6
7
|
import type { RecursivePartial } from "../../Types";
|
|
@@ -8,7 +9,7 @@ export declare class EmitterInstance {
|
|
|
8
9
|
#private;
|
|
9
10
|
private readonly emitters;
|
|
10
11
|
private readonly container;
|
|
11
|
-
position
|
|
12
|
+
position?: ICoordinates;
|
|
12
13
|
size: IEmitterSize;
|
|
13
14
|
options: Emitter;
|
|
14
15
|
spawnColor?: IHsl;
|
|
@@ -26,13 +27,15 @@ export declare class EmitterInstance {
|
|
|
26
27
|
private readonly shape?;
|
|
27
28
|
private readonly initialPosition?;
|
|
28
29
|
private readonly particlesOptions;
|
|
29
|
-
constructor(emitters: Emitters, container: Container, options: RecursivePartial<IEmitter>, position?: ICoordinates);
|
|
30
|
+
constructor(engine: EmittersEngine, emitters: Emitters, container: Container, options: RecursivePartial<IEmitter>, position?: ICoordinates);
|
|
30
31
|
externalPlay(): void;
|
|
31
32
|
externalPause(): void;
|
|
32
33
|
play(): void;
|
|
33
34
|
pause(): void;
|
|
34
35
|
resize(): void;
|
|
35
36
|
update(delta: IDelta): void;
|
|
37
|
+
getPosition(): ICoordinates | undefined;
|
|
38
|
+
getSize(): IDimension;
|
|
36
39
|
private prepareToDie;
|
|
37
40
|
private destroy;
|
|
38
41
|
private calcPosition;
|
|
@@ -9,19 +9,20 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
9
9
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
11
|
};
|
|
12
|
-
var _EmitterInstance_firstSpawn, _EmitterInstance_startParticlesAdded;
|
|
12
|
+
var _EmitterInstance_firstSpawn, _EmitterInstance_startParticlesAdded, _EmitterInstance_engine;
|
|
13
13
|
import { colorToHsl, deepExtend, getRangeValue, isPointInside, randomInRange } from "../../Utils";
|
|
14
14
|
import { Emitter } from "./Options/Classes/Emitter";
|
|
15
15
|
import { EmitterSize } from "./Options/Classes/EmitterSize";
|
|
16
|
-
import { ShapeManager } from "./ShapeManager";
|
|
17
16
|
export class EmitterInstance {
|
|
18
|
-
constructor(emitters, container, options, position) {
|
|
17
|
+
constructor(engine, emitters, container, options, position) {
|
|
19
18
|
var _a, _b, _c, _d, _e, _f;
|
|
20
19
|
var _g;
|
|
21
20
|
this.emitters = emitters;
|
|
22
21
|
this.container = container;
|
|
23
22
|
_EmitterInstance_firstSpawn.set(this, void 0);
|
|
24
23
|
_EmitterInstance_startParticlesAdded.set(this, void 0);
|
|
24
|
+
_EmitterInstance_engine.set(this, void 0);
|
|
25
|
+
__classPrivateFieldSet(this, _EmitterInstance_engine, engine, "f");
|
|
25
26
|
this.currentDuration = 0;
|
|
26
27
|
this.currentEmitDelay = 0;
|
|
27
28
|
this.currentSpawnDelay = 0;
|
|
@@ -34,9 +35,8 @@ export class EmitterInstance {
|
|
|
34
35
|
this.options.load(options);
|
|
35
36
|
}
|
|
36
37
|
this.spawnDelay = (((_a = this.options.life.delay) !== null && _a !== void 0 ? _a : 0) * 1000) / this.container.retina.reduceFactor;
|
|
37
|
-
this.position = (_b = this.initialPosition) !== null && _b !== void 0 ? _b : this.calcPosition();
|
|
38
38
|
this.name = this.options.name;
|
|
39
|
-
this.shape =
|
|
39
|
+
this.shape = (_b = __classPrivateFieldGet(this, _EmitterInstance_engine, "f").emitterShapeManager) === null || _b === void 0 ? void 0 : _b.getShape(this.options.shape);
|
|
40
40
|
this.fill = this.options.fill;
|
|
41
41
|
__classPrivateFieldSet(this, _EmitterInstance_firstSpawn, !this.options.life.wait, "f");
|
|
42
42
|
__classPrivateFieldSet(this, _EmitterInstance_startParticlesAdded, false, "f");
|
|
@@ -152,6 +152,40 @@ export class EmitterInstance {
|
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
|
+
getPosition() {
|
|
156
|
+
if (this.options.domId) {
|
|
157
|
+
const container = this.container, element = document.getElementById(this.options.domId);
|
|
158
|
+
if (element) {
|
|
159
|
+
const elRect = element.getBoundingClientRect();
|
|
160
|
+
return {
|
|
161
|
+
x: (elRect.x + elRect.width / 2) * container.retina.pixelRatio,
|
|
162
|
+
y: (elRect.y + elRect.height / 2) * container.retina.pixelRatio,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return this.position;
|
|
167
|
+
}
|
|
168
|
+
getSize() {
|
|
169
|
+
const container = this.container;
|
|
170
|
+
if (this.options.domId) {
|
|
171
|
+
const element = document.getElementById(this.options.domId);
|
|
172
|
+
if (element) {
|
|
173
|
+
const elRect = element.getBoundingClientRect();
|
|
174
|
+
return {
|
|
175
|
+
width: elRect.width * container.retina.pixelRatio,
|
|
176
|
+
height: elRect.height * container.retina.pixelRatio,
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return {
|
|
181
|
+
width: this.size.mode === "percent"
|
|
182
|
+
? (container.canvas.size.width * this.size.width) / 100
|
|
183
|
+
: this.size.width,
|
|
184
|
+
height: this.size.mode === "percent"
|
|
185
|
+
? (container.canvas.size.height * this.size.height) / 100
|
|
186
|
+
: this.size.height,
|
|
187
|
+
};
|
|
188
|
+
}
|
|
155
189
|
prepareToDie() {
|
|
156
190
|
var _a;
|
|
157
191
|
if (this.paused) {
|
|
@@ -187,15 +221,8 @@ export class EmitterInstance {
|
|
|
187
221
|
emitParticles(quantity) {
|
|
188
222
|
var _a, _b, _c;
|
|
189
223
|
const container = this.container;
|
|
190
|
-
const position = this.
|
|
191
|
-
const
|
|
192
|
-
x: this.size.mode === "percent"
|
|
193
|
-
? (container.canvas.size.width * this.size.width) / 100
|
|
194
|
-
: this.size.width,
|
|
195
|
-
y: this.size.mode === "percent"
|
|
196
|
-
? (container.canvas.size.height * this.size.height) / 100
|
|
197
|
-
: this.size.height,
|
|
198
|
-
};
|
|
224
|
+
const position = this.getPosition();
|
|
225
|
+
const size = this.getSize();
|
|
199
226
|
for (let i = 0; i < quantity; i++) {
|
|
200
227
|
const particlesOptions = deepExtend({}, this.particlesOptions);
|
|
201
228
|
if (this.spawnColor) {
|
|
@@ -214,7 +241,10 @@ export class EmitterInstance {
|
|
|
214
241
|
particlesOptions.color.value = this.spawnColor;
|
|
215
242
|
}
|
|
216
243
|
}
|
|
217
|
-
|
|
244
|
+
if (!position) {
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
const pPosition = (_c = (_b = this.shape) === null || _b === void 0 ? void 0 : _b.randomPosition(position, size, this.fill)) !== null && _c !== void 0 ? _c : position;
|
|
218
248
|
container.particles.addParticle(pPosition, particlesOptions);
|
|
219
249
|
}
|
|
220
250
|
}
|
|
@@ -231,4 +261,4 @@ export class EmitterInstance {
|
|
|
231
261
|
return (initValue + (colorSpeed * container.fpsLimit) / emitFactor + colorOffset * 3.6) % maxValue;
|
|
232
262
|
}
|
|
233
263
|
}
|
|
234
|
-
_EmitterInstance_firstSpawn = new WeakMap(), _EmitterInstance_startParticlesAdded = new WeakMap();
|
|
264
|
+
_EmitterInstance_firstSpawn = new WeakMap(), _EmitterInstance_startParticlesAdded = new WeakMap(), _EmitterInstance_engine = new WeakMap();
|
|
@@ -2,15 +2,17 @@ import type { Container, IContainerPlugin, ICoordinates, IDelta } from "../../Co
|
|
|
2
2
|
import type { RecursivePartial, SingleOrMultiple } from "../../Types";
|
|
3
3
|
import { Emitter } from "./Options/Classes/Emitter";
|
|
4
4
|
import { EmitterInstance } from "./EmitterInstance";
|
|
5
|
+
import type { EmittersEngine } from "./EmittersEngine";
|
|
5
6
|
import type { IEmitter } from "./Options/Interfaces/IEmitter";
|
|
6
7
|
import type { IEmitterOptions } from "./Options/Interfaces/IEmitterOptions";
|
|
7
8
|
import type { IOptions } from "../../Options/Interfaces/IOptions";
|
|
8
9
|
export declare class Emitters implements IContainerPlugin {
|
|
10
|
+
#private;
|
|
9
11
|
private readonly container;
|
|
10
12
|
array: EmitterInstance[];
|
|
11
13
|
emitters: SingleOrMultiple<Emitter>;
|
|
12
14
|
interactivityEmitters: SingleOrMultiple<Emitter>;
|
|
13
|
-
constructor(container: Container);
|
|
15
|
+
constructor(engine: EmittersEngine, container: Container);
|
|
14
16
|
init(options?: RecursivePartial<IOptions & IEmitterOptions>): void;
|
|
15
17
|
play(): void;
|
|
16
18
|
pause(): void;
|
|
@@ -1,9 +1,23 @@
|
|
|
1
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
+
};
|
|
7
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
+
};
|
|
12
|
+
var _Emitters_engine;
|
|
1
13
|
import { deepExtend, itemFromArray } from "../../Utils";
|
|
2
14
|
import { Emitter } from "./Options/Classes/Emitter";
|
|
3
15
|
import { EmitterInstance } from "./EmitterInstance";
|
|
4
16
|
export class Emitters {
|
|
5
|
-
constructor(container) {
|
|
17
|
+
constructor(engine, container) {
|
|
6
18
|
this.container = container;
|
|
19
|
+
_Emitters_engine.set(this, void 0);
|
|
20
|
+
__classPrivateFieldSet(this, _Emitters_engine, engine, "f");
|
|
7
21
|
this.array = [];
|
|
8
22
|
this.emitters = [];
|
|
9
23
|
this.interactivityEmitters = [];
|
|
@@ -121,7 +135,7 @@ export class Emitters {
|
|
|
121
135
|
addEmitter(options, position) {
|
|
122
136
|
const emitterOptions = new Emitter();
|
|
123
137
|
emitterOptions.load(options);
|
|
124
|
-
const emitter = new EmitterInstance(this, this.container, emitterOptions, position);
|
|
138
|
+
const emitter = new EmitterInstance(__classPrivateFieldGet(this, _Emitters_engine, "f"), this, this.container, emitterOptions, position);
|
|
125
139
|
this.array.push(emitter);
|
|
126
140
|
return emitter;
|
|
127
141
|
}
|
|
@@ -132,3 +146,4 @@ export class Emitters {
|
|
|
132
146
|
}
|
|
133
147
|
}
|
|
134
148
|
}
|
|
149
|
+
_Emitters_engine = new WeakMap();
|
package/{browser/Plugins/Emitters/EmittersMain.d.ts → esm/Plugins/Emitters/EmittersEngine.d.ts}
RENAMED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { Engine } from "../../engine";
|
|
2
2
|
import type { IEmitterShape } from "./IEmitterShape";
|
|
3
|
-
|
|
3
|
+
import type { ShapeManager } from "./ShapeManager";
|
|
4
|
+
export declare type EmittersEngine = Engine & {
|
|
5
|
+
emitterShapeManager?: ShapeManager;
|
|
4
6
|
addEmitterShape?: (name: string, shape: IEmitterShape) => void;
|
|
5
7
|
};
|
|
File without changes
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ICoordinates } from "../../Core";
|
|
1
|
+
import type { ICoordinates, IDimension } from "../../Core";
|
|
2
2
|
export interface IEmitterShape {
|
|
3
|
-
randomPosition(position: ICoordinates,
|
|
3
|
+
randomPosition(position: ICoordinates, size: IDimension, fill: boolean): ICoordinates;
|
|
4
4
|
}
|
|
@@ -13,6 +13,7 @@ export declare class Emitter implements IEmitter, IOptionLoader<IEmitter> {
|
|
|
13
13
|
autoPlay: boolean;
|
|
14
14
|
size?: EmitterSize;
|
|
15
15
|
direction?: MoveDirection | keyof typeof MoveDirection | MoveDirectionAlt | number;
|
|
16
|
+
domId?: string;
|
|
16
17
|
fill: boolean;
|
|
17
18
|
life: EmitterLife;
|
|
18
19
|
name?: string;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import type { Engine } from "../../engine";
|
|
1
2
|
import type { IEmitterShape } from "./IEmitterShape";
|
|
2
3
|
export declare class ShapeManager {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
#private;
|
|
5
|
+
constructor(engine: Engine);
|
|
6
|
+
addShape(name: string, drawer: IEmitterShape): void;
|
|
7
|
+
getShape(name: string): IEmitterShape | undefined;
|
|
8
|
+
getSupportedShapes(): IterableIterator<string>;
|
|
6
9
|
}
|
|
@@ -1,14 +1,26 @@
|
|
|
1
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
+
};
|
|
7
|
+
var _ShapeManager_engine;
|
|
1
8
|
const shapes = new Map();
|
|
2
9
|
export class ShapeManager {
|
|
3
|
-
|
|
4
|
-
|
|
10
|
+
constructor(engine) {
|
|
11
|
+
_ShapeManager_engine.set(this, void 0);
|
|
12
|
+
__classPrivateFieldSet(this, _ShapeManager_engine, engine, "f");
|
|
13
|
+
}
|
|
14
|
+
addShape(name, drawer) {
|
|
15
|
+
if (!this.getShape(name)) {
|
|
5
16
|
shapes.set(name, drawer);
|
|
6
17
|
}
|
|
7
18
|
}
|
|
8
|
-
|
|
19
|
+
getShape(name) {
|
|
9
20
|
return shapes.get(name);
|
|
10
21
|
}
|
|
11
|
-
|
|
22
|
+
getSupportedShapes() {
|
|
12
23
|
return shapes.keys();
|
|
13
24
|
}
|
|
14
25
|
}
|
|
26
|
+
_ShapeManager_engine = new WeakMap();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ICoordinates } from "../../../../Core";
|
|
1
|
+
import type { ICoordinates, IDimension } from "../../../../Core";
|
|
2
2
|
import type { IEmitterShape } from "../../IEmitterShape";
|
|
3
3
|
export declare class CircleShape implements IEmitterShape {
|
|
4
|
-
randomPosition(position: ICoordinates,
|
|
4
|
+
randomPosition(position: ICoordinates, size: IDimension, fill: boolean): ICoordinates;
|
|
5
5
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export class CircleShape {
|
|
2
|
-
randomPosition(position,
|
|
2
|
+
randomPosition(position, size, fill) {
|
|
3
3
|
const generateTheta = (x, y) => {
|
|
4
4
|
const u = Math.random() / 4.0;
|
|
5
5
|
const theta = Math.atan((y / x) * Math.tan(2 * Math.PI * u));
|
|
@@ -18,7 +18,7 @@ export class CircleShape {
|
|
|
18
18
|
}
|
|
19
19
|
};
|
|
20
20
|
const radius = (x, y, theta) => (x * y) / Math.sqrt((y * Math.cos(theta)) ** 2 + (x * Math.sin(theta)) ** 2);
|
|
21
|
-
const [a, b] = [
|
|
21
|
+
const [a, b] = [size.width / 2, size.height / 2];
|
|
22
22
|
const randomTheta = generateTheta(a, b), maxRadius = radius(a, b, randomTheta), randomRadius = fill ? maxRadius * Math.sqrt(Math.random()) : maxRadius;
|
|
23
23
|
return {
|
|
24
24
|
x: position.x + randomRadius * Math.cos(randomTheta),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ICoordinates } from "../../../../Core";
|
|
1
|
+
import type { ICoordinates, IDimension } from "../../../../Core";
|
|
2
2
|
import type { IEmitterShape } from "../../IEmitterShape";
|
|
3
3
|
export declare class SquareShape implements IEmitterShape {
|
|
4
|
-
randomPosition(position: ICoordinates,
|
|
4
|
+
randomPosition(position: ICoordinates, size: IDimension, fill: boolean): ICoordinates;
|
|
5
5
|
}
|
|
@@ -2,15 +2,15 @@ function randomSquareCoordinate(position, offset) {
|
|
|
2
2
|
return position + offset * (Math.random() - 0.5);
|
|
3
3
|
}
|
|
4
4
|
export class SquareShape {
|
|
5
|
-
randomPosition(position,
|
|
5
|
+
randomPosition(position, size, fill) {
|
|
6
6
|
if (fill) {
|
|
7
7
|
return {
|
|
8
|
-
x: randomSquareCoordinate(position.x,
|
|
9
|
-
y: randomSquareCoordinate(position.y,
|
|
8
|
+
x: randomSquareCoordinate(position.x, size.width),
|
|
9
|
+
y: randomSquareCoordinate(position.y, size.height),
|
|
10
10
|
};
|
|
11
11
|
}
|
|
12
12
|
else {
|
|
13
|
-
const halfW =
|
|
13
|
+
const halfW = size.width / 2, halfH = size.height / 2, side = Math.floor(Math.random() * 4), v = (Math.random() - 0.5) * 2;
|
|
14
14
|
switch (side) {
|
|
15
15
|
case 0:
|
|
16
16
|
return {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function loadEmittersPlugin(engine:
|
|
3
|
-
export * from "./
|
|
1
|
+
import { EmittersEngine } from "./EmittersEngine";
|
|
2
|
+
export declare function loadEmittersPlugin(engine: EmittersEngine): Promise<void>;
|
|
3
|
+
export * from "./EmittersEngine";
|
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
+
};
|
|
7
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
+
};
|
|
12
|
+
var _EmittersPlugin_engine;
|
|
1
13
|
import { CircleShape } from "./Shapes/Circle/CircleShape";
|
|
2
14
|
import { Emitter } from "./Options/Classes/Emitter";
|
|
3
15
|
import { Emitters } from "./Emitters";
|
|
@@ -5,11 +17,13 @@ import { ShapeManager } from "./ShapeManager";
|
|
|
5
17
|
import { SquareShape } from "./Shapes/Square/SquareShape";
|
|
6
18
|
import { isInArray } from "../../Utils";
|
|
7
19
|
class EmittersPlugin {
|
|
8
|
-
constructor() {
|
|
20
|
+
constructor(engine) {
|
|
21
|
+
_EmittersPlugin_engine.set(this, void 0);
|
|
22
|
+
__classPrivateFieldSet(this, _EmittersPlugin_engine, engine, "f");
|
|
9
23
|
this.id = "emitters";
|
|
10
24
|
}
|
|
11
25
|
getPlugin(container) {
|
|
12
|
-
return new Emitters(container);
|
|
26
|
+
return new Emitters(__classPrivateFieldGet(this, _EmittersPlugin_engine, "f"), container);
|
|
13
27
|
}
|
|
14
28
|
needsPlugin(options) {
|
|
15
29
|
var _a, _b, _c;
|
|
@@ -63,15 +77,20 @@ class EmittersPlugin {
|
|
|
63
77
|
}
|
|
64
78
|
}
|
|
65
79
|
}
|
|
80
|
+
_EmittersPlugin_engine = new WeakMap();
|
|
66
81
|
export async function loadEmittersPlugin(engine) {
|
|
67
|
-
|
|
68
|
-
|
|
82
|
+
if (!engine.emitterShapeManager) {
|
|
83
|
+
engine.emitterShapeManager = new ShapeManager(engine);
|
|
84
|
+
}
|
|
69
85
|
if (!engine.addEmitterShape) {
|
|
70
86
|
engine.addEmitterShape = (name, shape) => {
|
|
71
|
-
|
|
87
|
+
var _a;
|
|
88
|
+
(_a = engine.emitterShapeManager) === null || _a === void 0 ? void 0 : _a.addShape(name, shape);
|
|
72
89
|
};
|
|
73
90
|
}
|
|
91
|
+
const plugin = new EmittersPlugin(engine);
|
|
92
|
+
await engine.addPlugin(plugin);
|
|
74
93
|
engine.addEmitterShape("circle", new CircleShape());
|
|
75
94
|
engine.addEmitterShape("square", new SquareShape());
|
|
76
95
|
}
|
|
77
|
-
export * from "./
|
|
96
|
+
export * from "./EmittersEngine";
|
package/esm/engine.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import type { Container, IInteractor, IMovePathGenerator, IParticleUpdater, IPlugin, IShapeDrawer, Particle } from "./Core";
|
|
2
|
+
import { Plugins } from "./Core";
|
|
2
3
|
import type { RecursivePartial, ShapeDrawerAfterEffectFunction, ShapeDrawerDestroyFunction, ShapeDrawerDrawFunction, ShapeDrawerInitFunction, SingleOrMultiple } from "./Types";
|
|
3
4
|
import type { IOptions } from "./Options/Interfaces/IOptions";
|
|
4
5
|
export declare class Engine {
|
|
5
6
|
#private;
|
|
7
|
+
readonly domArray: Container[];
|
|
8
|
+
readonly plugins: Plugins;
|
|
6
9
|
constructor();
|
|
7
10
|
init(): void;
|
|
8
11
|
loadFromArray(tagId: string, options: RecursivePartial<IOptions>[], index?: number): Promise<Container | undefined>;
|
package/esm/engine.js
CHANGED
|
@@ -9,12 +9,16 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
9
9
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
11
|
};
|
|
12
|
-
var _Engine_initialized;
|
|
12
|
+
var _Engine_initialized, _Engine_loader;
|
|
13
13
|
import { Loader, Plugins } from "./Core";
|
|
14
14
|
export class Engine {
|
|
15
15
|
constructor() {
|
|
16
16
|
_Engine_initialized.set(this, void 0);
|
|
17
|
+
_Engine_loader.set(this, void 0);
|
|
17
18
|
__classPrivateFieldSet(this, _Engine_initialized, false, "f");
|
|
19
|
+
this.domArray = [];
|
|
20
|
+
__classPrivateFieldSet(this, _Engine_loader, new Loader(this), "f");
|
|
21
|
+
this.plugins = new Plugins(this);
|
|
18
22
|
}
|
|
19
23
|
init() {
|
|
20
24
|
if (!__classPrivateFieldGet(this, _Engine_initialized, "f")) {
|
|
@@ -22,28 +26,28 @@ export class Engine {
|
|
|
22
26
|
}
|
|
23
27
|
}
|
|
24
28
|
async loadFromArray(tagId, options, index) {
|
|
25
|
-
return
|
|
29
|
+
return __classPrivateFieldGet(this, _Engine_loader, "f").load(tagId, options, index);
|
|
26
30
|
}
|
|
27
31
|
async load(tagId, options) {
|
|
28
|
-
return
|
|
32
|
+
return __classPrivateFieldGet(this, _Engine_loader, "f").load(tagId, options);
|
|
29
33
|
}
|
|
30
34
|
async set(id, element, options) {
|
|
31
|
-
return
|
|
35
|
+
return __classPrivateFieldGet(this, _Engine_loader, "f").set(id, element, options);
|
|
32
36
|
}
|
|
33
37
|
async loadJSON(tagId, pathConfigJson, index) {
|
|
34
|
-
return
|
|
38
|
+
return __classPrivateFieldGet(this, _Engine_loader, "f").loadJSON(tagId, pathConfigJson, index);
|
|
35
39
|
}
|
|
36
40
|
async setJSON(id, element, pathConfigJson, index) {
|
|
37
|
-
return
|
|
41
|
+
return __classPrivateFieldGet(this, _Engine_loader, "f").setJSON(id, element, pathConfigJson, index);
|
|
38
42
|
}
|
|
39
43
|
setOnClickHandler(callback) {
|
|
40
|
-
|
|
44
|
+
__classPrivateFieldGet(this, _Engine_loader, "f").setOnClickHandler(callback);
|
|
41
45
|
}
|
|
42
46
|
dom() {
|
|
43
|
-
return
|
|
47
|
+
return __classPrivateFieldGet(this, _Engine_loader, "f").dom();
|
|
44
48
|
}
|
|
45
49
|
domItem(index) {
|
|
46
|
-
return
|
|
50
|
+
return __classPrivateFieldGet(this, _Engine_loader, "f").domItem(index);
|
|
47
51
|
}
|
|
48
52
|
async refresh() {
|
|
49
53
|
for (const instance of this.dom()) {
|
|
@@ -63,28 +67,28 @@ export class Engine {
|
|
|
63
67
|
else {
|
|
64
68
|
customDrawer = drawer;
|
|
65
69
|
}
|
|
66
|
-
|
|
70
|
+
this.plugins.addShapeDrawer(shape, customDrawer);
|
|
67
71
|
await this.refresh();
|
|
68
72
|
}
|
|
69
73
|
async addPreset(preset, options, override = false) {
|
|
70
|
-
|
|
74
|
+
this.plugins.addPreset(preset, options, override);
|
|
71
75
|
await this.refresh();
|
|
72
76
|
}
|
|
73
77
|
async addPlugin(plugin) {
|
|
74
|
-
|
|
78
|
+
this.plugins.addPlugin(plugin);
|
|
75
79
|
await this.refresh();
|
|
76
80
|
}
|
|
77
81
|
async addPathGenerator(name, generator) {
|
|
78
|
-
|
|
82
|
+
this.plugins.addPathGenerator(name, generator);
|
|
79
83
|
await this.refresh();
|
|
80
84
|
}
|
|
81
85
|
async addInteractor(name, interactorInitializer) {
|
|
82
|
-
|
|
86
|
+
this.plugins.addInteractor(name, interactorInitializer);
|
|
83
87
|
await this.refresh();
|
|
84
88
|
}
|
|
85
89
|
async addParticleUpdater(name, updaterInitializer) {
|
|
86
|
-
|
|
90
|
+
this.plugins.addParticleUpdater(name, updaterInitializer);
|
|
87
91
|
await this.refresh();
|
|
88
92
|
}
|
|
89
93
|
}
|
|
90
|
-
_Engine_initialized = new WeakMap();
|
|
94
|
+
_Engine_initialized = new WeakMap(), _Engine_loader = new WeakMap();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tsparticles",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.40.2",
|
|
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": {
|
|
@@ -60,14 +60,19 @@
|
|
|
60
60
|
"bugs": {
|
|
61
61
|
"url": "https://github.com/matteobruni/tsparticles/issues"
|
|
62
62
|
},
|
|
63
|
-
"funding":
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
63
|
+
"funding": [
|
|
64
|
+
{
|
|
65
|
+
"type": "github",
|
|
66
|
+
"url": "https://github.com/sponsors/matteobruni"
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"type": "buymeacoffee",
|
|
70
|
+
"url": "https://www.buymeacoffee.com/matteobruni"
|
|
71
|
+
}
|
|
72
|
+
],
|
|
67
73
|
"main": "index.js",
|
|
68
74
|
"module": "esm/index.js",
|
|
69
75
|
"jsdelivr": "tsparticles.min.js",
|
|
70
76
|
"unpkg": "tsparticles.min.js",
|
|
71
|
-
"browser": "index.js",
|
|
72
77
|
"types": "index.d.ts"
|
|
73
78
|
}
|