@tsparticles/preset-links 4.5.1 → 4.5.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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
(function(g){g.__tsParticlesInternals=g.__tsParticlesInternals||{};g.__tsParticlesInternals.bundles=g.__tsParticlesInternals.bundles||{};g.__tsParticlesInternals.effects=g.__tsParticlesInternals.effects||{};g.__tsParticlesInternals.engine=g.__tsParticlesInternals.engine||{};g.__tsParticlesInternals.interactions=g.__tsParticlesInternals.interactions||{};g.__tsParticlesInternals.palettes=g.__tsParticlesInternals.palettes||{};g.__tsParticlesInternals.paths=g.__tsParticlesInternals.paths||{};g.__tsParticlesInternals.plugins=g.__tsParticlesInternals.plugins||{};g.__tsParticlesInternals.plugins=g.__tsParticlesInternals.plugins||{};g.__tsParticlesInternals.plugins.emittersShapes=g.__tsParticlesInternals.plugins.emittersShapes||{};g.__tsParticlesInternals.presets=g.__tsParticlesInternals.presets||{};g.__tsParticlesInternals.shapes=g.__tsParticlesInternals.shapes||{};g.__tsParticlesInternals.updaters=g.__tsParticlesInternals.updaters||{};g.__tsParticlesInternals.utils=g.__tsParticlesInternals.utils||{};g.__tsParticlesInternals.canvas=g.__tsParticlesInternals.canvas||{};g.__tsParticlesInternals.canvas=g.__tsParticlesInternals.canvas||{};g.__tsParticlesInternals.canvas.utils=g.__tsParticlesInternals.canvas.utils||{};g.__tsParticlesInternals.path=g.__tsParticlesInternals.path||{};g.__tsParticlesInternals.path=g.__tsParticlesInternals.path||{};g.__tsParticlesInternals.path.utils=g.__tsParticlesInternals.path.utils||{};var __tsProxyFactory=typeof Proxy!=="undefined"?function(obj){return new Proxy(obj,{get:function(target,key){if(!(key in target)){target[key]={};}return target[key];}});}:function(obj){return obj;};g.__tsParticlesInternals.bundles=__tsProxyFactory(g.__tsParticlesInternals.bundles);g.__tsParticlesInternals.effects=__tsProxyFactory(g.__tsParticlesInternals.effects);g.__tsParticlesInternals.interactions=__tsProxyFactory(g.__tsParticlesInternals.interactions);g.__tsParticlesInternals.palettes=__tsProxyFactory(g.__tsParticlesInternals.palettes);g.__tsParticlesInternals.paths=__tsProxyFactory(g.__tsParticlesInternals.paths);g.__tsParticlesInternals.plugins=__tsProxyFactory(g.__tsParticlesInternals.plugins);g.__tsParticlesInternals.plugins.emittersShapes=__tsProxyFactory(g.__tsParticlesInternals.plugins.emittersShapes);g.__tsParticlesInternals.presets=__tsProxyFactory(g.__tsParticlesInternals.presets);g.__tsParticlesInternals.shapes=__tsProxyFactory(g.__tsParticlesInternals.shapes);g.__tsParticlesInternals.updaters=__tsProxyFactory(g.__tsParticlesInternals.updaters);g.__tsParticlesInternals.utils=__tsProxyFactory(g.__tsParticlesInternals.utils);g.__tsParticlesInternals.canvas=__tsProxyFactory(g.__tsParticlesInternals.canvas);g.__tsParticlesInternals.path=__tsProxyFactory(g.__tsParticlesInternals.path);})(typeof globalThis!=="undefined"?globalThis:typeof window!=="undefined"?window:this);
|
|
2
2
|
(function (g) {
|
|
3
|
-
/* Preset v4.5.
|
|
3
|
+
/* Preset v4.5.2 */
|
|
4
4
|
g.__tsParticlesInternals = g.__tsParticlesInternals || {};
|
|
5
5
|
g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
6
6
|
(function (exports) {
|
|
@@ -120,7 +120,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
120
120
|
}
|
|
121
121
|
normalize() {
|
|
122
122
|
const length = this.length;
|
|
123
|
-
if (length
|
|
123
|
+
if (length !== none) {
|
|
124
124
|
this.multTo(inverseFactorNumerator / length);
|
|
125
125
|
}
|
|
126
126
|
}
|
|
@@ -867,11 +867,13 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
867
867
|
#domArray = [];
|
|
868
868
|
#eventDispatcher = new EventDispatcher();
|
|
869
869
|
#initialized = false;
|
|
870
|
+
#loadSequence = 0;
|
|
871
|
+
#loadSequences = new Map();
|
|
870
872
|
get items() {
|
|
871
873
|
return this.#domArray;
|
|
872
874
|
}
|
|
873
875
|
get version() {
|
|
874
|
-
return "4.5.
|
|
876
|
+
return "4.5.2";
|
|
875
877
|
}
|
|
876
878
|
addEventListener(type, listener) {
|
|
877
879
|
this.#eventDispatcher.addEventListener(type, listener);
|
|
@@ -901,44 +903,60 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
901
903
|
return item;
|
|
902
904
|
}
|
|
903
905
|
async load(params) {
|
|
904
|
-
await this.init();
|
|
905
906
|
let domSourceElement;
|
|
906
907
|
if (typeof HTMLElement !== "undefined" && params.element instanceof HTMLElement) {
|
|
907
908
|
domSourceElement = params.element;
|
|
908
909
|
}
|
|
909
|
-
const
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
910
|
+
const id = params.id ?? domSourceElement?.id ?? `tsparticles${Math.floor(getRandom() * loadRandomFactor).toString()}`, loadSequence = ++this.#loadSequence;
|
|
911
|
+
this.#loadSequences.set(id, loadSequence);
|
|
912
|
+
try {
|
|
913
|
+
await this.init();
|
|
914
|
+
const { Container } = await Promise.resolve().then(function () { return Container$1; }), { index, url } = params, options = url ? await getDataFromUrl({ fallback: params.options, url, index }) : params.options;
|
|
915
|
+
if (this.#loadSequences.get(id) !== loadSequence) {
|
|
916
|
+
return undefined;
|
|
917
|
+
}
|
|
918
|
+
const currentOptions = itemFromSingleOrMultiple(options, index), { items } = this, oldIndex = items.findIndex(v => v.id.description === id), newItem = new Container({
|
|
919
|
+
dispatchCallback: (eventType, args) => {
|
|
920
|
+
this.dispatchEvent(eventType, args);
|
|
921
|
+
},
|
|
922
|
+
id,
|
|
923
|
+
onDestroy: (remove) => {
|
|
924
|
+
if (!remove) {
|
|
925
|
+
return;
|
|
926
|
+
}
|
|
927
|
+
const mainArr = this.items, idx = mainArr.indexOf(newItem);
|
|
928
|
+
if (idx >= removeMinIndex) {
|
|
929
|
+
mainArr.splice(idx, removeDeleteCount);
|
|
930
|
+
}
|
|
931
|
+
},
|
|
932
|
+
pluginManager: this.pluginManager,
|
|
933
|
+
sourceOptions: currentOptions,
|
|
934
|
+
});
|
|
935
|
+
if (oldIndex >= loadMinIndex) {
|
|
936
|
+
const old = this.item(oldIndex), deleteCount = old ? one : none;
|
|
937
|
+
if (old && !old.destroyed) {
|
|
938
|
+
old.destroy(false);
|
|
921
939
|
}
|
|
922
|
-
|
|
923
|
-
pluginManager: this.pluginManager,
|
|
924
|
-
sourceOptions: currentOptions,
|
|
925
|
-
});
|
|
926
|
-
if (oldIndex >= loadMinIndex) {
|
|
927
|
-
const old = this.item(oldIndex), deleteCount = old ? one : none;
|
|
928
|
-
if (old && !old.destroyed) {
|
|
929
|
-
old.destroy(false);
|
|
940
|
+
items.splice(oldIndex, deleteCount, newItem);
|
|
930
941
|
}
|
|
931
|
-
|
|
942
|
+
else {
|
|
943
|
+
items.push(newItem);
|
|
944
|
+
}
|
|
945
|
+
const sourceCanvas = typeof OffscreenCanvas !== "undefined" && params.element instanceof OffscreenCanvas
|
|
946
|
+
? params.element
|
|
947
|
+
: getCanvasFromContainer(getDomContainer(id, domSourceElement));
|
|
948
|
+
newItem.canvas.loadCanvas(sourceCanvas);
|
|
949
|
+
await newItem.start();
|
|
950
|
+
if (newItem.destroyed) {
|
|
951
|
+
return undefined;
|
|
952
|
+
}
|
|
953
|
+
return newItem;
|
|
932
954
|
}
|
|
933
|
-
|
|
934
|
-
|
|
955
|
+
finally {
|
|
956
|
+
if (this.#loadSequences.get(id) === loadSequence) {
|
|
957
|
+
this.#loadSequences.delete(id);
|
|
958
|
+
}
|
|
935
959
|
}
|
|
936
|
-
const sourceCanvas = typeof OffscreenCanvas !== "undefined" && params.element instanceof OffscreenCanvas
|
|
937
|
-
? params.element
|
|
938
|
-
: getCanvasFromContainer(getDomContainer(id, domSourceElement));
|
|
939
|
-
newItem.canvas.loadCanvas(sourceCanvas);
|
|
940
|
-
await newItem.start();
|
|
941
|
-
return newItem;
|
|
942
960
|
}
|
|
943
961
|
async refresh(refresh = true) {
|
|
944
962
|
if (!refresh) {
|
|
@@ -2325,6 +2343,13 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
2325
2343
|
}
|
|
2326
2344
|
}
|
|
2327
2345
|
|
|
2346
|
+
function hasEnabledBlend(particleOptions) {
|
|
2347
|
+
if (!particleOptions || typeof particleOptions !== "object" || !("blend" in particleOptions)) {
|
|
2348
|
+
return false;
|
|
2349
|
+
}
|
|
2350
|
+
const blend = particleOptions.blend;
|
|
2351
|
+
return !!blend && typeof blend === "object" && "enable" in blend && !!blend.enable;
|
|
2352
|
+
}
|
|
2328
2353
|
class BlendPlugin {
|
|
2329
2354
|
id = "blend";
|
|
2330
2355
|
async getPlugin(container) {
|
|
@@ -2346,12 +2371,31 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
2346
2371
|
options.blend.load(source?.blend);
|
|
2347
2372
|
}
|
|
2348
2373
|
needsPlugin(options) {
|
|
2349
|
-
|
|
2374
|
+
if (options?.blend?.enable ||
|
|
2375
|
+
options?.particles?.blend?.enable ||
|
|
2376
|
+
Object.values(options?.particles?.groups ?? {}).some(hasEnabledBlend)) {
|
|
2377
|
+
return true;
|
|
2378
|
+
}
|
|
2379
|
+
const emitters = options?.["emitters"];
|
|
2380
|
+
let emitterList = [];
|
|
2381
|
+
if (Array.isArray(emitters)) {
|
|
2382
|
+
emitterList = emitters;
|
|
2383
|
+
}
|
|
2384
|
+
else if (emitters) {
|
|
2385
|
+
emitterList = [emitters];
|
|
2386
|
+
}
|
|
2387
|
+
return emitterList.some(emitter => {
|
|
2388
|
+
if (!emitter || typeof emitter !== "object" || !("particles" in emitter)) {
|
|
2389
|
+
return false;
|
|
2390
|
+
}
|
|
2391
|
+
const particles = emitter.particles;
|
|
2392
|
+
return Array.isArray(particles) ? particles.some(hasEnabledBlend) : hasEnabledBlend(particles);
|
|
2393
|
+
});
|
|
2350
2394
|
}
|
|
2351
2395
|
}
|
|
2352
2396
|
|
|
2353
2397
|
async function loadBlendPlugin(engine) {
|
|
2354
|
-
engine.checkVersion("4.5.
|
|
2398
|
+
engine.checkVersion("4.5.2");
|
|
2355
2399
|
await engine.pluginManager.register(e => {
|
|
2356
2400
|
e.pluginManager.addPlugin(new BlendPlugin());
|
|
2357
2401
|
});
|
|
@@ -2388,7 +2432,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
2388
2432
|
}
|
|
2389
2433
|
|
|
2390
2434
|
async function loadCircleShape(engine) {
|
|
2391
|
-
engine.checkVersion("4.5.
|
|
2435
|
+
engine.checkVersion("4.5.2");
|
|
2392
2436
|
await engine.pluginManager.register(e => {
|
|
2393
2437
|
e.pluginManager.addShape(["circle"], () => {
|
|
2394
2438
|
return Promise.resolve(new CircleDrawer());
|
|
@@ -2436,7 +2480,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
2436
2480
|
}
|
|
2437
2481
|
|
|
2438
2482
|
async function loadHexColorPlugin(engine) {
|
|
2439
|
-
engine.checkVersion("4.5.
|
|
2483
|
+
engine.checkVersion("4.5.2");
|
|
2440
2484
|
await engine.pluginManager.register(e => {
|
|
2441
2485
|
e.pluginManager.addColorManager("hex", new HexColorManager());
|
|
2442
2486
|
});
|
|
@@ -2489,7 +2533,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
2489
2533
|
}
|
|
2490
2534
|
|
|
2491
2535
|
async function loadHslColorPlugin(engine) {
|
|
2492
|
-
engine.checkVersion("4.5.
|
|
2536
|
+
engine.checkVersion("4.5.2");
|
|
2493
2537
|
await engine.pluginManager.register(e => {
|
|
2494
2538
|
e.pluginManager.addColorManager("hsl", new HslColorManager());
|
|
2495
2539
|
});
|
|
@@ -2521,7 +2565,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
2521
2565
|
}
|
|
2522
2566
|
|
|
2523
2567
|
async function loadMovePlugin(engine) {
|
|
2524
|
-
engine.checkVersion("4.5.
|
|
2568
|
+
engine.checkVersion("4.5.2");
|
|
2525
2569
|
if (typeof process !== "undefined" && process.env.NODE_ENV !== "production") {
|
|
2526
2570
|
addErrorMessages(ErrorMessages$1);
|
|
2527
2571
|
}
|
|
@@ -2731,7 +2775,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
2731
2775
|
}
|
|
2732
2776
|
|
|
2733
2777
|
async function loadOpacityUpdater(engine) {
|
|
2734
|
-
engine.checkVersion("4.5.
|
|
2778
|
+
engine.checkVersion("4.5.2");
|
|
2735
2779
|
await engine.pluginManager.register(e => {
|
|
2736
2780
|
e.pluginManager.addParticleUpdater("opacity", container => {
|
|
2737
2781
|
return Promise.resolve(new OpacityUpdater(container));
|
|
@@ -3060,7 +3104,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
3060
3104
|
}
|
|
3061
3105
|
|
|
3062
3106
|
async function loadOutModesUpdater(engine) {
|
|
3063
|
-
engine.checkVersion("4.5.
|
|
3107
|
+
engine.checkVersion("4.5.2");
|
|
3064
3108
|
await engine.pluginManager.register(e => {
|
|
3065
3109
|
e.pluginManager.addParticleUpdater("outModes", container => {
|
|
3066
3110
|
return Promise.resolve(new OutOfCanvasUpdater(container));
|
|
@@ -3139,7 +3183,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
3139
3183
|
}
|
|
3140
3184
|
|
|
3141
3185
|
async function loadPaintUpdater(engine) {
|
|
3142
|
-
engine.checkVersion("4.5.
|
|
3186
|
+
engine.checkVersion("4.5.2");
|
|
3143
3187
|
await engine.pluginManager.register(e => {
|
|
3144
3188
|
e.pluginManager.addParticleUpdater("paint", container => {
|
|
3145
3189
|
return Promise.resolve(new PaintUpdater(e.pluginManager, container));
|
|
@@ -3194,7 +3238,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
3194
3238
|
}
|
|
3195
3239
|
|
|
3196
3240
|
async function loadRgbColorPlugin(engine) {
|
|
3197
|
-
engine.checkVersion("4.5.
|
|
3241
|
+
engine.checkVersion("4.5.2");
|
|
3198
3242
|
await engine.pluginManager.register(e => {
|
|
3199
3243
|
e.pluginManager.addColorManager("rgb", new RgbColorManager());
|
|
3200
3244
|
});
|
|
@@ -3279,7 +3323,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
3279
3323
|
}
|
|
3280
3324
|
|
|
3281
3325
|
async function loadSizeUpdater(engine) {
|
|
3282
|
-
engine.checkVersion("4.5.
|
|
3326
|
+
engine.checkVersion("4.5.2");
|
|
3283
3327
|
await engine.pluginManager.register(e => {
|
|
3284
3328
|
e.pluginManager.addParticleUpdater("size", container => {
|
|
3285
3329
|
return Promise.resolve(new SizeUpdater(container));
|
|
@@ -3288,7 +3332,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
3288
3332
|
}
|
|
3289
3333
|
|
|
3290
3334
|
async function loadBasic(engine) {
|
|
3291
|
-
engine.checkVersion("4.5.
|
|
3335
|
+
engine.checkVersion("4.5.2");
|
|
3292
3336
|
await engine.pluginManager.register(async (e) => {
|
|
3293
3337
|
await Promise.all([
|
|
3294
3338
|
loadBlendPlugin(e),
|
|
@@ -3494,7 +3538,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
3494
3538
|
const clickEvent = "click", mouseDownEvent = "pointerdown", mouseUpEvent = "pointerup", mouseLeaveEvent = "pointerleave", mouseMoveEvent = "pointermove", touchStartEvent = "touchstart", touchEndEvent = "touchend", touchMoveEvent = "touchmove", touchCancelEvent = "touchcancel";
|
|
3495
3539
|
|
|
3496
3540
|
async function loadInteractivityPlugin(engine) {
|
|
3497
|
-
engine.checkVersion("4.5.
|
|
3541
|
+
engine.checkVersion("4.5.2");
|
|
3498
3542
|
if (typeof process !== "undefined" && process.env.NODE_ENV !== "production") {
|
|
3499
3543
|
addErrorMessages(ErrorMessages);
|
|
3500
3544
|
}
|
|
@@ -3534,8 +3578,9 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
3534
3578
|
this.#canvasSize = canvasSize;
|
|
3535
3579
|
}
|
|
3536
3580
|
contains(point) {
|
|
3537
|
-
if (super.contains(point))
|
|
3581
|
+
if (super.contains(point)) {
|
|
3538
3582
|
return true;
|
|
3583
|
+
}
|
|
3539
3584
|
const { width, height } = this.#canvasSize, { x, y } = point;
|
|
3540
3585
|
return (super.contains({ x: x - width, y }) ||
|
|
3541
3586
|
super.contains({ x: x + width, y }) ||
|
|
@@ -3547,8 +3592,9 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
3547
3592
|
super.contains({ x: x + width, y: y - height }));
|
|
3548
3593
|
}
|
|
3549
3594
|
intersects(range) {
|
|
3550
|
-
if (super.intersects(range))
|
|
3595
|
+
if (super.intersects(range)) {
|
|
3551
3596
|
return true;
|
|
3597
|
+
}
|
|
3552
3598
|
const { width, height } = this.#canvasSize, pos = range.position, shifts = [
|
|
3553
3599
|
{ x: -width, y: 0 },
|
|
3554
3600
|
{ x: width, y: 0 },
|
|
@@ -3569,8 +3615,9 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
3569
3615
|
const rect = range;
|
|
3570
3616
|
shiftedRange = new Rectangle(shiftedPos.x, shiftedPos.y, rect.size.width, rect.size.height);
|
|
3571
3617
|
}
|
|
3572
|
-
if (super.intersects(shiftedRange))
|
|
3618
|
+
if (super.intersects(shiftedRange)) {
|
|
3573
3619
|
return true;
|
|
3620
|
+
}
|
|
3574
3621
|
}
|
|
3575
3622
|
return false;
|
|
3576
3623
|
}
|
|
@@ -3580,14 +3627,18 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
3580
3627
|
return grid.query(this);
|
|
3581
3628
|
}
|
|
3582
3629
|
const xShifts = [originPoint.x], yShifts = [originPoint.y];
|
|
3583
|
-
if (crossesLeft)
|
|
3630
|
+
if (crossesLeft) {
|
|
3584
3631
|
xShifts.push(width);
|
|
3585
|
-
|
|
3632
|
+
}
|
|
3633
|
+
if (crossesRight) {
|
|
3586
3634
|
xShifts.push(-width);
|
|
3587
|
-
|
|
3635
|
+
}
|
|
3636
|
+
if (crossesTop) {
|
|
3588
3637
|
yShifts.push(height);
|
|
3589
|
-
|
|
3638
|
+
}
|
|
3639
|
+
if (crossesBottom) {
|
|
3590
3640
|
yShifts.push(-height);
|
|
3641
|
+
}
|
|
3591
3642
|
const particles = new Set();
|
|
3592
3643
|
for (const dx of xShifts) {
|
|
3593
3644
|
for (const dy of yShifts) {
|
|
@@ -3797,7 +3848,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
3797
3848
|
}
|
|
3798
3849
|
|
|
3799
3850
|
async function loadParticlesLinksInteraction(engine) {
|
|
3800
|
-
engine.checkVersion("4.5.
|
|
3851
|
+
engine.checkVersion("4.5.2");
|
|
3801
3852
|
await engine.pluginManager.register((e) => {
|
|
3802
3853
|
const pluginManager = e.pluginManager;
|
|
3803
3854
|
ensureInteractivityPluginLoaded(e);
|
|
@@ -4019,7 +4070,8 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
4019
4070
|
});
|
|
4020
4071
|
}
|
|
4021
4072
|
drawParticles(delta) {
|
|
4022
|
-
const { particles, actualOptions } = this.#container
|
|
4073
|
+
const { particles, actualOptions } = this.#container;
|
|
4074
|
+
this.clear();
|
|
4023
4075
|
particles.update(delta);
|
|
4024
4076
|
this.draw(ctx => {
|
|
4025
4077
|
const width = this.#canvasManager.size.width, height = this.#canvasManager.size.height;
|
|
@@ -4041,9 +4093,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
4041
4093
|
}
|
|
4042
4094
|
}
|
|
4043
4095
|
for (const plugin of this.#getLayerPlugins(DrawLayer.BackgroundMask)) {
|
|
4044
|
-
|
|
4045
|
-
plugin.canvasPaint?.();
|
|
4046
|
-
}
|
|
4096
|
+
plugin.canvasPaint?.();
|
|
4047
4097
|
}
|
|
4048
4098
|
for (const plugin of this.#getLayerPlugins(DrawLayer.CanvasSetup)) {
|
|
4049
4099
|
plugin.drawSettingsSetup?.(ctx, delta);
|
|
@@ -4133,6 +4183,9 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
4133
4183
|
ctx.clearRect(originPoint.x, originPoint.y, this.#canvasManager.size.width, this.#canvasManager.size.height);
|
|
4134
4184
|
});
|
|
4135
4185
|
}
|
|
4186
|
+
updateBackgroundElement() {
|
|
4187
|
+
this.#resolveBackgroundElement();
|
|
4188
|
+
}
|
|
4136
4189
|
#applyPostDrawUpdaters(particle) {
|
|
4137
4190
|
for (const updater of this.#postDrawUpdaters) {
|
|
4138
4191
|
updater.afterDraw?.(particle);
|
|
@@ -4331,7 +4384,14 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
4331
4384
|
}
|
|
4332
4385
|
if (typeof background.element === "string") {
|
|
4333
4386
|
if (typeof document !== "undefined") {
|
|
4334
|
-
|
|
4387
|
+
let node;
|
|
4388
|
+
try {
|
|
4389
|
+
node = document.querySelector(background.element);
|
|
4390
|
+
}
|
|
4391
|
+
catch {
|
|
4392
|
+
this.#warnOnce("background-element-invalid-selector", `Background element selector "${background.element}" is invalid`);
|
|
4393
|
+
return;
|
|
4394
|
+
}
|
|
4335
4395
|
if (node && this.#isSupportedElement(node)) {
|
|
4336
4396
|
this.#backgroundElement = node;
|
|
4337
4397
|
}
|
|
@@ -5155,10 +5215,10 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
5155
5215
|
runParticleCreatedPlugins(container, this);
|
|
5156
5216
|
}
|
|
5157
5217
|
isInsideCanvas(direction) {
|
|
5158
|
-
return this.#getInsideCanvasResult(
|
|
5218
|
+
return this.#getInsideCanvasResult(direction).inside;
|
|
5159
5219
|
}
|
|
5160
5220
|
isInsideCanvasForOutMode(outMode, direction) {
|
|
5161
|
-
return this.#getInsideCanvasResult(
|
|
5221
|
+
return this.#getInsideCanvasResult(direction, outMode).inside;
|
|
5162
5222
|
}
|
|
5163
5223
|
isShowingBack() {
|
|
5164
5224
|
if (!this.roll) {
|
|
@@ -5275,7 +5335,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
5275
5335
|
});
|
|
5276
5336
|
}
|
|
5277
5337
|
#getDefaultInsideCanvasResult(direction, outMode) {
|
|
5278
|
-
const radius = this.getRadius(), canvasSize = this.#container.canvas.size, position = this.position, isBounce = outMode === OutMode.bounce;
|
|
5338
|
+
const radius = this.getRadius(), canvasSize = this.#container.canvas.size, position = this.position, isBounce = outMode === OutMode.bounce || outMode === OutMode.split;
|
|
5279
5339
|
if (direction === OutModeDirection.bottom) {
|
|
5280
5340
|
return {
|
|
5281
5341
|
inside: isBounce ? position.y + radius < canvasSize.height : position.y - radius < canvasSize.height,
|
|
@@ -5317,12 +5377,16 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
5317
5377
|
radius: this.getRadius(),
|
|
5318
5378
|
};
|
|
5319
5379
|
}
|
|
5320
|
-
#getInsideCanvasResult(
|
|
5321
|
-
const defaultResult = this.#getDefaultInsideCanvasResult(
|
|
5322
|
-
if (!
|
|
5380
|
+
#getInsideCanvasResult(direction, outMode) {
|
|
5381
|
+
const defaultResult = this.#getDefaultInsideCanvasResult(direction, outMode), container = this.#container, shapeDrawer = this.shape ? container.shapeDrawers.get(this.shape) : undefined, effectDrawer = this.effect ? container.effectDrawers.get(this.effect) : undefined;
|
|
5382
|
+
if (!shapeDrawer?.isInsideCanvas && !effectDrawer?.isInsideCanvas) {
|
|
5323
5383
|
return defaultResult;
|
|
5324
5384
|
}
|
|
5325
|
-
const callbackData = this.#getInsideCanvasCallbackData(
|
|
5385
|
+
const callbackData = this.#getInsideCanvasCallbackData(direction, outMode), shapeResult = shapeDrawer?.isInsideCanvas
|
|
5386
|
+
? this.#normalizeInsideCanvasResult(shapeDrawer.isInsideCanvas(callbackData), "shape")
|
|
5387
|
+
: undefined, effectResult = effectDrawer?.isInsideCanvas
|
|
5388
|
+
? this.#normalizeInsideCanvasResult(effectDrawer.isInsideCanvas(callbackData), "effect")
|
|
5389
|
+
: undefined;
|
|
5326
5390
|
if (shapeResult && effectResult) {
|
|
5327
5391
|
const margin = Math.max(shapeResult.margin ?? defaultAngle, effectResult.margin ?? defaultAngle);
|
|
5328
5392
|
return {
|
|
@@ -5388,8 +5452,8 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
5388
5452
|
}
|
|
5389
5453
|
|
|
5390
5454
|
class SpatialHashGrid {
|
|
5391
|
-
#cellSize;
|
|
5392
5455
|
#cells = new Map();
|
|
5456
|
+
#cellSize;
|
|
5393
5457
|
#circlePool = [];
|
|
5394
5458
|
#circlePoolIdx;
|
|
5395
5459
|
#pendingCellSize;
|
|
@@ -6047,8 +6111,8 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
6047
6111
|
particleCreatedPlugins;
|
|
6048
6112
|
particleDestroyedPlugins;
|
|
6049
6113
|
particlePositionPlugins;
|
|
6050
|
-
particleUpdaters;
|
|
6051
6114
|
particles;
|
|
6115
|
+
particleUpdaters;
|
|
6052
6116
|
peakNits;
|
|
6053
6117
|
plugins;
|
|
6054
6118
|
retina;
|
|
@@ -6342,6 +6406,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
6342
6406
|
refresh = plugin.updateActualOptions() || refresh;
|
|
6343
6407
|
}
|
|
6344
6408
|
}
|
|
6409
|
+
this.canvas.render.updateBackgroundElement();
|
|
6345
6410
|
return refresh;
|
|
6346
6411
|
}
|
|
6347
6412
|
#initPlugins(allContainerPlugins) {
|