@tsparticles/preset-big-circles 4.1.2 → 4.2.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.
|
@@ -1,5 +1,5 @@
|
|
|
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);g.tsparticlesInternalExports=g.tsparticlesInternalExports||{};})(typeof globalThis!=="undefined"?globalThis:typeof window!=="undefined"?window:this);
|
|
2
|
-
/* Preset v4.
|
|
2
|
+
/* Preset v4.2.0 */
|
|
3
3
|
(function (global, factory) {
|
|
4
4
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
5
5
|
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
b: 0,
|
|
16
16
|
c: 0,
|
|
17
17
|
d: 1,
|
|
18
|
-
}, randomColorValue = "random", double = 2, doublePI = Math.PI * double, defaultFps = 60, generatedTrue = "true", generatedFalse = "false", canvasTag = "canvas", defaultRetryCount = 0, squareExp = 2, spatialHashGridCellSize = 100, defaultRemoveQuantity = 1, defaultRatio = 1, defaultReduceFactor = 1, inverseFactorNumerator = 1, rgbMax = 255, hMax = 360, sMax = 100, lMax = 100, hMin = 0, sMin = 0, hPhase = 60, empty = 0, quarter = 0.25, threeQuarter = half + quarter, defaultTransformValue = 1, minimumSize = 0, zIndexFactorOffset = 1, defaultOpacity$1 = 1, removeDeleteCount = 1, removeMinIndex = 0, defaultFpsLimit = 120, minFpsLimit = 0, canvasFirstIndex = 0, loadRandomFactor = 10000, loadMinIndex = 0, one = 1, none = 0, decayOffset = 1, tryCountIncrement = 1, minZ = 0, minLimit = 0, countOffset = 1, minCount = 0, minIndex = 0, defaultDensityFactor = 1, deleteCount = 1, defaultAngle = 0, identity
|
|
18
|
+
}, randomColorValue = "random", double = 2, doublePI = Math.PI * double, defaultFps = 60, generatedTrue = "true", generatedFalse = "false", canvasTag = "canvas", defaultRetryCount = 0, squareExp = 2, spatialHashGridCellSize = 100, defaultRemoveQuantity = 1, defaultRatio = 1, defaultReduceFactor = 1, inverseFactorNumerator = 1, rgbMax = 255, hMax = 360, sMax = 100, lMax = 100, hMin = 0, sMin = 0, hPhase = 60, empty = 0, quarter = 0.25, threeQuarter = half + quarter, minVelocity = 0, minDistance = 0, defaultTransformValue = 1, minimumSize = 0, zIndexFactorOffset = 1, defaultOpacity$1 = 1, removeDeleteCount = 1, removeMinIndex = 0, defaultFpsLimit = 120, minFpsLimit = 0, canvasFirstIndex = 0, loadRandomFactor = 10000, loadMinIndex = 0, one = 1, none = 0, decayOffset = 1, tryCountIncrement = 1, minZ = 0, minLimit = 0, countOffset = 1, minCount = 0, minIndex = 0, defaultDensityFactor = 1, deleteCount = 1, defaultAngle = 0, identity = 1, minStrokeWidth = 0, lFactor = 1, lMin = 0, maxNits = 400, triple = 3, sextuple = 6, sNormalizedOffset = 1, phaseNumerator = 1, defaultRgbMin = 0, defaultVelocity = 0, defaultLoops = 0, defaultTime = 0, defaultZoom = 1;
|
|
19
19
|
|
|
20
20
|
var MoveDirection;
|
|
21
21
|
(function (MoveDirection) {
|
|
@@ -82,11 +82,6 @@
|
|
|
82
82
|
div(n) {
|
|
83
83
|
return Vector3d.create(this.x / n, this.y / n, this.z / n);
|
|
84
84
|
}
|
|
85
|
-
divTo(n) {
|
|
86
|
-
this.x /= n;
|
|
87
|
-
this.y /= n;
|
|
88
|
-
this.z /= n;
|
|
89
|
-
}
|
|
90
85
|
getLengthSq() {
|
|
91
86
|
return this.x ** squareExp + this.y ** squareExp;
|
|
92
87
|
}
|
|
@@ -282,27 +277,6 @@
|
|
|
282
277
|
return input.endsWith("%") ? parseFloat(input) / percentDenominator : parseFloat(input);
|
|
283
278
|
}
|
|
284
279
|
|
|
285
|
-
var AnimationMode;
|
|
286
|
-
(function (AnimationMode) {
|
|
287
|
-
AnimationMode["auto"] = "auto";
|
|
288
|
-
AnimationMode["increase"] = "increase";
|
|
289
|
-
AnimationMode["decrease"] = "decrease";
|
|
290
|
-
AnimationMode["random"] = "random";
|
|
291
|
-
})(AnimationMode || (AnimationMode = {}));
|
|
292
|
-
|
|
293
|
-
var AnimationStatus;
|
|
294
|
-
(function (AnimationStatus) {
|
|
295
|
-
AnimationStatus["increasing"] = "increasing";
|
|
296
|
-
AnimationStatus["decreasing"] = "decreasing";
|
|
297
|
-
})(AnimationStatus || (AnimationStatus = {}));
|
|
298
|
-
|
|
299
|
-
var DestroyType;
|
|
300
|
-
(function (DestroyType) {
|
|
301
|
-
DestroyType["none"] = "none";
|
|
302
|
-
DestroyType["max"] = "max";
|
|
303
|
-
DestroyType["min"] = "min";
|
|
304
|
-
})(DestroyType || (DestroyType = {}));
|
|
305
|
-
|
|
306
280
|
var OutModeDirection;
|
|
307
281
|
(function (OutModeDirection) {
|
|
308
282
|
OutModeDirection["bottom"] = "bottom";
|
|
@@ -317,67 +291,7 @@
|
|
|
317
291
|
PixelMode["percent"] = "percent";
|
|
318
292
|
})(PixelMode || (PixelMode = {}));
|
|
319
293
|
|
|
320
|
-
var StartValueType;
|
|
321
|
-
(function (StartValueType) {
|
|
322
|
-
StartValueType["max"] = "max";
|
|
323
|
-
StartValueType["min"] = "min";
|
|
324
|
-
StartValueType["random"] = "random";
|
|
325
|
-
})(StartValueType || (StartValueType = {}));
|
|
326
|
-
|
|
327
294
|
const minRadius = 0;
|
|
328
|
-
function memoize(fn, options) {
|
|
329
|
-
const cache = new Map(), stableStringify = (obj, seen = new WeakSet()) => {
|
|
330
|
-
if (obj === null) {
|
|
331
|
-
return "null";
|
|
332
|
-
}
|
|
333
|
-
const t = typeof obj;
|
|
334
|
-
if (t === "undefined") {
|
|
335
|
-
return "undefined";
|
|
336
|
-
}
|
|
337
|
-
if (t === "number" || t === "boolean" || t === "string") {
|
|
338
|
-
return JSON.stringify(obj);
|
|
339
|
-
}
|
|
340
|
-
if (t === "function") {
|
|
341
|
-
try {
|
|
342
|
-
const fn = obj;
|
|
343
|
-
return fn.toString();
|
|
344
|
-
}
|
|
345
|
-
catch {
|
|
346
|
-
return '"[Function]"';
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
if (t === "symbol") {
|
|
350
|
-
try {
|
|
351
|
-
return obj.toString();
|
|
352
|
-
}
|
|
353
|
-
catch {
|
|
354
|
-
return '"[Symbol]"';
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
if (Array.isArray(obj)) {
|
|
358
|
-
return `[${obj.map(i => stableStringify(i, seen)).join(",")}]`;
|
|
359
|
-
}
|
|
360
|
-
if (seen.has(obj)) {
|
|
361
|
-
return '"[Circular]"';
|
|
362
|
-
}
|
|
363
|
-
seen.add(obj);
|
|
364
|
-
const keys = Object.keys(obj).sort();
|
|
365
|
-
return `{${keys.map(k => `${JSON.stringify(k)}:${stableStringify(obj[k], seen)}`).join(",")}}`;
|
|
366
|
-
}, defaultKeyer = (args) => stableStringify(args), makeKey = (args) => (defaultKeyer(args));
|
|
367
|
-
return (...args) => {
|
|
368
|
-
const key = makeKey(args), now = Date.now(), entry = cache.get(key);
|
|
369
|
-
if (entry !== undefined) {
|
|
370
|
-
{
|
|
371
|
-
cache.delete(key);
|
|
372
|
-
cache.set(key, { value: entry.value, ts: entry.ts });
|
|
373
|
-
return entry.value;
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
const result = fn(...args);
|
|
377
|
-
cache.set(key, { value: result, ts: now });
|
|
378
|
-
return result;
|
|
379
|
-
};
|
|
380
|
-
}
|
|
381
295
|
function hasMatchMedia() {
|
|
382
296
|
return typeof matchMedia !== "undefined";
|
|
383
297
|
}
|
|
@@ -399,11 +313,8 @@
|
|
|
399
313
|
function isInArray(value, array) {
|
|
400
314
|
return value === array || (isArray(array) && array.includes(value));
|
|
401
315
|
}
|
|
402
|
-
function arrayRandomIndex(array) {
|
|
403
|
-
return Math.floor(getRandom() * array.length);
|
|
404
|
-
}
|
|
405
316
|
function itemFromArray(array, index, useIndex = true) {
|
|
406
|
-
return array[index !== undefined && useIndex ? index % array.length :
|
|
317
|
+
return array[index !== undefined && useIndex ? index % array.length : Math.floor(getRandom() * array.length)];
|
|
407
318
|
}
|
|
408
319
|
function isPointInside(point, size, offset, radius, direction) {
|
|
409
320
|
return areBoundsInside(calculateBounds(point, radius ?? minRadius), size, offset, direction);
|
|
@@ -487,56 +398,6 @@
|
|
|
487
398
|
function itemFromSingleOrMultiple(obj, index, useIndex) {
|
|
488
399
|
return isArray(obj) ? itemFromArray(obj, index, useIndex) : obj;
|
|
489
400
|
}
|
|
490
|
-
function initParticleNumericAnimationValue(options, pxRatio) {
|
|
491
|
-
const valueRange = options.value, animationOptions = options.animation, res = {
|
|
492
|
-
delayTime: getRangeValue(animationOptions.delay) * millisecondsToSeconds,
|
|
493
|
-
enable: animationOptions.enable,
|
|
494
|
-
value: getRangeValue(options.value) * pxRatio,
|
|
495
|
-
max: getRangeMax(valueRange) * pxRatio,
|
|
496
|
-
min: getRangeMin(valueRange) * pxRatio,
|
|
497
|
-
loops: 0,
|
|
498
|
-
maxLoops: getRangeValue(animationOptions.count),
|
|
499
|
-
time: 0,
|
|
500
|
-
}, decayOffset = 1;
|
|
501
|
-
if (animationOptions.enable) {
|
|
502
|
-
res.decay = decayOffset - getRangeValue(animationOptions.decay);
|
|
503
|
-
switch (animationOptions.mode) {
|
|
504
|
-
case AnimationMode.increase:
|
|
505
|
-
res.status = AnimationStatus.increasing;
|
|
506
|
-
break;
|
|
507
|
-
case AnimationMode.decrease:
|
|
508
|
-
res.status = AnimationStatus.decreasing;
|
|
509
|
-
break;
|
|
510
|
-
case AnimationMode.random:
|
|
511
|
-
res.status = getRandom() >= half ? AnimationStatus.increasing : AnimationStatus.decreasing;
|
|
512
|
-
break;
|
|
513
|
-
}
|
|
514
|
-
const autoStatus = animationOptions.mode === AnimationMode.auto;
|
|
515
|
-
switch (animationOptions.startValue) {
|
|
516
|
-
case StartValueType.min:
|
|
517
|
-
res.value = res.min;
|
|
518
|
-
if (autoStatus) {
|
|
519
|
-
res.status = AnimationStatus.increasing;
|
|
520
|
-
}
|
|
521
|
-
break;
|
|
522
|
-
case StartValueType.max:
|
|
523
|
-
res.value = res.max;
|
|
524
|
-
if (autoStatus) {
|
|
525
|
-
res.status = AnimationStatus.decreasing;
|
|
526
|
-
}
|
|
527
|
-
break;
|
|
528
|
-
case StartValueType.random:
|
|
529
|
-
default:
|
|
530
|
-
res.value = randomInRangeValue(res);
|
|
531
|
-
if (autoStatus) {
|
|
532
|
-
res.status = getRandom() >= half ? AnimationStatus.increasing : AnimationStatus.decreasing;
|
|
533
|
-
}
|
|
534
|
-
break;
|
|
535
|
-
}
|
|
536
|
-
}
|
|
537
|
-
res.initialValue = res.value;
|
|
538
|
-
return res;
|
|
539
|
-
}
|
|
540
401
|
function getPositionOrSize(positionOrSize, canvasSize) {
|
|
541
402
|
const isPercent = positionOrSize.mode === PixelMode.percent;
|
|
542
403
|
if (!isPercent) {
|
|
@@ -560,71 +421,6 @@
|
|
|
560
421
|
function getPosition(position, canvasSize) {
|
|
561
422
|
return getPositionOrSize(position, canvasSize);
|
|
562
423
|
}
|
|
563
|
-
function checkDestroy(particle, destroyType, value, minValue, maxValue) {
|
|
564
|
-
switch (destroyType) {
|
|
565
|
-
case DestroyType.max:
|
|
566
|
-
if (value >= maxValue) {
|
|
567
|
-
particle.destroy();
|
|
568
|
-
}
|
|
569
|
-
break;
|
|
570
|
-
case DestroyType.min:
|
|
571
|
-
if (value <= minValue) {
|
|
572
|
-
particle.destroy();
|
|
573
|
-
}
|
|
574
|
-
break;
|
|
575
|
-
}
|
|
576
|
-
}
|
|
577
|
-
function updateAnimation(particle, data, changeDirection, destroyType, delta) {
|
|
578
|
-
const minLoops = 0, minDelay = 0, identity = 1, minVelocity = 0, minDecay = 1;
|
|
579
|
-
if (particle.destroyed ||
|
|
580
|
-
!data.enable ||
|
|
581
|
-
((data.maxLoops ?? minLoops) > minLoops && (data.loops ?? minLoops) > (data.maxLoops ?? minLoops))) {
|
|
582
|
-
return;
|
|
583
|
-
}
|
|
584
|
-
const velocity = (data.velocity ?? minVelocity) * delta.factor, minValue = data.min, maxValue = data.max, decay = data.decay ?? minDecay;
|
|
585
|
-
data.time ??= 0;
|
|
586
|
-
if ((data.delayTime ?? minDelay) > minDelay && data.time < (data.delayTime ?? minDelay)) {
|
|
587
|
-
data.time += delta.value;
|
|
588
|
-
}
|
|
589
|
-
if ((data.delayTime ?? minDelay) > minDelay && data.time < (data.delayTime ?? minDelay)) {
|
|
590
|
-
return;
|
|
591
|
-
}
|
|
592
|
-
switch (data.status) {
|
|
593
|
-
case AnimationStatus.increasing:
|
|
594
|
-
data.value += velocity;
|
|
595
|
-
break;
|
|
596
|
-
case AnimationStatus.decreasing:
|
|
597
|
-
data.value -= velocity;
|
|
598
|
-
break;
|
|
599
|
-
}
|
|
600
|
-
if (data.velocity && decay !== identity) {
|
|
601
|
-
data.velocity *= decay;
|
|
602
|
-
}
|
|
603
|
-
switch (data.status) {
|
|
604
|
-
case AnimationStatus.increasing:
|
|
605
|
-
if (data.value >= maxValue) {
|
|
606
|
-
{
|
|
607
|
-
data.status = AnimationStatus.decreasing;
|
|
608
|
-
}
|
|
609
|
-
data.loops ??= minLoops;
|
|
610
|
-
data.loops++;
|
|
611
|
-
}
|
|
612
|
-
break;
|
|
613
|
-
case AnimationStatus.decreasing:
|
|
614
|
-
if (data.value <= minValue) {
|
|
615
|
-
{
|
|
616
|
-
data.status = AnimationStatus.increasing;
|
|
617
|
-
}
|
|
618
|
-
data.loops ??= minLoops;
|
|
619
|
-
data.loops++;
|
|
620
|
-
}
|
|
621
|
-
break;
|
|
622
|
-
}
|
|
623
|
-
checkDestroy(particle, destroyType, data.value, minValue, maxValue);
|
|
624
|
-
if (!particle.destroyed) {
|
|
625
|
-
data.value = clamp(data.value, minValue, maxValue);
|
|
626
|
-
}
|
|
627
|
-
}
|
|
628
424
|
function cloneStyle(style) {
|
|
629
425
|
const clonedStyle = safeDocument().createElement("div").style;
|
|
630
426
|
for (const key in style) {
|
|
@@ -646,30 +442,34 @@
|
|
|
646
442
|
}
|
|
647
443
|
return clonedStyle;
|
|
648
444
|
}
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
445
|
+
let _cachedZIndex, _cachedStyle;
|
|
446
|
+
function getFullScreenStyle(zIndex) {
|
|
447
|
+
if (_cachedZIndex !== zIndex || !_cachedStyle) {
|
|
448
|
+
_cachedZIndex = zIndex;
|
|
449
|
+
const fullScreenStyle = safeDocument().createElement("div").style, radix = 10, style = {
|
|
450
|
+
width: "100%",
|
|
451
|
+
height: "100%",
|
|
452
|
+
margin: "0",
|
|
453
|
+
padding: "0",
|
|
454
|
+
borderWidth: "0",
|
|
455
|
+
position: "fixed",
|
|
456
|
+
zIndex: zIndex.toString(radix),
|
|
457
|
+
"z-index": zIndex.toString(radix),
|
|
458
|
+
top: "0",
|
|
459
|
+
left: "0",
|
|
460
|
+
"pointer-events": "none",
|
|
461
|
+
};
|
|
462
|
+
for (const key in style) {
|
|
463
|
+
const value = style[key];
|
|
464
|
+
if (value === undefined) {
|
|
465
|
+
continue;
|
|
466
|
+
}
|
|
467
|
+
fullScreenStyle.setProperty(key, value);
|
|
667
468
|
}
|
|
668
|
-
fullScreenStyle
|
|
469
|
+
_cachedStyle = fullScreenStyle;
|
|
669
470
|
}
|
|
670
|
-
return
|
|
471
|
+
return _cachedStyle;
|
|
671
472
|
}
|
|
672
|
-
const getFullScreenStyle = memoize(computeFullScreenStyle);
|
|
673
473
|
function manageListener(element, event, handler, add, options) {
|
|
674
474
|
if (add) {
|
|
675
475
|
let addOptions = { passive: true };
|
|
@@ -996,7 +796,7 @@
|
|
|
996
796
|
return this.#domArray;
|
|
997
797
|
}
|
|
998
798
|
get version() {
|
|
999
|
-
return "4.
|
|
799
|
+
return "4.2.0";
|
|
1000
800
|
}
|
|
1001
801
|
addEventListener(type, listener) {
|
|
1002
802
|
this.#eventDispatcher.addEventListener(type, listener);
|
|
@@ -1166,6 +966,14 @@
|
|
|
1166
966
|
RotateDirection["random"] = "random";
|
|
1167
967
|
})(RotateDirection || (RotateDirection = {}));
|
|
1168
968
|
|
|
969
|
+
var AnimationMode;
|
|
970
|
+
(function (AnimationMode) {
|
|
971
|
+
AnimationMode["auto"] = "auto";
|
|
972
|
+
AnimationMode["increase"] = "increase";
|
|
973
|
+
AnimationMode["decrease"] = "decrease";
|
|
974
|
+
AnimationMode["random"] = "random";
|
|
975
|
+
})(AnimationMode || (AnimationMode = {}));
|
|
976
|
+
|
|
1169
977
|
var LimitMode;
|
|
1170
978
|
(function (LimitMode) {
|
|
1171
979
|
LimitMode["delete"] = "delete";
|
|
@@ -1187,6 +995,13 @@
|
|
|
1187
995
|
AlterType["enlighten"] = "enlighten";
|
|
1188
996
|
})(AlterType || (AlterType = {}));
|
|
1189
997
|
|
|
998
|
+
var DestroyType;
|
|
999
|
+
(function (DestroyType) {
|
|
1000
|
+
DestroyType["none"] = "none";
|
|
1001
|
+
DestroyType["max"] = "max";
|
|
1002
|
+
DestroyType["min"] = "min";
|
|
1003
|
+
})(DestroyType || (DestroyType = {}));
|
|
1004
|
+
|
|
1190
1005
|
var GradientType;
|
|
1191
1006
|
(function (GradientType) {
|
|
1192
1007
|
GradientType["linear"] = "linear";
|
|
@@ -1201,160 +1016,121 @@
|
|
|
1201
1016
|
ParticleOutType["outside"] = "outside";
|
|
1202
1017
|
})(ParticleOutType || (ParticleOutType = {}));
|
|
1203
1018
|
|
|
1204
|
-
var
|
|
1205
|
-
(function (
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
EasingType["easeInElastic"] = "ease-in-elastic";
|
|
1211
|
-
EasingType["easeInExpo"] = "ease-in-expo";
|
|
1212
|
-
EasingType["easeInGaussian"] = "ease-in-gaussian";
|
|
1213
|
-
EasingType["easeInLinear"] = "ease-in-linear";
|
|
1214
|
-
EasingType["easeInQuad"] = "ease-in-quad";
|
|
1215
|
-
EasingType["easeInQuart"] = "ease-in-quart";
|
|
1216
|
-
EasingType["easeInQuint"] = "ease-in-quint";
|
|
1217
|
-
EasingType["easeInSigmoid"] = "ease-in-sigmoid";
|
|
1218
|
-
EasingType["easeInSine"] = "ease-in-sine";
|
|
1219
|
-
EasingType["easeInSmoothstep"] = "ease-in-smoothstep";
|
|
1220
|
-
EasingType["easeOutBack"] = "ease-out-back";
|
|
1221
|
-
EasingType["easeOutBounce"] = "ease-out-bounce";
|
|
1222
|
-
EasingType["easeOutCirc"] = "ease-out-circ";
|
|
1223
|
-
EasingType["easeOutCubic"] = "ease-out-cubic";
|
|
1224
|
-
EasingType["easeOutElastic"] = "ease-out-elastic";
|
|
1225
|
-
EasingType["easeOutExpo"] = "ease-out-expo";
|
|
1226
|
-
EasingType["easeOutGaussian"] = "ease-out-gaussian";
|
|
1227
|
-
EasingType["easeOutLinear"] = "ease-out-linear";
|
|
1228
|
-
EasingType["easeOutQuad"] = "ease-out-quad";
|
|
1229
|
-
EasingType["easeOutQuart"] = "ease-out-quart";
|
|
1230
|
-
EasingType["easeOutQuint"] = "ease-out-quint";
|
|
1231
|
-
EasingType["easeOutSigmoid"] = "ease-out-sigmoid";
|
|
1232
|
-
EasingType["easeOutSine"] = "ease-out-sine";
|
|
1233
|
-
EasingType["easeOutSmoothstep"] = "ease-out-smoothstep";
|
|
1234
|
-
EasingType["easeInOutBack"] = "ease-in-out-back";
|
|
1235
|
-
EasingType["easeInOutBounce"] = "ease-in-out-bounce";
|
|
1236
|
-
EasingType["easeInOutCirc"] = "ease-in-out-circ";
|
|
1237
|
-
EasingType["easeInOutCubic"] = "ease-in-out-cubic";
|
|
1238
|
-
EasingType["easeInOutElastic"] = "ease-in-out-elastic";
|
|
1239
|
-
EasingType["easeInOutExpo"] = "ease-in-out-expo";
|
|
1240
|
-
EasingType["easeInOutGaussian"] = "ease-in-out-gaussian";
|
|
1241
|
-
EasingType["easeInOutLinear"] = "ease-in-out-linear";
|
|
1242
|
-
EasingType["easeInOutQuad"] = "ease-in-out-quad";
|
|
1243
|
-
EasingType["easeInOutQuart"] = "ease-in-out-quart";
|
|
1244
|
-
EasingType["easeInOutQuint"] = "ease-in-out-quint";
|
|
1245
|
-
EasingType["easeInOutSigmoid"] = "ease-in-out-sigmoid";
|
|
1246
|
-
EasingType["easeInOutSine"] = "ease-in-out-sine";
|
|
1247
|
-
EasingType["easeInOutSmoothstep"] = "ease-in-out-smoothstep";
|
|
1248
|
-
})(EasingType || (EasingType = {}));
|
|
1019
|
+
var StartValueType;
|
|
1020
|
+
(function (StartValueType) {
|
|
1021
|
+
StartValueType["max"] = "max";
|
|
1022
|
+
StartValueType["min"] = "min";
|
|
1023
|
+
StartValueType["random"] = "random";
|
|
1024
|
+
})(StartValueType || (StartValueType = {}));
|
|
1249
1025
|
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
constructor() {
|
|
1258
|
-
this.count = 0;
|
|
1259
|
-
this.enable = false;
|
|
1260
|
-
this.speed = 1;
|
|
1261
|
-
this.decay = 0;
|
|
1262
|
-
this.delay = 0;
|
|
1263
|
-
this.sync = false;
|
|
1264
|
-
}
|
|
1026
|
+
var AnimationStatus;
|
|
1027
|
+
(function (AnimationStatus) {
|
|
1028
|
+
AnimationStatus["increasing"] = "increasing";
|
|
1029
|
+
AnimationStatus["decreasing"] = "decreasing";
|
|
1030
|
+
})(AnimationStatus || (AnimationStatus = {}));
|
|
1031
|
+
|
|
1032
|
+
class OptionLoader {
|
|
1265
1033
|
load(data) {
|
|
1266
1034
|
if (isNull(data)) {
|
|
1267
1035
|
return;
|
|
1268
1036
|
}
|
|
1269
|
-
|
|
1270
|
-
this.count = setRangeValue(data.count);
|
|
1271
|
-
}
|
|
1272
|
-
if (data.enable !== undefined) {
|
|
1273
|
-
this.enable = data.enable;
|
|
1274
|
-
}
|
|
1275
|
-
if (data.speed !== undefined) {
|
|
1276
|
-
this.speed = setRangeValue(data.speed);
|
|
1277
|
-
}
|
|
1278
|
-
if (data.decay !== undefined) {
|
|
1279
|
-
this.decay = setRangeValue(data.decay);
|
|
1280
|
-
}
|
|
1281
|
-
if (data.delay !== undefined) {
|
|
1282
|
-
this.delay = setRangeValue(data.delay);
|
|
1283
|
-
}
|
|
1284
|
-
if (data.sync !== undefined) {
|
|
1285
|
-
this.sync = data.sync;
|
|
1286
|
-
}
|
|
1037
|
+
this.doLoad(data);
|
|
1287
1038
|
}
|
|
1288
1039
|
}
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
constructor() {
|
|
1293
|
-
super();
|
|
1294
|
-
this.mode = AnimationMode.auto;
|
|
1295
|
-
this.startValue = StartValueType.random;
|
|
1040
|
+
function loadOptions(options, ...sourceOptionsArr) {
|
|
1041
|
+
for (const sourceOptions of sourceOptionsArr) {
|
|
1042
|
+
options.load(sourceOptions);
|
|
1296
1043
|
}
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1046
|
+
function loadProperty(obj, key, value) {
|
|
1047
|
+
if (value !== undefined) {
|
|
1048
|
+
obj[key] = value;
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
function loadRangeProperty(obj, key, value) {
|
|
1052
|
+
if (value !== undefined) {
|
|
1053
|
+
obj[key] = setRangeValue(value);
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
function loadNestedProperty(obj, key, value) {
|
|
1057
|
+
if (value !== undefined) {
|
|
1058
|
+
obj[key].load(value);
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1061
|
+
function loadLazyProperty(obj, key, value, factory) {
|
|
1062
|
+
if (value !== undefined) {
|
|
1063
|
+
const objRecord = obj;
|
|
1064
|
+
objRecord[key] ??= factory();
|
|
1065
|
+
objRecord[key].load(value);
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1068
|
+
function loadOptionProperty(obj, key, optionClass, ...sources) {
|
|
1069
|
+
const objRecord = obj;
|
|
1070
|
+
objRecord[key] ??= new optionClass();
|
|
1071
|
+
const target = objRecord[key];
|
|
1072
|
+
for (const source of sources) {
|
|
1073
|
+
target.load(source?.[key]);
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1077
|
+
class AnimationOptions extends OptionLoader {
|
|
1078
|
+
count = 0;
|
|
1079
|
+
decay = 0;
|
|
1080
|
+
delay = 0;
|
|
1081
|
+
enable = false;
|
|
1082
|
+
speed = 1;
|
|
1083
|
+
sync = false;
|
|
1084
|
+
doLoad(data) {
|
|
1085
|
+
loadRangeProperty(this, "count", data.count);
|
|
1086
|
+
loadProperty(this, "enable", data.enable);
|
|
1087
|
+
loadRangeProperty(this, "speed", data.speed);
|
|
1088
|
+
loadRangeProperty(this, "decay", data.decay);
|
|
1089
|
+
loadRangeProperty(this, "delay", data.delay);
|
|
1090
|
+
loadProperty(this, "sync", data.sync);
|
|
1091
|
+
}
|
|
1092
|
+
}
|
|
1093
|
+
class RangedAnimationOptions extends AnimationOptions {
|
|
1094
|
+
mode = AnimationMode.auto;
|
|
1095
|
+
startValue = StartValueType.random;
|
|
1096
|
+
doLoad(data) {
|
|
1097
|
+
super.doLoad(data);
|
|
1098
|
+
loadProperty(this, "mode", data.mode);
|
|
1099
|
+
loadProperty(this, "startValue", data.startValue);
|
|
1308
1100
|
}
|
|
1309
1101
|
}
|
|
1310
1102
|
|
|
1311
1103
|
class ColorAnimation extends AnimationOptions {
|
|
1312
1104
|
max;
|
|
1313
1105
|
min;
|
|
1314
|
-
offset;
|
|
1106
|
+
offset = 0;
|
|
1107
|
+
sync = true;
|
|
1315
1108
|
constructor(min, max) {
|
|
1316
1109
|
super();
|
|
1317
1110
|
this.min = min;
|
|
1318
1111
|
this.max = max;
|
|
1319
|
-
this.offset = 0;
|
|
1320
|
-
this.sync = true;
|
|
1321
1112
|
}
|
|
1322
|
-
|
|
1323
|
-
super.
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
if (data.max !== undefined) {
|
|
1328
|
-
this.max = data.max;
|
|
1329
|
-
}
|
|
1330
|
-
if (data.min !== undefined) {
|
|
1331
|
-
this.min = data.min;
|
|
1332
|
-
}
|
|
1333
|
-
if (data.offset !== undefined) {
|
|
1334
|
-
this.offset = setRangeValue(data.offset);
|
|
1335
|
-
}
|
|
1113
|
+
doLoad(data) {
|
|
1114
|
+
super.doLoad(data);
|
|
1115
|
+
loadProperty(this, "max", data.max);
|
|
1116
|
+
loadProperty(this, "min", data.min);
|
|
1117
|
+
loadRangeProperty(this, "offset", data.offset);
|
|
1336
1118
|
}
|
|
1337
1119
|
}
|
|
1338
1120
|
|
|
1339
|
-
class HslAnimation {
|
|
1121
|
+
class HslAnimation extends OptionLoader {
|
|
1340
1122
|
h = new ColorAnimation(hMin, hMax);
|
|
1341
1123
|
l = new ColorAnimation(lMin, lMax);
|
|
1342
1124
|
s = new ColorAnimation(sMin, sMax);
|
|
1343
|
-
|
|
1344
|
-
if (isNull(data)) {
|
|
1345
|
-
return;
|
|
1346
|
-
}
|
|
1125
|
+
doLoad(data) {
|
|
1347
1126
|
this.h.load(data.h);
|
|
1348
1127
|
this.s.load(data.s);
|
|
1349
1128
|
this.l.load(data.l);
|
|
1350
1129
|
}
|
|
1351
1130
|
}
|
|
1352
1131
|
|
|
1353
|
-
class OptionsColor {
|
|
1354
|
-
value;
|
|
1355
|
-
constructor() {
|
|
1356
|
-
this.value = "";
|
|
1357
|
-
}
|
|
1132
|
+
class OptionsColor extends OptionLoader {
|
|
1133
|
+
value = "";
|
|
1358
1134
|
static create(source, data) {
|
|
1359
1135
|
const color = new OptionsColor();
|
|
1360
1136
|
color.load(source);
|
|
@@ -1368,10 +1144,7 @@
|
|
|
1368
1144
|
}
|
|
1369
1145
|
return color;
|
|
1370
1146
|
}
|
|
1371
|
-
|
|
1372
|
-
if (isNull(data)) {
|
|
1373
|
-
return;
|
|
1374
|
-
}
|
|
1147
|
+
doLoad(data) {
|
|
1375
1148
|
if (!isNull(data.value)) {
|
|
1376
1149
|
this.value = data.value;
|
|
1377
1150
|
}
|
|
@@ -1379,11 +1152,7 @@
|
|
|
1379
1152
|
}
|
|
1380
1153
|
|
|
1381
1154
|
class AnimatableColor extends OptionsColor {
|
|
1382
|
-
animation;
|
|
1383
|
-
constructor() {
|
|
1384
|
-
super();
|
|
1385
|
-
this.animation = new HslAnimation();
|
|
1386
|
-
}
|
|
1155
|
+
animation = new HslAnimation();
|
|
1387
1156
|
static create(source, data) {
|
|
1388
1157
|
const color = new AnimatableColor();
|
|
1389
1158
|
color.load(source);
|
|
@@ -1397,11 +1166,8 @@
|
|
|
1397
1166
|
}
|
|
1398
1167
|
return color;
|
|
1399
1168
|
}
|
|
1400
|
-
|
|
1401
|
-
super.
|
|
1402
|
-
if (isNull(data)) {
|
|
1403
|
-
return;
|
|
1404
|
-
}
|
|
1169
|
+
doLoad(data) {
|
|
1170
|
+
super.doLoad(data);
|
|
1405
1171
|
const colorAnimation = data.animation;
|
|
1406
1172
|
if (colorAnimation !== undefined) {
|
|
1407
1173
|
if (colorAnimation.enable === undefined) {
|
|
@@ -1414,100 +1180,53 @@
|
|
|
1414
1180
|
}
|
|
1415
1181
|
}
|
|
1416
1182
|
|
|
1417
|
-
class Background {
|
|
1183
|
+
class Background extends OptionLoader {
|
|
1418
1184
|
color;
|
|
1419
|
-
image;
|
|
1420
|
-
opacity;
|
|
1421
|
-
position;
|
|
1422
|
-
repeat;
|
|
1423
|
-
size;
|
|
1185
|
+
image = "";
|
|
1186
|
+
opacity = 1;
|
|
1187
|
+
position = "";
|
|
1188
|
+
repeat = "";
|
|
1189
|
+
size = "";
|
|
1424
1190
|
constructor() {
|
|
1191
|
+
super();
|
|
1425
1192
|
this.color = new OptionsColor();
|
|
1426
1193
|
this.color.value = "";
|
|
1427
|
-
this.image = "";
|
|
1428
|
-
this.position = "";
|
|
1429
|
-
this.repeat = "";
|
|
1430
|
-
this.size = "";
|
|
1431
|
-
this.opacity = 1;
|
|
1432
1194
|
}
|
|
1433
|
-
|
|
1434
|
-
if (isNull(data)) {
|
|
1435
|
-
return;
|
|
1436
|
-
}
|
|
1195
|
+
doLoad(data) {
|
|
1437
1196
|
if (data.color !== undefined) {
|
|
1438
1197
|
this.color = OptionsColor.create(this.color, data.color);
|
|
1439
1198
|
}
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
}
|
|
1446
|
-
if (data.repeat !== undefined) {
|
|
1447
|
-
this.repeat = data.repeat;
|
|
1448
|
-
}
|
|
1449
|
-
if (data.size !== undefined) {
|
|
1450
|
-
this.size = data.size;
|
|
1451
|
-
}
|
|
1452
|
-
if (data.opacity !== undefined) {
|
|
1453
|
-
this.opacity = data.opacity;
|
|
1454
|
-
}
|
|
1199
|
+
loadProperty(this, "image", data.image);
|
|
1200
|
+
loadProperty(this, "position", data.position);
|
|
1201
|
+
loadProperty(this, "repeat", data.repeat);
|
|
1202
|
+
loadProperty(this, "size", data.size);
|
|
1203
|
+
loadProperty(this, "opacity", data.opacity);
|
|
1455
1204
|
}
|
|
1456
1205
|
}
|
|
1457
1206
|
|
|
1458
|
-
class FullScreen {
|
|
1459
|
-
enable;
|
|
1460
|
-
zIndex;
|
|
1461
|
-
|
|
1462
|
-
this.enable
|
|
1463
|
-
this.zIndex
|
|
1464
|
-
}
|
|
1465
|
-
load(data) {
|
|
1466
|
-
if (isNull(data)) {
|
|
1467
|
-
return;
|
|
1468
|
-
}
|
|
1469
|
-
if (data.enable !== undefined) {
|
|
1470
|
-
this.enable = data.enable;
|
|
1471
|
-
}
|
|
1472
|
-
if (data.zIndex !== undefined) {
|
|
1473
|
-
this.zIndex = data.zIndex;
|
|
1474
|
-
}
|
|
1207
|
+
class FullScreen extends OptionLoader {
|
|
1208
|
+
enable = true;
|
|
1209
|
+
zIndex = 0;
|
|
1210
|
+
doLoad(data) {
|
|
1211
|
+
loadProperty(this, "enable", data.enable);
|
|
1212
|
+
loadProperty(this, "zIndex", data.zIndex);
|
|
1475
1213
|
}
|
|
1476
1214
|
}
|
|
1477
1215
|
|
|
1478
|
-
class ResizeEvent {
|
|
1479
|
-
delay;
|
|
1480
|
-
enable;
|
|
1481
|
-
|
|
1482
|
-
this
|
|
1483
|
-
this.enable
|
|
1484
|
-
}
|
|
1485
|
-
load(data) {
|
|
1486
|
-
if (isNull(data)) {
|
|
1487
|
-
return;
|
|
1488
|
-
}
|
|
1489
|
-
if (data.delay !== undefined) {
|
|
1490
|
-
this.delay = data.delay;
|
|
1491
|
-
}
|
|
1492
|
-
if (data.enable !== undefined) {
|
|
1493
|
-
this.enable = data.enable;
|
|
1494
|
-
}
|
|
1216
|
+
class ResizeEvent extends OptionLoader {
|
|
1217
|
+
delay = 0.5;
|
|
1218
|
+
enable = true;
|
|
1219
|
+
doLoad(data) {
|
|
1220
|
+
loadProperty(this, "delay", data.delay);
|
|
1221
|
+
loadProperty(this, "enable", data.enable);
|
|
1495
1222
|
}
|
|
1496
1223
|
}
|
|
1497
1224
|
|
|
1498
|
-
class Effect {
|
|
1499
|
-
close;
|
|
1500
|
-
options;
|
|
1501
|
-
type;
|
|
1502
|
-
|
|
1503
|
-
this.close = true;
|
|
1504
|
-
this.options = {};
|
|
1505
|
-
this.type = [];
|
|
1506
|
-
}
|
|
1507
|
-
load(data) {
|
|
1508
|
-
if (isNull(data)) {
|
|
1509
|
-
return;
|
|
1510
|
-
}
|
|
1225
|
+
class Effect extends OptionLoader {
|
|
1226
|
+
close = true;
|
|
1227
|
+
options = {};
|
|
1228
|
+
type = [];
|
|
1229
|
+
doLoad(data) {
|
|
1511
1230
|
const options = data.options;
|
|
1512
1231
|
if (options !== undefined) {
|
|
1513
1232
|
for (const effect in options) {
|
|
@@ -1517,128 +1236,62 @@
|
|
|
1517
1236
|
}
|
|
1518
1237
|
}
|
|
1519
1238
|
}
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
}
|
|
1523
|
-
if (data.type !== undefined) {
|
|
1524
|
-
this.type = data.type;
|
|
1525
|
-
}
|
|
1239
|
+
loadProperty(this, "close", data.close);
|
|
1240
|
+
loadProperty(this, "type", data.type);
|
|
1526
1241
|
}
|
|
1527
1242
|
}
|
|
1528
1243
|
|
|
1529
|
-
class Fill {
|
|
1244
|
+
class Fill extends OptionLoader {
|
|
1530
1245
|
color;
|
|
1531
|
-
enable;
|
|
1532
|
-
opacity;
|
|
1533
|
-
|
|
1534
|
-
this.enable = true;
|
|
1535
|
-
this.opacity = 1;
|
|
1536
|
-
}
|
|
1537
|
-
load(data) {
|
|
1538
|
-
if (isNull(data)) {
|
|
1539
|
-
return;
|
|
1540
|
-
}
|
|
1246
|
+
enable = true;
|
|
1247
|
+
opacity = 1;
|
|
1248
|
+
doLoad(data) {
|
|
1541
1249
|
if (data.color !== undefined) {
|
|
1542
1250
|
this.color = AnimatableColor.create(this.color, data.color);
|
|
1543
1251
|
}
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
}
|
|
1547
|
-
if (data.opacity !== undefined) {
|
|
1548
|
-
this.opacity = setRangeValue(data.opacity);
|
|
1549
|
-
}
|
|
1252
|
+
loadProperty(this, "enable", data.enable);
|
|
1253
|
+
loadRangeProperty(this, "opacity", data.opacity);
|
|
1550
1254
|
}
|
|
1551
1255
|
}
|
|
1552
1256
|
|
|
1553
|
-
class MoveAngle {
|
|
1554
|
-
offset;
|
|
1555
|
-
value;
|
|
1556
|
-
|
|
1557
|
-
this.offset
|
|
1558
|
-
this.value
|
|
1559
|
-
}
|
|
1560
|
-
load(data) {
|
|
1561
|
-
if (isNull(data)) {
|
|
1562
|
-
return;
|
|
1563
|
-
}
|
|
1564
|
-
if (data.offset !== undefined) {
|
|
1565
|
-
this.offset = setRangeValue(data.offset);
|
|
1566
|
-
}
|
|
1567
|
-
if (data.value !== undefined) {
|
|
1568
|
-
this.value = setRangeValue(data.value);
|
|
1569
|
-
}
|
|
1257
|
+
class MoveAngle extends OptionLoader {
|
|
1258
|
+
offset = 0;
|
|
1259
|
+
value = 90;
|
|
1260
|
+
doLoad(data) {
|
|
1261
|
+
loadRangeProperty(this, "offset", data.offset);
|
|
1262
|
+
loadRangeProperty(this, "value", data.value);
|
|
1570
1263
|
}
|
|
1571
1264
|
}
|
|
1572
1265
|
|
|
1573
|
-
class MoveCenter {
|
|
1574
|
-
mode;
|
|
1575
|
-
radius;
|
|
1576
|
-
x;
|
|
1577
|
-
y;
|
|
1578
|
-
|
|
1579
|
-
this.x
|
|
1580
|
-
this.y
|
|
1581
|
-
this
|
|
1582
|
-
this.radius
|
|
1583
|
-
}
|
|
1584
|
-
load(data) {
|
|
1585
|
-
if (isNull(data)) {
|
|
1586
|
-
return;
|
|
1587
|
-
}
|
|
1588
|
-
if (data.x !== undefined) {
|
|
1589
|
-
this.x = data.x;
|
|
1590
|
-
}
|
|
1591
|
-
if (data.y !== undefined) {
|
|
1592
|
-
this.y = data.y;
|
|
1593
|
-
}
|
|
1594
|
-
if (data.mode !== undefined) {
|
|
1595
|
-
this.mode = data.mode;
|
|
1596
|
-
}
|
|
1597
|
-
if (data.radius !== undefined) {
|
|
1598
|
-
this.radius = data.radius;
|
|
1599
|
-
}
|
|
1266
|
+
class MoveCenter extends OptionLoader {
|
|
1267
|
+
mode = PixelMode.percent;
|
|
1268
|
+
radius = 0;
|
|
1269
|
+
x = 50;
|
|
1270
|
+
y = 50;
|
|
1271
|
+
doLoad(data) {
|
|
1272
|
+
loadProperty(this, "x", data.x);
|
|
1273
|
+
loadProperty(this, "y", data.y);
|
|
1274
|
+
loadProperty(this, "mode", data.mode);
|
|
1275
|
+
loadProperty(this, "radius", data.radius);
|
|
1600
1276
|
}
|
|
1601
1277
|
}
|
|
1602
1278
|
|
|
1603
|
-
class MoveGravity {
|
|
1604
|
-
acceleration;
|
|
1605
|
-
enable;
|
|
1606
|
-
inverse;
|
|
1607
|
-
maxSpeed;
|
|
1608
|
-
|
|
1609
|
-
this
|
|
1610
|
-
this.enable
|
|
1611
|
-
this.inverse
|
|
1612
|
-
this.maxSpeed
|
|
1613
|
-
}
|
|
1614
|
-
load(data) {
|
|
1615
|
-
if (isNull(data)) {
|
|
1616
|
-
return;
|
|
1617
|
-
}
|
|
1618
|
-
if (data.acceleration !== undefined) {
|
|
1619
|
-
this.acceleration = setRangeValue(data.acceleration);
|
|
1620
|
-
}
|
|
1621
|
-
if (data.enable !== undefined) {
|
|
1622
|
-
this.enable = data.enable;
|
|
1623
|
-
}
|
|
1624
|
-
if (data.inverse !== undefined) {
|
|
1625
|
-
this.inverse = data.inverse;
|
|
1626
|
-
}
|
|
1627
|
-
if (data.maxSpeed !== undefined) {
|
|
1628
|
-
this.maxSpeed = setRangeValue(data.maxSpeed);
|
|
1629
|
-
}
|
|
1279
|
+
class MoveGravity extends OptionLoader {
|
|
1280
|
+
acceleration = 9.81;
|
|
1281
|
+
enable = false;
|
|
1282
|
+
inverse = false;
|
|
1283
|
+
maxSpeed = 50;
|
|
1284
|
+
doLoad(data) {
|
|
1285
|
+
loadRangeProperty(this, "acceleration", data.acceleration);
|
|
1286
|
+
loadProperty(this, "enable", data.enable);
|
|
1287
|
+
loadProperty(this, "inverse", data.inverse);
|
|
1288
|
+
loadRangeProperty(this, "maxSpeed", data.maxSpeed);
|
|
1630
1289
|
}
|
|
1631
1290
|
}
|
|
1632
1291
|
|
|
1633
|
-
class ValueWithRandom {
|
|
1634
|
-
value;
|
|
1635
|
-
|
|
1636
|
-
this.value = 0;
|
|
1637
|
-
}
|
|
1638
|
-
load(data) {
|
|
1639
|
-
if (isNull(data)) {
|
|
1640
|
-
return;
|
|
1641
|
-
}
|
|
1292
|
+
class ValueWithRandom extends OptionLoader {
|
|
1293
|
+
value = 0;
|
|
1294
|
+
doLoad(data) {
|
|
1642
1295
|
if (!isNull(data.value)) {
|
|
1643
1296
|
this.value = setRangeValue(data.value);
|
|
1644
1297
|
}
|
|
@@ -1646,51 +1299,25 @@
|
|
|
1646
1299
|
}
|
|
1647
1300
|
class AnimationValueWithRandom extends ValueWithRandom {
|
|
1648
1301
|
animation = new AnimationOptions();
|
|
1649
|
-
|
|
1650
|
-
super.
|
|
1651
|
-
|
|
1652
|
-
return;
|
|
1653
|
-
}
|
|
1654
|
-
const animation = data.animation;
|
|
1655
|
-
if (animation !== undefined) {
|
|
1656
|
-
this.animation.load(animation);
|
|
1657
|
-
}
|
|
1302
|
+
doLoad(data) {
|
|
1303
|
+
super.doLoad(data);
|
|
1304
|
+
loadNestedProperty(this, "animation", data.animation);
|
|
1658
1305
|
}
|
|
1659
1306
|
}
|
|
1660
1307
|
class RangedAnimationValueWithRandom extends AnimationValueWithRandom {
|
|
1661
|
-
animation;
|
|
1662
|
-
constructor() {
|
|
1663
|
-
super();
|
|
1664
|
-
this.animation = new RangedAnimationOptions();
|
|
1665
|
-
}
|
|
1666
|
-
load(data) {
|
|
1667
|
-
super.load(data);
|
|
1668
|
-
}
|
|
1308
|
+
animation = new RangedAnimationOptions();
|
|
1669
1309
|
}
|
|
1670
1310
|
|
|
1671
|
-
class MovePath {
|
|
1672
|
-
clamp;
|
|
1673
|
-
delay;
|
|
1674
|
-
enable;
|
|
1311
|
+
class MovePath extends OptionLoader {
|
|
1312
|
+
clamp = true;
|
|
1313
|
+
delay = new ValueWithRandom();
|
|
1314
|
+
enable = false;
|
|
1675
1315
|
generator;
|
|
1676
|
-
options;
|
|
1677
|
-
|
|
1678
|
-
this.clamp
|
|
1679
|
-
this.delay = new ValueWithRandom();
|
|
1680
|
-
this.enable = false;
|
|
1681
|
-
this.options = {};
|
|
1682
|
-
}
|
|
1683
|
-
load(data) {
|
|
1684
|
-
if (isNull(data)) {
|
|
1685
|
-
return;
|
|
1686
|
-
}
|
|
1687
|
-
if (data.clamp !== undefined) {
|
|
1688
|
-
this.clamp = data.clamp;
|
|
1689
|
-
}
|
|
1316
|
+
options = {};
|
|
1317
|
+
doLoad(data) {
|
|
1318
|
+
loadProperty(this, "clamp", data.clamp);
|
|
1690
1319
|
this.delay.load(data.delay);
|
|
1691
|
-
|
|
1692
|
-
this.enable = data.enable;
|
|
1693
|
-
}
|
|
1320
|
+
loadProperty(this, "enable", data.enable);
|
|
1694
1321
|
this.generator = data.generator;
|
|
1695
1322
|
if (data.options) {
|
|
1696
1323
|
this.options = deepExtend(this.options, data.options);
|
|
@@ -1698,19 +1325,13 @@
|
|
|
1698
1325
|
}
|
|
1699
1326
|
}
|
|
1700
1327
|
|
|
1701
|
-
class OutModes {
|
|
1328
|
+
class OutModes extends OptionLoader {
|
|
1702
1329
|
bottom;
|
|
1703
|
-
default;
|
|
1330
|
+
default = OutMode.out;
|
|
1704
1331
|
left;
|
|
1705
1332
|
right;
|
|
1706
1333
|
top;
|
|
1707
|
-
|
|
1708
|
-
this.default = OutMode.out;
|
|
1709
|
-
}
|
|
1710
|
-
load(data) {
|
|
1711
|
-
if (isNull(data)) {
|
|
1712
|
-
return;
|
|
1713
|
-
}
|
|
1334
|
+
doLoad(data) {
|
|
1714
1335
|
if (data.default !== undefined) {
|
|
1715
1336
|
this.default = data.default;
|
|
1716
1337
|
}
|
|
@@ -1721,79 +1342,42 @@
|
|
|
1721
1342
|
}
|
|
1722
1343
|
}
|
|
1723
1344
|
|
|
1724
|
-
class Spin {
|
|
1725
|
-
acceleration;
|
|
1726
|
-
enable;
|
|
1345
|
+
class Spin extends OptionLoader {
|
|
1346
|
+
acceleration = 0;
|
|
1347
|
+
enable = false;
|
|
1727
1348
|
position;
|
|
1728
|
-
|
|
1729
|
-
this.acceleration
|
|
1730
|
-
this.enable
|
|
1731
|
-
}
|
|
1732
|
-
load(data) {
|
|
1733
|
-
if (isNull(data)) {
|
|
1734
|
-
return;
|
|
1735
|
-
}
|
|
1736
|
-
if (data.acceleration !== undefined) {
|
|
1737
|
-
this.acceleration = setRangeValue(data.acceleration);
|
|
1738
|
-
}
|
|
1739
|
-
if (data.enable !== undefined) {
|
|
1740
|
-
this.enable = data.enable;
|
|
1741
|
-
}
|
|
1349
|
+
doLoad(data) {
|
|
1350
|
+
loadRangeProperty(this, "acceleration", data.acceleration);
|
|
1351
|
+
loadProperty(this, "enable", data.enable);
|
|
1742
1352
|
if (data.position) {
|
|
1743
1353
|
this.position = deepExtend({}, data.position);
|
|
1744
1354
|
}
|
|
1745
1355
|
}
|
|
1746
1356
|
}
|
|
1747
1357
|
|
|
1748
|
-
class Move {
|
|
1749
|
-
angle;
|
|
1750
|
-
center;
|
|
1751
|
-
decay;
|
|
1752
|
-
direction;
|
|
1753
|
-
distance;
|
|
1754
|
-
drift;
|
|
1755
|
-
enable;
|
|
1756
|
-
gravity;
|
|
1757
|
-
outModes;
|
|
1758
|
-
path;
|
|
1759
|
-
random;
|
|
1760
|
-
size;
|
|
1761
|
-
speed;
|
|
1762
|
-
spin;
|
|
1763
|
-
straight;
|
|
1764
|
-
vibrate;
|
|
1765
|
-
warp;
|
|
1766
|
-
|
|
1767
|
-
this.angle = new MoveAngle();
|
|
1768
|
-
this.center = new MoveCenter();
|
|
1769
|
-
this.decay = 0;
|
|
1770
|
-
this.distance = {};
|
|
1771
|
-
this.direction = MoveDirection.none;
|
|
1772
|
-
this.drift = 0;
|
|
1773
|
-
this.enable = false;
|
|
1774
|
-
this.gravity = new MoveGravity();
|
|
1775
|
-
this.path = new MovePath();
|
|
1776
|
-
this.outModes = new OutModes();
|
|
1777
|
-
this.random = false;
|
|
1778
|
-
this.size = false;
|
|
1779
|
-
this.speed = 2;
|
|
1780
|
-
this.spin = new Spin();
|
|
1781
|
-
this.straight = false;
|
|
1782
|
-
this.vibrate = false;
|
|
1783
|
-
this.warp = false;
|
|
1784
|
-
}
|
|
1785
|
-
load(data) {
|
|
1786
|
-
if (isNull(data)) {
|
|
1787
|
-
return;
|
|
1788
|
-
}
|
|
1358
|
+
class Move extends OptionLoader {
|
|
1359
|
+
angle = new MoveAngle();
|
|
1360
|
+
center = new MoveCenter();
|
|
1361
|
+
decay = 0;
|
|
1362
|
+
direction = MoveDirection.none;
|
|
1363
|
+
distance = {};
|
|
1364
|
+
drift = 0;
|
|
1365
|
+
enable = false;
|
|
1366
|
+
gravity = new MoveGravity();
|
|
1367
|
+
outModes = new OutModes();
|
|
1368
|
+
path = new MovePath();
|
|
1369
|
+
random = false;
|
|
1370
|
+
size = false;
|
|
1371
|
+
speed = 2;
|
|
1372
|
+
spin = new Spin();
|
|
1373
|
+
straight = false;
|
|
1374
|
+
vibrate = false;
|
|
1375
|
+
warp = false;
|
|
1376
|
+
doLoad(data) {
|
|
1789
1377
|
this.angle.load(isNumber(data.angle) ? { value: data.angle } : data.angle);
|
|
1790
1378
|
this.center.load(data.center);
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
}
|
|
1794
|
-
if (data.direction !== undefined) {
|
|
1795
|
-
this.direction = data.direction;
|
|
1796
|
-
}
|
|
1379
|
+
loadRangeProperty(this, "decay", data.decay);
|
|
1380
|
+
loadProperty(this, "direction", data.direction);
|
|
1797
1381
|
if (data.distance !== undefined) {
|
|
1798
1382
|
this.distance = isNumber(data.distance)
|
|
1799
1383
|
? {
|
|
@@ -1802,12 +1386,8 @@
|
|
|
1802
1386
|
}
|
|
1803
1387
|
: { ...data.distance };
|
|
1804
1388
|
}
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
}
|
|
1808
|
-
if (data.enable !== undefined) {
|
|
1809
|
-
this.enable = data.enable;
|
|
1810
|
-
}
|
|
1389
|
+
loadRangeProperty(this, "drift", data.drift);
|
|
1390
|
+
loadProperty(this, "enable", data.enable);
|
|
1811
1391
|
this.gravity.load(data.gravity);
|
|
1812
1392
|
const outModes = data.outModes;
|
|
1813
1393
|
if (outModes !== undefined) {
|
|
@@ -1821,177 +1401,91 @@
|
|
|
1821
1401
|
}
|
|
1822
1402
|
}
|
|
1823
1403
|
this.path.load(data.path);
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
if (data.size !== undefined) {
|
|
1828
|
-
this.size = data.size;
|
|
1829
|
-
}
|
|
1830
|
-
if (data.speed !== undefined) {
|
|
1831
|
-
this.speed = setRangeValue(data.speed);
|
|
1832
|
-
}
|
|
1404
|
+
loadProperty(this, "random", data.random);
|
|
1405
|
+
loadProperty(this, "size", data.size);
|
|
1406
|
+
loadRangeProperty(this, "speed", data.speed);
|
|
1833
1407
|
this.spin.load(data.spin);
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
if (data.vibrate !== undefined) {
|
|
1838
|
-
this.vibrate = data.vibrate;
|
|
1839
|
-
}
|
|
1840
|
-
if (data.warp !== undefined) {
|
|
1841
|
-
this.warp = data.warp;
|
|
1842
|
-
}
|
|
1408
|
+
loadProperty(this, "straight", data.straight);
|
|
1409
|
+
loadProperty(this, "vibrate", data.vibrate);
|
|
1410
|
+
loadProperty(this, "warp", data.warp);
|
|
1843
1411
|
}
|
|
1844
1412
|
}
|
|
1845
1413
|
|
|
1846
|
-
class Stroke {
|
|
1414
|
+
class Stroke extends OptionLoader {
|
|
1847
1415
|
color;
|
|
1848
1416
|
opacity;
|
|
1849
|
-
width;
|
|
1850
|
-
|
|
1851
|
-
this.width = 0;
|
|
1852
|
-
}
|
|
1853
|
-
load(data) {
|
|
1854
|
-
if (isNull(data)) {
|
|
1855
|
-
return;
|
|
1856
|
-
}
|
|
1417
|
+
width = 0;
|
|
1418
|
+
doLoad(data) {
|
|
1857
1419
|
if (data.color !== undefined) {
|
|
1858
1420
|
this.color = AnimatableColor.create(this.color, data.color);
|
|
1859
1421
|
}
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
}
|
|
1863
|
-
if (data.opacity !== undefined) {
|
|
1864
|
-
this.opacity = setRangeValue(data.opacity);
|
|
1865
|
-
}
|
|
1422
|
+
loadRangeProperty(this, "width", data.width);
|
|
1423
|
+
loadRangeProperty(this, "opacity", data.opacity);
|
|
1866
1424
|
}
|
|
1867
1425
|
}
|
|
1868
1426
|
|
|
1869
|
-
class Paint {
|
|
1427
|
+
class Paint extends OptionLoader {
|
|
1870
1428
|
color;
|
|
1871
1429
|
fill;
|
|
1872
1430
|
stroke;
|
|
1873
|
-
|
|
1874
|
-
if (isNull(data)) {
|
|
1875
|
-
return;
|
|
1876
|
-
}
|
|
1431
|
+
doLoad(data) {
|
|
1877
1432
|
if (data.color !== undefined) {
|
|
1878
1433
|
this.color = AnimatableColor.create(this.color, data.color);
|
|
1879
1434
|
}
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
this.fill.load(data.fill);
|
|
1883
|
-
}
|
|
1884
|
-
if (data.stroke !== undefined) {
|
|
1885
|
-
this.stroke ??= new Stroke();
|
|
1886
|
-
this.stroke.load(data.stroke);
|
|
1887
|
-
}
|
|
1435
|
+
loadLazyProperty(this, "fill", data.fill, () => new Fill());
|
|
1436
|
+
loadLazyProperty(this, "stroke", data.stroke, () => new Stroke());
|
|
1888
1437
|
}
|
|
1889
1438
|
}
|
|
1890
1439
|
|
|
1891
1440
|
class ParticlesBounceFactor extends ValueWithRandom {
|
|
1892
|
-
|
|
1893
|
-
super();
|
|
1894
|
-
this.value = 1;
|
|
1895
|
-
}
|
|
1441
|
+
value = 1;
|
|
1896
1442
|
}
|
|
1897
1443
|
|
|
1898
|
-
class ParticlesBounce {
|
|
1899
|
-
horizontal;
|
|
1900
|
-
vertical;
|
|
1901
|
-
|
|
1902
|
-
this.horizontal = new ParticlesBounceFactor();
|
|
1903
|
-
this.vertical = new ParticlesBounceFactor();
|
|
1904
|
-
}
|
|
1905
|
-
load(data) {
|
|
1906
|
-
if (isNull(data)) {
|
|
1907
|
-
return;
|
|
1908
|
-
}
|
|
1444
|
+
class ParticlesBounce extends OptionLoader {
|
|
1445
|
+
horizontal = new ParticlesBounceFactor();
|
|
1446
|
+
vertical = new ParticlesBounceFactor();
|
|
1447
|
+
doLoad(data) {
|
|
1909
1448
|
this.horizontal.load(data.horizontal);
|
|
1910
1449
|
this.vertical.load(data.vertical);
|
|
1911
1450
|
}
|
|
1912
1451
|
}
|
|
1913
1452
|
|
|
1914
|
-
class ParticlesDensity {
|
|
1915
|
-
enable;
|
|
1916
|
-
height;
|
|
1917
|
-
width;
|
|
1918
|
-
|
|
1919
|
-
this.enable
|
|
1920
|
-
this.width
|
|
1921
|
-
this.height
|
|
1922
|
-
}
|
|
1923
|
-
load(data) {
|
|
1924
|
-
if (isNull(data)) {
|
|
1925
|
-
return;
|
|
1926
|
-
}
|
|
1927
|
-
if (data.enable !== undefined) {
|
|
1928
|
-
this.enable = data.enable;
|
|
1929
|
-
}
|
|
1930
|
-
const width = data.width;
|
|
1931
|
-
if (width !== undefined) {
|
|
1932
|
-
this.width = width;
|
|
1933
|
-
}
|
|
1934
|
-
const height = data.height;
|
|
1935
|
-
if (height !== undefined) {
|
|
1936
|
-
this.height = height;
|
|
1937
|
-
}
|
|
1453
|
+
class ParticlesDensity extends OptionLoader {
|
|
1454
|
+
enable = false;
|
|
1455
|
+
height = 1080;
|
|
1456
|
+
width = 1920;
|
|
1457
|
+
doLoad(data) {
|
|
1458
|
+
loadProperty(this, "enable", data.enable);
|
|
1459
|
+
loadProperty(this, "width", data.width);
|
|
1460
|
+
loadProperty(this, "height", data.height);
|
|
1938
1461
|
}
|
|
1939
1462
|
}
|
|
1940
1463
|
|
|
1941
|
-
class ParticlesNumberLimit {
|
|
1942
|
-
mode;
|
|
1943
|
-
value;
|
|
1944
|
-
|
|
1945
|
-
this
|
|
1946
|
-
this.value
|
|
1947
|
-
}
|
|
1948
|
-
load(data) {
|
|
1949
|
-
if (isNull(data)) {
|
|
1950
|
-
return;
|
|
1951
|
-
}
|
|
1952
|
-
if (data.mode !== undefined) {
|
|
1953
|
-
this.mode = data.mode;
|
|
1954
|
-
}
|
|
1955
|
-
if (data.value !== undefined) {
|
|
1956
|
-
this.value = data.value;
|
|
1957
|
-
}
|
|
1464
|
+
class ParticlesNumberLimit extends OptionLoader {
|
|
1465
|
+
mode = LimitMode.delete;
|
|
1466
|
+
value = 0;
|
|
1467
|
+
doLoad(data) {
|
|
1468
|
+
loadProperty(this, "mode", data.mode);
|
|
1469
|
+
loadProperty(this, "value", data.value);
|
|
1958
1470
|
}
|
|
1959
1471
|
}
|
|
1960
1472
|
|
|
1961
|
-
class ParticlesNumber {
|
|
1962
|
-
density;
|
|
1963
|
-
limit;
|
|
1964
|
-
value;
|
|
1965
|
-
|
|
1966
|
-
this.density = new ParticlesDensity();
|
|
1967
|
-
this.limit = new ParticlesNumberLimit();
|
|
1968
|
-
this.value = 0;
|
|
1969
|
-
}
|
|
1970
|
-
load(data) {
|
|
1971
|
-
if (isNull(data)) {
|
|
1972
|
-
return;
|
|
1973
|
-
}
|
|
1473
|
+
class ParticlesNumber extends OptionLoader {
|
|
1474
|
+
density = new ParticlesDensity();
|
|
1475
|
+
limit = new ParticlesNumberLimit();
|
|
1476
|
+
value = 0;
|
|
1477
|
+
doLoad(data) {
|
|
1974
1478
|
this.density.load(data.density);
|
|
1975
1479
|
this.limit.load(data.limit);
|
|
1976
|
-
|
|
1977
|
-
this.value = data.value;
|
|
1978
|
-
}
|
|
1480
|
+
loadProperty(this, "value", data.value);
|
|
1979
1481
|
}
|
|
1980
1482
|
}
|
|
1981
1483
|
|
|
1982
|
-
class Shape {
|
|
1983
|
-
close;
|
|
1984
|
-
options;
|
|
1985
|
-
type;
|
|
1986
|
-
|
|
1987
|
-
this.close = true;
|
|
1988
|
-
this.options = {};
|
|
1989
|
-
this.type = "circle";
|
|
1990
|
-
}
|
|
1991
|
-
load(data) {
|
|
1992
|
-
if (isNull(data)) {
|
|
1993
|
-
return;
|
|
1994
|
-
}
|
|
1484
|
+
class Shape extends OptionLoader {
|
|
1485
|
+
close = true;
|
|
1486
|
+
options = {};
|
|
1487
|
+
type = "circle";
|
|
1488
|
+
doLoad(data) {
|
|
1995
1489
|
const options = data.options;
|
|
1996
1490
|
if (options !== undefined) {
|
|
1997
1491
|
for (const shape in options) {
|
|
@@ -2001,76 +1495,47 @@
|
|
|
2001
1495
|
}
|
|
2002
1496
|
}
|
|
2003
1497
|
}
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
}
|
|
2007
|
-
if (data.type !== undefined) {
|
|
2008
|
-
this.type = data.type;
|
|
2009
|
-
}
|
|
1498
|
+
loadProperty(this, "close", data.close);
|
|
1499
|
+
loadProperty(this, "type", data.type);
|
|
2010
1500
|
}
|
|
2011
1501
|
}
|
|
2012
1502
|
|
|
2013
1503
|
class ZIndex extends ValueWithRandom {
|
|
2014
|
-
opacityRate;
|
|
2015
|
-
sizeRate;
|
|
2016
|
-
velocityRate;
|
|
2017
|
-
|
|
2018
|
-
super();
|
|
2019
|
-
this.opacityRate
|
|
2020
|
-
this.sizeRate
|
|
2021
|
-
this.velocityRate
|
|
2022
|
-
}
|
|
2023
|
-
load(data) {
|
|
2024
|
-
super.load(data);
|
|
2025
|
-
if (isNull(data)) {
|
|
2026
|
-
return;
|
|
2027
|
-
}
|
|
2028
|
-
if (data.opacityRate !== undefined) {
|
|
2029
|
-
this.opacityRate = data.opacityRate;
|
|
2030
|
-
}
|
|
2031
|
-
if (data.sizeRate !== undefined) {
|
|
2032
|
-
this.sizeRate = data.sizeRate;
|
|
2033
|
-
}
|
|
2034
|
-
if (data.velocityRate !== undefined) {
|
|
2035
|
-
this.velocityRate = data.velocityRate;
|
|
2036
|
-
}
|
|
1504
|
+
opacityRate = 1;
|
|
1505
|
+
sizeRate = 1;
|
|
1506
|
+
velocityRate = 1;
|
|
1507
|
+
doLoad(data) {
|
|
1508
|
+
super.doLoad(data);
|
|
1509
|
+
loadProperty(this, "opacityRate", data.opacityRate);
|
|
1510
|
+
loadProperty(this, "sizeRate", data.sizeRate);
|
|
1511
|
+
loadProperty(this, "velocityRate", data.velocityRate);
|
|
2037
1512
|
}
|
|
2038
1513
|
}
|
|
2039
1514
|
|
|
2040
|
-
class ParticlesOptions {
|
|
2041
|
-
bounce;
|
|
2042
|
-
effect;
|
|
2043
|
-
groups;
|
|
2044
|
-
move;
|
|
2045
|
-
number;
|
|
1515
|
+
class ParticlesOptions extends OptionLoader {
|
|
1516
|
+
bounce = new ParticlesBounce();
|
|
1517
|
+
effect = new Effect();
|
|
1518
|
+
groups = {};
|
|
1519
|
+
move = new Move();
|
|
1520
|
+
number = new ParticlesNumber();
|
|
2046
1521
|
paint;
|
|
2047
1522
|
palette;
|
|
2048
|
-
reduceDuplicates;
|
|
2049
|
-
shape;
|
|
2050
|
-
zIndex;
|
|
1523
|
+
reduceDuplicates = false;
|
|
1524
|
+
shape = new Shape();
|
|
1525
|
+
zIndex = new ZIndex();
|
|
2051
1526
|
#container;
|
|
2052
1527
|
#pluginManager;
|
|
2053
1528
|
constructor(pluginManager, container) {
|
|
1529
|
+
super();
|
|
2054
1530
|
this.#pluginManager = pluginManager;
|
|
2055
1531
|
this.#container = container;
|
|
2056
|
-
this.bounce = new ParticlesBounce();
|
|
2057
|
-
this.effect = new Effect();
|
|
2058
|
-
this.groups = {};
|
|
2059
|
-
this.move = new Move();
|
|
2060
|
-
this.number = new ParticlesNumber();
|
|
2061
1532
|
this.paint = new Paint();
|
|
2062
1533
|
this.paint.color = new AnimatableColor();
|
|
2063
1534
|
this.paint.color.value = "#fff";
|
|
2064
1535
|
this.paint.fill = new Fill();
|
|
2065
1536
|
this.paint.fill.enable = true;
|
|
2066
|
-
this.reduceDuplicates = false;
|
|
2067
|
-
this.shape = new Shape();
|
|
2068
|
-
this.zIndex = new ZIndex();
|
|
2069
1537
|
}
|
|
2070
|
-
|
|
2071
|
-
if (isNull(data)) {
|
|
2072
|
-
return;
|
|
2073
|
-
}
|
|
1538
|
+
doLoad(data) {
|
|
2074
1539
|
if (data.palette) {
|
|
2075
1540
|
this.palette = data.palette;
|
|
2076
1541
|
this.#importPalette(this.palette);
|
|
@@ -2128,7 +1593,7 @@
|
|
|
2128
1593
|
}
|
|
2129
1594
|
}
|
|
2130
1595
|
}
|
|
2131
|
-
#importPalette
|
|
1596
|
+
#importPalette(palette) {
|
|
2132
1597
|
const paletteData = this.#pluginManager.getPalette(palette);
|
|
2133
1598
|
if (!paletteData) {
|
|
2134
1599
|
return;
|
|
@@ -2172,69 +1637,49 @@
|
|
|
2172
1637
|
mode: paletteData.blendMode,
|
|
2173
1638
|
},
|
|
2174
1639
|
});
|
|
2175
|
-
};
|
|
2176
|
-
}
|
|
2177
|
-
|
|
2178
|
-
function loadOptions(options, ...sourceOptionsArr) {
|
|
2179
|
-
for (const sourceOptions of sourceOptionsArr) {
|
|
2180
|
-
options.load(sourceOptions);
|
|
2181
1640
|
}
|
|
2182
1641
|
}
|
|
1642
|
+
|
|
2183
1643
|
function loadParticlesOptions(pluginManager, container, ...sourceOptionsArr) {
|
|
2184
1644
|
const options = new ParticlesOptions(pluginManager, container);
|
|
2185
1645
|
loadOptions(options, ...sourceOptionsArr);
|
|
2186
1646
|
return options;
|
|
2187
1647
|
}
|
|
2188
1648
|
|
|
2189
|
-
class Options {
|
|
2190
|
-
autoPlay;
|
|
1649
|
+
class Options extends OptionLoader {
|
|
1650
|
+
autoPlay = true;
|
|
2191
1651
|
background;
|
|
2192
|
-
clear;
|
|
2193
|
-
defaultThemes;
|
|
2194
|
-
delay;
|
|
2195
|
-
detectRetina;
|
|
2196
|
-
duration;
|
|
2197
|
-
fpsLimit;
|
|
1652
|
+
clear = true;
|
|
1653
|
+
defaultThemes = {};
|
|
1654
|
+
delay = 0;
|
|
1655
|
+
detectRetina = true;
|
|
1656
|
+
duration = 0;
|
|
1657
|
+
fpsLimit = 120;
|
|
2198
1658
|
fullScreen;
|
|
2199
|
-
hdr;
|
|
1659
|
+
hdr = true;
|
|
2200
1660
|
key;
|
|
2201
1661
|
name;
|
|
2202
1662
|
palette;
|
|
2203
1663
|
particles;
|
|
2204
|
-
pauseOnBlur;
|
|
2205
|
-
pauseOnOutsideViewport;
|
|
1664
|
+
pauseOnBlur = true;
|
|
1665
|
+
pauseOnOutsideViewport = true;
|
|
2206
1666
|
preset;
|
|
2207
1667
|
resize;
|
|
2208
|
-
smooth;
|
|
2209
|
-
style;
|
|
2210
|
-
zLayers;
|
|
1668
|
+
smooth = false;
|
|
1669
|
+
style = {};
|
|
1670
|
+
zLayers = 100;
|
|
2211
1671
|
#container;
|
|
2212
1672
|
#pluginManager;
|
|
2213
1673
|
constructor(pluginManager, container) {
|
|
1674
|
+
super();
|
|
2214
1675
|
this.#pluginManager = pluginManager;
|
|
2215
1676
|
this.#container = container;
|
|
2216
|
-
this.autoPlay = true;
|
|
2217
1677
|
this.background = new Background();
|
|
2218
|
-
this.clear = true;
|
|
2219
|
-
this.defaultThemes = {};
|
|
2220
|
-
this.delay = 0;
|
|
2221
1678
|
this.fullScreen = new FullScreen();
|
|
2222
|
-
this.detectRetina = true;
|
|
2223
|
-
this.duration = 0;
|
|
2224
|
-
this.fpsLimit = 120;
|
|
2225
|
-
this.hdr = true;
|
|
2226
1679
|
this.particles = loadParticlesOptions(this.#pluginManager, this.#container);
|
|
2227
|
-
this.pauseOnBlur = true;
|
|
2228
|
-
this.pauseOnOutsideViewport = true;
|
|
2229
1680
|
this.resize = new ResizeEvent();
|
|
2230
|
-
this.smooth = false;
|
|
2231
|
-
this.style = {};
|
|
2232
|
-
this.zLayers = 100;
|
|
2233
1681
|
}
|
|
2234
|
-
|
|
2235
|
-
if (isNull(data)) {
|
|
2236
|
-
return;
|
|
2237
|
-
}
|
|
1682
|
+
doLoad(data) {
|
|
2238
1683
|
if (data.preset !== undefined) {
|
|
2239
1684
|
this.preset = data.preset;
|
|
2240
1685
|
executeOnSingleOrMultiple(this.preset, preset => {
|
|
@@ -2245,44 +1690,18 @@
|
|
|
2245
1690
|
this.palette = data.palette;
|
|
2246
1691
|
this.#importPalette(this.palette);
|
|
2247
1692
|
}
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
if (data.delay !== undefined) {
|
|
2261
|
-
this.delay = setRangeValue(data.delay);
|
|
2262
|
-
}
|
|
2263
|
-
const detectRetina = data.detectRetina;
|
|
2264
|
-
if (detectRetina !== undefined) {
|
|
2265
|
-
this.detectRetina = detectRetina;
|
|
2266
|
-
}
|
|
2267
|
-
if (data.duration !== undefined) {
|
|
2268
|
-
this.duration = setRangeValue(data.duration);
|
|
2269
|
-
}
|
|
2270
|
-
const fpsLimit = data.fpsLimit;
|
|
2271
|
-
if (fpsLimit !== undefined) {
|
|
2272
|
-
this.fpsLimit = fpsLimit;
|
|
2273
|
-
}
|
|
2274
|
-
if (data.hdr !== undefined) {
|
|
2275
|
-
this.hdr = data.hdr;
|
|
2276
|
-
}
|
|
2277
|
-
if (data.pauseOnBlur !== undefined) {
|
|
2278
|
-
this.pauseOnBlur = data.pauseOnBlur;
|
|
2279
|
-
}
|
|
2280
|
-
if (data.pauseOnOutsideViewport !== undefined) {
|
|
2281
|
-
this.pauseOnOutsideViewport = data.pauseOnOutsideViewport;
|
|
2282
|
-
}
|
|
2283
|
-
if (data.zLayers !== undefined) {
|
|
2284
|
-
this.zLayers = data.zLayers;
|
|
2285
|
-
}
|
|
1693
|
+
loadProperty(this, "autoPlay", data.autoPlay);
|
|
1694
|
+
loadProperty(this, "clear", data.clear);
|
|
1695
|
+
loadProperty(this, "key", data.key);
|
|
1696
|
+
loadProperty(this, "name", data.name);
|
|
1697
|
+
loadRangeProperty(this, "delay", data.delay);
|
|
1698
|
+
loadProperty(this, "detectRetina", data.detectRetina);
|
|
1699
|
+
loadRangeProperty(this, "duration", data.duration);
|
|
1700
|
+
loadProperty(this, "fpsLimit", data.fpsLimit);
|
|
1701
|
+
loadProperty(this, "hdr", data.hdr);
|
|
1702
|
+
loadProperty(this, "pauseOnBlur", data.pauseOnBlur);
|
|
1703
|
+
loadProperty(this, "pauseOnOutsideViewport", data.pauseOnOutsideViewport);
|
|
1704
|
+
loadProperty(this, "zLayers", data.zLayers);
|
|
2286
1705
|
this.background.load(data.background);
|
|
2287
1706
|
const fullScreen = data.fullScreen;
|
|
2288
1707
|
if (isBoolean(fullScreen)) {
|
|
@@ -2294,14 +1713,12 @@
|
|
|
2294
1713
|
this.particles.load(data.particles);
|
|
2295
1714
|
this.resize.load(data.resize);
|
|
2296
1715
|
this.style = deepExtend(this.style, data.style);
|
|
2297
|
-
|
|
2298
|
-
this.smooth = data.smooth;
|
|
2299
|
-
}
|
|
1716
|
+
loadProperty(this, "smooth", data.smooth);
|
|
2300
1717
|
this.#pluginManager.plugins.forEach(plugin => {
|
|
2301
1718
|
plugin.loadOptions(this.#container, this, data);
|
|
2302
1719
|
});
|
|
2303
1720
|
}
|
|
2304
|
-
#importPalette
|
|
1721
|
+
#importPalette(palette) {
|
|
2305
1722
|
const paletteData = this.#pluginManager.getPalette(palette);
|
|
2306
1723
|
if (!paletteData) {
|
|
2307
1724
|
return;
|
|
@@ -2318,143 +1735,19 @@
|
|
|
2318
1735
|
palette,
|
|
2319
1736
|
},
|
|
2320
1737
|
});
|
|
2321
|
-
};
|
|
2322
|
-
#importPreset = preset => {
|
|
2323
|
-
this.load(this.#pluginManager.getPreset(preset));
|
|
2324
|
-
};
|
|
2325
|
-
}
|
|
2326
|
-
|
|
2327
|
-
function paintBase(context, dimension, baseColor) {
|
|
2328
|
-
context.fillStyle = baseColor ?? "rgba(0,0,0,0)";
|
|
2329
|
-
context.fillRect(originPoint.x, originPoint.y, dimension.width, dimension.height);
|
|
2330
|
-
}
|
|
2331
|
-
function paintImage(context, dimension, image, opacity) {
|
|
2332
|
-
if (!image) {
|
|
2333
|
-
return;
|
|
2334
|
-
}
|
|
2335
|
-
const prevAlpha = context.globalAlpha;
|
|
2336
|
-
context.globalAlpha = opacity;
|
|
2337
|
-
context.drawImage(image, originPoint.x, originPoint.y, dimension.width, dimension.height);
|
|
2338
|
-
context.globalAlpha = prevAlpha;
|
|
2339
|
-
}
|
|
2340
|
-
function clear(context, dimension) {
|
|
2341
|
-
context.clearRect(originPoint.x, originPoint.y, dimension.width, dimension.height);
|
|
2342
|
-
}
|
|
2343
|
-
function drawParticle(data) {
|
|
2344
|
-
const { container, context, particle, delta, colorStyles, radius, opacity, transform } = data, { effectDrawers, shapeDrawers } = container, pos = particle.getPosition(), transformData = particle.getTransformData(transform), drawScale = defaultZoom, drawPosition = {
|
|
2345
|
-
x: pos.x,
|
|
2346
|
-
y: pos.y,
|
|
2347
|
-
};
|
|
2348
|
-
context.setTransform(transformData.a, transformData.b, transformData.c, transformData.d, pos.x, pos.y);
|
|
2349
|
-
if (colorStyles.fill) {
|
|
2350
|
-
context.fillStyle = colorStyles.fill;
|
|
2351
|
-
}
|
|
2352
|
-
const fillEnabled = !!particle.fillEnabled, strokeWidth = particle.strokeWidth ?? minStrokeWidth;
|
|
2353
|
-
context.lineWidth = strokeWidth;
|
|
2354
|
-
if (colorStyles.stroke) {
|
|
2355
|
-
context.strokeStyle = colorStyles.stroke;
|
|
2356
|
-
}
|
|
2357
|
-
const drawData = {
|
|
2358
|
-
context,
|
|
2359
|
-
particle,
|
|
2360
|
-
radius,
|
|
2361
|
-
drawRadius: radius * drawScale,
|
|
2362
|
-
opacity,
|
|
2363
|
-
delta,
|
|
2364
|
-
pixelRatio: container.retina.pixelRatio,
|
|
2365
|
-
fill: fillEnabled,
|
|
2366
|
-
stroke: strokeWidth > minStrokeWidth,
|
|
2367
|
-
transformData,
|
|
2368
|
-
position: { ...pos },
|
|
2369
|
-
drawPosition,
|
|
2370
|
-
drawScale,
|
|
2371
|
-
};
|
|
2372
|
-
for (const plugin of container.plugins) {
|
|
2373
|
-
plugin.drawParticleTransform?.(drawData);
|
|
2374
|
-
}
|
|
2375
|
-
const effect = particle.effect ? effectDrawers.get(particle.effect) : undefined, shape = particle.shape ? shapeDrawers.get(particle.shape) : undefined;
|
|
2376
|
-
drawBeforeEffect(effect, drawData);
|
|
2377
|
-
drawShapeBeforeDraw(shape, drawData);
|
|
2378
|
-
drawShape(shape, drawData);
|
|
2379
|
-
drawShapeAfterDraw(shape, drawData);
|
|
2380
|
-
drawAfterEffect(effect, drawData);
|
|
2381
|
-
context.resetTransform();
|
|
2382
|
-
}
|
|
2383
|
-
function drawAfterEffect(drawer, data) {
|
|
2384
|
-
if (!drawer?.drawAfter) {
|
|
2385
|
-
return;
|
|
2386
|
-
}
|
|
2387
|
-
const { particle } = data;
|
|
2388
|
-
if (!particle.effect) {
|
|
2389
|
-
return;
|
|
2390
|
-
}
|
|
2391
|
-
drawer.drawAfter(data);
|
|
2392
|
-
}
|
|
2393
|
-
function drawBeforeEffect(drawer, data) {
|
|
2394
|
-
if (!drawer?.drawBefore) {
|
|
2395
|
-
return;
|
|
2396
|
-
}
|
|
2397
|
-
const { particle } = data;
|
|
2398
|
-
if (!particle.effect) {
|
|
2399
|
-
return;
|
|
2400
|
-
}
|
|
2401
|
-
drawer.drawBefore(data);
|
|
2402
|
-
}
|
|
2403
|
-
function drawShape(drawer, data) {
|
|
2404
|
-
if (!drawer) {
|
|
2405
|
-
return;
|
|
2406
|
-
}
|
|
2407
|
-
const { context, fill, particle, stroke } = data;
|
|
2408
|
-
if (!particle.shape) {
|
|
2409
|
-
return;
|
|
2410
|
-
}
|
|
2411
|
-
context.beginPath();
|
|
2412
|
-
drawer.draw(data);
|
|
2413
|
-
if (particle.shapeClose) {
|
|
2414
|
-
context.closePath();
|
|
2415
|
-
}
|
|
2416
|
-
if (fill) {
|
|
2417
|
-
context.fill();
|
|
2418
|
-
}
|
|
2419
|
-
if (stroke) {
|
|
2420
|
-
context.stroke();
|
|
2421
1738
|
}
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
if (!drawer?.afterDraw) {
|
|
2425
|
-
return;
|
|
2426
|
-
}
|
|
2427
|
-
const { particle } = data;
|
|
2428
|
-
if (!particle.shape) {
|
|
2429
|
-
return;
|
|
2430
|
-
}
|
|
2431
|
-
drawer.afterDraw(data);
|
|
2432
|
-
}
|
|
2433
|
-
function drawShapeBeforeDraw(drawer, data) {
|
|
2434
|
-
if (!drawer?.beforeDraw) {
|
|
2435
|
-
return;
|
|
2436
|
-
}
|
|
2437
|
-
const { particle } = data;
|
|
2438
|
-
if (!particle.shape) {
|
|
2439
|
-
return;
|
|
2440
|
-
}
|
|
2441
|
-
drawer.beforeDraw(data);
|
|
2442
|
-
}
|
|
2443
|
-
function drawParticlePlugin(context, plugin, particle, delta) {
|
|
2444
|
-
if (!plugin.drawParticle) {
|
|
2445
|
-
return;
|
|
1739
|
+
#importPreset(preset) {
|
|
1740
|
+
this.load(this.#pluginManager.getPreset(preset));
|
|
2446
1741
|
}
|
|
2447
|
-
plugin.drawParticle(context, particle, delta);
|
|
2448
1742
|
}
|
|
2449
1743
|
|
|
2450
|
-
const styleCache = new Map(),
|
|
1744
|
+
const styleCache = new Map(), maxStyleCacheSize = 2000, rgbFixedPrecision = 2, hslFixedPrecision = 2, sdrReferenceWhiteNits = 203;
|
|
2451
1745
|
function getCachedStyle(key, generator) {
|
|
2452
1746
|
let cached = styleCache.get(key);
|
|
2453
1747
|
if (!cached) {
|
|
2454
1748
|
cached = generator();
|
|
2455
|
-
if (styleCache.size
|
|
2456
|
-
|
|
2457
|
-
keysToDelete.forEach(k => styleCache.delete(k));
|
|
1749
|
+
if (styleCache.size > maxStyleCacheSize) {
|
|
1750
|
+
styleCache.clear();
|
|
2458
1751
|
}
|
|
2459
1752
|
styleCache.set(key, cached);
|
|
2460
1753
|
}
|
|
@@ -2557,34 +1850,35 @@
|
|
|
2557
1850
|
function stringToRgb(pluginManager, input) {
|
|
2558
1851
|
return stringToRgba(pluginManager, input);
|
|
2559
1852
|
}
|
|
1853
|
+
function hslChannel(temp1, temp2, temp3) {
|
|
1854
|
+
const temp3Min = 0, temp3Max = 1;
|
|
1855
|
+
if (temp3 < temp3Min) {
|
|
1856
|
+
temp3++;
|
|
1857
|
+
}
|
|
1858
|
+
if (temp3 > temp3Max) {
|
|
1859
|
+
temp3--;
|
|
1860
|
+
}
|
|
1861
|
+
if (temp3 * sextuple < temp3Max) {
|
|
1862
|
+
return temp1 + (temp2 - temp1) * sextuple * temp3;
|
|
1863
|
+
}
|
|
1864
|
+
if (temp3 * double < temp3Max) {
|
|
1865
|
+
return temp2;
|
|
1866
|
+
}
|
|
1867
|
+
if (temp3 * triple < temp3Max * double) {
|
|
1868
|
+
const temp3Offset = double / triple;
|
|
1869
|
+
return temp1 + (temp2 - temp1) * (temp3Offset - temp3) * sextuple;
|
|
1870
|
+
}
|
|
1871
|
+
return temp1;
|
|
1872
|
+
}
|
|
2560
1873
|
function hslToRgb(hsl) {
|
|
2561
1874
|
const h = ((hsl.h % hMax) + hMax) % hMax, s = Math.max(sMin, Math.min(sMax, hsl.s)), l = Math.max(lMin, Math.min(lMax, hsl.l)), hNormalized = h / hMax, sNormalized = s / sMax, lNormalized = l / lMax;
|
|
2562
1875
|
if (s === sMin) {
|
|
2563
1876
|
const grayscaleValue = Math.round(lNormalized * rgbMax);
|
|
2564
1877
|
return { r: grayscaleValue, g: grayscaleValue, b: grayscaleValue };
|
|
2565
1878
|
}
|
|
2566
|
-
const
|
|
2567
|
-
const temp3Min = 0, temp3Max = 1;
|
|
2568
|
-
if (temp3 < temp3Min) {
|
|
2569
|
-
temp3++;
|
|
2570
|
-
}
|
|
2571
|
-
if (temp3 > temp3Max) {
|
|
2572
|
-
temp3--;
|
|
2573
|
-
}
|
|
2574
|
-
if (temp3 * sextuple < temp3Max) {
|
|
2575
|
-
return temp1 + (temp2 - temp1) * sextuple * temp3;
|
|
2576
|
-
}
|
|
2577
|
-
if (temp3 * double < temp3Max) {
|
|
2578
|
-
return temp2;
|
|
2579
|
-
}
|
|
2580
|
-
if (temp3 * triple < temp3Max * double) {
|
|
2581
|
-
const temp3Offset = double / triple;
|
|
2582
|
-
return temp1 + (temp2 - temp1) * (temp3Offset - temp3) * sextuple;
|
|
2583
|
-
}
|
|
2584
|
-
return temp1;
|
|
2585
|
-
}, temp1 = lNormalized < half
|
|
1879
|
+
const temp1 = lNormalized < half
|
|
2586
1880
|
? lNormalized * (sNormalizedOffset + sNormalized)
|
|
2587
|
-
: lNormalized + sNormalized - lNormalized * sNormalized, temp2 = double * lNormalized - temp1, phaseThird = phaseNumerator / triple, red = Math.min(rgbMax, rgbMax *
|
|
1881
|
+
: lNormalized + sNormalized - lNormalized * sNormalized, temp2 = double * lNormalized - temp1, phaseThird = phaseNumerator / triple, red = Math.min(rgbMax, rgbMax * hslChannel(temp2, temp1, hNormalized + phaseThird)), green = Math.min(rgbMax, rgbMax * hslChannel(temp2, temp1, hNormalized)), blue = Math.min(rgbMax, rgbMax * hslChannel(temp2, temp1, hNormalized - phaseThird));
|
|
2588
1882
|
return { r: Math.round(red), g: Math.round(green), b: Math.round(blue) };
|
|
2589
1883
|
}
|
|
2590
1884
|
function hslaToRgba(hsla) {
|
|
@@ -2597,7 +1891,7 @@
|
|
|
2597
1891
|
};
|
|
2598
1892
|
}
|
|
2599
1893
|
function getRandomRgbColor(min) {
|
|
2600
|
-
const fixedMin = defaultRgbMin, fixedMax = rgbMax + identity
|
|
1894
|
+
const fixedMin = defaultRgbMin, fixedMax = rgbMax + identity, getRgbInRangeValue = () => Math.floor(getRandomInRange(fixedMin, fixedMax));
|
|
2601
1895
|
return {
|
|
2602
1896
|
b: getRgbInRangeValue(),
|
|
2603
1897
|
g: getRgbInRangeValue(),
|
|
@@ -2608,21 +1902,18 @@
|
|
|
2608
1902
|
const op = opacity ?? defaultOpacity$1, key = `rgb-${color.r.toFixed(rgbFixedPrecision)}-${color.g.toFixed(rgbFixedPrecision)}-${color.b.toFixed(rgbFixedPrecision)}-${hdr ? "hdr" : "sdr"}-${op.toString()}`;
|
|
2609
1903
|
return getCachedStyle(key, () => (hdr ? getHdrStyleFromRgb(color, opacity) : getSdrStyleFromRgb(color, opacity)));
|
|
2610
1904
|
}
|
|
2611
|
-
function getHdrStyleFromRgb(color, opacity) {
|
|
2612
|
-
|
|
1905
|
+
function getHdrStyleFromRgb(color, opacity, peakNits = maxNits) {
|
|
1906
|
+
const headroom = peakNits / sdrReferenceWhiteNits;
|
|
1907
|
+
return `color(display-p3 ${((color.r / rgbMax) * headroom).toString()} ${((color.g / rgbMax) * headroom).toString()} ${((color.b / rgbMax) * headroom).toString()} / ${(opacity ?? defaultOpacity$1).toString()})`;
|
|
2613
1908
|
}
|
|
2614
1909
|
function getSdrStyleFromRgb(color, opacity) {
|
|
2615
1910
|
return `rgba(${color.r.toString()}, ${color.g.toString()}, ${color.b.toString()}, ${(opacity ?? defaultOpacity$1).toString()})`;
|
|
2616
1911
|
}
|
|
2617
1912
|
function getStyleFromHsl(color, hdr, opacity) {
|
|
2618
1913
|
const op = opacity ?? defaultOpacity$1, key = `hsl-${color.h.toFixed(hslFixedPrecision)}-${color.s.toFixed(hslFixedPrecision)}-${color.l.toFixed(hslFixedPrecision)}-${hdr ? "hdr" : "sdr"}-${op.toString()}`;
|
|
2619
|
-
return getCachedStyle(key, () =>
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
return getHdrStyleFromRgb(hslToRgb(color), opacity);
|
|
2623
|
-
}
|
|
2624
|
-
function getSdrStyleFromHsl(color, opacity) {
|
|
2625
|
-
return `hsla(${color.h.toString()}, ${color.s.toString()}%, ${color.l.toString()}%, ${(opacity ?? defaultOpacity$1).toString()})`;
|
|
1914
|
+
return getCachedStyle(key, () => hdr
|
|
1915
|
+
? getStyleFromRgb(hslToRgb(color), true, opacity)
|
|
1916
|
+
: `hsla(${color.h.toString()}, ${color.s.toString()}%, ${color.l.toString()}%, ${op.toString()})`);
|
|
2626
1917
|
}
|
|
2627
1918
|
function getHslFromAnimation(animation) {
|
|
2628
1919
|
return animation === undefined
|
|
@@ -2744,22 +2035,14 @@
|
|
|
2744
2035
|
const tsParticles = initEngine();
|
|
2745
2036
|
|
|
2746
2037
|
class Blend {
|
|
2747
|
-
enable;
|
|
2748
|
-
mode;
|
|
2749
|
-
constructor() {
|
|
2750
|
-
this.mode = "destination-out";
|
|
2751
|
-
this.enable = false;
|
|
2752
|
-
}
|
|
2038
|
+
enable = false;
|
|
2039
|
+
mode = "destination-out";
|
|
2753
2040
|
load(data) {
|
|
2754
2041
|
if (isNull(data)) {
|
|
2755
2042
|
return;
|
|
2756
2043
|
}
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
}
|
|
2760
|
-
if (data.enable !== undefined) {
|
|
2761
|
-
this.enable = data.enable;
|
|
2762
|
-
}
|
|
2044
|
+
loadProperty(this, "mode", data.mode);
|
|
2045
|
+
loadProperty(this, "enable", data.enable);
|
|
2763
2046
|
}
|
|
2764
2047
|
}
|
|
2765
2048
|
|
|
@@ -2789,7 +2072,7 @@
|
|
|
2789
2072
|
}
|
|
2790
2073
|
|
|
2791
2074
|
async function loadBlendPlugin(engine) {
|
|
2792
|
-
engine.checkVersion("4.
|
|
2075
|
+
engine.checkVersion("4.2.0");
|
|
2793
2076
|
await engine.pluginManager.register(e => {
|
|
2794
2077
|
e.pluginManager.addPlugin(new BlendPlugin());
|
|
2795
2078
|
});
|
|
@@ -2826,7 +2109,7 @@
|
|
|
2826
2109
|
}
|
|
2827
2110
|
|
|
2828
2111
|
async function loadCircleShape(engine) {
|
|
2829
|
-
engine.checkVersion("4.
|
|
2112
|
+
engine.checkVersion("4.2.0");
|
|
2830
2113
|
await engine.pluginManager.register(e => {
|
|
2831
2114
|
e.pluginManager.addShape(["circle"], () => {
|
|
2832
2115
|
return Promise.resolve(new CircleDrawer());
|
|
@@ -2874,7 +2157,7 @@
|
|
|
2874
2157
|
}
|
|
2875
2158
|
|
|
2876
2159
|
async function loadHexColorPlugin(engine) {
|
|
2877
|
-
engine.checkVersion("4.
|
|
2160
|
+
engine.checkVersion("4.2.0");
|
|
2878
2161
|
await engine.pluginManager.register(e => {
|
|
2879
2162
|
e.pluginManager.addColorManager("hex", new HexColorManager());
|
|
2880
2163
|
});
|
|
@@ -2927,7 +2210,7 @@
|
|
|
2927
2210
|
}
|
|
2928
2211
|
|
|
2929
2212
|
async function loadHslColorPlugin(engine) {
|
|
2930
|
-
engine.checkVersion("4.
|
|
2213
|
+
engine.checkVersion("4.2.0");
|
|
2931
2214
|
await engine.pluginManager.register(e => {
|
|
2932
2215
|
e.pluginManager.addColorManager("hsl", new HslColorManager());
|
|
2933
2216
|
});
|
|
@@ -2945,55 +2228,161 @@
|
|
|
2945
2228
|
}
|
|
2946
2229
|
loadOptions() {
|
|
2947
2230
|
}
|
|
2948
|
-
needsPlugin() {
|
|
2949
|
-
return true;
|
|
2231
|
+
needsPlugin() {
|
|
2232
|
+
return true;
|
|
2233
|
+
}
|
|
2234
|
+
}
|
|
2235
|
+
|
|
2236
|
+
async function loadMovePlugin(engine) {
|
|
2237
|
+
engine.checkVersion("4.2.0");
|
|
2238
|
+
await engine.pluginManager.register(e => {
|
|
2239
|
+
const moveEngine = e, movePluginManager = moveEngine.pluginManager;
|
|
2240
|
+
movePluginManager.initializers.pathGenerators ??= new Map();
|
|
2241
|
+
movePluginManager.pathGenerators ??= new Map();
|
|
2242
|
+
movePluginManager.addPathGenerator = (name, generator) => {
|
|
2243
|
+
movePluginManager.initializers.pathGenerators ??= new Map();
|
|
2244
|
+
movePluginManager.initializers.pathGenerators.set(name, generator);
|
|
2245
|
+
};
|
|
2246
|
+
movePluginManager.getPathGenerators = async (container, force = false) => {
|
|
2247
|
+
movePluginManager.initializers.pathGenerators ??= new Map();
|
|
2248
|
+
movePluginManager.pathGenerators ??= new Map();
|
|
2249
|
+
return getItemMapFromInitializer(container, movePluginManager.pathGenerators, movePluginManager.initializers.pathGenerators, force);
|
|
2250
|
+
};
|
|
2251
|
+
e.pluginManager.addPlugin(new MovePlugin(e.pluginManager));
|
|
2252
|
+
});
|
|
2253
|
+
}
|
|
2254
|
+
|
|
2255
|
+
function checkDestroy(particle, destroyType, value, minValue, maxValue) {
|
|
2256
|
+
switch (destroyType) {
|
|
2257
|
+
case DestroyType.max:
|
|
2258
|
+
if (value >= maxValue) {
|
|
2259
|
+
particle.destroy();
|
|
2260
|
+
}
|
|
2261
|
+
break;
|
|
2262
|
+
case DestroyType.min:
|
|
2263
|
+
if (value <= minValue) {
|
|
2264
|
+
particle.destroy();
|
|
2265
|
+
}
|
|
2266
|
+
break;
|
|
2267
|
+
}
|
|
2268
|
+
}
|
|
2269
|
+
function initParticleNumericAnimationValue(options, pxRatio) {
|
|
2270
|
+
const valueRange = options.value, animationOptions = options.animation, res = {
|
|
2271
|
+
delayTime: getRangeValue(animationOptions.delay) * millisecondsToSeconds,
|
|
2272
|
+
enable: animationOptions.enable,
|
|
2273
|
+
value: getRangeValue(options.value) * pxRatio,
|
|
2274
|
+
max: getRangeMax(valueRange) * pxRatio,
|
|
2275
|
+
min: getRangeMin(valueRange) * pxRatio,
|
|
2276
|
+
loops: 0,
|
|
2277
|
+
maxLoops: getRangeValue(animationOptions.count),
|
|
2278
|
+
time: 0,
|
|
2279
|
+
}, decayOffset = 1;
|
|
2280
|
+
if (animationOptions.enable) {
|
|
2281
|
+
res.decay = decayOffset - getRangeValue(animationOptions.decay);
|
|
2282
|
+
switch (animationOptions.mode) {
|
|
2283
|
+
case AnimationMode.increase:
|
|
2284
|
+
res.status = AnimationStatus.increasing;
|
|
2285
|
+
break;
|
|
2286
|
+
case AnimationMode.decrease:
|
|
2287
|
+
res.status = AnimationStatus.decreasing;
|
|
2288
|
+
break;
|
|
2289
|
+
case AnimationMode.random:
|
|
2290
|
+
res.status = getRandom() >= half ? AnimationStatus.increasing : AnimationStatus.decreasing;
|
|
2291
|
+
break;
|
|
2292
|
+
}
|
|
2293
|
+
const autoStatus = animationOptions.mode === AnimationMode.auto;
|
|
2294
|
+
switch (animationOptions.startValue) {
|
|
2295
|
+
case StartValueType.min:
|
|
2296
|
+
res.value = res.min;
|
|
2297
|
+
if (autoStatus) {
|
|
2298
|
+
res.status = AnimationStatus.increasing;
|
|
2299
|
+
}
|
|
2300
|
+
break;
|
|
2301
|
+
case StartValueType.max:
|
|
2302
|
+
res.value = res.max;
|
|
2303
|
+
if (autoStatus) {
|
|
2304
|
+
res.status = AnimationStatus.decreasing;
|
|
2305
|
+
}
|
|
2306
|
+
break;
|
|
2307
|
+
case StartValueType.random:
|
|
2308
|
+
default:
|
|
2309
|
+
res.value = randomInRangeValue(res);
|
|
2310
|
+
if (autoStatus) {
|
|
2311
|
+
res.status = getRandom() >= half ? AnimationStatus.increasing : AnimationStatus.decreasing;
|
|
2312
|
+
}
|
|
2313
|
+
break;
|
|
2314
|
+
}
|
|
2315
|
+
}
|
|
2316
|
+
res.initialValue = res.value;
|
|
2317
|
+
return res;
|
|
2318
|
+
}
|
|
2319
|
+
function updateAnimation(particle, data, changeDirection, destroyType, delta) {
|
|
2320
|
+
const minLoops = 0, minDelay = 0, identity = 1, minVelocity = 0, minDecay = 1;
|
|
2321
|
+
if (particle.destroyed ||
|
|
2322
|
+
!data.enable ||
|
|
2323
|
+
((data.maxLoops ?? minLoops) > minLoops && (data.loops ?? minLoops) > (data.maxLoops ?? minLoops))) {
|
|
2324
|
+
return;
|
|
2325
|
+
}
|
|
2326
|
+
const velocity = (data.velocity ?? minVelocity) * delta.factor, minValue = data.min, maxValue = data.max, decay = data.decay ?? minDecay;
|
|
2327
|
+
data.time ??= 0;
|
|
2328
|
+
const delayTime = data.delayTime ?? minDelay;
|
|
2329
|
+
if (delayTime > minDelay && data.time < delayTime) {
|
|
2330
|
+
data.time += delta.value;
|
|
2331
|
+
if (data.time < delayTime) {
|
|
2332
|
+
return;
|
|
2333
|
+
}
|
|
2334
|
+
}
|
|
2335
|
+
switch (data.status) {
|
|
2336
|
+
case AnimationStatus.increasing:
|
|
2337
|
+
data.value += velocity;
|
|
2338
|
+
break;
|
|
2339
|
+
case AnimationStatus.decreasing:
|
|
2340
|
+
data.value -= velocity;
|
|
2341
|
+
break;
|
|
2342
|
+
}
|
|
2343
|
+
if (data.velocity && decay !== identity) {
|
|
2344
|
+
data.velocity *= decay;
|
|
2345
|
+
}
|
|
2346
|
+
switch (data.status) {
|
|
2347
|
+
case AnimationStatus.increasing:
|
|
2348
|
+
if (data.value >= maxValue) {
|
|
2349
|
+
{
|
|
2350
|
+
data.status = AnimationStatus.decreasing;
|
|
2351
|
+
}
|
|
2352
|
+
data.loops ??= minLoops;
|
|
2353
|
+
data.loops++;
|
|
2354
|
+
}
|
|
2355
|
+
break;
|
|
2356
|
+
case AnimationStatus.decreasing:
|
|
2357
|
+
if (data.value <= minValue) {
|
|
2358
|
+
{
|
|
2359
|
+
data.status = AnimationStatus.increasing;
|
|
2360
|
+
}
|
|
2361
|
+
data.loops ??= minLoops;
|
|
2362
|
+
data.loops++;
|
|
2363
|
+
}
|
|
2364
|
+
break;
|
|
2365
|
+
}
|
|
2366
|
+
checkDestroy(particle, destroyType, data.value, minValue, maxValue);
|
|
2367
|
+
if (!particle.destroyed) {
|
|
2368
|
+
data.value = clamp(data.value, minValue, maxValue);
|
|
2950
2369
|
}
|
|
2951
2370
|
}
|
|
2952
2371
|
|
|
2953
|
-
async function loadMovePlugin(engine) {
|
|
2954
|
-
engine.checkVersion("4.1.2");
|
|
2955
|
-
await engine.pluginManager.register(e => {
|
|
2956
|
-
const moveEngine = e, movePluginManager = moveEngine.pluginManager;
|
|
2957
|
-
movePluginManager.initializers.pathGenerators ??= new Map();
|
|
2958
|
-
movePluginManager.pathGenerators ??= new Map();
|
|
2959
|
-
movePluginManager.addPathGenerator = (name, generator) => {
|
|
2960
|
-
movePluginManager.initializers.pathGenerators ??= new Map();
|
|
2961
|
-
movePluginManager.initializers.pathGenerators.set(name, generator);
|
|
2962
|
-
};
|
|
2963
|
-
movePluginManager.getPathGenerators = async (container, force = false) => {
|
|
2964
|
-
movePluginManager.initializers.pathGenerators ??= new Map();
|
|
2965
|
-
movePluginManager.pathGenerators ??= new Map();
|
|
2966
|
-
return getItemMapFromInitializer(container, movePluginManager.pathGenerators, movePluginManager.initializers.pathGenerators, force);
|
|
2967
|
-
};
|
|
2968
|
-
e.pluginManager.addPlugin(new MovePlugin(e.pluginManager));
|
|
2969
|
-
});
|
|
2970
|
-
}
|
|
2971
|
-
|
|
2972
2372
|
class OpacityAnimation extends RangedAnimationOptions {
|
|
2973
|
-
destroy;
|
|
2974
|
-
constructor() {
|
|
2975
|
-
super();
|
|
2976
|
-
this.destroy = DestroyType.none;
|
|
2977
|
-
this.speed = 2;
|
|
2978
|
-
}
|
|
2373
|
+
destroy = DestroyType.none;
|
|
2979
2374
|
load(data) {
|
|
2980
2375
|
super.load(data);
|
|
2981
2376
|
if (isNull(data)) {
|
|
2982
2377
|
return;
|
|
2983
2378
|
}
|
|
2984
|
-
|
|
2985
|
-
this.destroy = data.destroy;
|
|
2986
|
-
}
|
|
2379
|
+
loadProperty(this, "destroy", data.destroy);
|
|
2987
2380
|
}
|
|
2988
2381
|
}
|
|
2989
2382
|
|
|
2990
2383
|
class Opacity extends RangedAnimationValueWithRandom {
|
|
2991
|
-
animation;
|
|
2992
|
-
|
|
2993
|
-
super();
|
|
2994
|
-
this.animation = new OpacityAnimation();
|
|
2995
|
-
this.value = 1;
|
|
2996
|
-
}
|
|
2384
|
+
animation = new OpacityAnimation();
|
|
2385
|
+
value = 1;
|
|
2997
2386
|
load(data) {
|
|
2998
2387
|
if (isNull(data)) {
|
|
2999
2388
|
return;
|
|
@@ -3037,10 +2426,7 @@
|
|
|
3037
2426
|
(particle.opacity.loops ?? none) < (particle.opacity.maxLoops ?? none))));
|
|
3038
2427
|
}
|
|
3039
2428
|
loadOptions(options, ...sources) {
|
|
3040
|
-
options
|
|
3041
|
-
for (const source of sources) {
|
|
3042
|
-
options.opacity.load(source?.opacity);
|
|
3043
|
-
}
|
|
2429
|
+
loadOptionProperty(options, "opacity", Opacity, ...sources);
|
|
3044
2430
|
}
|
|
3045
2431
|
reset(particle) {
|
|
3046
2432
|
if (!particle.opacity) {
|
|
@@ -3058,7 +2444,7 @@
|
|
|
3058
2444
|
}
|
|
3059
2445
|
|
|
3060
2446
|
async function loadOpacityUpdater(engine) {
|
|
3061
|
-
engine.checkVersion("4.
|
|
2447
|
+
engine.checkVersion("4.2.0");
|
|
3062
2448
|
await engine.pluginManager.register(e => {
|
|
3063
2449
|
e.pluginManager.addParticleUpdater("opacity", container => {
|
|
3064
2450
|
return Promise.resolve(new OpacityUpdater(container));
|
|
@@ -3066,7 +2452,7 @@
|
|
|
3066
2452
|
});
|
|
3067
2453
|
}
|
|
3068
2454
|
|
|
3069
|
-
const
|
|
2455
|
+
const boundsMin = 0;
|
|
3070
2456
|
function bounceHorizontal(data) {
|
|
3071
2457
|
if ((data.outMode !== OutMode.bounce && data.outMode !== OutMode.split) ||
|
|
3072
2458
|
(data.direction !== OutModeDirection.left && data.direction !== OutModeDirection.right)) {
|
|
@@ -3081,8 +2467,8 @@
|
|
|
3081
2467
|
const velocity = data.particle.velocity.x;
|
|
3082
2468
|
let bounced = false;
|
|
3083
2469
|
if (data.outOfCanvas &&
|
|
3084
|
-
((data.direction === OutModeDirection.right && velocity > minVelocity
|
|
3085
|
-
(data.direction === OutModeDirection.left && velocity < minVelocity
|
|
2470
|
+
((data.direction === OutModeDirection.right && velocity > minVelocity) ||
|
|
2471
|
+
(data.direction === OutModeDirection.left && velocity < minVelocity))) {
|
|
3086
2472
|
const newVelocity = getRangeValue(data.particle.options.bounce.horizontal.value);
|
|
3087
2473
|
data.particle.velocity.x *= -newVelocity;
|
|
3088
2474
|
bounced = true;
|
|
@@ -3115,8 +2501,8 @@
|
|
|
3115
2501
|
const velocity = data.particle.velocity.y;
|
|
3116
2502
|
let bounced = false;
|
|
3117
2503
|
if (data.outOfCanvas &&
|
|
3118
|
-
((data.direction === OutModeDirection.bottom && velocity > minVelocity
|
|
3119
|
-
(data.direction === OutModeDirection.top && velocity < minVelocity
|
|
2504
|
+
((data.direction === OutModeDirection.bottom && velocity > minVelocity) ||
|
|
2505
|
+
(data.direction === OutModeDirection.top && velocity < minVelocity))) {
|
|
3120
2506
|
const newVelocity = getRangeValue(data.particle.options.bounce.vertical.value);
|
|
3121
2507
|
data.particle.velocity.y *= -newVelocity;
|
|
3122
2508
|
bounced = true;
|
|
@@ -3169,7 +2555,6 @@
|
|
|
3169
2555
|
}
|
|
3170
2556
|
}
|
|
3171
2557
|
|
|
3172
|
-
const minVelocity$3 = 0;
|
|
3173
2558
|
class DestroyOutMode {
|
|
3174
2559
|
modes;
|
|
3175
2560
|
constructor(_container) {
|
|
@@ -3188,10 +2573,10 @@
|
|
|
3188
2573
|
break;
|
|
3189
2574
|
case ParticleOutType.inside: {
|
|
3190
2575
|
const { dx, dy } = getDistances(particle.position, particle.moveCenter), { x: vx, y: vy } = particle.velocity;
|
|
3191
|
-
if ((vx < minVelocity
|
|
3192
|
-
(vy < minVelocity
|
|
3193
|
-
(vx >= minVelocity
|
|
3194
|
-
(vy >= minVelocity
|
|
2576
|
+
if ((vx < minVelocity && dx > particle.moveCenter.radius) ||
|
|
2577
|
+
(vy < minVelocity && dy > particle.moveCenter.radius) ||
|
|
2578
|
+
(vx >= minVelocity && dx < -particle.moveCenter.radius) ||
|
|
2579
|
+
(vy >= minVelocity && dy < -particle.moveCenter.radius)) {
|
|
3195
2580
|
return;
|
|
3196
2581
|
}
|
|
3197
2582
|
break;
|
|
@@ -3201,7 +2586,6 @@
|
|
|
3201
2586
|
}
|
|
3202
2587
|
}
|
|
3203
2588
|
|
|
3204
|
-
const minVelocity$2 = 0;
|
|
3205
2589
|
class NoneOutMode {
|
|
3206
2590
|
modes;
|
|
3207
2591
|
#container;
|
|
@@ -3221,10 +2605,10 @@
|
|
|
3221
2605
|
}
|
|
3222
2606
|
const gravityOptions = particle.options.move.gravity, container = this.#container, canvasSize = container.canvas.size, pRadius = particle.getRadius();
|
|
3223
2607
|
if (!gravityOptions.enable) {
|
|
3224
|
-
if ((particle.velocity.y > minVelocity
|
|
3225
|
-
(particle.velocity.y < minVelocity
|
|
3226
|
-
(particle.velocity.x > minVelocity
|
|
3227
|
-
(particle.velocity.x < minVelocity
|
|
2608
|
+
if ((particle.velocity.y > minVelocity && particle.position.y <= canvasSize.height + pRadius) ||
|
|
2609
|
+
(particle.velocity.y < minVelocity && particle.position.y >= -pRadius) ||
|
|
2610
|
+
(particle.velocity.x > minVelocity && particle.position.x <= canvasSize.width + pRadius) ||
|
|
2611
|
+
(particle.velocity.x < minVelocity && particle.position.x >= -pRadius)) {
|
|
3228
2612
|
return;
|
|
3229
2613
|
}
|
|
3230
2614
|
if (!isPointInside(particle.position, container.canvas.size, originPoint, pRadius, direction)) {
|
|
@@ -3243,7 +2627,7 @@
|
|
|
3243
2627
|
}
|
|
3244
2628
|
}
|
|
3245
2629
|
|
|
3246
|
-
const
|
|
2630
|
+
const updateVector = Vector.origin;
|
|
3247
2631
|
class OutOutMode {
|
|
3248
2632
|
modes;
|
|
3249
2633
|
#container;
|
|
@@ -3264,10 +2648,10 @@
|
|
|
3264
2648
|
updateVector.angle = particle.velocity.angle + Math.PI;
|
|
3265
2649
|
updateVector.addTo(particle.moveCenter);
|
|
3266
2650
|
const { dx, dy } = getDistances(particle.position, updateVector);
|
|
3267
|
-
if ((vx <= minVelocity
|
|
3268
|
-
(vy <= minVelocity
|
|
3269
|
-
(vx >= minVelocity
|
|
3270
|
-
(vy >= minVelocity
|
|
2651
|
+
if ((vx <= minVelocity && dx >= minDistance) ||
|
|
2652
|
+
(vy <= minVelocity && dy >= minDistance) ||
|
|
2653
|
+
(vx >= minVelocity && dx <= minDistance) ||
|
|
2654
|
+
(vy >= minVelocity && dy <= minDistance)) {
|
|
3271
2655
|
return;
|
|
3272
2656
|
}
|
|
3273
2657
|
particle.position.x = Math.floor(randomInRangeValue({
|
|
@@ -3391,21 +2775,21 @@
|
|
|
3391
2775
|
this.#updateOutMode(particle, delta, outModes.right ?? outModes.default, OutModeDirection.right);
|
|
3392
2776
|
this.#updateOutMode(particle, delta, outModes.top ?? outModes.default, OutModeDirection.top);
|
|
3393
2777
|
}
|
|
3394
|
-
#addUpdaterIfMissing
|
|
2778
|
+
#addUpdaterIfMissing(particle, outMode, getUpdater) {
|
|
3395
2779
|
const outModes = particle.options.move.outModes;
|
|
3396
2780
|
if (!this.updaters.has(outMode) && checkOutMode(outModes, outMode)) {
|
|
3397
2781
|
this.updaters.set(outMode, getUpdater(this.#container));
|
|
3398
2782
|
}
|
|
3399
|
-
}
|
|
3400
|
-
#updateOutMode
|
|
2783
|
+
}
|
|
2784
|
+
#updateOutMode(particle, delta, outMode, direction) {
|
|
3401
2785
|
for (const updater of this.updaters.values()) {
|
|
3402
2786
|
updater.update(particle, direction, delta, outMode);
|
|
3403
2787
|
}
|
|
3404
|
-
}
|
|
2788
|
+
}
|
|
3405
2789
|
}
|
|
3406
2790
|
|
|
3407
2791
|
async function loadOutModesUpdater(engine) {
|
|
3408
|
-
engine.checkVersion("4.
|
|
2792
|
+
engine.checkVersion("4.2.0");
|
|
3409
2793
|
await engine.pluginManager.register(e => {
|
|
3410
2794
|
e.pluginManager.addParticleUpdater("outModes", container => {
|
|
3411
2795
|
return Promise.resolve(new OutOfCanvasUpdater(container));
|
|
@@ -3476,7 +2860,7 @@
|
|
|
3476
2860
|
}
|
|
3477
2861
|
|
|
3478
2862
|
async function loadPaintUpdater(engine) {
|
|
3479
|
-
engine.checkVersion("4.
|
|
2863
|
+
engine.checkVersion("4.2.0");
|
|
3480
2864
|
await engine.pluginManager.register(e => {
|
|
3481
2865
|
e.pluginManager.addParticleUpdater("paint", container => {
|
|
3482
2866
|
return Promise.resolve(new PaintUpdater(e.pluginManager, container));
|
|
@@ -3531,37 +2915,26 @@
|
|
|
3531
2915
|
}
|
|
3532
2916
|
|
|
3533
2917
|
async function loadRgbColorPlugin(engine) {
|
|
3534
|
-
engine.checkVersion("4.
|
|
2918
|
+
engine.checkVersion("4.2.0");
|
|
3535
2919
|
await engine.pluginManager.register(e => {
|
|
3536
2920
|
e.pluginManager.addColorManager("rgb", new RgbColorManager());
|
|
3537
2921
|
});
|
|
3538
2922
|
}
|
|
3539
2923
|
|
|
3540
2924
|
class SizeAnimation extends RangedAnimationOptions {
|
|
3541
|
-
destroy;
|
|
3542
|
-
constructor() {
|
|
3543
|
-
super();
|
|
3544
|
-
this.destroy = DestroyType.none;
|
|
3545
|
-
this.speed = 5;
|
|
3546
|
-
}
|
|
2925
|
+
destroy = DestroyType.none;
|
|
3547
2926
|
load(data) {
|
|
3548
2927
|
super.load(data);
|
|
3549
2928
|
if (isNull(data)) {
|
|
3550
2929
|
return;
|
|
3551
2930
|
}
|
|
3552
|
-
|
|
3553
|
-
this.destroy = data.destroy;
|
|
3554
|
-
}
|
|
2931
|
+
loadProperty(this, "destroy", data.destroy);
|
|
3555
2932
|
}
|
|
3556
2933
|
}
|
|
3557
2934
|
|
|
3558
2935
|
class Size extends RangedAnimationValueWithRandom {
|
|
3559
|
-
animation;
|
|
3560
|
-
|
|
3561
|
-
super();
|
|
3562
|
-
this.animation = new SizeAnimation();
|
|
3563
|
-
this.value = 3;
|
|
3564
|
-
}
|
|
2936
|
+
animation = new SizeAnimation();
|
|
2937
|
+
value = 3;
|
|
3565
2938
|
load(data) {
|
|
3566
2939
|
super.load(data);
|
|
3567
2940
|
if (isNull(data)) {
|
|
@@ -3604,10 +2977,7 @@
|
|
|
3604
2977
|
(particle.size.loops ?? minLoops) < (particle.size.maxLoops ?? minLoops))));
|
|
3605
2978
|
}
|
|
3606
2979
|
loadOptions(options, ...sources) {
|
|
3607
|
-
options
|
|
3608
|
-
for (const source of sources) {
|
|
3609
|
-
options.size.load(source?.size);
|
|
3610
|
-
}
|
|
2980
|
+
loadOptionProperty(options, "size", Size, ...sources);
|
|
3611
2981
|
}
|
|
3612
2982
|
preInit(particle) {
|
|
3613
2983
|
const pxRatio = this.#container.retina.pixelRatio, options = particle.options, sizeOptions = options.size;
|
|
@@ -3630,7 +3000,7 @@
|
|
|
3630
3000
|
}
|
|
3631
3001
|
|
|
3632
3002
|
async function loadSizeUpdater(engine) {
|
|
3633
|
-
engine.checkVersion("4.
|
|
3003
|
+
engine.checkVersion("4.2.0");
|
|
3634
3004
|
await engine.pluginManager.register(e => {
|
|
3635
3005
|
e.pluginManager.addParticleUpdater("size", container => {
|
|
3636
3006
|
return Promise.resolve(new SizeUpdater(container));
|
|
@@ -3639,7 +3009,7 @@
|
|
|
3639
3009
|
}
|
|
3640
3010
|
|
|
3641
3011
|
async function loadBasic(engine) {
|
|
3642
|
-
engine.checkVersion("4.
|
|
3012
|
+
engine.checkVersion("4.2.0");
|
|
3643
3013
|
await engine.pluginManager.register(async (e) => {
|
|
3644
3014
|
await Promise.all([
|
|
3645
3015
|
loadBlendPlugin(e),
|
|
@@ -3807,7 +3177,7 @@
|
|
|
3807
3177
|
return;
|
|
3808
3178
|
}
|
|
3809
3179
|
this.draw(ctx => {
|
|
3810
|
-
|
|
3180
|
+
ctx.clearRect(originPoint.x, originPoint.y, this.#canvasManager.size.width, this.#canvasManager.size.height);
|
|
3811
3181
|
});
|
|
3812
3182
|
}
|
|
3813
3183
|
clear() {
|
|
@@ -3869,7 +3239,7 @@
|
|
|
3869
3239
|
plugin.drawParticleSetup?.(context, particle, delta);
|
|
3870
3240
|
}
|
|
3871
3241
|
this.#applyPreDrawUpdaters(context, particle, radius, opacity, colorStyles, transform);
|
|
3872
|
-
drawParticle({
|
|
3242
|
+
this.#drawParticle({
|
|
3873
3243
|
container,
|
|
3874
3244
|
context,
|
|
3875
3245
|
particle,
|
|
@@ -3888,7 +3258,7 @@
|
|
|
3888
3258
|
drawParticlePlugins(particle, delta) {
|
|
3889
3259
|
this.draw(ctx => {
|
|
3890
3260
|
for (const plugin of this.#drawParticlePlugins) {
|
|
3891
|
-
drawParticlePlugin(ctx, plugin, particle, delta);
|
|
3261
|
+
this.#drawParticlePlugin(ctx, plugin, particle, delta);
|
|
3892
3262
|
}
|
|
3893
3263
|
});
|
|
3894
3264
|
}
|
|
@@ -3988,12 +3358,19 @@
|
|
|
3988
3358
|
}
|
|
3989
3359
|
paintBase(baseColor) {
|
|
3990
3360
|
this.draw(ctx => {
|
|
3991
|
-
|
|
3361
|
+
ctx.fillStyle = baseColor ?? "rgba(0,0,0,0)";
|
|
3362
|
+
ctx.fillRect(originPoint.x, originPoint.y, this.#canvasManager.size.width, this.#canvasManager.size.height);
|
|
3992
3363
|
});
|
|
3993
3364
|
}
|
|
3994
3365
|
paintImage(image, opacity) {
|
|
3995
3366
|
this.draw(ctx => {
|
|
3996
|
-
|
|
3367
|
+
if (!image) {
|
|
3368
|
+
return;
|
|
3369
|
+
}
|
|
3370
|
+
const prevAlpha = ctx.globalAlpha;
|
|
3371
|
+
ctx.globalAlpha = opacity;
|
|
3372
|
+
ctx.drawImage(image, originPoint.x, originPoint.y, this.#canvasManager.size.width, this.#canvasManager.size.height);
|
|
3373
|
+
ctx.globalAlpha = prevAlpha;
|
|
3997
3374
|
});
|
|
3998
3375
|
}
|
|
3999
3376
|
setContext(context) {
|
|
@@ -4007,15 +3384,15 @@
|
|
|
4007
3384
|
}
|
|
4008
3385
|
stop() {
|
|
4009
3386
|
this.draw(ctx => {
|
|
4010
|
-
|
|
3387
|
+
ctx.clearRect(originPoint.x, originPoint.y, this.#canvasManager.size.width, this.#canvasManager.size.height);
|
|
4011
3388
|
});
|
|
4012
3389
|
}
|
|
4013
|
-
#applyPostDrawUpdaters
|
|
3390
|
+
#applyPostDrawUpdaters(particle) {
|
|
4014
3391
|
for (const updater of this.#postDrawUpdaters) {
|
|
4015
3392
|
updater.afterDraw?.(particle);
|
|
4016
3393
|
}
|
|
4017
|
-
}
|
|
4018
|
-
#applyPreDrawUpdaters
|
|
3394
|
+
}
|
|
3395
|
+
#applyPreDrawUpdaters(ctx, particle, radius, zOpacity, colorStyles, transform) {
|
|
4019
3396
|
for (const updater of this.#preDrawUpdaters) {
|
|
4020
3397
|
if (updater.getColorStyles) {
|
|
4021
3398
|
const { fill, stroke } = updater.getColorStyles(particle, ctx, radius, zOpacity);
|
|
@@ -4034,8 +3411,114 @@
|
|
|
4034
3411
|
}
|
|
4035
3412
|
updater.beforeDraw?.(particle);
|
|
4036
3413
|
}
|
|
4037
|
-
}
|
|
4038
|
-
#
|
|
3414
|
+
}
|
|
3415
|
+
#drawAfterEffect(drawer, data) {
|
|
3416
|
+
if (!drawer?.drawAfter) {
|
|
3417
|
+
return;
|
|
3418
|
+
}
|
|
3419
|
+
const { particle } = data;
|
|
3420
|
+
if (!particle.effect) {
|
|
3421
|
+
return;
|
|
3422
|
+
}
|
|
3423
|
+
drawer.drawAfter(data);
|
|
3424
|
+
}
|
|
3425
|
+
#drawBeforeEffect(drawer, data) {
|
|
3426
|
+
if (!drawer?.drawBefore) {
|
|
3427
|
+
return;
|
|
3428
|
+
}
|
|
3429
|
+
const { particle } = data;
|
|
3430
|
+
if (!particle.effect) {
|
|
3431
|
+
return;
|
|
3432
|
+
}
|
|
3433
|
+
drawer.drawBefore(data);
|
|
3434
|
+
}
|
|
3435
|
+
#drawParticle(data) {
|
|
3436
|
+
const { container, context, particle, delta, colorStyles, radius, opacity, transform } = data, { effectDrawers, shapeDrawers } = container, pos = particle.getPosition(), transformData = particle.getTransformData(transform), drawScale = defaultZoom, drawPosition = {
|
|
3437
|
+
x: pos.x,
|
|
3438
|
+
y: pos.y,
|
|
3439
|
+
};
|
|
3440
|
+
context.setTransform(transformData.a, transformData.b, transformData.c, transformData.d, pos.x, pos.y);
|
|
3441
|
+
if (colorStyles.fill) {
|
|
3442
|
+
context.fillStyle = colorStyles.fill;
|
|
3443
|
+
}
|
|
3444
|
+
const fillEnabled = !!particle.fillEnabled, strokeWidth = particle.strokeWidth ?? minStrokeWidth;
|
|
3445
|
+
context.lineWidth = strokeWidth;
|
|
3446
|
+
if (colorStyles.stroke) {
|
|
3447
|
+
context.strokeStyle = colorStyles.stroke;
|
|
3448
|
+
}
|
|
3449
|
+
const drawData = {
|
|
3450
|
+
context,
|
|
3451
|
+
particle,
|
|
3452
|
+
radius,
|
|
3453
|
+
drawRadius: radius * drawScale,
|
|
3454
|
+
opacity,
|
|
3455
|
+
delta,
|
|
3456
|
+
pixelRatio: container.retina.pixelRatio,
|
|
3457
|
+
fill: fillEnabled,
|
|
3458
|
+
stroke: strokeWidth > minStrokeWidth,
|
|
3459
|
+
transformData,
|
|
3460
|
+
position: { ...pos },
|
|
3461
|
+
drawPosition,
|
|
3462
|
+
drawScale,
|
|
3463
|
+
};
|
|
3464
|
+
for (const plugin of container.plugins) {
|
|
3465
|
+
plugin.drawParticleTransform?.(drawData);
|
|
3466
|
+
}
|
|
3467
|
+
const effect = particle.effect ? effectDrawers.get(particle.effect) : undefined, shape = particle.shape ? shapeDrawers.get(particle.shape) : undefined;
|
|
3468
|
+
this.#drawBeforeEffect(effect, drawData);
|
|
3469
|
+
this.#drawShapeBeforeDraw(shape, drawData);
|
|
3470
|
+
this.#drawShape(shape, drawData);
|
|
3471
|
+
this.#drawShapeAfterDraw(shape, drawData);
|
|
3472
|
+
this.#drawAfterEffect(effect, drawData);
|
|
3473
|
+
context.resetTransform();
|
|
3474
|
+
}
|
|
3475
|
+
#drawParticlePlugin(context, plugin, particle, delta) {
|
|
3476
|
+
if (!plugin.drawParticle) {
|
|
3477
|
+
return;
|
|
3478
|
+
}
|
|
3479
|
+
plugin.drawParticle(context, particle, delta);
|
|
3480
|
+
}
|
|
3481
|
+
#drawShape(drawer, data) {
|
|
3482
|
+
if (!drawer) {
|
|
3483
|
+
return;
|
|
3484
|
+
}
|
|
3485
|
+
const { context, fill, particle, stroke } = data;
|
|
3486
|
+
if (!particle.shape) {
|
|
3487
|
+
return;
|
|
3488
|
+
}
|
|
3489
|
+
context.beginPath();
|
|
3490
|
+
drawer.draw(data);
|
|
3491
|
+
if (particle.shapeClose) {
|
|
3492
|
+
context.closePath();
|
|
3493
|
+
}
|
|
3494
|
+
if (fill) {
|
|
3495
|
+
context.fill();
|
|
3496
|
+
}
|
|
3497
|
+
if (stroke) {
|
|
3498
|
+
context.stroke();
|
|
3499
|
+
}
|
|
3500
|
+
}
|
|
3501
|
+
#drawShapeAfterDraw(drawer, data) {
|
|
3502
|
+
if (!drawer?.afterDraw) {
|
|
3503
|
+
return;
|
|
3504
|
+
}
|
|
3505
|
+
const { particle } = data;
|
|
3506
|
+
if (!particle.shape) {
|
|
3507
|
+
return;
|
|
3508
|
+
}
|
|
3509
|
+
drawer.afterDraw(data);
|
|
3510
|
+
}
|
|
3511
|
+
#drawShapeBeforeDraw(drawer, data) {
|
|
3512
|
+
if (!drawer?.beforeDraw) {
|
|
3513
|
+
return;
|
|
3514
|
+
}
|
|
3515
|
+
const { particle } = data;
|
|
3516
|
+
if (!particle.shape) {
|
|
3517
|
+
return;
|
|
3518
|
+
}
|
|
3519
|
+
drawer.beforeDraw(data);
|
|
3520
|
+
}
|
|
3521
|
+
#getPluginParticleColors(particle) {
|
|
4039
3522
|
let fColor, sColor;
|
|
4040
3523
|
for (const plugin of this.#colorPlugins) {
|
|
4041
3524
|
if (!fColor && plugin.particleFillColor) {
|
|
@@ -4051,7 +3534,7 @@
|
|
|
4051
3534
|
this.#reusablePluginColors[fColorIndex] = fColor;
|
|
4052
3535
|
this.#reusablePluginColors[sColorIndex] = sColor;
|
|
4053
3536
|
return this.#reusablePluginColors;
|
|
4054
|
-
}
|
|
3537
|
+
}
|
|
4055
3538
|
}
|
|
4056
3539
|
|
|
4057
3540
|
const transferredCanvases = new WeakMap(), getTransferredCanvas = (canvas) => {
|
|
@@ -4183,6 +3666,7 @@
|
|
|
4183
3666
|
obs.observe(element, { attributes: true });
|
|
4184
3667
|
});
|
|
4185
3668
|
this.initPlugins();
|
|
3669
|
+
this.#initContext();
|
|
4186
3670
|
this.render.init();
|
|
4187
3671
|
}
|
|
4188
3672
|
initBackground() {
|
|
@@ -4192,7 +3676,7 @@
|
|
|
4192
3676
|
}
|
|
4193
3677
|
const elementStyle = element.style, color = rangeColorToRgb(this.#pluginManager, background.color);
|
|
4194
3678
|
if (color) {
|
|
4195
|
-
elementStyle.backgroundColor = getStyleFromRgb(color, container.hdr, background.opacity);
|
|
3679
|
+
elementStyle.backgroundColor = getStyleFromRgb(color, container.actualOptions.hdr, background.opacity);
|
|
4196
3680
|
}
|
|
4197
3681
|
else {
|
|
4198
3682
|
elementStyle.backgroundColor = "";
|
|
@@ -4214,7 +3698,7 @@
|
|
|
4214
3698
|
if (this.#generated && this.domElement) {
|
|
4215
3699
|
this.domElement.remove();
|
|
4216
3700
|
}
|
|
4217
|
-
const
|
|
3701
|
+
const domCanvas = isHtmlCanvasElement(canvas) ? canvas : undefined;
|
|
4218
3702
|
this.domElement = domCanvas;
|
|
4219
3703
|
this.#generated = domCanvas ? domCanvas.dataset[generatedAttribute] === "true" : false;
|
|
4220
3704
|
this.renderCanvas = domCanvas ? getTransferredCanvas(domCanvas) : canvas;
|
|
@@ -4235,26 +3719,6 @@
|
|
|
4235
3719
|
const pxRatio = this.#container.retina.pixelRatio, retinaSize = this.size;
|
|
4236
3720
|
renderCanvas.height = retinaSize.height = standardSize.height * pxRatio;
|
|
4237
3721
|
renderCanvas.width = retinaSize.width = standardSize.width * pxRatio;
|
|
4238
|
-
const canSupportHdrQuery = safeMatchMedia("(color-gamut: p3)");
|
|
4239
|
-
this.render.setContextSettings({
|
|
4240
|
-
alpha: true,
|
|
4241
|
-
colorSpace: canSupportHdrQuery?.matches && container.hdr ? "display-p3" : "srgb",
|
|
4242
|
-
desynchronized: true,
|
|
4243
|
-
willReadFrequently: false,
|
|
4244
|
-
});
|
|
4245
|
-
this.render.setContext(renderCanvas.getContext("2d", this.render.settings));
|
|
4246
|
-
this.#safeMutationObserver(obs => {
|
|
4247
|
-
obs.disconnect();
|
|
4248
|
-
});
|
|
4249
|
-
container.retina.init();
|
|
4250
|
-
this.initBackground();
|
|
4251
|
-
this.#safeMutationObserver(obs => {
|
|
4252
|
-
const element = this.domElement;
|
|
4253
|
-
if (!element || !(element instanceof Node)) {
|
|
4254
|
-
return;
|
|
4255
|
-
}
|
|
4256
|
-
obs.observe(element, { attributes: true });
|
|
4257
|
-
});
|
|
4258
3722
|
}
|
|
4259
3723
|
resize() {
|
|
4260
3724
|
const element = this.domElement;
|
|
@@ -4322,12 +3786,30 @@
|
|
|
4322
3786
|
await container.refresh();
|
|
4323
3787
|
}
|
|
4324
3788
|
}
|
|
4325
|
-
#applyResizePlugins
|
|
3789
|
+
#applyResizePlugins() {
|
|
4326
3790
|
for (const plugin of this.#resizePlugins) {
|
|
4327
3791
|
plugin.resize?.();
|
|
4328
3792
|
}
|
|
4329
|
-
}
|
|
4330
|
-
#
|
|
3793
|
+
}
|
|
3794
|
+
#initContext() {
|
|
3795
|
+
const container = this.#container, canSupportHdr = container.actualOptions.hdr &&
|
|
3796
|
+
safeMatchMedia("(color-gamut: p3)")?.matches &&
|
|
3797
|
+
safeMatchMedia("(dynamic-range: high)")?.matches;
|
|
3798
|
+
this.render.setContextSettings({
|
|
3799
|
+
alpha: true,
|
|
3800
|
+
desynchronized: true,
|
|
3801
|
+
willReadFrequently: false,
|
|
3802
|
+
...(canSupportHdr
|
|
3803
|
+
? { colorSpace: "display-p3", colorType: "float16" }
|
|
3804
|
+
: { colorSpace: "srgb" }),
|
|
3805
|
+
});
|
|
3806
|
+
const renderCanvas = this.renderCanvas;
|
|
3807
|
+
if (!renderCanvas) {
|
|
3808
|
+
return;
|
|
3809
|
+
}
|
|
3810
|
+
this.render.setContext(renderCanvas.getContext("2d", this.render.settings));
|
|
3811
|
+
}
|
|
3812
|
+
#initStyle() {
|
|
4331
3813
|
const element = this.domElement, options = this.#container.actualOptions;
|
|
4332
3814
|
if (!element) {
|
|
4333
3815
|
return;
|
|
@@ -4348,8 +3830,8 @@
|
|
|
4348
3830
|
}
|
|
4349
3831
|
element.style.setProperty(key, value, "important");
|
|
4350
3832
|
}
|
|
4351
|
-
}
|
|
4352
|
-
#repairStyle
|
|
3833
|
+
}
|
|
3834
|
+
#repairStyle() {
|
|
4353
3835
|
const element = this.domElement;
|
|
4354
3836
|
if (!element) {
|
|
4355
3837
|
return;
|
|
@@ -4368,27 +3850,27 @@
|
|
|
4368
3850
|
}
|
|
4369
3851
|
observer.observe(element, { attributes: true });
|
|
4370
3852
|
});
|
|
4371
|
-
}
|
|
4372
|
-
#resetOriginalStyle
|
|
3853
|
+
}
|
|
3854
|
+
#resetOriginalStyle() {
|
|
4373
3855
|
const element = this.domElement, originalStyle = this.#originalStyle;
|
|
4374
3856
|
if (!element || !originalStyle) {
|
|
4375
3857
|
return;
|
|
4376
3858
|
}
|
|
4377
3859
|
setStyle(element, originalStyle, true);
|
|
4378
|
-
}
|
|
4379
|
-
#safeMutationObserver
|
|
3860
|
+
}
|
|
3861
|
+
#safeMutationObserver(callback) {
|
|
4380
3862
|
if (!this.#mutationObserver) {
|
|
4381
3863
|
return;
|
|
4382
3864
|
}
|
|
4383
3865
|
callback(this.#mutationObserver);
|
|
4384
|
-
}
|
|
4385
|
-
#setFullScreenStyle
|
|
3866
|
+
}
|
|
3867
|
+
#setFullScreenStyle() {
|
|
4386
3868
|
const element = this.domElement;
|
|
4387
3869
|
if (!element) {
|
|
4388
3870
|
return;
|
|
4389
3871
|
}
|
|
4390
3872
|
setStyle(element, getFullScreenStyle(this.#container.actualOptions.fullScreen.zIndex), true);
|
|
4391
|
-
}
|
|
3873
|
+
}
|
|
4392
3874
|
}
|
|
4393
3875
|
|
|
4394
3876
|
class EventListeners {
|
|
@@ -4413,7 +3895,7 @@
|
|
|
4413
3895
|
removeListeners() {
|
|
4414
3896
|
this.#manageListeners(false);
|
|
4415
3897
|
}
|
|
4416
|
-
#handleVisibilityChange
|
|
3898
|
+
#handleVisibilityChange() {
|
|
4417
3899
|
const container = this.#container, options = container.actualOptions;
|
|
4418
3900
|
if (!options.pauseOnBlur) {
|
|
4419
3901
|
return;
|
|
@@ -4431,8 +3913,8 @@
|
|
|
4431
3913
|
container.draw(true);
|
|
4432
3914
|
}
|
|
4433
3915
|
}
|
|
4434
|
-
}
|
|
4435
|
-
#handleWindowResize
|
|
3916
|
+
}
|
|
3917
|
+
#handleWindowResize() {
|
|
4436
3918
|
if (this.#resizeTimeout) {
|
|
4437
3919
|
clearTimeout(this.#resizeTimeout);
|
|
4438
3920
|
this.#resizeTimeout = undefined;
|
|
@@ -4442,13 +3924,13 @@
|
|
|
4442
3924
|
await canvas.windowResize();
|
|
4443
3925
|
};
|
|
4444
3926
|
this.#resizeTimeout = setTimeout(() => void handleResize(), this.#container.actualOptions.resize.delay * millisecondsToSeconds);
|
|
4445
|
-
}
|
|
4446
|
-
#manageListeners
|
|
3927
|
+
}
|
|
3928
|
+
#manageListeners(add) {
|
|
4447
3929
|
const handlers = this.#handlers;
|
|
4448
3930
|
this.#manageResize(add);
|
|
4449
3931
|
manageListener(document, visibilityChangeEvent, handlers.visibilityChange, add, false);
|
|
4450
|
-
}
|
|
4451
|
-
#manageResize
|
|
3932
|
+
}
|
|
3933
|
+
#manageResize(add) {
|
|
4452
3934
|
const handlers = this.#handlers, container = this.#container, options = container.actualOptions;
|
|
4453
3935
|
if (!options.resize.enable) {
|
|
4454
3936
|
return;
|
|
@@ -4475,7 +3957,7 @@
|
|
|
4475
3957
|
});
|
|
4476
3958
|
this.#resizeObserver.observe(canvasEl);
|
|
4477
3959
|
}
|
|
4478
|
-
}
|
|
3960
|
+
}
|
|
4479
3961
|
}
|
|
4480
3962
|
|
|
4481
3963
|
function loadEffectData(effect, effectOptions, id, reduceDuplicates) {
|
|
@@ -4502,6 +3984,131 @@
|
|
|
4502
3984
|
data.setCb(data.radius);
|
|
4503
3985
|
}
|
|
4504
3986
|
}
|
|
3987
|
+
function normalizeAngle(angle, modulus) {
|
|
3988
|
+
const normalized = angle % modulus;
|
|
3989
|
+
return normalized < defaultAngle ? normalized + modulus : normalized;
|
|
3990
|
+
}
|
|
3991
|
+
function initParticleState(particle, id, group) {
|
|
3992
|
+
particle.id = id;
|
|
3993
|
+
particle.group = group;
|
|
3994
|
+
particle.justWarped = false;
|
|
3995
|
+
particle.effectClose = true;
|
|
3996
|
+
particle.shapeClose = true;
|
|
3997
|
+
particle.pathRotation = false;
|
|
3998
|
+
particle.lastPathTime = 0;
|
|
3999
|
+
particle.destroyed = false;
|
|
4000
|
+
particle.unbreakable = false;
|
|
4001
|
+
particle.isRotating = false;
|
|
4002
|
+
particle.rotation = 0;
|
|
4003
|
+
particle.misplaced = false;
|
|
4004
|
+
particle.retina = {
|
|
4005
|
+
maxDistance: {},
|
|
4006
|
+
maxSpeed: 0,
|
|
4007
|
+
moveDrift: 0,
|
|
4008
|
+
moveSpeed: 0,
|
|
4009
|
+
sizeAnimationSpeed: 0,
|
|
4010
|
+
};
|
|
4011
|
+
particle.size = {
|
|
4012
|
+
value: 1,
|
|
4013
|
+
max: 1,
|
|
4014
|
+
min: 1,
|
|
4015
|
+
enable: false,
|
|
4016
|
+
};
|
|
4017
|
+
particle.outType = ParticleOutType.normal;
|
|
4018
|
+
particle.ignoresResizeRatio = true;
|
|
4019
|
+
}
|
|
4020
|
+
function resolveParticleOptions(particle, container, pluginManager, overrideOptions) {
|
|
4021
|
+
const mainOptions = container.actualOptions, particlesOptions = loadParticlesOptions(pluginManager, container, mainOptions.particles), reduceDuplicates = particlesOptions.reduceDuplicates;
|
|
4022
|
+
particle.effect = itemFromSingleOrMultiple(particlesOptions.effect.type, particle.id, reduceDuplicates);
|
|
4023
|
+
particle.shape = itemFromSingleOrMultiple(particlesOptions.shape.type, particle.id, reduceDuplicates);
|
|
4024
|
+
const effectOptions = particlesOptions.effect, shapeOptions = particlesOptions.shape;
|
|
4025
|
+
if (overrideOptions) {
|
|
4026
|
+
if (overrideOptions.effect) {
|
|
4027
|
+
const overrideEffectType = overrideOptions.effect.type;
|
|
4028
|
+
if (overrideEffectType && overrideEffectType !== particle.effect) {
|
|
4029
|
+
const effect = itemFromSingleOrMultiple(overrideEffectType, particle.id, reduceDuplicates);
|
|
4030
|
+
if (effect) {
|
|
4031
|
+
particle.effect = effect;
|
|
4032
|
+
}
|
|
4033
|
+
}
|
|
4034
|
+
effectOptions.load(overrideOptions.effect);
|
|
4035
|
+
}
|
|
4036
|
+
if (overrideOptions.shape) {
|
|
4037
|
+
const overrideShapeType = overrideOptions.shape.type;
|
|
4038
|
+
if (overrideShapeType && overrideShapeType !== particle.shape) {
|
|
4039
|
+
const shape = itemFromSingleOrMultiple(overrideShapeType, particle.id, reduceDuplicates);
|
|
4040
|
+
if (shape) {
|
|
4041
|
+
particle.shape = shape;
|
|
4042
|
+
}
|
|
4043
|
+
}
|
|
4044
|
+
shapeOptions.load(overrideOptions.shape);
|
|
4045
|
+
}
|
|
4046
|
+
}
|
|
4047
|
+
if (particle.effect === randomColorValue) {
|
|
4048
|
+
const availableEffects = [...container.effectDrawers.keys()];
|
|
4049
|
+
particle.effect = availableEffects[Math.floor(getRandom() * availableEffects.length)];
|
|
4050
|
+
}
|
|
4051
|
+
if (particle.shape === randomColorValue) {
|
|
4052
|
+
const availableShapes = [...container.shapeDrawers.keys()];
|
|
4053
|
+
particle.shape = availableShapes[Math.floor(getRandom() * availableShapes.length)];
|
|
4054
|
+
}
|
|
4055
|
+
particle.effectData = particle.effect
|
|
4056
|
+
? loadEffectData(particle.effect, effectOptions, particle.id, reduceDuplicates)
|
|
4057
|
+
: undefined;
|
|
4058
|
+
particle.shapeData = particle.shape
|
|
4059
|
+
? loadShapeData(particle.shape, shapeOptions, particle.id, reduceDuplicates)
|
|
4060
|
+
: undefined;
|
|
4061
|
+
particlesOptions.load(overrideOptions);
|
|
4062
|
+
const effectData = particle.effectData, shapeData = particle.shapeData;
|
|
4063
|
+
if (effectData) {
|
|
4064
|
+
particlesOptions.load(effectData.particles);
|
|
4065
|
+
}
|
|
4066
|
+
if (shapeData) {
|
|
4067
|
+
particlesOptions.load(shapeData.particles);
|
|
4068
|
+
}
|
|
4069
|
+
particle.effectClose = effectData?.close ?? particlesOptions.effect.close;
|
|
4070
|
+
particle.shapeClose = shapeData?.close ?? particlesOptions.shape.close;
|
|
4071
|
+
return particlesOptions;
|
|
4072
|
+
}
|
|
4073
|
+
function initParticleDrawers(particle, container) {
|
|
4074
|
+
let effectDrawer, shapeDrawer;
|
|
4075
|
+
if (particle.effect) {
|
|
4076
|
+
effectDrawer = container.effectDrawers.get(particle.effect);
|
|
4077
|
+
}
|
|
4078
|
+
if (effectDrawer?.loadEffect) {
|
|
4079
|
+
effectDrawer.loadEffect(particle);
|
|
4080
|
+
}
|
|
4081
|
+
if (particle.shape) {
|
|
4082
|
+
shapeDrawer = container.shapeDrawers.get(particle.shape);
|
|
4083
|
+
}
|
|
4084
|
+
if (shapeDrawer?.loadShape) {
|
|
4085
|
+
shapeDrawer.loadShape(particle);
|
|
4086
|
+
}
|
|
4087
|
+
const sideCountFunc = shapeDrawer?.getSidesCount;
|
|
4088
|
+
if (sideCountFunc) {
|
|
4089
|
+
particle.sides = sideCountFunc(particle);
|
|
4090
|
+
}
|
|
4091
|
+
}
|
|
4092
|
+
function runUpdaterPreInit(updaters, particle) {
|
|
4093
|
+
for (const updater of updaters) {
|
|
4094
|
+
updater.preInit?.(particle);
|
|
4095
|
+
}
|
|
4096
|
+
}
|
|
4097
|
+
function runUpdaterInit(updaters, particle) {
|
|
4098
|
+
for (const updater of updaters) {
|
|
4099
|
+
updater.init(particle);
|
|
4100
|
+
}
|
|
4101
|
+
}
|
|
4102
|
+
function runDrawerInit(container, particle) {
|
|
4103
|
+
const shapeDrawer = particle.shape ? container.shapeDrawers.get(particle.shape) : undefined, effectDrawer = particle.effect ? container.effectDrawers.get(particle.effect) : undefined;
|
|
4104
|
+
effectDrawer?.particleInit?.(container, particle);
|
|
4105
|
+
shapeDrawer?.particleInit?.(container, particle);
|
|
4106
|
+
}
|
|
4107
|
+
function runParticleCreatedPlugins(container, particle) {
|
|
4108
|
+
for (const plugin of container.particleCreatedPlugins) {
|
|
4109
|
+
plugin.particleCreated?.(particle);
|
|
4110
|
+
}
|
|
4111
|
+
}
|
|
4505
4112
|
class Particle {
|
|
4506
4113
|
backColor;
|
|
4507
4114
|
bubble;
|
|
@@ -4627,88 +4234,20 @@
|
|
|
4627
4234
|
const rotateData = this.getRotateData(), rotating = this.isRotating;
|
|
4628
4235
|
this.#cachedTransform.a = rotateData.cos * (externalTransform.a ?? defaultTransform.a);
|
|
4629
4236
|
this.#cachedTransform.b = rotating
|
|
4630
|
-
? rotateData.sin * (externalTransform.b ?? identity
|
|
4237
|
+
? rotateData.sin * (externalTransform.b ?? identity)
|
|
4631
4238
|
: (externalTransform.b ?? defaultTransform.b);
|
|
4632
4239
|
this.#cachedTransform.c = rotating
|
|
4633
|
-
? -rotateData.sin * (externalTransform.c ?? identity
|
|
4240
|
+
? -rotateData.sin * (externalTransform.c ?? identity)
|
|
4634
4241
|
: (externalTransform.c ?? defaultTransform.c);
|
|
4635
4242
|
this.#cachedTransform.d = rotateData.cos * (externalTransform.d ?? defaultTransform.d);
|
|
4636
4243
|
return this.#cachedTransform;
|
|
4637
4244
|
}
|
|
4638
4245
|
init(id, position, overrideOptions, group) {
|
|
4639
4246
|
const container = this.#container;
|
|
4640
|
-
this
|
|
4641
|
-
this.
|
|
4642
|
-
this.justWarped = false;
|
|
4643
|
-
this.effectClose = true;
|
|
4644
|
-
this.shapeClose = true;
|
|
4645
|
-
this.pathRotation = false;
|
|
4646
|
-
this.lastPathTime = 0;
|
|
4647
|
-
this.destroyed = false;
|
|
4648
|
-
this.unbreakable = false;
|
|
4649
|
-
this.isRotating = false;
|
|
4650
|
-
this.rotation = 0;
|
|
4651
|
-
this.misplaced = false;
|
|
4652
|
-
this.retina = {
|
|
4653
|
-
maxDistance: {},
|
|
4654
|
-
maxSpeed: 0,
|
|
4655
|
-
moveDrift: 0,
|
|
4656
|
-
moveSpeed: 0,
|
|
4657
|
-
sizeAnimationSpeed: 0,
|
|
4658
|
-
};
|
|
4659
|
-
this.size = {
|
|
4660
|
-
value: 1,
|
|
4661
|
-
max: 1,
|
|
4662
|
-
min: 1,
|
|
4663
|
-
enable: false,
|
|
4664
|
-
};
|
|
4665
|
-
this.outType = ParticleOutType.normal;
|
|
4666
|
-
this.ignoresResizeRatio = true;
|
|
4667
|
-
const mainOptions = container.actualOptions, particlesOptions = loadParticlesOptions(this.#pluginManager, container, mainOptions.particles), reduceDuplicates = particlesOptions.reduceDuplicates, effectType = particlesOptions.effect.type, shapeType = particlesOptions.shape.type;
|
|
4668
|
-
this.effect = itemFromSingleOrMultiple(effectType, this.id, reduceDuplicates);
|
|
4669
|
-
this.shape = itemFromSingleOrMultiple(shapeType, this.id, reduceDuplicates);
|
|
4670
|
-
const effectOptions = particlesOptions.effect, shapeOptions = particlesOptions.shape;
|
|
4671
|
-
if (overrideOptions) {
|
|
4672
|
-
if (overrideOptions.effect?.type && overrideOptions.effect.type !== this.effect) {
|
|
4673
|
-
const overrideEffectType = overrideOptions.effect.type, effect = itemFromSingleOrMultiple(overrideEffectType, this.id, reduceDuplicates);
|
|
4674
|
-
if (effect) {
|
|
4675
|
-
this.effect = effect;
|
|
4676
|
-
effectOptions.load(overrideOptions.effect);
|
|
4677
|
-
}
|
|
4678
|
-
}
|
|
4679
|
-
if (overrideOptions.shape?.type && overrideOptions.shape.type !== this.shape) {
|
|
4680
|
-
const overrideShapeType = overrideOptions.shape.type, shape = itemFromSingleOrMultiple(overrideShapeType, this.id, reduceDuplicates);
|
|
4681
|
-
if (shape) {
|
|
4682
|
-
this.shape = shape;
|
|
4683
|
-
shapeOptions.load(overrideOptions.shape);
|
|
4684
|
-
}
|
|
4685
|
-
}
|
|
4686
|
-
}
|
|
4687
|
-
if (this.effect === randomColorValue) {
|
|
4688
|
-
const availableEffects = [...this.#container.effectDrawers.keys()];
|
|
4689
|
-
this.effect = availableEffects[Math.floor(getRandom() * availableEffects.length)];
|
|
4690
|
-
}
|
|
4691
|
-
if (this.shape === randomColorValue) {
|
|
4692
|
-
const availableShapes = [...this.#container.shapeDrawers.keys()];
|
|
4693
|
-
this.shape = availableShapes[Math.floor(getRandom() * availableShapes.length)];
|
|
4694
|
-
}
|
|
4695
|
-
this.effectData = this.effect ? loadEffectData(this.effect, effectOptions, this.id, reduceDuplicates) : undefined;
|
|
4696
|
-
this.shapeData = this.shape ? loadShapeData(this.shape, shapeOptions, this.id, reduceDuplicates) : undefined;
|
|
4697
|
-
particlesOptions.load(overrideOptions);
|
|
4698
|
-
const effectData = this.effectData, shapeData = this.shapeData;
|
|
4699
|
-
if (effectData) {
|
|
4700
|
-
particlesOptions.load(effectData.particles);
|
|
4701
|
-
}
|
|
4702
|
-
if (shapeData) {
|
|
4703
|
-
particlesOptions.load(shapeData.particles);
|
|
4704
|
-
}
|
|
4705
|
-
this.effectClose = effectData?.close ?? particlesOptions.effect.close;
|
|
4706
|
-
this.shapeClose = shapeData?.close ?? particlesOptions.shape.close;
|
|
4707
|
-
this.options = particlesOptions;
|
|
4247
|
+
initParticleState(this, id, group);
|
|
4248
|
+
this.options = resolveParticleOptions(this, container, this.#pluginManager, overrideOptions);
|
|
4708
4249
|
container.retina.initParticle(this);
|
|
4709
|
-
|
|
4710
|
-
updater.preInit?.(this);
|
|
4711
|
-
}
|
|
4250
|
+
runUpdaterPreInit(container.particleUpdaters, this);
|
|
4712
4251
|
this.bubble = {
|
|
4713
4252
|
inRange: false,
|
|
4714
4253
|
};
|
|
@@ -4721,32 +4260,11 @@
|
|
|
4721
4260
|
this.velocity = this.initialVelocity.copy();
|
|
4722
4261
|
this.zIndexFactor = this.position.z / container.zLayers;
|
|
4723
4262
|
this.sides = 24;
|
|
4724
|
-
|
|
4725
|
-
if (this.effect) {
|
|
4726
|
-
effectDrawer = container.effectDrawers.get(this.effect);
|
|
4727
|
-
}
|
|
4728
|
-
if (effectDrawer?.loadEffect) {
|
|
4729
|
-
effectDrawer.loadEffect(this);
|
|
4730
|
-
}
|
|
4731
|
-
if (this.shape) {
|
|
4732
|
-
shapeDrawer = container.shapeDrawers.get(this.shape);
|
|
4733
|
-
}
|
|
4734
|
-
if (shapeDrawer?.loadShape) {
|
|
4735
|
-
shapeDrawer.loadShape(this);
|
|
4736
|
-
}
|
|
4737
|
-
const sideCountFunc = shapeDrawer?.getSidesCount;
|
|
4738
|
-
if (sideCountFunc) {
|
|
4739
|
-
this.sides = sideCountFunc(this);
|
|
4740
|
-
}
|
|
4263
|
+
initParticleDrawers(this, container);
|
|
4741
4264
|
this.spawning = false;
|
|
4742
|
-
|
|
4743
|
-
|
|
4744
|
-
|
|
4745
|
-
effectDrawer?.particleInit?.(container, this);
|
|
4746
|
-
shapeDrawer?.particleInit?.(container, this);
|
|
4747
|
-
for (const plugin of container.particleCreatedPlugins) {
|
|
4748
|
-
plugin.particleCreated?.(this);
|
|
4749
|
-
}
|
|
4265
|
+
runUpdaterInit(container.particleUpdaters, this);
|
|
4266
|
+
runDrawerInit(container, this);
|
|
4267
|
+
runParticleCreatedPlugins(container, this);
|
|
4750
4268
|
}
|
|
4751
4269
|
isInsideCanvas(direction) {
|
|
4752
4270
|
return this.#getInsideCanvasResult({ direction }).inside;
|
|
@@ -4760,15 +4278,15 @@
|
|
|
4760
4278
|
}
|
|
4761
4279
|
const angle = this.roll.angle;
|
|
4762
4280
|
if (this.roll.horizontal && this.roll.vertical) {
|
|
4763
|
-
const
|
|
4281
|
+
const adjustedAngle = normalizeAngle(angle, doublePI);
|
|
4764
4282
|
return adjustedAngle >= Math.PI * half && adjustedAngle < Math.PI * triple * half;
|
|
4765
4283
|
}
|
|
4766
4284
|
if (this.roll.horizontal) {
|
|
4767
|
-
const
|
|
4285
|
+
const adjustedAngle = normalizeAngle(angle + Math.PI * half, doublePI);
|
|
4768
4286
|
return adjustedAngle >= Math.PI && adjustedAngle < Math.PI * double;
|
|
4769
4287
|
}
|
|
4770
4288
|
if (this.roll.vertical) {
|
|
4771
|
-
const
|
|
4289
|
+
const adjustedAngle = normalizeAngle(angle, doublePI);
|
|
4772
4290
|
return adjustedAngle >= Math.PI && adjustedAngle < Math.PI * double;
|
|
4773
4291
|
}
|
|
4774
4292
|
return false;
|
|
@@ -4781,10 +4299,10 @@
|
|
|
4781
4299
|
updater.reset?.(this);
|
|
4782
4300
|
}
|
|
4783
4301
|
}
|
|
4784
|
-
#calcPosition
|
|
4302
|
+
#calcPosition(position, zIndex) {
|
|
4785
4303
|
let tryCount = defaultRetryCount, posVec = position ? Vector3d.create(position.x, position.y, zIndex) : undefined;
|
|
4786
|
-
const container = this.#container, plugins = container.particlePositionPlugins, outModes = this.options.move.outModes, radius = this.getRadius(), canvasSize = container.canvas.size
|
|
4787
|
-
|
|
4304
|
+
const container = this.#container, plugins = container.particlePositionPlugins, outModes = this.options.move.outModes, radius = this.getRadius(), canvasSize = container.canvas.size;
|
|
4305
|
+
for (;;) {
|
|
4788
4306
|
for (const plugin of plugins) {
|
|
4789
4307
|
const pluginPos = plugin.particlePosition?.(posVec, this);
|
|
4790
4308
|
if (pluginPos) {
|
|
@@ -4812,9 +4330,8 @@
|
|
|
4812
4330
|
tryCount += tryCountIncrement;
|
|
4813
4331
|
posVec = undefined;
|
|
4814
4332
|
}
|
|
4815
|
-
|
|
4816
|
-
|
|
4817
|
-
#calculateVelocity = () => {
|
|
4333
|
+
}
|
|
4334
|
+
#calculateVelocity() {
|
|
4818
4335
|
const moveOptions = this.options.move, baseVelocity = getParticleBaseVelocity(this.direction), res = baseVelocity.copy();
|
|
4819
4336
|
if (moveOptions.direction === MoveDirection.inside || moveOptions.direction === MoveDirection.outside) {
|
|
4820
4337
|
return res;
|
|
@@ -4830,8 +4347,8 @@
|
|
|
4830
4347
|
res.length *= getRandom();
|
|
4831
4348
|
}
|
|
4832
4349
|
return res;
|
|
4833
|
-
}
|
|
4834
|
-
#fixHorizontal
|
|
4350
|
+
}
|
|
4351
|
+
#fixHorizontal(pos, radius, outMode) {
|
|
4835
4352
|
fixOutMode({
|
|
4836
4353
|
outMode,
|
|
4837
4354
|
checkModes: [OutMode.bounce],
|
|
@@ -4840,8 +4357,8 @@
|
|
|
4840
4357
|
setCb: (value) => (pos.x += value),
|
|
4841
4358
|
radius,
|
|
4842
4359
|
});
|
|
4843
|
-
}
|
|
4844
|
-
#fixVertical
|
|
4360
|
+
}
|
|
4361
|
+
#fixVertical(pos, radius, outMode) {
|
|
4845
4362
|
fixOutMode({
|
|
4846
4363
|
outMode,
|
|
4847
4364
|
checkModes: [OutMode.bounce],
|
|
@@ -4850,8 +4367,8 @@
|
|
|
4850
4367
|
setCb: (value) => (pos.y += value),
|
|
4851
4368
|
radius,
|
|
4852
4369
|
});
|
|
4853
|
-
}
|
|
4854
|
-
#getDefaultInsideCanvasResult
|
|
4370
|
+
}
|
|
4371
|
+
#getDefaultInsideCanvasResult(direction, outMode) {
|
|
4855
4372
|
const radius = this.getRadius(), canvasSize = this.#container.canvas.size, position = this.position, isBounce = outMode === OutMode.bounce;
|
|
4856
4373
|
if (direction === OutModeDirection.bottom) {
|
|
4857
4374
|
return {
|
|
@@ -4884,8 +4401,8 @@
|
|
|
4884
4401
|
position.x <= canvasSize.width + radius,
|
|
4885
4402
|
reason: "default",
|
|
4886
4403
|
};
|
|
4887
|
-
}
|
|
4888
|
-
#getInsideCanvasCallbackData
|
|
4404
|
+
}
|
|
4405
|
+
#getInsideCanvasCallbackData(direction, outMode) {
|
|
4889
4406
|
return {
|
|
4890
4407
|
canvasSize: this.#container.canvas.size,
|
|
4891
4408
|
direction,
|
|
@@ -4893,8 +4410,8 @@
|
|
|
4893
4410
|
particle: this,
|
|
4894
4411
|
radius: this.getRadius(),
|
|
4895
4412
|
};
|
|
4896
|
-
}
|
|
4897
|
-
#getInsideCanvasResult
|
|
4413
|
+
}
|
|
4414
|
+
#getInsideCanvasResult(data) {
|
|
4898
4415
|
const defaultResult = this.#getDefaultInsideCanvasResult(data.direction, data.outMode), container = this.#container, shapeDrawer = this.shape ? container.shapeDrawers.get(this.shape) : undefined, effectDrawer = this.effect ? container.effectDrawers.get(this.effect) : undefined, shapeCheck = shapeDrawer?.isInsideCanvas, effectCheck = effectDrawer?.isInsideCanvas;
|
|
4899
4416
|
if (!shapeCheck && !effectCheck) {
|
|
4900
4417
|
return defaultResult;
|
|
@@ -4909,8 +4426,8 @@
|
|
|
4909
4426
|
};
|
|
4910
4427
|
}
|
|
4911
4428
|
return shapeResult ?? effectResult ?? defaultResult;
|
|
4912
|
-
}
|
|
4913
|
-
#getRollColor
|
|
4429
|
+
}
|
|
4430
|
+
#getRollColor(color) {
|
|
4914
4431
|
if (!color || !this.roll || (!this.backColor && !this.roll.alter)) {
|
|
4915
4432
|
return color;
|
|
4916
4433
|
}
|
|
@@ -4924,8 +4441,8 @@
|
|
|
4924
4441
|
return alterHsl(color, this.roll.alter.type, this.roll.alter.value);
|
|
4925
4442
|
}
|
|
4926
4443
|
return color;
|
|
4927
|
-
}
|
|
4928
|
-
#initPosition
|
|
4444
|
+
}
|
|
4445
|
+
#initPosition(position) {
|
|
4929
4446
|
const container = this.#container, zIndexValue = Math.floor(getRangeValue(this.options.zIndex.value)), initialPosition = this.#calcPosition(position, clamp(zIndexValue, minZ, container.zLayers));
|
|
4930
4447
|
if (!initialPosition) {
|
|
4931
4448
|
throw new Error("a valid position cannot be found for particle");
|
|
@@ -4948,8 +4465,8 @@
|
|
|
4948
4465
|
break;
|
|
4949
4466
|
}
|
|
4950
4467
|
this.offset = Vector.origin;
|
|
4951
|
-
}
|
|
4952
|
-
#normalizeInsideCanvasResult
|
|
4468
|
+
}
|
|
4469
|
+
#normalizeInsideCanvasResult(result, reason) {
|
|
4953
4470
|
if (typeof result === "boolean") {
|
|
4954
4471
|
return {
|
|
4955
4472
|
inside: result,
|
|
@@ -4961,7 +4478,7 @@
|
|
|
4961
4478
|
margin: result.margin,
|
|
4962
4479
|
reason: result.reason ?? reason,
|
|
4963
4480
|
};
|
|
4964
|
-
}
|
|
4481
|
+
}
|
|
4965
4482
|
}
|
|
4966
4483
|
|
|
4967
4484
|
class SpatialHashGrid {
|
|
@@ -5314,10 +4831,10 @@
|
|
|
5314
4831
|
}
|
|
5315
4832
|
this.#resizeFactor = undefined;
|
|
5316
4833
|
}
|
|
5317
|
-
#addToPool
|
|
4834
|
+
#addToPool(...particles) {
|
|
5318
4835
|
this.#pool.push(...particles);
|
|
5319
|
-
}
|
|
5320
|
-
#applyDensity
|
|
4836
|
+
}
|
|
4837
|
+
#applyDensity(options, pluginsCount, group, groupOptions) {
|
|
5321
4838
|
const numberOptions = options.number;
|
|
5322
4839
|
if (!numberOptions.density.enable) {
|
|
5323
4840
|
if (group === undefined) {
|
|
@@ -5341,36 +4858,19 @@
|
|
|
5341
4858
|
else if (particlesCount > particlesNumber) {
|
|
5342
4859
|
this.removeQuantity(particlesCount - particlesNumber, group);
|
|
5343
4860
|
}
|
|
5344
|
-
}
|
|
5345
|
-
#createBuckets
|
|
4861
|
+
}
|
|
4862
|
+
#createBuckets(zLayers) {
|
|
5346
4863
|
const bucketCount = Math.max(Math.floor(zLayers), one);
|
|
5347
4864
|
return Array.from({ length: bucketCount }, () => []);
|
|
5348
|
-
}
|
|
5349
|
-
#getBucketIndex
|
|
4865
|
+
}
|
|
4866
|
+
#getBucketIndex(zIndex) {
|
|
5350
4867
|
const maxBucketIndex = this.#zBuckets.length - one;
|
|
5351
4868
|
if (maxBucketIndex <= minIndex) {
|
|
5352
4869
|
return minIndex;
|
|
5353
4870
|
}
|
|
5354
4871
|
return Math.min(Math.max(Math.floor(zIndex), minIndex), maxBucketIndex);
|
|
5355
|
-
}
|
|
5356
|
-
#
|
|
5357
|
-
let start = minIndex, end = bucket.length;
|
|
5358
|
-
while (start < end) {
|
|
5359
|
-
const middle = Math.floor((start + end) / double), middleParticle = bucket[middle];
|
|
5360
|
-
if (!middleParticle) {
|
|
5361
|
-
end = middle;
|
|
5362
|
-
continue;
|
|
5363
|
-
}
|
|
5364
|
-
if (middleParticle.id < particleId) {
|
|
5365
|
-
start = middle + one;
|
|
5366
|
-
}
|
|
5367
|
-
else {
|
|
5368
|
-
end = middle;
|
|
5369
|
-
}
|
|
5370
|
-
}
|
|
5371
|
-
return start;
|
|
5372
|
-
};
|
|
5373
|
-
#initDensityFactor = densityOptions => {
|
|
4872
|
+
}
|
|
4873
|
+
#initDensityFactor(densityOptions) {
|
|
5374
4874
|
const container = this.#container;
|
|
5375
4875
|
if (!densityOptions.enable) {
|
|
5376
4876
|
return defaultDensityFactor;
|
|
@@ -5380,16 +4880,16 @@
|
|
|
5380
4880
|
return defaultDensityFactor;
|
|
5381
4881
|
}
|
|
5382
4882
|
return ((canvasSize.width * canvasSize.height) / (densityOptions.height * densityOptions.width * pxRatio ** squareExp));
|
|
5383
|
-
}
|
|
5384
|
-
#insertParticleIntoBucket
|
|
4883
|
+
}
|
|
4884
|
+
#insertParticleIntoBucket(particle) {
|
|
5385
4885
|
const bucketIndex = this.#getBucketIndex(particle.position.z), bucket = this.#zBuckets[bucketIndex];
|
|
5386
4886
|
if (!bucket) {
|
|
5387
4887
|
return;
|
|
5388
4888
|
}
|
|
5389
|
-
bucket.
|
|
4889
|
+
bucket.push(particle);
|
|
5390
4890
|
this.#particleBuckets.set(particle.id, bucketIndex);
|
|
5391
|
-
}
|
|
5392
|
-
#removeParticle
|
|
4891
|
+
}
|
|
4892
|
+
#removeParticle(index, group, override) {
|
|
5393
4893
|
const particle = this.#array[index];
|
|
5394
4894
|
if (!particle) {
|
|
5395
4895
|
return false;
|
|
@@ -5405,22 +4905,20 @@
|
|
|
5405
4905
|
});
|
|
5406
4906
|
this.#addToPool(particle);
|
|
5407
4907
|
return true;
|
|
5408
|
-
}
|
|
5409
|
-
#removeParticleFromBucket
|
|
4908
|
+
}
|
|
4909
|
+
#removeParticleFromBucket(particle) {
|
|
5410
4910
|
const bucketIndex = this.#particleBuckets.get(particle.id) ?? this.#getBucketIndex(particle.position.z), bucket = this.#zBuckets[bucketIndex];
|
|
5411
4911
|
if (!bucket) {
|
|
5412
4912
|
this.#particleBuckets.delete(particle.id);
|
|
5413
4913
|
return;
|
|
5414
4914
|
}
|
|
5415
|
-
const
|
|
5416
|
-
if (
|
|
5417
|
-
|
|
5418
|
-
return;
|
|
4915
|
+
const idx = bucket.findIndex(p => p.id === particle.id);
|
|
4916
|
+
if (idx >= minIndex) {
|
|
4917
|
+
bucket.splice(idx, deleteCount);
|
|
5419
4918
|
}
|
|
5420
|
-
bucket.splice(particleIndex, deleteCount);
|
|
5421
4919
|
this.#particleBuckets.delete(particle.id);
|
|
5422
|
-
}
|
|
5423
|
-
#resetBuckets
|
|
4920
|
+
}
|
|
4921
|
+
#resetBuckets(zLayers) {
|
|
5424
4922
|
const bucketCount = Math.max(Math.floor(zLayers), one);
|
|
5425
4923
|
if (this.#zBuckets.length !== bucketCount) {
|
|
5426
4924
|
this.#zBuckets = this.#createBuckets(bucketCount);
|
|
@@ -5429,8 +4927,8 @@
|
|
|
5429
4927
|
for (const bucket of this.#zBuckets) {
|
|
5430
4928
|
bucket.length = minIndex;
|
|
5431
4929
|
}
|
|
5432
|
-
}
|
|
5433
|
-
#updateParticleBucket
|
|
4930
|
+
}
|
|
4931
|
+
#updateParticleBucket(particle) {
|
|
5434
4932
|
const newBucketIndex = this.#getBucketIndex(particle.position.z), currentBucketIndex = this.#particleBuckets.get(particle.id);
|
|
5435
4933
|
if (currentBucketIndex === undefined) {
|
|
5436
4934
|
this.#insertParticleIntoBucket(particle);
|
|
@@ -5441,9 +4939,9 @@
|
|
|
5441
4939
|
}
|
|
5442
4940
|
const currentBucket = this.#zBuckets[currentBucketIndex];
|
|
5443
4941
|
if (currentBucket) {
|
|
5444
|
-
const
|
|
5445
|
-
if (
|
|
5446
|
-
currentBucket.splice(
|
|
4942
|
+
const idx = currentBucket.findIndex(p => p.id === particle.id);
|
|
4943
|
+
if (idx >= minIndex) {
|
|
4944
|
+
currentBucket.splice(idx, deleteCount);
|
|
5447
4945
|
}
|
|
5448
4946
|
}
|
|
5449
4947
|
const newBucket = this.#zBuckets[newBucketIndex];
|
|
@@ -5451,10 +4949,16 @@
|
|
|
5451
4949
|
this.#particleBuckets.set(particle.id, newBucketIndex);
|
|
5452
4950
|
return;
|
|
5453
4951
|
}
|
|
5454
|
-
newBucket.
|
|
4952
|
+
newBucket.push(particle);
|
|
4953
|
+
if (newBucket.length >= double) {
|
|
4954
|
+
const prev = newBucket[newBucket.length - double];
|
|
4955
|
+
if (prev && particle.id < prev.id) {
|
|
4956
|
+
newBucket.sort((a, b) => a.id - b.id);
|
|
4957
|
+
}
|
|
4958
|
+
}
|
|
5455
4959
|
this.#particleBuckets.set(particle.id, newBucketIndex);
|
|
5456
|
-
}
|
|
5457
|
-
#updateParticlesPhase1
|
|
4960
|
+
}
|
|
4961
|
+
#updateParticlesPhase1(delta) {
|
|
5458
4962
|
const particlesToDelete = new Set(), resizeFactor = this.#resizeFactor;
|
|
5459
4963
|
for (const particle of this.#array) {
|
|
5460
4964
|
if (resizeFactor && !particle.ignoresResizeRatio) {
|
|
@@ -5480,8 +4984,8 @@
|
|
|
5480
4984
|
this.grid.insert(particle);
|
|
5481
4985
|
}
|
|
5482
4986
|
return particlesToDelete;
|
|
5483
|
-
}
|
|
5484
|
-
#updateParticlesPhase2
|
|
4987
|
+
}
|
|
4988
|
+
#updateParticlesPhase2(delta, particlesToDelete) {
|
|
5485
4989
|
for (const particle of this.#array) {
|
|
5486
4990
|
if (particle.destroyed) {
|
|
5487
4991
|
particlesToDelete.add(particle);
|
|
@@ -5497,7 +5001,7 @@
|
|
|
5497
5001
|
}
|
|
5498
5002
|
this.#updateParticleBucket(particle);
|
|
5499
5003
|
}
|
|
5500
|
-
}
|
|
5004
|
+
}
|
|
5501
5005
|
}
|
|
5502
5006
|
|
|
5503
5007
|
class Retina {
|
|
@@ -5859,7 +5363,7 @@
|
|
|
5859
5363
|
}
|
|
5860
5364
|
return refresh;
|
|
5861
5365
|
}
|
|
5862
|
-
#nextFrame
|
|
5366
|
+
#nextFrame(timestamp) {
|
|
5863
5367
|
try {
|
|
5864
5368
|
if (!this.#smooth &&
|
|
5865
5369
|
this.#lastFrameTime !== undefined &&
|
|
@@ -5887,7 +5391,7 @@
|
|
|
5887
5391
|
catch (e) {
|
|
5888
5392
|
getLogger().error("error in animation loop", e);
|
|
5889
5393
|
}
|
|
5890
|
-
}
|
|
5394
|
+
}
|
|
5891
5395
|
}
|
|
5892
5396
|
|
|
5893
5397
|
var Container$1 = /*#__PURE__*/Object.freeze({
|
|
@@ -5933,7 +5437,7 @@
|
|
|
5933
5437
|
BlendPluginInstance: BlendPluginInstance
|
|
5934
5438
|
});
|
|
5935
5439
|
|
|
5936
|
-
const
|
|
5440
|
+
const moveSpeedFactor = 60, minSpinRadius = 0, spinFactor = 0.01, defaultPathDelay = 0, noDecay = 1;
|
|
5937
5441
|
function applyDistance(particle) {
|
|
5938
5442
|
const initialPosition = particle.initialPosition, { dx, dy } = getDistances(initialPosition, particle.position), dxFixed = Math.abs(dx), dyFixed = Math.abs(dy), { maxDistance } = particle.retina, hDistance = maxDistance.horizontal, vDistance = maxDistance.vertical;
|
|
5939
5443
|
if (!hDistance && !vDistance) {
|