@tsparticles/engine 3.0.0-beta.3 → 3.0.0-beta.4
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/browser/Core/Canvas.js +2 -2
- package/browser/Core/Container.js +36 -19
- package/browser/Core/Engine.js +18 -5
- package/browser/Core/Particle.js +75 -40
- package/browser/Core/Particles.js +51 -26
- package/browser/Core/Retina.js +0 -2
- package/browser/Core/Utils/QuadTree.js +1 -1
- package/browser/Options/Classes/BackgroundMask/BackgroundMask.js +1 -2
- package/browser/Options/Classes/ColorAnimation.js +4 -24
- package/browser/Options/Classes/Particles/Bounce/ParticlesBounceFactor.js +0 -1
- package/browser/Options/Classes/Particles/Effect/Effect.js +32 -0
- package/browser/Options/Classes/Particles/Number/ParticlesNumber.js +3 -5
- package/browser/Options/Classes/Particles/Number/ParticlesNumberLimit.js +17 -0
- package/browser/Options/Classes/Particles/Opacity/Opacity.js +2 -3
- package/browser/Options/Classes/Particles/ParticlesOptions.js +3 -0
- package/browser/Options/Classes/Particles/Size/Size.js +2 -3
- package/browser/Options/Classes/ValueWithRandom.js +1 -10
- package/browser/Utils/CanvasUtils.js +23 -18
- package/browser/Utils/ColorUtils.js +24 -38
- package/browser/Utils/NumberUtils.js +7 -16
- package/browser/Utils/Utils.js +7 -7
- package/browser/export-types.js +4 -0
- package/browser/exports.js +2 -3
- package/cjs/Core/Canvas.js +2 -2
- package/cjs/Core/Container.js +36 -19
- package/cjs/Core/Engine.js +18 -5
- package/cjs/Core/Particle.js +74 -39
- package/cjs/Core/Particles.js +51 -26
- package/cjs/Core/Retina.js +0 -2
- package/cjs/Core/Utils/QuadTree.js +1 -1
- package/cjs/Options/Classes/BackgroundMask/BackgroundMask.js +1 -2
- package/cjs/Options/Classes/ColorAnimation.js +4 -24
- package/cjs/Options/Classes/Particles/Bounce/ParticlesBounceFactor.js +0 -1
- package/cjs/Options/Classes/Particles/Effect/Effect.js +36 -0
- package/cjs/Options/Classes/Particles/Number/ParticlesNumber.js +3 -5
- package/cjs/Options/Classes/Particles/Number/ParticlesNumberLimit.js +21 -0
- package/cjs/Options/Classes/Particles/Opacity/Opacity.js +1 -2
- package/cjs/Options/Classes/Particles/ParticlesOptions.js +3 -0
- package/cjs/Options/Classes/Particles/Size/Size.js +2 -3
- package/cjs/Options/Classes/ValueWithRandom.js +1 -10
- package/cjs/Options/Interfaces/Particles/Number/IParticlesNumberLimit.js +2 -0
- package/cjs/Utils/CanvasUtils.js +26 -21
- package/cjs/Utils/ColorUtils.js +24 -38
- package/cjs/Utils/NumberUtils.js +8 -18
- package/cjs/Utils/Utils.js +6 -6
- package/cjs/export-types.js +4 -0
- package/cjs/exports.js +2 -3
- package/esm/Core/Canvas.js +2 -2
- package/esm/Core/Container.js +36 -19
- package/esm/Core/Engine.js +18 -5
- package/esm/Core/Particle.js +75 -40
- package/esm/Core/Particles.js +51 -26
- package/esm/Core/Retina.js +0 -2
- package/esm/Core/Utils/QuadTree.js +1 -1
- package/esm/Options/Classes/BackgroundMask/BackgroundMask.js +1 -2
- package/esm/Options/Classes/ColorAnimation.js +4 -24
- package/esm/Options/Classes/Particles/Bounce/ParticlesBounceFactor.js +0 -1
- package/esm/Options/Classes/Particles/Effect/Effect.js +32 -0
- package/esm/Options/Classes/Particles/Number/ParticlesNumber.js +3 -5
- package/esm/Options/Classes/Particles/Number/ParticlesNumberLimit.js +17 -0
- package/esm/Options/Classes/Particles/Opacity/Opacity.js +2 -3
- package/esm/Options/Classes/Particles/ParticlesOptions.js +3 -0
- package/esm/Options/Classes/Particles/Size/Size.js +2 -3
- package/esm/Options/Classes/ValueWithRandom.js +1 -10
- package/esm/Options/Interfaces/Particles/Effect/IEffect.js +1 -0
- package/esm/Options/Interfaces/Particles/Number/IParticlesNumberLimit.js +1 -0
- package/esm/Utils/CanvasUtils.js +23 -18
- package/esm/Utils/ColorUtils.js +24 -38
- package/esm/Utils/NumberUtils.js +7 -16
- package/esm/Utils/Utils.js +7 -7
- package/esm/export-types.js +4 -0
- package/esm/exports.js +2 -3
- package/package.json +1 -1
- package/report.html +4 -22
- package/tsparticles.engine.js +387 -283
- package/tsparticles.engine.min.js +1 -1
- package/tsparticles.engine.min.js.LICENSE.txt +1 -1
- package/types/Core/Canvas.d.ts +0 -1
- package/types/Core/Container.d.ts +8 -7
- package/types/Core/Engine.d.ts +7 -2
- package/types/Core/Interfaces/IContainerPlugin.d.ts +2 -3
- package/types/Core/Interfaces/IEffectDrawer.d.ts +10 -0
- package/types/Core/Interfaces/IExternalInteractor.d.ts +3 -4
- package/types/Core/Interfaces/IInteractor.d.ts +3 -3
- package/types/Core/Interfaces/IParticleRetinaProps.d.ts +0 -1
- package/types/Core/Interfaces/IParticlesInteractor.d.ts +3 -3
- package/types/Core/Interfaces/IShapeDrawData.d.ts +10 -0
- package/types/Core/Interfaces/IShapeDrawer.d.ts +2 -10
- package/types/Core/Particle.d.ts +6 -2
- package/types/Core/Particles.d.ts +10 -7
- package/types/Core/Retina.d.ts +0 -1
- package/types/Core/Utils/ExternalInteractorBase.d.ts +4 -4
- package/types/Core/Utils/InteractionManager.d.ts +1 -2
- package/types/Core/Utils/ParticlesInteractorBase.d.ts +5 -5
- package/types/Enums/Modes/LimitMode.d.ts +4 -0
- package/types/Enums/Types/EasingType.d.ts +3 -0
- package/types/Options/Classes/BackgroundMask/BackgroundMask.d.ts +1 -1
- package/types/Options/Classes/ColorAnimation.d.ts +2 -7
- package/types/Options/Classes/Interactivity/Events/ClickEvent.d.ts +1 -2
- package/types/Options/Classes/Interactivity/Events/DivEvent.d.ts +1 -2
- package/types/Options/Classes/Interactivity/Events/Events.d.ts +3 -3
- package/types/Options/Classes/Interactivity/Events/HoverEvent.d.ts +2 -3
- package/types/Options/Classes/Interactivity/Interactivity.d.ts +2 -2
- package/types/Options/Classes/Options.d.ts +6 -6
- package/types/Options/Classes/Particles/Bounce/ParticlesBounce.d.ts +2 -2
- package/types/Options/Classes/Particles/Collisions/Collisions.d.ts +3 -3
- package/types/Options/Classes/Particles/Effect/Effect.d.ts +13 -0
- package/types/Options/Classes/Particles/Move/Move.d.ts +8 -8
- package/types/Options/Classes/Particles/Move/MoveTrail.d.ts +1 -1
- package/types/Options/Classes/Particles/Number/ParticlesNumber.d.ts +3 -2
- package/types/Options/Classes/Particles/Number/ParticlesNumberLimit.d.ts +10 -0
- package/types/Options/Classes/Particles/Opacity/Opacity.d.ts +3 -3
- package/types/Options/Classes/Particles/ParticlesOptions.d.ts +12 -10
- package/types/Options/Classes/Particles/Size/Size.d.ts +3 -3
- package/types/Options/Classes/Theme/Theme.d.ts +1 -1
- package/types/Options/Classes/ValueWithRandom.d.ts +2 -4
- package/types/Options/Interfaces/IValueWithRandom.d.ts +0 -2
- package/types/Options/Interfaces/Interactivity/Events/IClickEvent.d.ts +1 -2
- package/types/Options/Interfaces/Interactivity/Events/IDivEvent.d.ts +1 -2
- package/types/Options/Interfaces/Interactivity/Events/IHoverEvent.d.ts +1 -2
- package/types/Options/Interfaces/Particles/Effect/IEffect.d.ts +8 -0
- package/types/Options/Interfaces/Particles/IParticlesOptions.d.ts +2 -0
- package/types/Options/Interfaces/Particles/Number/IParticlesNumber.d.ts +2 -1
- package/types/Options/Interfaces/Particles/Number/IParticlesNumberLimit.d.ts +5 -0
- package/types/Utils/CanvasUtils.d.ts +2 -2
- package/types/Utils/NumberUtils.d.ts +0 -2
- package/types/Utils/Utils.d.ts +2 -3
- package/types/export-types.d.ts +5 -0
- package/types/exports.d.ts +2 -3
- package/umd/Core/Canvas.js +2 -2
- package/umd/Core/Container.js +36 -19
- package/umd/Core/Engine.js +18 -5
- package/umd/Core/Particle.js +74 -39
- package/umd/Core/Particles.js +51 -26
- package/umd/Core/Retina.js +0 -2
- package/umd/Core/Utils/QuadTree.js +1 -1
- package/umd/Options/Classes/BackgroundMask/BackgroundMask.js +1 -2
- package/umd/Options/Classes/ColorAnimation.js +5 -25
- package/umd/Options/Classes/Particles/Bounce/ParticlesBounceFactor.js +0 -1
- package/umd/Options/Classes/Particles/Effect/Effect.js +46 -0
- package/umd/Options/Classes/Particles/Number/ParticlesNumber.js +4 -6
- package/umd/Options/Classes/{Random.js → Particles/Number/ParticlesNumberLimit.js} +9 -9
- package/umd/Options/Classes/Particles/Opacity/Opacity.js +1 -2
- package/umd/Options/Classes/Particles/ParticlesOptions.js +4 -1
- package/umd/Options/Classes/Particles/Size/Size.js +3 -4
- package/umd/Options/Classes/ValueWithRandom.js +2 -11
- package/umd/Options/Interfaces/Particles/Number/IParticlesNumberLimit.js +12 -0
- package/umd/Utils/CanvasUtils.js +26 -21
- package/umd/Utils/ColorUtils.js +24 -38
- package/umd/Utils/NumberUtils.js +9 -19
- package/umd/Utils/Utils.js +6 -6
- package/umd/export-types.js +5 -1
- package/umd/exports.js +3 -4
- package/browser/Options/Classes/Random.js +0 -17
- package/cjs/Options/Classes/Random.js +0 -21
- package/esm/Options/Classes/Random.js +0 -17
- package/types/Enums/Modes/ClickMode.d.ts +0 -9
- package/types/Enums/Modes/DivMode.d.ts +0 -5
- package/types/Enums/Modes/HoverMode.d.ts +0 -11
- package/types/Options/Classes/Random.d.ts +0 -9
- package/types/Options/Interfaces/IRandom.d.ts +0 -4
- /package/browser/{Enums/Modes/ClickMode.js → Core/Interfaces/IEffectDrawer.js} +0 -0
- /package/browser/{Enums/Modes/DivMode.js → Core/Interfaces/IShapeDrawData.js} +0 -0
- /package/browser/Enums/Modes/{HoverMode.js → LimitMode.js} +0 -0
- /package/browser/Options/Interfaces/{IRandom.js → Particles/Effect/IEffect.js} +0 -0
- /package/{esm/Enums/Modes/ClickMode.js → browser/Options/Interfaces/Particles/Number/IParticlesNumberLimit.js} +0 -0
- /package/cjs/{Enums/Modes/ClickMode.js → Core/Interfaces/IEffectDrawer.js} +0 -0
- /package/cjs/{Enums/Modes/DivMode.js → Core/Interfaces/IShapeDrawData.js} +0 -0
- /package/cjs/Enums/Modes/{HoverMode.js → LimitMode.js} +0 -0
- /package/cjs/Options/Interfaces/{IRandom.js → Particles/Effect/IEffect.js} +0 -0
- /package/esm/{Enums/Modes/DivMode.js → Core/Interfaces/IEffectDrawer.js} +0 -0
- /package/esm/{Enums/Modes/HoverMode.js → Core/Interfaces/IShapeDrawData.js} +0 -0
- /package/esm/{Options/Interfaces/IRandom.js → Enums/Modes/LimitMode.js} +0 -0
- /package/umd/{Enums/Modes/ClickMode.js → Core/Interfaces/IEffectDrawer.js} +0 -0
- /package/umd/{Enums/Modes/DivMode.js → Core/Interfaces/IShapeDrawData.js} +0 -0
- /package/umd/Enums/Modes/{HoverMode.js → LimitMode.js} +0 -0
- /package/umd/Options/Interfaces/{IRandom.js → Particles/Effect/IEffect.js} +0 -0
package/umd/Core/Particles.js
CHANGED
|
@@ -19,16 +19,29 @@
|
|
|
19
19
|
const Constants_js_1 = require("./Utils/Constants.js");
|
|
20
20
|
const qTreeCapacity = 4;
|
|
21
21
|
const qTreeRectangle = (canvasSize) => {
|
|
22
|
-
|
|
22
|
+
const { height, width } = canvasSize, posOffset = -0.25, sizeFactor = 1.5;
|
|
23
|
+
return new Rectangle_js_1.Rectangle(posOffset * width, posOffset * height, sizeFactor * width, sizeFactor * height);
|
|
23
24
|
};
|
|
24
25
|
class Particles {
|
|
25
26
|
constructor(engine, container) {
|
|
26
27
|
this._applyDensity = (options, manualCount, group) => {
|
|
28
|
+
const numberOptions = options.number;
|
|
27
29
|
if (!options.number.density?.enable) {
|
|
30
|
+
if (group === undefined) {
|
|
31
|
+
this._limit = numberOptions.limit.value;
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
this._groupLimits.set(group, numberOptions.limit.value);
|
|
35
|
+
}
|
|
28
36
|
return;
|
|
29
37
|
}
|
|
30
|
-
const
|
|
31
|
-
|
|
38
|
+
const densityFactor = this._initDensityFactor(numberOptions.density), optParticlesNumber = numberOptions.value, optParticlesLimit = numberOptions.limit.value > 0 ? numberOptions.limit.value : optParticlesNumber, particlesNumber = Math.min(optParticlesNumber, optParticlesLimit) * densityFactor + manualCount, particlesCount = Math.min(this.count, this.filter((t) => t.group === group).length);
|
|
39
|
+
if (group === undefined) {
|
|
40
|
+
this._limit = numberOptions.limit.value * densityFactor;
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
this._groupLimits.set(group, numberOptions.limit.value * densityFactor);
|
|
44
|
+
}
|
|
32
45
|
if (particlesCount < particlesNumber) {
|
|
33
46
|
this.push(Math.abs(particlesNumber - particlesCount), undefined, options, group);
|
|
34
47
|
}
|
|
@@ -46,7 +59,7 @@
|
|
|
46
59
|
};
|
|
47
60
|
this._pushParticle = (position, overrideOptions, group, initializer) => {
|
|
48
61
|
try {
|
|
49
|
-
let particle = this.
|
|
62
|
+
let particle = this._pool.pop();
|
|
50
63
|
if (particle) {
|
|
51
64
|
particle.init(this._nextId, position, overrideOptions, group);
|
|
52
65
|
}
|
|
@@ -85,7 +98,7 @@
|
|
|
85
98
|
const zIdx = this._zArray.indexOf(particle);
|
|
86
99
|
this._array.splice(index, 1);
|
|
87
100
|
this._zArray.splice(zIdx, 1);
|
|
88
|
-
this.
|
|
101
|
+
this._pool.push(particle);
|
|
89
102
|
this._engine.dispatchEvent("particleRemoved", {
|
|
90
103
|
container: this._container,
|
|
91
104
|
data: {
|
|
@@ -99,10 +112,11 @@
|
|
|
99
112
|
this._nextId = 0;
|
|
100
113
|
this._array = [];
|
|
101
114
|
this._zArray = [];
|
|
102
|
-
this.
|
|
103
|
-
this.
|
|
104
|
-
this.
|
|
105
|
-
this.
|
|
115
|
+
this._pool = [];
|
|
116
|
+
this._limit = 0;
|
|
117
|
+
this._groupLimits = new Map();
|
|
118
|
+
this._needsSort = false;
|
|
119
|
+
this._lastZIndex = 0;
|
|
106
120
|
this._interactionManager = new InteractionManager_js_1.InteractionManager(engine, container);
|
|
107
121
|
const canvasSize = container.canvas.size;
|
|
108
122
|
this.quadTree = new QuadTree_js_1.QuadTree(qTreeRectangle(canvasSize), qTreeCapacity);
|
|
@@ -119,17 +133,21 @@
|
|
|
119
133
|
}
|
|
120
134
|
}
|
|
121
135
|
addParticle(position, overrideOptions, group, initializer) {
|
|
122
|
-
this.
|
|
123
|
-
const container = this._container, options = container.actualOptions, limit = options.particles.number.limit;
|
|
136
|
+
const limitOptions = this._container.actualOptions.particles.number.limit, limit = group === undefined ? this._limit : this._groupLimits.get(group) ?? this._limit, currentCount = this.count;
|
|
124
137
|
if (limit > 0) {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
138
|
+
if (limitOptions.mode === "delete") {
|
|
139
|
+
const countToRemove = currentCount + 1 - limit;
|
|
140
|
+
if (countToRemove > 0) {
|
|
141
|
+
this.removeQuantity(countToRemove);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
else if (limitOptions.mode === "wait") {
|
|
145
|
+
if (currentCount >= limit) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
128
148
|
}
|
|
129
149
|
}
|
|
130
|
-
|
|
131
|
-
this.pushing = false;
|
|
132
|
-
return res;
|
|
150
|
+
return this._pushParticle(position, overrideOptions, group, initializer);
|
|
133
151
|
}
|
|
134
152
|
clear() {
|
|
135
153
|
this._array = [];
|
|
@@ -166,8 +184,8 @@
|
|
|
166
184
|
}
|
|
167
185
|
init() {
|
|
168
186
|
const container = this._container, options = container.actualOptions;
|
|
169
|
-
this.
|
|
170
|
-
this.
|
|
187
|
+
this._lastZIndex = 0;
|
|
188
|
+
this._needsSort = false;
|
|
171
189
|
let handled = false;
|
|
172
190
|
this.updaters = this._engine.getUpdaters(container, true);
|
|
173
191
|
this._interactionManager.init();
|
|
@@ -229,6 +247,13 @@
|
|
|
229
247
|
}
|
|
230
248
|
this._applyDensity(options.particles, options.manualParticles.length);
|
|
231
249
|
}
|
|
250
|
+
setLastZIndex(zIndex) {
|
|
251
|
+
this._lastZIndex = zIndex;
|
|
252
|
+
this._needsSort = this._needsSort || this._lastZIndex < zIndex;
|
|
253
|
+
}
|
|
254
|
+
setResizeFactor(factor) {
|
|
255
|
+
this._resizeFactor = factor;
|
|
256
|
+
}
|
|
232
257
|
async update(delta) {
|
|
233
258
|
const container = this._container, particlesToDelete = new Set();
|
|
234
259
|
this.quadTree = new QuadTree_js_1.QuadTree(qTreeRectangle(container.canvas.size), qTreeCapacity);
|
|
@@ -236,10 +261,10 @@
|
|
|
236
261
|
pathGenerator.update();
|
|
237
262
|
}
|
|
238
263
|
for (const [, plugin] of container.plugins) {
|
|
239
|
-
plugin.update && plugin.update(delta);
|
|
264
|
+
plugin.update && (await plugin.update(delta));
|
|
240
265
|
}
|
|
266
|
+
const resizeFactor = this._resizeFactor;
|
|
241
267
|
for (const particle of this._array) {
|
|
242
|
-
const resizeFactor = container.canvas.resizeFactor;
|
|
243
268
|
if (resizeFactor && !particle.ignoresResizeRatio) {
|
|
244
269
|
particle.position.x *= resizeFactor.width;
|
|
245
270
|
particle.position.y *= resizeFactor.height;
|
|
@@ -267,7 +292,7 @@
|
|
|
267
292
|
const checkDelete = (p) => !particlesToDelete.has(p);
|
|
268
293
|
this._array = this.filter(checkDelete);
|
|
269
294
|
this._zArray = this._zArray.filter(checkDelete);
|
|
270
|
-
this.
|
|
295
|
+
this._pool.push(...particlesToDelete);
|
|
271
296
|
}
|
|
272
297
|
await this._interactionManager.externalInteract(delta);
|
|
273
298
|
for (const particle of this._array) {
|
|
@@ -278,12 +303,12 @@
|
|
|
278
303
|
await this._interactionManager.particlesInteract(particle, delta);
|
|
279
304
|
}
|
|
280
305
|
}
|
|
281
|
-
delete
|
|
282
|
-
if (this.
|
|
306
|
+
delete this._resizeFactor;
|
|
307
|
+
if (this._needsSort) {
|
|
283
308
|
const zArray = this._zArray;
|
|
284
309
|
zArray.sort((a, b) => b.position.z - a.position.z || a.id - b.id);
|
|
285
|
-
this.
|
|
286
|
-
this.
|
|
310
|
+
this._lastZIndex = zArray[zArray.length - 1].position.z;
|
|
311
|
+
this._needsSort = false;
|
|
287
312
|
}
|
|
288
313
|
}
|
|
289
314
|
}
|
package/umd/Core/Retina.js
CHANGED
|
@@ -29,13 +29,11 @@
|
|
|
29
29
|
canvas.size.height = element.offsetHeight * ratio;
|
|
30
30
|
}
|
|
31
31
|
const particles = options.particles, moveOptions = particles.move;
|
|
32
|
-
this.attractDistance = (0, NumberUtils_js_1.getRangeValue)(moveOptions.attract.distance) * ratio;
|
|
33
32
|
this.maxSpeed = (0, NumberUtils_js_1.getRangeValue)(moveOptions.gravity.maxSpeed) * ratio;
|
|
34
33
|
this.sizeAnimationSpeed = (0, NumberUtils_js_1.getRangeValue)(particles.size.animation.speed) * ratio;
|
|
35
34
|
}
|
|
36
35
|
initParticle(particle) {
|
|
37
36
|
const options = particle.options, ratio = this.pixelRatio, moveOptions = options.move, moveDistance = moveOptions.distance, props = particle.retina;
|
|
38
|
-
props.attractDistance = (0, NumberUtils_js_1.getRangeValue)(moveOptions.attract.distance) * ratio;
|
|
39
37
|
props.moveDrift = (0, NumberUtils_js_1.getRangeValue)(moveOptions.drift) * ratio;
|
|
40
38
|
props.moveSpeed = (0, NumberUtils_js_1.getRangeValue)(moveOptions.speed) * ratio;
|
|
41
39
|
props.sizeAnimationSpeed = (0, NumberUtils_js_1.getRangeValue)(options.size.animation.speed) * ratio;
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
this._subdivide = () => {
|
|
21
21
|
const { x, y } = this.rectangle.position, { width, height } = this.rectangle.size, { capacity } = this;
|
|
22
22
|
for (let i = 0; i < 4; i++) {
|
|
23
|
-
this._subs.push(new QuadTree(new Rectangle_js_1.Rectangle(x +
|
|
23
|
+
this._subs.push(new QuadTree(new Rectangle_js_1.Rectangle(x + width * 0.5 * (i % 2), y + height * 0.5 * (Math.round(i * 0.5) - (i % 2)), width * 0.5, height * 0.5), capacity));
|
|
24
24
|
}
|
|
25
25
|
this._divided = true;
|
|
26
26
|
};
|
|
@@ -26,8 +26,7 @@
|
|
|
26
26
|
this.composite = data.composite;
|
|
27
27
|
}
|
|
28
28
|
if (data.cover !== undefined) {
|
|
29
|
-
const cover = data.cover;
|
|
30
|
-
const color = ((0, Utils_js_1.isString)(data.cover) ? { color: data.cover } : data.cover);
|
|
29
|
+
const cover = data.cover, color = ((0, Utils_js_1.isString)(data.cover) ? { color: data.cover } : data.cover);
|
|
31
30
|
this.cover.load(cover.color !== undefined ? cover : { color: color });
|
|
32
31
|
}
|
|
33
32
|
if (data.enable !== undefined) {
|
|
@@ -4,48 +4,28 @@
|
|
|
4
4
|
if (v !== undefined) module.exports = v;
|
|
5
5
|
}
|
|
6
6
|
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "../../Utils/NumberUtils.js"], factory);
|
|
7
|
+
define(["require", "exports", "./AnimationOptions.js", "../../Utils/NumberUtils.js"], factory);
|
|
8
8
|
}
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
"use strict";
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.ColorAnimation = void 0;
|
|
13
|
+
const AnimationOptions_js_1 = require("./AnimationOptions.js");
|
|
13
14
|
const NumberUtils_js_1 = require("../../Utils/NumberUtils.js");
|
|
14
|
-
class ColorAnimation {
|
|
15
|
+
class ColorAnimation extends AnimationOptions_js_1.AnimationOptions {
|
|
15
16
|
constructor() {
|
|
16
|
-
|
|
17
|
-
this.enable = false;
|
|
17
|
+
super();
|
|
18
18
|
this.offset = 0;
|
|
19
|
-
this.speed = 1;
|
|
20
|
-
this.delay = 0;
|
|
21
|
-
this.decay = 0;
|
|
22
19
|
this.sync = true;
|
|
23
20
|
}
|
|
24
21
|
load(data) {
|
|
22
|
+
super.load(data);
|
|
25
23
|
if (!data) {
|
|
26
24
|
return;
|
|
27
25
|
}
|
|
28
|
-
if (data.count !== undefined) {
|
|
29
|
-
this.count = (0, NumberUtils_js_1.setRangeValue)(data.count);
|
|
30
|
-
}
|
|
31
|
-
if (data.enable !== undefined) {
|
|
32
|
-
this.enable = data.enable;
|
|
33
|
-
}
|
|
34
26
|
if (data.offset !== undefined) {
|
|
35
27
|
this.offset = (0, NumberUtils_js_1.setRangeValue)(data.offset);
|
|
36
28
|
}
|
|
37
|
-
if (data.speed !== undefined) {
|
|
38
|
-
this.speed = (0, NumberUtils_js_1.setRangeValue)(data.speed);
|
|
39
|
-
}
|
|
40
|
-
if (data.decay !== undefined) {
|
|
41
|
-
this.decay = (0, NumberUtils_js_1.setRangeValue)(data.decay);
|
|
42
|
-
}
|
|
43
|
-
if (data.delay !== undefined) {
|
|
44
|
-
this.delay = (0, NumberUtils_js_1.setRangeValue)(data.delay);
|
|
45
|
-
}
|
|
46
|
-
if (data.sync !== undefined) {
|
|
47
|
-
this.sync = data.sync;
|
|
48
|
-
}
|
|
49
29
|
}
|
|
50
30
|
}
|
|
51
31
|
exports.ColorAnimation = ColorAnimation;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
5
|
+
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports", "../../../../Utils/Utils.js"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.Effect = void 0;
|
|
13
|
+
const Utils_js_1 = require("../../../../Utils/Utils.js");
|
|
14
|
+
class Effect {
|
|
15
|
+
constructor() {
|
|
16
|
+
this.close = true;
|
|
17
|
+
this.fill = true;
|
|
18
|
+
this.options = {};
|
|
19
|
+
this.type = [];
|
|
20
|
+
}
|
|
21
|
+
load(data) {
|
|
22
|
+
if (!data) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const options = data.options;
|
|
26
|
+
if (options !== undefined) {
|
|
27
|
+
for (const effect in options) {
|
|
28
|
+
const item = options[effect];
|
|
29
|
+
if (item) {
|
|
30
|
+
this.options[effect] = (0, Utils_js_1.deepExtend)(this.options[effect] ?? {}, item);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (data.close !== undefined) {
|
|
35
|
+
this.close = data.close;
|
|
36
|
+
}
|
|
37
|
+
if (data.fill !== undefined) {
|
|
38
|
+
this.fill = data.fill;
|
|
39
|
+
}
|
|
40
|
+
if (data.type !== undefined) {
|
|
41
|
+
this.type = data.type;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.Effect = Effect;
|
|
46
|
+
});
|
|
@@ -4,17 +4,18 @@
|
|
|
4
4
|
if (v !== undefined) module.exports = v;
|
|
5
5
|
}
|
|
6
6
|
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "./ParticlesDensity.js"], factory);
|
|
7
|
+
define(["require", "exports", "./ParticlesDensity.js", "./ParticlesNumberLimit.js"], factory);
|
|
8
8
|
}
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
"use strict";
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.ParticlesNumber = void 0;
|
|
13
13
|
const ParticlesDensity_js_1 = require("./ParticlesDensity.js");
|
|
14
|
+
const ParticlesNumberLimit_js_1 = require("./ParticlesNumberLimit.js");
|
|
14
15
|
class ParticlesNumber {
|
|
15
16
|
constructor() {
|
|
16
17
|
this.density = new ParticlesDensity_js_1.ParticlesDensity();
|
|
17
|
-
this.limit =
|
|
18
|
+
this.limit = new ParticlesNumberLimit_js_1.ParticlesNumberLimit();
|
|
18
19
|
this.value = 0;
|
|
19
20
|
}
|
|
20
21
|
load(data) {
|
|
@@ -22,10 +23,7 @@
|
|
|
22
23
|
return;
|
|
23
24
|
}
|
|
24
25
|
this.density.load(data.density);
|
|
25
|
-
|
|
26
|
-
if (limit !== undefined) {
|
|
27
|
-
this.limit = limit;
|
|
28
|
-
}
|
|
26
|
+
this.limit.load(data.limit);
|
|
29
27
|
if (data.value !== undefined) {
|
|
30
28
|
this.value = data.value;
|
|
31
29
|
}
|
|
@@ -9,23 +9,23 @@
|
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
"use strict";
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
13
|
-
class
|
|
12
|
+
exports.ParticlesNumberLimit = void 0;
|
|
13
|
+
class ParticlesNumberLimit {
|
|
14
14
|
constructor() {
|
|
15
|
-
this.
|
|
16
|
-
this.
|
|
15
|
+
this.mode = "delete";
|
|
16
|
+
this.value = 0;
|
|
17
17
|
}
|
|
18
18
|
load(data) {
|
|
19
19
|
if (!data) {
|
|
20
20
|
return;
|
|
21
21
|
}
|
|
22
|
-
if (data.
|
|
23
|
-
this.
|
|
22
|
+
if (data.mode !== undefined) {
|
|
23
|
+
this.mode = data.mode;
|
|
24
24
|
}
|
|
25
|
-
if (data.
|
|
26
|
-
this.
|
|
25
|
+
if (data.value !== undefined) {
|
|
26
|
+
this.value = data.value;
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
|
-
exports.
|
|
30
|
+
exports.ParticlesNumberLimit = ParticlesNumberLimit;
|
|
31
31
|
});
|
|
@@ -12,11 +12,10 @@
|
|
|
12
12
|
exports.Opacity = void 0;
|
|
13
13
|
const OpacityAnimation_js_1 = require("./OpacityAnimation.js");
|
|
14
14
|
const ValueWithRandom_js_1 = require("../../ValueWithRandom.js");
|
|
15
|
-
class Opacity extends ValueWithRandom_js_1.
|
|
15
|
+
class Opacity extends ValueWithRandom_js_1.RangedAnimationValueWithRandom {
|
|
16
16
|
constructor() {
|
|
17
17
|
super();
|
|
18
18
|
this.animation = new OpacityAnimation_js_1.OpacityAnimation();
|
|
19
|
-
this.random.minimumValue = 0.1;
|
|
20
19
|
this.value = 1;
|
|
21
20
|
}
|
|
22
21
|
load(data) {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
if (v !== undefined) module.exports = v;
|
|
5
5
|
}
|
|
6
6
|
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "../../../Utils/Utils.js", "../AnimatableColor.js", "./Collisions/Collisions.js", "./Move/Move.js", "./Opacity/Opacity.js", "./Bounce/ParticlesBounce.js", "./Number/ParticlesNumber.js", "./Shadow.js", "./Shape/Shape.js", "./Size/Size.js", "./Stroke.js", "./ZIndex/ZIndex.js"], factory);
|
|
7
|
+
define(["require", "exports", "../../../Utils/Utils.js", "../AnimatableColor.js", "./Collisions/Collisions.js", "./Effect/Effect.js", "./Move/Move.js", "./Opacity/Opacity.js", "./Bounce/ParticlesBounce.js", "./Number/ParticlesNumber.js", "./Shadow.js", "./Shape/Shape.js", "./Size/Size.js", "./Stroke.js", "./ZIndex/ZIndex.js"], factory);
|
|
8
8
|
}
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
"use strict";
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
const Utils_js_1 = require("../../../Utils/Utils.js");
|
|
14
14
|
const AnimatableColor_js_1 = require("../AnimatableColor.js");
|
|
15
15
|
const Collisions_js_1 = require("./Collisions/Collisions.js");
|
|
16
|
+
const Effect_js_1 = require("./Effect/Effect.js");
|
|
16
17
|
const Move_js_1 = require("./Move/Move.js");
|
|
17
18
|
const Opacity_js_1 = require("./Opacity/Opacity.js");
|
|
18
19
|
const ParticlesBounce_js_1 = require("./Bounce/ParticlesBounce.js");
|
|
@@ -30,6 +31,7 @@
|
|
|
30
31
|
this.collisions = new Collisions_js_1.Collisions();
|
|
31
32
|
this.color = new AnimatableColor_js_1.AnimatableColor();
|
|
32
33
|
this.color.value = "#fff";
|
|
34
|
+
this.effect = new Effect_js_1.Effect();
|
|
33
35
|
this.groups = {};
|
|
34
36
|
this.move = new Move_js_1.Move();
|
|
35
37
|
this.number = new ParticlesNumber_js_1.ParticlesNumber();
|
|
@@ -47,6 +49,7 @@
|
|
|
47
49
|
}
|
|
48
50
|
this.bounce.load(data.bounce);
|
|
49
51
|
this.color.load(AnimatableColor_js_1.AnimatableColor.create(this.color, data.color));
|
|
52
|
+
this.effect.load(data.effect);
|
|
50
53
|
if (data.groups !== undefined) {
|
|
51
54
|
for (const group in data.groups) {
|
|
52
55
|
const item = data.groups[group];
|
|
@@ -4,19 +4,18 @@
|
|
|
4
4
|
if (v !== undefined) module.exports = v;
|
|
5
5
|
}
|
|
6
6
|
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "
|
|
7
|
+
define(["require", "exports", "../../ValueWithRandom.js", "./SizeAnimation.js"], factory);
|
|
8
8
|
}
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
"use strict";
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.Size = void 0;
|
|
13
|
-
const SizeAnimation_js_1 = require("./SizeAnimation.js");
|
|
14
13
|
const ValueWithRandom_js_1 = require("../../ValueWithRandom.js");
|
|
15
|
-
|
|
14
|
+
const SizeAnimation_js_1 = require("./SizeAnimation.js");
|
|
15
|
+
class Size extends ValueWithRandom_js_1.RangedAnimationValueWithRandom {
|
|
16
16
|
constructor() {
|
|
17
17
|
super();
|
|
18
18
|
this.animation = new SizeAnimation_js_1.SizeAnimation();
|
|
19
|
-
this.random.minimumValue = 1;
|
|
20
19
|
this.value = 3;
|
|
21
20
|
}
|
|
22
21
|
load(data) {
|
|
@@ -4,33 +4,24 @@
|
|
|
4
4
|
if (v !== undefined) module.exports = v;
|
|
5
5
|
}
|
|
6
6
|
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "./AnimationOptions.js", "
|
|
7
|
+
define(["require", "exports", "./AnimationOptions.js", "../../Utils/NumberUtils.js"], factory);
|
|
8
8
|
}
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
"use strict";
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.RangedAnimationValueWithRandom = exports.AnimationValueWithRandom = exports.ValueWithRandom = void 0;
|
|
13
13
|
const AnimationOptions_js_1 = require("./AnimationOptions.js");
|
|
14
|
-
const Random_js_1 = require("./Random.js");
|
|
15
|
-
const Utils_js_1 = require("../../Utils/Utils.js");
|
|
16
14
|
const NumberUtils_js_1 = require("../../Utils/NumberUtils.js");
|
|
17
15
|
class ValueWithRandom {
|
|
18
16
|
constructor() {
|
|
19
|
-
this.random = new Random_js_1.Random();
|
|
20
17
|
this.value = 0;
|
|
21
18
|
}
|
|
22
19
|
load(data) {
|
|
23
20
|
if (!data) {
|
|
24
21
|
return;
|
|
25
22
|
}
|
|
26
|
-
if ((0, Utils_js_1.isBoolean)(data.random)) {
|
|
27
|
-
this.random.enable = data.random;
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
this.random.load(data.random);
|
|
31
|
-
}
|
|
32
23
|
if (data.value !== undefined) {
|
|
33
|
-
this.value = (0, NumberUtils_js_1.setRangeValue)(data.value
|
|
24
|
+
this.value = (0, NumberUtils_js_1.setRangeValue)(data.value);
|
|
34
25
|
}
|
|
35
26
|
}
|
|
36
27
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
5
|
+
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
});
|
package/umd/Utils/CanvasUtils.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.alterHsl = exports.drawParticlePlugin = exports.drawPlugin = exports.
|
|
12
|
+
exports.alterHsl = exports.drawParticlePlugin = exports.drawPlugin = exports.drawShapeAfterDraw = exports.drawShape = exports.drawEffect = exports.drawParticle = exports.clear = exports.paintImage = exports.paintBase = exports.drawLine = void 0;
|
|
13
13
|
const ColorUtils_js_1 = require("./ColorUtils.js");
|
|
14
14
|
function drawLine(context, begin, end) {
|
|
15
15
|
context.beginPath();
|
|
@@ -18,14 +18,6 @@
|
|
|
18
18
|
context.closePath();
|
|
19
19
|
}
|
|
20
20
|
exports.drawLine = drawLine;
|
|
21
|
-
function drawTriangle(context, p1, p2, p3) {
|
|
22
|
-
context.beginPath();
|
|
23
|
-
context.moveTo(p1.x, p1.y);
|
|
24
|
-
context.lineTo(p2.x, p2.y);
|
|
25
|
-
context.lineTo(p3.x, p3.y);
|
|
26
|
-
context.closePath();
|
|
27
|
-
}
|
|
28
|
-
exports.drawTriangle = drawTriangle;
|
|
29
21
|
function paintBase(context, dimension, baseColor) {
|
|
30
22
|
context.fillStyle = baseColor ?? "rgba(0,0,0,0)";
|
|
31
23
|
context.fillRect(0, 0, dimension.width, dimension.height);
|
|
@@ -56,7 +48,6 @@
|
|
|
56
48
|
d: rotateData.cos * (transform.d ?? 1),
|
|
57
49
|
};
|
|
58
50
|
context.setTransform(transformData.a, transformData.b, transformData.c, transformData.d, pos.x, pos.y);
|
|
59
|
-
context.beginPath();
|
|
60
51
|
if (backgroundMask) {
|
|
61
52
|
context.globalCompositeOperation = composite;
|
|
62
53
|
}
|
|
@@ -76,45 +67,59 @@
|
|
|
76
67
|
context.strokeStyle = colorStyles.stroke;
|
|
77
68
|
}
|
|
78
69
|
const drawData = { container, context, particle, radius, opacity, delta };
|
|
70
|
+
context.beginPath();
|
|
79
71
|
drawShape(drawData);
|
|
72
|
+
if (particle.shapeClose) {
|
|
73
|
+
context.closePath();
|
|
74
|
+
}
|
|
80
75
|
if (strokeWidth > 0) {
|
|
81
76
|
context.stroke();
|
|
82
77
|
}
|
|
83
|
-
if (particle.
|
|
84
|
-
context.closePath();
|
|
85
|
-
}
|
|
86
|
-
if (particle.fill) {
|
|
78
|
+
if (particle.shapeFill) {
|
|
87
79
|
context.fill();
|
|
88
80
|
}
|
|
89
|
-
|
|
81
|
+
drawShapeAfterDraw(drawData);
|
|
82
|
+
drawEffect(drawData);
|
|
90
83
|
context.globalCompositeOperation = "source-over";
|
|
91
84
|
context.setTransform(1, 0, 0, 1, 0, 0);
|
|
92
85
|
}
|
|
93
86
|
exports.drawParticle = drawParticle;
|
|
87
|
+
function drawEffect(data) {
|
|
88
|
+
const { container, context, particle, radius, opacity, delta } = data;
|
|
89
|
+
if (!particle.effect) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
const drawer = container.effectDrawers.get(particle.effect);
|
|
93
|
+
if (!drawer) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
drawer.draw({ context, particle, radius, opacity, delta, pixelRatio: container.retina.pixelRatio });
|
|
97
|
+
}
|
|
98
|
+
exports.drawEffect = drawEffect;
|
|
94
99
|
function drawShape(data) {
|
|
95
100
|
const { container, context, particle, radius, opacity, delta } = data;
|
|
96
101
|
if (!particle.shape) {
|
|
97
102
|
return;
|
|
98
103
|
}
|
|
99
|
-
const drawer = container.
|
|
104
|
+
const drawer = container.shapeDrawers.get(particle.shape);
|
|
100
105
|
if (!drawer) {
|
|
101
106
|
return;
|
|
102
107
|
}
|
|
103
108
|
drawer.draw({ context, particle, radius, opacity, delta, pixelRatio: container.retina.pixelRatio });
|
|
104
109
|
}
|
|
105
110
|
exports.drawShape = drawShape;
|
|
106
|
-
function
|
|
111
|
+
function drawShapeAfterDraw(data) {
|
|
107
112
|
const { container, context, particle, radius, opacity, delta } = data;
|
|
108
113
|
if (!particle.shape) {
|
|
109
114
|
return;
|
|
110
115
|
}
|
|
111
|
-
const drawer = container.
|
|
112
|
-
if (!drawer || !drawer.
|
|
116
|
+
const drawer = container.shapeDrawers.get(particle.shape);
|
|
117
|
+
if (!drawer || !drawer.afterDraw) {
|
|
113
118
|
return;
|
|
114
119
|
}
|
|
115
|
-
drawer.
|
|
120
|
+
drawer.afterDraw({ context, particle, radius, opacity, delta, pixelRatio: container.retina.pixelRatio });
|
|
116
121
|
}
|
|
117
|
-
exports.
|
|
122
|
+
exports.drawShapeAfterDraw = drawShapeAfterDraw;
|
|
118
123
|
function drawPlugin(context, plugin, delta) {
|
|
119
124
|
if (!plugin.draw) {
|
|
120
125
|
return;
|