@tsparticles/engine 3.2.2 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/174.min.js +2 -0
- package/174.min.js.LICENSE.txt +1 -0
- package/browser/Core/Canvas.js +9 -9
- package/browser/Core/Container.js +6 -6
- package/browser/Core/Engine.js +1 -1
- package/browser/Core/Particle.js +11 -11
- package/browser/Core/Particles.js +29 -29
- package/browser/Core/Utils/InteractionManager.js +4 -4
- package/browser/Utils/CanvasUtils.js +14 -14
- package/cjs/Core/Canvas.js +9 -9
- package/cjs/Core/Container.js +6 -6
- package/cjs/Core/Engine.js +2 -25
- package/cjs/Core/Particle.js +11 -11
- package/cjs/Core/Particles.js +30 -53
- package/cjs/Core/Utils/InteractionManager.js +4 -4
- package/cjs/Utils/CanvasUtils.js +14 -14
- package/dist_browser_Core_Container_js.js +15 -5
- package/esm/Core/Canvas.js +9 -9
- package/esm/Core/Container.js +6 -6
- package/esm/Core/Engine.js +1 -1
- package/esm/Core/Particle.js +11 -11
- package/esm/Core/Particles.js +29 -29
- package/esm/Core/Utils/InteractionManager.js +4 -4
- package/esm/Utils/CanvasUtils.js +14 -14
- package/package.json +1 -1
- package/report.html +1 -1
- package/tsparticles.engine.js +4 -4
- package/tsparticles.engine.min.js +1 -1
- package/tsparticles.engine.min.js.LICENSE.txt +1 -1
- package/types/Core/Canvas.d.ts +4 -4
- package/types/Core/Interfaces/IContainerPlugin.d.ts +4 -4
- package/types/Core/Interfaces/IEffectDrawer.d.ts +3 -3
- package/types/Core/Interfaces/IExternalInteractor.d.ts +1 -1
- package/types/Core/Interfaces/IMovePathGenerator.d.ts +2 -2
- package/types/Core/Interfaces/IParticleMover.d.ts +2 -2
- package/types/Core/Interfaces/IParticleUpdater.d.ts +2 -2
- package/types/Core/Interfaces/IParticlesInteractor.d.ts +1 -1
- package/types/Core/Interfaces/IShapeDrawer.d.ts +4 -4
- package/types/Core/Particle.d.ts +2 -2
- package/types/Core/Particles.d.ts +7 -7
- package/types/Core/Utils/ExternalInteractorBase.d.ts +1 -1
- package/types/Core/Utils/InteractionManager.d.ts +2 -2
- package/types/Core/Utils/ParticlesInteractorBase.d.ts +1 -1
- package/types/Utils/CanvasUtils.d.ts +6 -6
- package/umd/Core/Canvas.js +9 -9
- package/umd/Core/Container.js +6 -6
- package/umd/Core/Engine.js +1 -1
- package/umd/Core/Particle.js +11 -11
- package/umd/Core/Particles.js +31 -55
- package/umd/Core/Utils/InteractionManager.js +4 -4
- package/umd/Utils/CanvasUtils.js +14 -14
- package/373.min.js +0 -2
- package/373.min.js.LICENSE.txt +0 -1
- package/438.min.js +0 -2
- package/438.min.js.LICENSE.txt +0 -1
- package/dist_browser_Core_Particle_js.js +0 -32
package/cjs/Core/Container.js
CHANGED
|
@@ -43,7 +43,7 @@ class Container {
|
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
};
|
|
46
|
-
this._nextFrame =
|
|
46
|
+
this._nextFrame = (timestamp) => {
|
|
47
47
|
try {
|
|
48
48
|
if (!this._smooth &&
|
|
49
49
|
this._lastFrameTime !== undefined &&
|
|
@@ -59,7 +59,7 @@ class Container {
|
|
|
59
59
|
this.draw(false);
|
|
60
60
|
return;
|
|
61
61
|
}
|
|
62
|
-
|
|
62
|
+
this.particles.draw(delta);
|
|
63
63
|
if (!this.alive()) {
|
|
64
64
|
this.destroy();
|
|
65
65
|
return;
|
|
@@ -240,14 +240,14 @@ class Container {
|
|
|
240
240
|
return;
|
|
241
241
|
}
|
|
242
242
|
let refreshTime = force;
|
|
243
|
-
const frame =
|
|
243
|
+
const frame = (timestamp) => {
|
|
244
244
|
if (refreshTime) {
|
|
245
245
|
this._lastFrameTime = undefined;
|
|
246
246
|
refreshTime = false;
|
|
247
247
|
}
|
|
248
|
-
|
|
248
|
+
this._nextFrame(timestamp);
|
|
249
249
|
};
|
|
250
|
-
this._drawAnimationFrame = requestAnimationFrame((timestamp) =>
|
|
250
|
+
this._drawAnimationFrame = requestAnimationFrame((timestamp) => frame(timestamp));
|
|
251
251
|
}
|
|
252
252
|
async export(type, options = {}) {
|
|
253
253
|
for (const [, plugin] of this.plugins) {
|
|
@@ -319,7 +319,7 @@ class Container {
|
|
|
319
319
|
}
|
|
320
320
|
this._engine.dispatchEvent("containerInit", { container: this });
|
|
321
321
|
await this.particles.init();
|
|
322
|
-
|
|
322
|
+
this.particles.setDensity();
|
|
323
323
|
for (const [, plugin] of this.plugins) {
|
|
324
324
|
plugin.particlesSetup?.();
|
|
325
325
|
}
|
package/cjs/Core/Engine.js
CHANGED
|
@@ -1,27 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
3
|
exports.Engine = void 0;
|
|
27
4
|
const Constants_js_1 = require("./Utils/Constants.js");
|
|
@@ -76,7 +53,7 @@ class Engine {
|
|
|
76
53
|
return res;
|
|
77
54
|
}
|
|
78
55
|
get version() {
|
|
79
|
-
return "3.
|
|
56
|
+
return "3.3.0";
|
|
80
57
|
}
|
|
81
58
|
addConfig(config) {
|
|
82
59
|
const key = config.key ?? config.name ?? "default";
|
|
@@ -238,7 +215,7 @@ class Engine {
|
|
|
238
215
|
if (!canvasEl.style.height) {
|
|
239
216
|
canvasEl.style.height = "100%";
|
|
240
217
|
}
|
|
241
|
-
const { Container } = await
|
|
218
|
+
const { Container } = await import("./Container.js"), newItem = new Container(this, id, currentOptions);
|
|
242
219
|
if (oldIndex >= minIndex) {
|
|
243
220
|
const deleteCount = 0;
|
|
244
221
|
dom.splice(oldIndex, deleteCount, newItem);
|
package/cjs/Core/Particle.js
CHANGED
|
@@ -178,12 +178,12 @@ class Particle {
|
|
|
178
178
|
},
|
|
179
179
|
});
|
|
180
180
|
}
|
|
181
|
-
|
|
181
|
+
draw(delta) {
|
|
182
182
|
const container = this.container, canvas = container.canvas;
|
|
183
183
|
for (const [, plugin] of container.plugins) {
|
|
184
|
-
|
|
184
|
+
canvas.drawParticlePlugin(plugin, this, delta);
|
|
185
185
|
}
|
|
186
|
-
|
|
186
|
+
canvas.drawParticle(this, delta);
|
|
187
187
|
}
|
|
188
188
|
getFillColor() {
|
|
189
189
|
return this._getRollColor(this.bubble.color ?? (0, ColorUtils_js_1.getHslFromAnimation)(this.color));
|
|
@@ -204,7 +204,7 @@ class Particle {
|
|
|
204
204
|
getStrokeColor() {
|
|
205
205
|
return this._getRollColor(this.bubble.color ?? (0, ColorUtils_js_1.getHslFromAnimation)(this.strokeColor));
|
|
206
206
|
}
|
|
207
|
-
|
|
207
|
+
init(id, position, overrideOptions, group) {
|
|
208
208
|
const container = this.container, engine = this._engine;
|
|
209
209
|
this.id = id;
|
|
210
210
|
this.group = group;
|
|
@@ -268,7 +268,7 @@ class Particle {
|
|
|
268
268
|
if (pathOptions.generator) {
|
|
269
269
|
this.pathGenerator = this._engine.getPathGenerator(pathOptions.generator);
|
|
270
270
|
if (this.pathGenerator && container.addPath(pathOptions.generator, this.pathGenerator)) {
|
|
271
|
-
|
|
271
|
+
this.pathGenerator.init(container);
|
|
272
272
|
}
|
|
273
273
|
}
|
|
274
274
|
container.retina.initParticle(this);
|
|
@@ -297,7 +297,7 @@ class Particle {
|
|
|
297
297
|
}
|
|
298
298
|
}
|
|
299
299
|
if (effectDrawer?.loadEffect) {
|
|
300
|
-
|
|
300
|
+
effectDrawer.loadEffect(this);
|
|
301
301
|
}
|
|
302
302
|
let shapeDrawer = container.shapeDrawers.get(this.shape);
|
|
303
303
|
if (!shapeDrawer) {
|
|
@@ -307,7 +307,7 @@ class Particle {
|
|
|
307
307
|
}
|
|
308
308
|
}
|
|
309
309
|
if (shapeDrawer?.loadShape) {
|
|
310
|
-
|
|
310
|
+
shapeDrawer.loadShape(this);
|
|
311
311
|
}
|
|
312
312
|
const sideCountFunc = shapeDrawer?.getSidesCount;
|
|
313
313
|
if (sideCountFunc) {
|
|
@@ -316,13 +316,13 @@ class Particle {
|
|
|
316
316
|
this.spawning = false;
|
|
317
317
|
this.shadowColor = (0, ColorUtils_js_1.rangeColorToRgb)(this.options.shadow.color);
|
|
318
318
|
for (const updater of particles.updaters) {
|
|
319
|
-
|
|
319
|
+
updater.init(this);
|
|
320
320
|
}
|
|
321
321
|
for (const mover of particles.movers) {
|
|
322
|
-
|
|
322
|
+
mover.init?.(this);
|
|
323
323
|
}
|
|
324
|
-
|
|
325
|
-
|
|
324
|
+
effectDrawer?.particleInit?.(container, this);
|
|
325
|
+
shapeDrawer?.particleInit?.(container, this);
|
|
326
326
|
for (const [, plugin] of container.plugins) {
|
|
327
327
|
plugin.particleCreated?.(this);
|
|
328
328
|
}
|
package/cjs/Core/Particles.js
CHANGED
|
@@ -1,31 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
3
|
exports.Particles = void 0;
|
|
27
4
|
const Utils_js_1 = require("../Utils/Utils.js");
|
|
28
5
|
const InteractionManager_js_1 = require("./Utils/InteractionManager.js");
|
|
6
|
+
const Particle_js_1 = require("./Particle.js");
|
|
29
7
|
const Point_js_1 = require("./Utils/Point.js");
|
|
30
8
|
const QuadTree_js_1 = require("./Utils/QuadTree.js");
|
|
31
9
|
const Ranges_js_1 = require("./Utils/Ranges.js");
|
|
@@ -42,7 +20,7 @@ class Particles {
|
|
|
42
20
|
this._pool.push(particle);
|
|
43
21
|
}
|
|
44
22
|
};
|
|
45
|
-
this._applyDensity =
|
|
23
|
+
this._applyDensity = (options, manualCount, group) => {
|
|
46
24
|
const numberOptions = options.number;
|
|
47
25
|
if (!options.number.density?.enable) {
|
|
48
26
|
if (group === undefined) {
|
|
@@ -61,7 +39,7 @@ class Particles {
|
|
|
61
39
|
this._groupLimits.set(group, numberOptions.limit.value * densityFactor);
|
|
62
40
|
}
|
|
63
41
|
if (particlesCount < particlesNumber) {
|
|
64
|
-
|
|
42
|
+
this.push(Math.abs(particlesNumber - particlesCount), undefined, options, group);
|
|
65
43
|
}
|
|
66
44
|
else if (particlesCount > particlesNumber) {
|
|
67
45
|
this.removeQuantity(particlesCount - particlesNumber, group);
|
|
@@ -75,14 +53,13 @@ class Particles {
|
|
|
75
53
|
const canvas = container.canvas.element, pxRatio = container.retina.pixelRatio;
|
|
76
54
|
return (canvas.width * canvas.height) / (densityOptions.height * densityOptions.width * pxRatio ** squareExp);
|
|
77
55
|
};
|
|
78
|
-
this._pushParticle =
|
|
56
|
+
this._pushParticle = (position, overrideOptions, group, initializer) => {
|
|
79
57
|
try {
|
|
80
58
|
let particle = this._pool.pop();
|
|
81
59
|
if (!particle) {
|
|
82
|
-
|
|
83
|
-
particle = new Particle(this._engine, this._container);
|
|
60
|
+
particle = new Particle_js_1.Particle(this._engine, this._container);
|
|
84
61
|
}
|
|
85
|
-
|
|
62
|
+
particle.init(this._nextId, position, overrideOptions, group);
|
|
86
63
|
let canAdd = true;
|
|
87
64
|
if (initializer) {
|
|
88
65
|
canAdd = initializer(particle);
|
|
@@ -143,13 +120,13 @@ class Particles {
|
|
|
143
120
|
get count() {
|
|
144
121
|
return this._array.length;
|
|
145
122
|
}
|
|
146
|
-
|
|
123
|
+
addManualParticles() {
|
|
147
124
|
const container = this._container, options = container.actualOptions;
|
|
148
125
|
for (const particle of options.manualParticles) {
|
|
149
|
-
|
|
126
|
+
this.addParticle(particle.position ? (0, Utils_js_1.getPosition)(particle.position, container.canvas.size) : undefined, particle.options);
|
|
150
127
|
}
|
|
151
128
|
}
|
|
152
|
-
|
|
129
|
+
addParticle(position, overrideOptions, group, initializer) {
|
|
153
130
|
const limitOptions = this._container.actualOptions.particles.number.limit, limit = group === undefined ? this._limit : this._groupLimits.get(group) ?? this._limit, currentCount = this.count, minLimit = 0;
|
|
154
131
|
if (limit > minLimit) {
|
|
155
132
|
if (limitOptions.mode === "delete") {
|
|
@@ -164,7 +141,7 @@ class Particles {
|
|
|
164
141
|
}
|
|
165
142
|
}
|
|
166
143
|
}
|
|
167
|
-
return
|
|
144
|
+
return this._pushParticle(position, overrideOptions, group, initializer);
|
|
168
145
|
}
|
|
169
146
|
clear() {
|
|
170
147
|
this._array = [];
|
|
@@ -177,15 +154,15 @@ class Particles {
|
|
|
177
154
|
this.movers = [];
|
|
178
155
|
this.updaters = [];
|
|
179
156
|
}
|
|
180
|
-
|
|
157
|
+
draw(delta) {
|
|
181
158
|
const container = this._container, canvas = container.canvas;
|
|
182
159
|
canvas.clear();
|
|
183
|
-
|
|
160
|
+
this.update(delta);
|
|
184
161
|
for (const [, plugin] of container.plugins) {
|
|
185
|
-
|
|
162
|
+
canvas.drawPlugin(plugin, delta);
|
|
186
163
|
}
|
|
187
164
|
for (const p of this._zArray) {
|
|
188
|
-
|
|
165
|
+
p.draw(delta);
|
|
189
166
|
}
|
|
190
167
|
}
|
|
191
168
|
filter(condition) {
|
|
@@ -214,17 +191,17 @@ class Particles {
|
|
|
214
191
|
break;
|
|
215
192
|
}
|
|
216
193
|
}
|
|
217
|
-
|
|
194
|
+
this.addManualParticles();
|
|
218
195
|
if (!handled) {
|
|
219
196
|
const particlesOptions = options.particles, groups = particlesOptions.groups;
|
|
220
197
|
for (const group in groups) {
|
|
221
198
|
const groupOptions = groups[group];
|
|
222
199
|
for (let i = this.count, j = 0; j < groupOptions.number?.value && i < particlesOptions.number.value; i++, j++) {
|
|
223
|
-
|
|
200
|
+
this.addParticle(undefined, groupOptions, group);
|
|
224
201
|
}
|
|
225
202
|
}
|
|
226
203
|
for (let i = this.count; i < particlesOptions.number.value; i++) {
|
|
227
|
-
|
|
204
|
+
this.addParticle();
|
|
228
205
|
}
|
|
229
206
|
}
|
|
230
207
|
}
|
|
@@ -237,18 +214,18 @@ class Particles {
|
|
|
237
214
|
this.updaters = await this._engine.getUpdaters(container, true);
|
|
238
215
|
await this._interactionManager.init();
|
|
239
216
|
for (const [, pathGenerator] of container.pathGenerators) {
|
|
240
|
-
|
|
217
|
+
pathGenerator.init(container);
|
|
241
218
|
}
|
|
242
219
|
}
|
|
243
|
-
|
|
220
|
+
push(nb, mouse, overrideOptions, group) {
|
|
244
221
|
for (let i = 0; i < nb; i++) {
|
|
245
|
-
|
|
222
|
+
this.addParticle(mouse?.position, overrideOptions, group);
|
|
246
223
|
}
|
|
247
224
|
}
|
|
248
225
|
async redraw() {
|
|
249
226
|
this.clear();
|
|
250
227
|
await this.init();
|
|
251
|
-
|
|
228
|
+
this.draw({ value: 0, factor: 0 });
|
|
252
229
|
}
|
|
253
230
|
remove(particle, group, override) {
|
|
254
231
|
this.removeAt(this._array.indexOf(particle), undefined, group, override);
|
|
@@ -269,12 +246,12 @@ class Particles {
|
|
|
269
246
|
const defaultIndex = 0;
|
|
270
247
|
this.removeAt(defaultIndex, quantity, group);
|
|
271
248
|
}
|
|
272
|
-
|
|
249
|
+
setDensity() {
|
|
273
250
|
const options = this._container.actualOptions, groups = options.particles.groups, manualCount = 0;
|
|
274
251
|
for (const group in groups) {
|
|
275
|
-
|
|
252
|
+
this._applyDensity(groups[group], manualCount, group);
|
|
276
253
|
}
|
|
277
|
-
|
|
254
|
+
this._applyDensity(options.particles, options.manualParticles.length);
|
|
278
255
|
}
|
|
279
256
|
setLastZIndex(zIndex) {
|
|
280
257
|
this._lastZIndex = zIndex;
|
|
@@ -283,14 +260,14 @@ class Particles {
|
|
|
283
260
|
setResizeFactor(factor) {
|
|
284
261
|
this._resizeFactor = factor;
|
|
285
262
|
}
|
|
286
|
-
|
|
263
|
+
update(delta) {
|
|
287
264
|
const container = this._container, particlesToDelete = new Set();
|
|
288
265
|
this.quadTree = new QuadTree_js_1.QuadTree(qTreeRectangle(container.canvas.size), qTreeCapacity);
|
|
289
266
|
for (const [, pathGenerator] of container.pathGenerators) {
|
|
290
267
|
pathGenerator.update();
|
|
291
268
|
}
|
|
292
269
|
for (const [, plugin] of container.plugins) {
|
|
293
|
-
|
|
270
|
+
plugin.update?.(delta);
|
|
294
271
|
}
|
|
295
272
|
const resizeFactor = this._resizeFactor;
|
|
296
273
|
for (const particle of this._array) {
|
|
@@ -310,7 +287,7 @@ class Particles {
|
|
|
310
287
|
}
|
|
311
288
|
for (const mover of this.movers) {
|
|
312
289
|
if (mover.isEnabled(particle)) {
|
|
313
|
-
|
|
290
|
+
mover.move(particle, delta);
|
|
314
291
|
}
|
|
315
292
|
}
|
|
316
293
|
if (particle.destroyed) {
|
|
@@ -333,13 +310,13 @@ class Particles {
|
|
|
333
310
|
}
|
|
334
311
|
this._addToPool(...particlesToDelete);
|
|
335
312
|
}
|
|
336
|
-
|
|
313
|
+
this._interactionManager.externalInteract(delta);
|
|
337
314
|
for (const particle of this._array) {
|
|
338
315
|
for (const updater of this.updaters) {
|
|
339
|
-
|
|
316
|
+
updater.update(particle, delta);
|
|
340
317
|
}
|
|
341
318
|
if (!particle.destroyed && !particle.spawning) {
|
|
342
|
-
|
|
319
|
+
this._interactionManager.particlesInteract(particle, delta);
|
|
343
320
|
}
|
|
344
321
|
}
|
|
345
322
|
delete this._resizeFactor;
|
|
@@ -9,10 +9,10 @@ class InteractionManager {
|
|
|
9
9
|
this._externalInteractors = [];
|
|
10
10
|
this._particleInteractors = [];
|
|
11
11
|
}
|
|
12
|
-
|
|
12
|
+
externalInteract(delta) {
|
|
13
13
|
for (const interactor of this._externalInteractors) {
|
|
14
14
|
if (interactor.isEnabled()) {
|
|
15
|
-
|
|
15
|
+
interactor.interact(delta);
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
}
|
|
@@ -37,13 +37,13 @@ class InteractionManager {
|
|
|
37
37
|
interactor.init();
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
|
|
40
|
+
particlesInteract(particle, delta) {
|
|
41
41
|
for (const interactor of this._externalInteractors) {
|
|
42
42
|
interactor.clear(particle, delta);
|
|
43
43
|
}
|
|
44
44
|
for (const interactor of this._particleInteractors) {
|
|
45
45
|
if (interactor.isEnabled(particle)) {
|
|
46
|
-
|
|
46
|
+
interactor.interact(particle, delta);
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
}
|
package/cjs/Utils/CanvasUtils.js
CHANGED
|
@@ -28,7 +28,7 @@ function clear(context, dimension) {
|
|
|
28
28
|
context.clearRect(origin.x, origin.y, dimension.width, dimension.height);
|
|
29
29
|
}
|
|
30
30
|
exports.clear = clear;
|
|
31
|
-
|
|
31
|
+
function drawParticle(data) {
|
|
32
32
|
const { container, context, particle, delta, colorStyles, backgroundMask, composite, radius, opacity, shadow, transform, } = data, pos = particle.getPosition(), defaultAngle = 0, angle = particle.rotation + (particle.pathRotation ? particle.velocity.angle : defaultAngle), rotateData = {
|
|
33
33
|
sin: Math.sin(angle),
|
|
34
34
|
cos: Math.cos(angle),
|
|
@@ -67,14 +67,14 @@ async function drawParticle(data) {
|
|
|
67
67
|
transformData,
|
|
68
68
|
strokeWidth,
|
|
69
69
|
};
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
drawShape(drawData);
|
|
71
|
+
drawShapeAfterDraw(drawData);
|
|
72
|
+
drawEffect(drawData);
|
|
73
73
|
context.globalCompositeOperation = "source-over";
|
|
74
74
|
context.resetTransform();
|
|
75
75
|
}
|
|
76
76
|
exports.drawParticle = drawParticle;
|
|
77
|
-
|
|
77
|
+
function drawEffect(data) {
|
|
78
78
|
const { container, context, particle, radius, opacity, delta, transformData } = data;
|
|
79
79
|
if (!particle.effect) {
|
|
80
80
|
return;
|
|
@@ -83,7 +83,7 @@ async function drawEffect(data) {
|
|
|
83
83
|
if (!drawer) {
|
|
84
84
|
return;
|
|
85
85
|
}
|
|
86
|
-
|
|
86
|
+
drawer.draw({
|
|
87
87
|
context,
|
|
88
88
|
particle,
|
|
89
89
|
radius,
|
|
@@ -94,7 +94,7 @@ async function drawEffect(data) {
|
|
|
94
94
|
});
|
|
95
95
|
}
|
|
96
96
|
exports.drawEffect = drawEffect;
|
|
97
|
-
|
|
97
|
+
function drawShape(data) {
|
|
98
98
|
const { container, context, particle, radius, opacity, delta, strokeWidth, transformData } = data, minStrokeWidth = 0;
|
|
99
99
|
if (!particle.shape) {
|
|
100
100
|
return;
|
|
@@ -104,7 +104,7 @@ async function drawShape(data) {
|
|
|
104
104
|
return;
|
|
105
105
|
}
|
|
106
106
|
context.beginPath();
|
|
107
|
-
|
|
107
|
+
drawer.draw({
|
|
108
108
|
context,
|
|
109
109
|
particle,
|
|
110
110
|
radius,
|
|
@@ -124,7 +124,7 @@ async function drawShape(data) {
|
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
exports.drawShape = drawShape;
|
|
127
|
-
|
|
127
|
+
function drawShapeAfterDraw(data) {
|
|
128
128
|
const { container, context, particle, radius, opacity, delta, transformData } = data;
|
|
129
129
|
if (!particle.shape) {
|
|
130
130
|
return;
|
|
@@ -133,7 +133,7 @@ async function drawShapeAfterDraw(data) {
|
|
|
133
133
|
if (!drawer?.afterDraw) {
|
|
134
134
|
return;
|
|
135
135
|
}
|
|
136
|
-
|
|
136
|
+
drawer.afterDraw({
|
|
137
137
|
context,
|
|
138
138
|
particle,
|
|
139
139
|
radius,
|
|
@@ -144,18 +144,18 @@ async function drawShapeAfterDraw(data) {
|
|
|
144
144
|
});
|
|
145
145
|
}
|
|
146
146
|
exports.drawShapeAfterDraw = drawShapeAfterDraw;
|
|
147
|
-
|
|
147
|
+
function drawPlugin(context, plugin, delta) {
|
|
148
148
|
if (!plugin.draw) {
|
|
149
149
|
return;
|
|
150
150
|
}
|
|
151
|
-
|
|
151
|
+
plugin.draw(context, delta);
|
|
152
152
|
}
|
|
153
153
|
exports.drawPlugin = drawPlugin;
|
|
154
|
-
|
|
154
|
+
function drawParticlePlugin(context, plugin, particle, delta) {
|
|
155
155
|
if (!plugin.drawParticle) {
|
|
156
156
|
return;
|
|
157
157
|
}
|
|
158
|
-
|
|
158
|
+
plugin.drawParticle(context, particle, delta);
|
|
159
159
|
}
|
|
160
160
|
exports.drawParticlePlugin = drawParticlePlugin;
|
|
161
161
|
function alterHsl(color, type, value) {
|