@tsparticles/preset-snow 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.
- package/README.md +1 -1
- package/package.json +5 -5
- package/report.html +1 -1
- package/tsparticles.preset.snow.bundle.js +934 -1450
- package/tsparticles.preset.snow.bundle.min.js +1 -1
- package/tsparticles.preset.snow.js +1 -1
|
@@ -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
1738
|
}
|
|
2407
|
-
|
|
2408
|
-
|
|
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
|
-
}
|
|
2422
|
-
}
|
|
2423
|
-
function drawShapeAfterDraw(drawer, data) {
|
|
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
|
});
|
|
@@ -2950,50 +2233,156 @@
|
|
|
2950
2233
|
}
|
|
2951
2234
|
}
|
|
2952
2235
|
|
|
2953
|
-
async function loadMovePlugin(engine) {
|
|
2954
|
-
engine.checkVersion("4.
|
|
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
|
-
|
|
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);
|
|
2369
|
+
}
|
|
2370
|
+
}
|
|
2371
|
+
|
|
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),
|
|
@@ -3682,44 +3052,27 @@
|
|
|
3682
3052
|
}
|
|
3683
3053
|
|
|
3684
3054
|
class WobbleSpeed {
|
|
3685
|
-
angle;
|
|
3686
|
-
move;
|
|
3687
|
-
constructor() {
|
|
3688
|
-
this.angle = 50;
|
|
3689
|
-
this.move = 10;
|
|
3690
|
-
}
|
|
3055
|
+
angle = 50;
|
|
3056
|
+
move = 10;
|
|
3691
3057
|
load(data) {
|
|
3692
3058
|
if (isNull(data)) {
|
|
3693
3059
|
return;
|
|
3694
3060
|
}
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
}
|
|
3698
|
-
if (data.move !== undefined) {
|
|
3699
|
-
this.move = setRangeValue(data.move);
|
|
3700
|
-
}
|
|
3061
|
+
loadRangeProperty(this, "angle", data.angle);
|
|
3062
|
+
loadRangeProperty(this, "move", data.move);
|
|
3701
3063
|
}
|
|
3702
3064
|
}
|
|
3703
3065
|
|
|
3704
3066
|
class Wobble {
|
|
3705
|
-
distance;
|
|
3706
|
-
enable;
|
|
3707
|
-
speed;
|
|
3708
|
-
constructor() {
|
|
3709
|
-
this.distance = 5;
|
|
3710
|
-
this.enable = false;
|
|
3711
|
-
this.speed = new WobbleSpeed();
|
|
3712
|
-
}
|
|
3067
|
+
distance = 5;
|
|
3068
|
+
enable = false;
|
|
3069
|
+
speed = new WobbleSpeed();
|
|
3713
3070
|
load(data) {
|
|
3714
3071
|
if (isNull(data)) {
|
|
3715
3072
|
return;
|
|
3716
3073
|
}
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
}
|
|
3720
|
-
if (data.enable !== undefined) {
|
|
3721
|
-
this.enable = data.enable;
|
|
3722
|
-
}
|
|
3074
|
+
loadRangeProperty(this, "distance", data.distance);
|
|
3075
|
+
loadProperty(this, "enable", data.enable);
|
|
3723
3076
|
if (data.speed !== undefined) {
|
|
3724
3077
|
if (isNumber(data.speed)) {
|
|
3725
3078
|
this.speed.load({ angle: data.speed });
|
|
@@ -3781,10 +3134,7 @@
|
|
|
3781
3134
|
return !particle.destroyed && !particle.spawning && !!particle.options.wobble?.enable;
|
|
3782
3135
|
}
|
|
3783
3136
|
loadOptions(options, ...sources) {
|
|
3784
|
-
options
|
|
3785
|
-
for (const source of sources) {
|
|
3786
|
-
options.wobble.load(source?.wobble);
|
|
3787
|
-
}
|
|
3137
|
+
loadOptionProperty(options, "wobble", Wobble, ...sources);
|
|
3788
3138
|
}
|
|
3789
3139
|
update(particle, delta) {
|
|
3790
3140
|
if (!this.isEnabled(particle)) {
|
|
@@ -3795,7 +3145,7 @@
|
|
|
3795
3145
|
}
|
|
3796
3146
|
|
|
3797
3147
|
async function loadWobbleUpdater(engine) {
|
|
3798
|
-
engine.checkVersion("4.
|
|
3148
|
+
engine.checkVersion("4.2.0");
|
|
3799
3149
|
await engine.pluginManager.register(e => {
|
|
3800
3150
|
e.pluginManager.addParticleUpdater("wobble", container => {
|
|
3801
3151
|
return Promise.resolve(new WobbleUpdater(container));
|
|
@@ -3898,7 +3248,7 @@
|
|
|
3898
3248
|
return;
|
|
3899
3249
|
}
|
|
3900
3250
|
this.draw(ctx => {
|
|
3901
|
-
|
|
3251
|
+
ctx.clearRect(originPoint.x, originPoint.y, this.#canvasManager.size.width, this.#canvasManager.size.height);
|
|
3902
3252
|
});
|
|
3903
3253
|
}
|
|
3904
3254
|
clear() {
|
|
@@ -3960,7 +3310,7 @@
|
|
|
3960
3310
|
plugin.drawParticleSetup?.(context, particle, delta);
|
|
3961
3311
|
}
|
|
3962
3312
|
this.#applyPreDrawUpdaters(context, particle, radius, opacity, colorStyles, transform);
|
|
3963
|
-
drawParticle({
|
|
3313
|
+
this.#drawParticle({
|
|
3964
3314
|
container,
|
|
3965
3315
|
context,
|
|
3966
3316
|
particle,
|
|
@@ -3979,7 +3329,7 @@
|
|
|
3979
3329
|
drawParticlePlugins(particle, delta) {
|
|
3980
3330
|
this.draw(ctx => {
|
|
3981
3331
|
for (const plugin of this.#drawParticlePlugins) {
|
|
3982
|
-
drawParticlePlugin(ctx, plugin, particle, delta);
|
|
3332
|
+
this.#drawParticlePlugin(ctx, plugin, particle, delta);
|
|
3983
3333
|
}
|
|
3984
3334
|
});
|
|
3985
3335
|
}
|
|
@@ -4079,12 +3429,19 @@
|
|
|
4079
3429
|
}
|
|
4080
3430
|
paintBase(baseColor) {
|
|
4081
3431
|
this.draw(ctx => {
|
|
4082
|
-
|
|
3432
|
+
ctx.fillStyle = baseColor ?? "rgba(0,0,0,0)";
|
|
3433
|
+
ctx.fillRect(originPoint.x, originPoint.y, this.#canvasManager.size.width, this.#canvasManager.size.height);
|
|
4083
3434
|
});
|
|
4084
3435
|
}
|
|
4085
3436
|
paintImage(image, opacity) {
|
|
4086
3437
|
this.draw(ctx => {
|
|
4087
|
-
|
|
3438
|
+
if (!image) {
|
|
3439
|
+
return;
|
|
3440
|
+
}
|
|
3441
|
+
const prevAlpha = ctx.globalAlpha;
|
|
3442
|
+
ctx.globalAlpha = opacity;
|
|
3443
|
+
ctx.drawImage(image, originPoint.x, originPoint.y, this.#canvasManager.size.width, this.#canvasManager.size.height);
|
|
3444
|
+
ctx.globalAlpha = prevAlpha;
|
|
4088
3445
|
});
|
|
4089
3446
|
}
|
|
4090
3447
|
setContext(context) {
|
|
@@ -4098,15 +3455,15 @@
|
|
|
4098
3455
|
}
|
|
4099
3456
|
stop() {
|
|
4100
3457
|
this.draw(ctx => {
|
|
4101
|
-
|
|
3458
|
+
ctx.clearRect(originPoint.x, originPoint.y, this.#canvasManager.size.width, this.#canvasManager.size.height);
|
|
4102
3459
|
});
|
|
4103
3460
|
}
|
|
4104
|
-
#applyPostDrawUpdaters
|
|
3461
|
+
#applyPostDrawUpdaters(particle) {
|
|
4105
3462
|
for (const updater of this.#postDrawUpdaters) {
|
|
4106
3463
|
updater.afterDraw?.(particle);
|
|
4107
3464
|
}
|
|
4108
|
-
}
|
|
4109
|
-
#applyPreDrawUpdaters
|
|
3465
|
+
}
|
|
3466
|
+
#applyPreDrawUpdaters(ctx, particle, radius, zOpacity, colorStyles, transform) {
|
|
4110
3467
|
for (const updater of this.#preDrawUpdaters) {
|
|
4111
3468
|
if (updater.getColorStyles) {
|
|
4112
3469
|
const { fill, stroke } = updater.getColorStyles(particle, ctx, radius, zOpacity);
|
|
@@ -4125,8 +3482,114 @@
|
|
|
4125
3482
|
}
|
|
4126
3483
|
updater.beforeDraw?.(particle);
|
|
4127
3484
|
}
|
|
4128
|
-
}
|
|
4129
|
-
#
|
|
3485
|
+
}
|
|
3486
|
+
#drawAfterEffect(drawer, data) {
|
|
3487
|
+
if (!drawer?.drawAfter) {
|
|
3488
|
+
return;
|
|
3489
|
+
}
|
|
3490
|
+
const { particle } = data;
|
|
3491
|
+
if (!particle.effect) {
|
|
3492
|
+
return;
|
|
3493
|
+
}
|
|
3494
|
+
drawer.drawAfter(data);
|
|
3495
|
+
}
|
|
3496
|
+
#drawBeforeEffect(drawer, data) {
|
|
3497
|
+
if (!drawer?.drawBefore) {
|
|
3498
|
+
return;
|
|
3499
|
+
}
|
|
3500
|
+
const { particle } = data;
|
|
3501
|
+
if (!particle.effect) {
|
|
3502
|
+
return;
|
|
3503
|
+
}
|
|
3504
|
+
drawer.drawBefore(data);
|
|
3505
|
+
}
|
|
3506
|
+
#drawParticle(data) {
|
|
3507
|
+
const { container, context, particle, delta, colorStyles, radius, opacity, transform } = data, { effectDrawers, shapeDrawers } = container, pos = particle.getPosition(), transformData = particle.getTransformData(transform), drawScale = defaultZoom, drawPosition = {
|
|
3508
|
+
x: pos.x,
|
|
3509
|
+
y: pos.y,
|
|
3510
|
+
};
|
|
3511
|
+
context.setTransform(transformData.a, transformData.b, transformData.c, transformData.d, pos.x, pos.y);
|
|
3512
|
+
if (colorStyles.fill) {
|
|
3513
|
+
context.fillStyle = colorStyles.fill;
|
|
3514
|
+
}
|
|
3515
|
+
const fillEnabled = !!particle.fillEnabled, strokeWidth = particle.strokeWidth ?? minStrokeWidth;
|
|
3516
|
+
context.lineWidth = strokeWidth;
|
|
3517
|
+
if (colorStyles.stroke) {
|
|
3518
|
+
context.strokeStyle = colorStyles.stroke;
|
|
3519
|
+
}
|
|
3520
|
+
const drawData = {
|
|
3521
|
+
context,
|
|
3522
|
+
particle,
|
|
3523
|
+
radius,
|
|
3524
|
+
drawRadius: radius * drawScale,
|
|
3525
|
+
opacity,
|
|
3526
|
+
delta,
|
|
3527
|
+
pixelRatio: container.retina.pixelRatio,
|
|
3528
|
+
fill: fillEnabled,
|
|
3529
|
+
stroke: strokeWidth > minStrokeWidth,
|
|
3530
|
+
transformData,
|
|
3531
|
+
position: { ...pos },
|
|
3532
|
+
drawPosition,
|
|
3533
|
+
drawScale,
|
|
3534
|
+
};
|
|
3535
|
+
for (const plugin of container.plugins) {
|
|
3536
|
+
plugin.drawParticleTransform?.(drawData);
|
|
3537
|
+
}
|
|
3538
|
+
const effect = particle.effect ? effectDrawers.get(particle.effect) : undefined, shape = particle.shape ? shapeDrawers.get(particle.shape) : undefined;
|
|
3539
|
+
this.#drawBeforeEffect(effect, drawData);
|
|
3540
|
+
this.#drawShapeBeforeDraw(shape, drawData);
|
|
3541
|
+
this.#drawShape(shape, drawData);
|
|
3542
|
+
this.#drawShapeAfterDraw(shape, drawData);
|
|
3543
|
+
this.#drawAfterEffect(effect, drawData);
|
|
3544
|
+
context.resetTransform();
|
|
3545
|
+
}
|
|
3546
|
+
#drawParticlePlugin(context, plugin, particle, delta) {
|
|
3547
|
+
if (!plugin.drawParticle) {
|
|
3548
|
+
return;
|
|
3549
|
+
}
|
|
3550
|
+
plugin.drawParticle(context, particle, delta);
|
|
3551
|
+
}
|
|
3552
|
+
#drawShape(drawer, data) {
|
|
3553
|
+
if (!drawer) {
|
|
3554
|
+
return;
|
|
3555
|
+
}
|
|
3556
|
+
const { context, fill, particle, stroke } = data;
|
|
3557
|
+
if (!particle.shape) {
|
|
3558
|
+
return;
|
|
3559
|
+
}
|
|
3560
|
+
context.beginPath();
|
|
3561
|
+
drawer.draw(data);
|
|
3562
|
+
if (particle.shapeClose) {
|
|
3563
|
+
context.closePath();
|
|
3564
|
+
}
|
|
3565
|
+
if (fill) {
|
|
3566
|
+
context.fill();
|
|
3567
|
+
}
|
|
3568
|
+
if (stroke) {
|
|
3569
|
+
context.stroke();
|
|
3570
|
+
}
|
|
3571
|
+
}
|
|
3572
|
+
#drawShapeAfterDraw(drawer, data) {
|
|
3573
|
+
if (!drawer?.afterDraw) {
|
|
3574
|
+
return;
|
|
3575
|
+
}
|
|
3576
|
+
const { particle } = data;
|
|
3577
|
+
if (!particle.shape) {
|
|
3578
|
+
return;
|
|
3579
|
+
}
|
|
3580
|
+
drawer.afterDraw(data);
|
|
3581
|
+
}
|
|
3582
|
+
#drawShapeBeforeDraw(drawer, data) {
|
|
3583
|
+
if (!drawer?.beforeDraw) {
|
|
3584
|
+
return;
|
|
3585
|
+
}
|
|
3586
|
+
const { particle } = data;
|
|
3587
|
+
if (!particle.shape) {
|
|
3588
|
+
return;
|
|
3589
|
+
}
|
|
3590
|
+
drawer.beforeDraw(data);
|
|
3591
|
+
}
|
|
3592
|
+
#getPluginParticleColors(particle) {
|
|
4130
3593
|
let fColor, sColor;
|
|
4131
3594
|
for (const plugin of this.#colorPlugins) {
|
|
4132
3595
|
if (!fColor && plugin.particleFillColor) {
|
|
@@ -4142,7 +3605,7 @@
|
|
|
4142
3605
|
this.#reusablePluginColors[fColorIndex] = fColor;
|
|
4143
3606
|
this.#reusablePluginColors[sColorIndex] = sColor;
|
|
4144
3607
|
return this.#reusablePluginColors;
|
|
4145
|
-
}
|
|
3608
|
+
}
|
|
4146
3609
|
}
|
|
4147
3610
|
|
|
4148
3611
|
const transferredCanvases = new WeakMap(), getTransferredCanvas = (canvas) => {
|
|
@@ -4274,6 +3737,7 @@
|
|
|
4274
3737
|
obs.observe(element, { attributes: true });
|
|
4275
3738
|
});
|
|
4276
3739
|
this.initPlugins();
|
|
3740
|
+
this.#initContext();
|
|
4277
3741
|
this.render.init();
|
|
4278
3742
|
}
|
|
4279
3743
|
initBackground() {
|
|
@@ -4283,7 +3747,7 @@
|
|
|
4283
3747
|
}
|
|
4284
3748
|
const elementStyle = element.style, color = rangeColorToRgb(this.#pluginManager, background.color);
|
|
4285
3749
|
if (color) {
|
|
4286
|
-
elementStyle.backgroundColor = getStyleFromRgb(color, container.hdr, background.opacity);
|
|
3750
|
+
elementStyle.backgroundColor = getStyleFromRgb(color, container.actualOptions.hdr, background.opacity);
|
|
4287
3751
|
}
|
|
4288
3752
|
else {
|
|
4289
3753
|
elementStyle.backgroundColor = "";
|
|
@@ -4305,7 +3769,7 @@
|
|
|
4305
3769
|
if (this.#generated && this.domElement) {
|
|
4306
3770
|
this.domElement.remove();
|
|
4307
3771
|
}
|
|
4308
|
-
const
|
|
3772
|
+
const domCanvas = isHtmlCanvasElement(canvas) ? canvas : undefined;
|
|
4309
3773
|
this.domElement = domCanvas;
|
|
4310
3774
|
this.#generated = domCanvas ? domCanvas.dataset[generatedAttribute] === "true" : false;
|
|
4311
3775
|
this.renderCanvas = domCanvas ? getTransferredCanvas(domCanvas) : canvas;
|
|
@@ -4326,26 +3790,6 @@
|
|
|
4326
3790
|
const pxRatio = this.#container.retina.pixelRatio, retinaSize = this.size;
|
|
4327
3791
|
renderCanvas.height = retinaSize.height = standardSize.height * pxRatio;
|
|
4328
3792
|
renderCanvas.width = retinaSize.width = standardSize.width * pxRatio;
|
|
4329
|
-
const canSupportHdrQuery = safeMatchMedia("(color-gamut: p3)");
|
|
4330
|
-
this.render.setContextSettings({
|
|
4331
|
-
alpha: true,
|
|
4332
|
-
colorSpace: canSupportHdrQuery?.matches && container.hdr ? "display-p3" : "srgb",
|
|
4333
|
-
desynchronized: true,
|
|
4334
|
-
willReadFrequently: false,
|
|
4335
|
-
});
|
|
4336
|
-
this.render.setContext(renderCanvas.getContext("2d", this.render.settings));
|
|
4337
|
-
this.#safeMutationObserver(obs => {
|
|
4338
|
-
obs.disconnect();
|
|
4339
|
-
});
|
|
4340
|
-
container.retina.init();
|
|
4341
|
-
this.initBackground();
|
|
4342
|
-
this.#safeMutationObserver(obs => {
|
|
4343
|
-
const element = this.domElement;
|
|
4344
|
-
if (!element || !(element instanceof Node)) {
|
|
4345
|
-
return;
|
|
4346
|
-
}
|
|
4347
|
-
obs.observe(element, { attributes: true });
|
|
4348
|
-
});
|
|
4349
3793
|
}
|
|
4350
3794
|
resize() {
|
|
4351
3795
|
const element = this.domElement;
|
|
@@ -4413,12 +3857,30 @@
|
|
|
4413
3857
|
await container.refresh();
|
|
4414
3858
|
}
|
|
4415
3859
|
}
|
|
4416
|
-
#applyResizePlugins
|
|
3860
|
+
#applyResizePlugins() {
|
|
4417
3861
|
for (const plugin of this.#resizePlugins) {
|
|
4418
3862
|
plugin.resize?.();
|
|
4419
3863
|
}
|
|
4420
|
-
}
|
|
4421
|
-
#
|
|
3864
|
+
}
|
|
3865
|
+
#initContext() {
|
|
3866
|
+
const container = this.#container, canSupportHdr = container.actualOptions.hdr &&
|
|
3867
|
+
safeMatchMedia("(color-gamut: p3)")?.matches &&
|
|
3868
|
+
safeMatchMedia("(dynamic-range: high)")?.matches;
|
|
3869
|
+
this.render.setContextSettings({
|
|
3870
|
+
alpha: true,
|
|
3871
|
+
desynchronized: true,
|
|
3872
|
+
willReadFrequently: false,
|
|
3873
|
+
...(canSupportHdr
|
|
3874
|
+
? { colorSpace: "display-p3", colorType: "float16" }
|
|
3875
|
+
: { colorSpace: "srgb" }),
|
|
3876
|
+
});
|
|
3877
|
+
const renderCanvas = this.renderCanvas;
|
|
3878
|
+
if (!renderCanvas) {
|
|
3879
|
+
return;
|
|
3880
|
+
}
|
|
3881
|
+
this.render.setContext(renderCanvas.getContext("2d", this.render.settings));
|
|
3882
|
+
}
|
|
3883
|
+
#initStyle() {
|
|
4422
3884
|
const element = this.domElement, options = this.#container.actualOptions;
|
|
4423
3885
|
if (!element) {
|
|
4424
3886
|
return;
|
|
@@ -4439,8 +3901,8 @@
|
|
|
4439
3901
|
}
|
|
4440
3902
|
element.style.setProperty(key, value, "important");
|
|
4441
3903
|
}
|
|
4442
|
-
}
|
|
4443
|
-
#repairStyle
|
|
3904
|
+
}
|
|
3905
|
+
#repairStyle() {
|
|
4444
3906
|
const element = this.domElement;
|
|
4445
3907
|
if (!element) {
|
|
4446
3908
|
return;
|
|
@@ -4459,27 +3921,27 @@
|
|
|
4459
3921
|
}
|
|
4460
3922
|
observer.observe(element, { attributes: true });
|
|
4461
3923
|
});
|
|
4462
|
-
}
|
|
4463
|
-
#resetOriginalStyle
|
|
3924
|
+
}
|
|
3925
|
+
#resetOriginalStyle() {
|
|
4464
3926
|
const element = this.domElement, originalStyle = this.#originalStyle;
|
|
4465
3927
|
if (!element || !originalStyle) {
|
|
4466
3928
|
return;
|
|
4467
3929
|
}
|
|
4468
3930
|
setStyle(element, originalStyle, true);
|
|
4469
|
-
}
|
|
4470
|
-
#safeMutationObserver
|
|
3931
|
+
}
|
|
3932
|
+
#safeMutationObserver(callback) {
|
|
4471
3933
|
if (!this.#mutationObserver) {
|
|
4472
3934
|
return;
|
|
4473
3935
|
}
|
|
4474
3936
|
callback(this.#mutationObserver);
|
|
4475
|
-
}
|
|
4476
|
-
#setFullScreenStyle
|
|
3937
|
+
}
|
|
3938
|
+
#setFullScreenStyle() {
|
|
4477
3939
|
const element = this.domElement;
|
|
4478
3940
|
if (!element) {
|
|
4479
3941
|
return;
|
|
4480
3942
|
}
|
|
4481
3943
|
setStyle(element, getFullScreenStyle(this.#container.actualOptions.fullScreen.zIndex), true);
|
|
4482
|
-
}
|
|
3944
|
+
}
|
|
4483
3945
|
}
|
|
4484
3946
|
|
|
4485
3947
|
class EventListeners {
|
|
@@ -4504,7 +3966,7 @@
|
|
|
4504
3966
|
removeListeners() {
|
|
4505
3967
|
this.#manageListeners(false);
|
|
4506
3968
|
}
|
|
4507
|
-
#handleVisibilityChange
|
|
3969
|
+
#handleVisibilityChange() {
|
|
4508
3970
|
const container = this.#container, options = container.actualOptions;
|
|
4509
3971
|
if (!options.pauseOnBlur) {
|
|
4510
3972
|
return;
|
|
@@ -4522,8 +3984,8 @@
|
|
|
4522
3984
|
container.draw(true);
|
|
4523
3985
|
}
|
|
4524
3986
|
}
|
|
4525
|
-
}
|
|
4526
|
-
#handleWindowResize
|
|
3987
|
+
}
|
|
3988
|
+
#handleWindowResize() {
|
|
4527
3989
|
if (this.#resizeTimeout) {
|
|
4528
3990
|
clearTimeout(this.#resizeTimeout);
|
|
4529
3991
|
this.#resizeTimeout = undefined;
|
|
@@ -4533,13 +3995,13 @@
|
|
|
4533
3995
|
await canvas.windowResize();
|
|
4534
3996
|
};
|
|
4535
3997
|
this.#resizeTimeout = setTimeout(() => void handleResize(), this.#container.actualOptions.resize.delay * millisecondsToSeconds);
|
|
4536
|
-
}
|
|
4537
|
-
#manageListeners
|
|
3998
|
+
}
|
|
3999
|
+
#manageListeners(add) {
|
|
4538
4000
|
const handlers = this.#handlers;
|
|
4539
4001
|
this.#manageResize(add);
|
|
4540
4002
|
manageListener(document, visibilityChangeEvent, handlers.visibilityChange, add, false);
|
|
4541
|
-
}
|
|
4542
|
-
#manageResize
|
|
4003
|
+
}
|
|
4004
|
+
#manageResize(add) {
|
|
4543
4005
|
const handlers = this.#handlers, container = this.#container, options = container.actualOptions;
|
|
4544
4006
|
if (!options.resize.enable) {
|
|
4545
4007
|
return;
|
|
@@ -4566,7 +4028,7 @@
|
|
|
4566
4028
|
});
|
|
4567
4029
|
this.#resizeObserver.observe(canvasEl);
|
|
4568
4030
|
}
|
|
4569
|
-
}
|
|
4031
|
+
}
|
|
4570
4032
|
}
|
|
4571
4033
|
|
|
4572
4034
|
function loadEffectData(effect, effectOptions, id, reduceDuplicates) {
|
|
@@ -4593,6 +4055,131 @@
|
|
|
4593
4055
|
data.setCb(data.radius);
|
|
4594
4056
|
}
|
|
4595
4057
|
}
|
|
4058
|
+
function normalizeAngle(angle, modulus) {
|
|
4059
|
+
const normalized = angle % modulus;
|
|
4060
|
+
return normalized < defaultAngle ? normalized + modulus : normalized;
|
|
4061
|
+
}
|
|
4062
|
+
function initParticleState(particle, id, group) {
|
|
4063
|
+
particle.id = id;
|
|
4064
|
+
particle.group = group;
|
|
4065
|
+
particle.justWarped = false;
|
|
4066
|
+
particle.effectClose = true;
|
|
4067
|
+
particle.shapeClose = true;
|
|
4068
|
+
particle.pathRotation = false;
|
|
4069
|
+
particle.lastPathTime = 0;
|
|
4070
|
+
particle.destroyed = false;
|
|
4071
|
+
particle.unbreakable = false;
|
|
4072
|
+
particle.isRotating = false;
|
|
4073
|
+
particle.rotation = 0;
|
|
4074
|
+
particle.misplaced = false;
|
|
4075
|
+
particle.retina = {
|
|
4076
|
+
maxDistance: {},
|
|
4077
|
+
maxSpeed: 0,
|
|
4078
|
+
moveDrift: 0,
|
|
4079
|
+
moveSpeed: 0,
|
|
4080
|
+
sizeAnimationSpeed: 0,
|
|
4081
|
+
};
|
|
4082
|
+
particle.size = {
|
|
4083
|
+
value: 1,
|
|
4084
|
+
max: 1,
|
|
4085
|
+
min: 1,
|
|
4086
|
+
enable: false,
|
|
4087
|
+
};
|
|
4088
|
+
particle.outType = ParticleOutType.normal;
|
|
4089
|
+
particle.ignoresResizeRatio = true;
|
|
4090
|
+
}
|
|
4091
|
+
function resolveParticleOptions(particle, container, pluginManager, overrideOptions) {
|
|
4092
|
+
const mainOptions = container.actualOptions, particlesOptions = loadParticlesOptions(pluginManager, container, mainOptions.particles), reduceDuplicates = particlesOptions.reduceDuplicates;
|
|
4093
|
+
particle.effect = itemFromSingleOrMultiple(particlesOptions.effect.type, particle.id, reduceDuplicates);
|
|
4094
|
+
particle.shape = itemFromSingleOrMultiple(particlesOptions.shape.type, particle.id, reduceDuplicates);
|
|
4095
|
+
const effectOptions = particlesOptions.effect, shapeOptions = particlesOptions.shape;
|
|
4096
|
+
if (overrideOptions) {
|
|
4097
|
+
if (overrideOptions.effect) {
|
|
4098
|
+
const overrideEffectType = overrideOptions.effect.type;
|
|
4099
|
+
if (overrideEffectType && overrideEffectType !== particle.effect) {
|
|
4100
|
+
const effect = itemFromSingleOrMultiple(overrideEffectType, particle.id, reduceDuplicates);
|
|
4101
|
+
if (effect) {
|
|
4102
|
+
particle.effect = effect;
|
|
4103
|
+
}
|
|
4104
|
+
}
|
|
4105
|
+
effectOptions.load(overrideOptions.effect);
|
|
4106
|
+
}
|
|
4107
|
+
if (overrideOptions.shape) {
|
|
4108
|
+
const overrideShapeType = overrideOptions.shape.type;
|
|
4109
|
+
if (overrideShapeType && overrideShapeType !== particle.shape) {
|
|
4110
|
+
const shape = itemFromSingleOrMultiple(overrideShapeType, particle.id, reduceDuplicates);
|
|
4111
|
+
if (shape) {
|
|
4112
|
+
particle.shape = shape;
|
|
4113
|
+
}
|
|
4114
|
+
}
|
|
4115
|
+
shapeOptions.load(overrideOptions.shape);
|
|
4116
|
+
}
|
|
4117
|
+
}
|
|
4118
|
+
if (particle.effect === randomColorValue) {
|
|
4119
|
+
const availableEffects = [...container.effectDrawers.keys()];
|
|
4120
|
+
particle.effect = availableEffects[Math.floor(getRandom() * availableEffects.length)];
|
|
4121
|
+
}
|
|
4122
|
+
if (particle.shape === randomColorValue) {
|
|
4123
|
+
const availableShapes = [...container.shapeDrawers.keys()];
|
|
4124
|
+
particle.shape = availableShapes[Math.floor(getRandom() * availableShapes.length)];
|
|
4125
|
+
}
|
|
4126
|
+
particle.effectData = particle.effect
|
|
4127
|
+
? loadEffectData(particle.effect, effectOptions, particle.id, reduceDuplicates)
|
|
4128
|
+
: undefined;
|
|
4129
|
+
particle.shapeData = particle.shape
|
|
4130
|
+
? loadShapeData(particle.shape, shapeOptions, particle.id, reduceDuplicates)
|
|
4131
|
+
: undefined;
|
|
4132
|
+
particlesOptions.load(overrideOptions);
|
|
4133
|
+
const effectData = particle.effectData, shapeData = particle.shapeData;
|
|
4134
|
+
if (effectData) {
|
|
4135
|
+
particlesOptions.load(effectData.particles);
|
|
4136
|
+
}
|
|
4137
|
+
if (shapeData) {
|
|
4138
|
+
particlesOptions.load(shapeData.particles);
|
|
4139
|
+
}
|
|
4140
|
+
particle.effectClose = effectData?.close ?? particlesOptions.effect.close;
|
|
4141
|
+
particle.shapeClose = shapeData?.close ?? particlesOptions.shape.close;
|
|
4142
|
+
return particlesOptions;
|
|
4143
|
+
}
|
|
4144
|
+
function initParticleDrawers(particle, container) {
|
|
4145
|
+
let effectDrawer, shapeDrawer;
|
|
4146
|
+
if (particle.effect) {
|
|
4147
|
+
effectDrawer = container.effectDrawers.get(particle.effect);
|
|
4148
|
+
}
|
|
4149
|
+
if (effectDrawer?.loadEffect) {
|
|
4150
|
+
effectDrawer.loadEffect(particle);
|
|
4151
|
+
}
|
|
4152
|
+
if (particle.shape) {
|
|
4153
|
+
shapeDrawer = container.shapeDrawers.get(particle.shape);
|
|
4154
|
+
}
|
|
4155
|
+
if (shapeDrawer?.loadShape) {
|
|
4156
|
+
shapeDrawer.loadShape(particle);
|
|
4157
|
+
}
|
|
4158
|
+
const sideCountFunc = shapeDrawer?.getSidesCount;
|
|
4159
|
+
if (sideCountFunc) {
|
|
4160
|
+
particle.sides = sideCountFunc(particle);
|
|
4161
|
+
}
|
|
4162
|
+
}
|
|
4163
|
+
function runUpdaterPreInit(updaters, particle) {
|
|
4164
|
+
for (const updater of updaters) {
|
|
4165
|
+
updater.preInit?.(particle);
|
|
4166
|
+
}
|
|
4167
|
+
}
|
|
4168
|
+
function runUpdaterInit(updaters, particle) {
|
|
4169
|
+
for (const updater of updaters) {
|
|
4170
|
+
updater.init(particle);
|
|
4171
|
+
}
|
|
4172
|
+
}
|
|
4173
|
+
function runDrawerInit(container, particle) {
|
|
4174
|
+
const shapeDrawer = particle.shape ? container.shapeDrawers.get(particle.shape) : undefined, effectDrawer = particle.effect ? container.effectDrawers.get(particle.effect) : undefined;
|
|
4175
|
+
effectDrawer?.particleInit?.(container, particle);
|
|
4176
|
+
shapeDrawer?.particleInit?.(container, particle);
|
|
4177
|
+
}
|
|
4178
|
+
function runParticleCreatedPlugins(container, particle) {
|
|
4179
|
+
for (const plugin of container.particleCreatedPlugins) {
|
|
4180
|
+
plugin.particleCreated?.(particle);
|
|
4181
|
+
}
|
|
4182
|
+
}
|
|
4596
4183
|
class Particle {
|
|
4597
4184
|
backColor;
|
|
4598
4185
|
bubble;
|
|
@@ -4718,88 +4305,20 @@
|
|
|
4718
4305
|
const rotateData = this.getRotateData(), rotating = this.isRotating;
|
|
4719
4306
|
this.#cachedTransform.a = rotateData.cos * (externalTransform.a ?? defaultTransform.a);
|
|
4720
4307
|
this.#cachedTransform.b = rotating
|
|
4721
|
-
? rotateData.sin * (externalTransform.b ?? identity
|
|
4308
|
+
? rotateData.sin * (externalTransform.b ?? identity)
|
|
4722
4309
|
: (externalTransform.b ?? defaultTransform.b);
|
|
4723
4310
|
this.#cachedTransform.c = rotating
|
|
4724
|
-
? -rotateData.sin * (externalTransform.c ?? identity
|
|
4311
|
+
? -rotateData.sin * (externalTransform.c ?? identity)
|
|
4725
4312
|
: (externalTransform.c ?? defaultTransform.c);
|
|
4726
4313
|
this.#cachedTransform.d = rotateData.cos * (externalTransform.d ?? defaultTransform.d);
|
|
4727
4314
|
return this.#cachedTransform;
|
|
4728
4315
|
}
|
|
4729
4316
|
init(id, position, overrideOptions, group) {
|
|
4730
4317
|
const container = this.#container;
|
|
4731
|
-
this
|
|
4732
|
-
this.
|
|
4733
|
-
this.justWarped = false;
|
|
4734
|
-
this.effectClose = true;
|
|
4735
|
-
this.shapeClose = true;
|
|
4736
|
-
this.pathRotation = false;
|
|
4737
|
-
this.lastPathTime = 0;
|
|
4738
|
-
this.destroyed = false;
|
|
4739
|
-
this.unbreakable = false;
|
|
4740
|
-
this.isRotating = false;
|
|
4741
|
-
this.rotation = 0;
|
|
4742
|
-
this.misplaced = false;
|
|
4743
|
-
this.retina = {
|
|
4744
|
-
maxDistance: {},
|
|
4745
|
-
maxSpeed: 0,
|
|
4746
|
-
moveDrift: 0,
|
|
4747
|
-
moveSpeed: 0,
|
|
4748
|
-
sizeAnimationSpeed: 0,
|
|
4749
|
-
};
|
|
4750
|
-
this.size = {
|
|
4751
|
-
value: 1,
|
|
4752
|
-
max: 1,
|
|
4753
|
-
min: 1,
|
|
4754
|
-
enable: false,
|
|
4755
|
-
};
|
|
4756
|
-
this.outType = ParticleOutType.normal;
|
|
4757
|
-
this.ignoresResizeRatio = true;
|
|
4758
|
-
const mainOptions = container.actualOptions, particlesOptions = loadParticlesOptions(this.#pluginManager, container, mainOptions.particles), reduceDuplicates = particlesOptions.reduceDuplicates, effectType = particlesOptions.effect.type, shapeType = particlesOptions.shape.type;
|
|
4759
|
-
this.effect = itemFromSingleOrMultiple(effectType, this.id, reduceDuplicates);
|
|
4760
|
-
this.shape = itemFromSingleOrMultiple(shapeType, this.id, reduceDuplicates);
|
|
4761
|
-
const effectOptions = particlesOptions.effect, shapeOptions = particlesOptions.shape;
|
|
4762
|
-
if (overrideOptions) {
|
|
4763
|
-
if (overrideOptions.effect?.type && overrideOptions.effect.type !== this.effect) {
|
|
4764
|
-
const overrideEffectType = overrideOptions.effect.type, effect = itemFromSingleOrMultiple(overrideEffectType, this.id, reduceDuplicates);
|
|
4765
|
-
if (effect) {
|
|
4766
|
-
this.effect = effect;
|
|
4767
|
-
effectOptions.load(overrideOptions.effect);
|
|
4768
|
-
}
|
|
4769
|
-
}
|
|
4770
|
-
if (overrideOptions.shape?.type && overrideOptions.shape.type !== this.shape) {
|
|
4771
|
-
const overrideShapeType = overrideOptions.shape.type, shape = itemFromSingleOrMultiple(overrideShapeType, this.id, reduceDuplicates);
|
|
4772
|
-
if (shape) {
|
|
4773
|
-
this.shape = shape;
|
|
4774
|
-
shapeOptions.load(overrideOptions.shape);
|
|
4775
|
-
}
|
|
4776
|
-
}
|
|
4777
|
-
}
|
|
4778
|
-
if (this.effect === randomColorValue) {
|
|
4779
|
-
const availableEffects = [...this.#container.effectDrawers.keys()];
|
|
4780
|
-
this.effect = availableEffects[Math.floor(getRandom() * availableEffects.length)];
|
|
4781
|
-
}
|
|
4782
|
-
if (this.shape === randomColorValue) {
|
|
4783
|
-
const availableShapes = [...this.#container.shapeDrawers.keys()];
|
|
4784
|
-
this.shape = availableShapes[Math.floor(getRandom() * availableShapes.length)];
|
|
4785
|
-
}
|
|
4786
|
-
this.effectData = this.effect ? loadEffectData(this.effect, effectOptions, this.id, reduceDuplicates) : undefined;
|
|
4787
|
-
this.shapeData = this.shape ? loadShapeData(this.shape, shapeOptions, this.id, reduceDuplicates) : undefined;
|
|
4788
|
-
particlesOptions.load(overrideOptions);
|
|
4789
|
-
const effectData = this.effectData, shapeData = this.shapeData;
|
|
4790
|
-
if (effectData) {
|
|
4791
|
-
particlesOptions.load(effectData.particles);
|
|
4792
|
-
}
|
|
4793
|
-
if (shapeData) {
|
|
4794
|
-
particlesOptions.load(shapeData.particles);
|
|
4795
|
-
}
|
|
4796
|
-
this.effectClose = effectData?.close ?? particlesOptions.effect.close;
|
|
4797
|
-
this.shapeClose = shapeData?.close ?? particlesOptions.shape.close;
|
|
4798
|
-
this.options = particlesOptions;
|
|
4318
|
+
initParticleState(this, id, group);
|
|
4319
|
+
this.options = resolveParticleOptions(this, container, this.#pluginManager, overrideOptions);
|
|
4799
4320
|
container.retina.initParticle(this);
|
|
4800
|
-
|
|
4801
|
-
updater.preInit?.(this);
|
|
4802
|
-
}
|
|
4321
|
+
runUpdaterPreInit(container.particleUpdaters, this);
|
|
4803
4322
|
this.bubble = {
|
|
4804
4323
|
inRange: false,
|
|
4805
4324
|
};
|
|
@@ -4812,32 +4331,11 @@
|
|
|
4812
4331
|
this.velocity = this.initialVelocity.copy();
|
|
4813
4332
|
this.zIndexFactor = this.position.z / container.zLayers;
|
|
4814
4333
|
this.sides = 24;
|
|
4815
|
-
|
|
4816
|
-
if (this.effect) {
|
|
4817
|
-
effectDrawer = container.effectDrawers.get(this.effect);
|
|
4818
|
-
}
|
|
4819
|
-
if (effectDrawer?.loadEffect) {
|
|
4820
|
-
effectDrawer.loadEffect(this);
|
|
4821
|
-
}
|
|
4822
|
-
if (this.shape) {
|
|
4823
|
-
shapeDrawer = container.shapeDrawers.get(this.shape);
|
|
4824
|
-
}
|
|
4825
|
-
if (shapeDrawer?.loadShape) {
|
|
4826
|
-
shapeDrawer.loadShape(this);
|
|
4827
|
-
}
|
|
4828
|
-
const sideCountFunc = shapeDrawer?.getSidesCount;
|
|
4829
|
-
if (sideCountFunc) {
|
|
4830
|
-
this.sides = sideCountFunc(this);
|
|
4831
|
-
}
|
|
4334
|
+
initParticleDrawers(this, container);
|
|
4832
4335
|
this.spawning = false;
|
|
4833
|
-
|
|
4834
|
-
|
|
4835
|
-
|
|
4836
|
-
effectDrawer?.particleInit?.(container, this);
|
|
4837
|
-
shapeDrawer?.particleInit?.(container, this);
|
|
4838
|
-
for (const plugin of container.particleCreatedPlugins) {
|
|
4839
|
-
plugin.particleCreated?.(this);
|
|
4840
|
-
}
|
|
4336
|
+
runUpdaterInit(container.particleUpdaters, this);
|
|
4337
|
+
runDrawerInit(container, this);
|
|
4338
|
+
runParticleCreatedPlugins(container, this);
|
|
4841
4339
|
}
|
|
4842
4340
|
isInsideCanvas(direction) {
|
|
4843
4341
|
return this.#getInsideCanvasResult({ direction }).inside;
|
|
@@ -4851,15 +4349,15 @@
|
|
|
4851
4349
|
}
|
|
4852
4350
|
const angle = this.roll.angle;
|
|
4853
4351
|
if (this.roll.horizontal && this.roll.vertical) {
|
|
4854
|
-
const
|
|
4352
|
+
const adjustedAngle = normalizeAngle(angle, doublePI);
|
|
4855
4353
|
return adjustedAngle >= Math.PI * half && adjustedAngle < Math.PI * triple * half;
|
|
4856
4354
|
}
|
|
4857
4355
|
if (this.roll.horizontal) {
|
|
4858
|
-
const
|
|
4356
|
+
const adjustedAngle = normalizeAngle(angle + Math.PI * half, doublePI);
|
|
4859
4357
|
return adjustedAngle >= Math.PI && adjustedAngle < Math.PI * double;
|
|
4860
4358
|
}
|
|
4861
4359
|
if (this.roll.vertical) {
|
|
4862
|
-
const
|
|
4360
|
+
const adjustedAngle = normalizeAngle(angle, doublePI);
|
|
4863
4361
|
return adjustedAngle >= Math.PI && adjustedAngle < Math.PI * double;
|
|
4864
4362
|
}
|
|
4865
4363
|
return false;
|
|
@@ -4872,10 +4370,10 @@
|
|
|
4872
4370
|
updater.reset?.(this);
|
|
4873
4371
|
}
|
|
4874
4372
|
}
|
|
4875
|
-
#calcPosition
|
|
4373
|
+
#calcPosition(position, zIndex) {
|
|
4876
4374
|
let tryCount = defaultRetryCount, posVec = position ? Vector3d.create(position.x, position.y, zIndex) : undefined;
|
|
4877
|
-
const container = this.#container, plugins = container.particlePositionPlugins, outModes = this.options.move.outModes, radius = this.getRadius(), canvasSize = container.canvas.size
|
|
4878
|
-
|
|
4375
|
+
const container = this.#container, plugins = container.particlePositionPlugins, outModes = this.options.move.outModes, radius = this.getRadius(), canvasSize = container.canvas.size;
|
|
4376
|
+
for (;;) {
|
|
4879
4377
|
for (const plugin of plugins) {
|
|
4880
4378
|
const pluginPos = plugin.particlePosition?.(posVec, this);
|
|
4881
4379
|
if (pluginPos) {
|
|
@@ -4903,9 +4401,8 @@
|
|
|
4903
4401
|
tryCount += tryCountIncrement;
|
|
4904
4402
|
posVec = undefined;
|
|
4905
4403
|
}
|
|
4906
|
-
|
|
4907
|
-
|
|
4908
|
-
#calculateVelocity = () => {
|
|
4404
|
+
}
|
|
4405
|
+
#calculateVelocity() {
|
|
4909
4406
|
const moveOptions = this.options.move, baseVelocity = getParticleBaseVelocity(this.direction), res = baseVelocity.copy();
|
|
4910
4407
|
if (moveOptions.direction === MoveDirection.inside || moveOptions.direction === MoveDirection.outside) {
|
|
4911
4408
|
return res;
|
|
@@ -4921,8 +4418,8 @@
|
|
|
4921
4418
|
res.length *= getRandom();
|
|
4922
4419
|
}
|
|
4923
4420
|
return res;
|
|
4924
|
-
}
|
|
4925
|
-
#fixHorizontal
|
|
4421
|
+
}
|
|
4422
|
+
#fixHorizontal(pos, radius, outMode) {
|
|
4926
4423
|
fixOutMode({
|
|
4927
4424
|
outMode,
|
|
4928
4425
|
checkModes: [OutMode.bounce],
|
|
@@ -4931,8 +4428,8 @@
|
|
|
4931
4428
|
setCb: (value) => (pos.x += value),
|
|
4932
4429
|
radius,
|
|
4933
4430
|
});
|
|
4934
|
-
}
|
|
4935
|
-
#fixVertical
|
|
4431
|
+
}
|
|
4432
|
+
#fixVertical(pos, radius, outMode) {
|
|
4936
4433
|
fixOutMode({
|
|
4937
4434
|
outMode,
|
|
4938
4435
|
checkModes: [OutMode.bounce],
|
|
@@ -4941,8 +4438,8 @@
|
|
|
4941
4438
|
setCb: (value) => (pos.y += value),
|
|
4942
4439
|
radius,
|
|
4943
4440
|
});
|
|
4944
|
-
}
|
|
4945
|
-
#getDefaultInsideCanvasResult
|
|
4441
|
+
}
|
|
4442
|
+
#getDefaultInsideCanvasResult(direction, outMode) {
|
|
4946
4443
|
const radius = this.getRadius(), canvasSize = this.#container.canvas.size, position = this.position, isBounce = outMode === OutMode.bounce;
|
|
4947
4444
|
if (direction === OutModeDirection.bottom) {
|
|
4948
4445
|
return {
|
|
@@ -4975,8 +4472,8 @@
|
|
|
4975
4472
|
position.x <= canvasSize.width + radius,
|
|
4976
4473
|
reason: "default",
|
|
4977
4474
|
};
|
|
4978
|
-
}
|
|
4979
|
-
#getInsideCanvasCallbackData
|
|
4475
|
+
}
|
|
4476
|
+
#getInsideCanvasCallbackData(direction, outMode) {
|
|
4980
4477
|
return {
|
|
4981
4478
|
canvasSize: this.#container.canvas.size,
|
|
4982
4479
|
direction,
|
|
@@ -4984,8 +4481,8 @@
|
|
|
4984
4481
|
particle: this,
|
|
4985
4482
|
radius: this.getRadius(),
|
|
4986
4483
|
};
|
|
4987
|
-
}
|
|
4988
|
-
#getInsideCanvasResult
|
|
4484
|
+
}
|
|
4485
|
+
#getInsideCanvasResult(data) {
|
|
4989
4486
|
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;
|
|
4990
4487
|
if (!shapeCheck && !effectCheck) {
|
|
4991
4488
|
return defaultResult;
|
|
@@ -5000,8 +4497,8 @@
|
|
|
5000
4497
|
};
|
|
5001
4498
|
}
|
|
5002
4499
|
return shapeResult ?? effectResult ?? defaultResult;
|
|
5003
|
-
}
|
|
5004
|
-
#getRollColor
|
|
4500
|
+
}
|
|
4501
|
+
#getRollColor(color) {
|
|
5005
4502
|
if (!color || !this.roll || (!this.backColor && !this.roll.alter)) {
|
|
5006
4503
|
return color;
|
|
5007
4504
|
}
|
|
@@ -5015,8 +4512,8 @@
|
|
|
5015
4512
|
return alterHsl(color, this.roll.alter.type, this.roll.alter.value);
|
|
5016
4513
|
}
|
|
5017
4514
|
return color;
|
|
5018
|
-
}
|
|
5019
|
-
#initPosition
|
|
4515
|
+
}
|
|
4516
|
+
#initPosition(position) {
|
|
5020
4517
|
const container = this.#container, zIndexValue = Math.floor(getRangeValue(this.options.zIndex.value)), initialPosition = this.#calcPosition(position, clamp(zIndexValue, minZ, container.zLayers));
|
|
5021
4518
|
if (!initialPosition) {
|
|
5022
4519
|
throw new Error("a valid position cannot be found for particle");
|
|
@@ -5039,8 +4536,8 @@
|
|
|
5039
4536
|
break;
|
|
5040
4537
|
}
|
|
5041
4538
|
this.offset = Vector.origin;
|
|
5042
|
-
}
|
|
5043
|
-
#normalizeInsideCanvasResult
|
|
4539
|
+
}
|
|
4540
|
+
#normalizeInsideCanvasResult(result, reason) {
|
|
5044
4541
|
if (typeof result === "boolean") {
|
|
5045
4542
|
return {
|
|
5046
4543
|
inside: result,
|
|
@@ -5052,7 +4549,7 @@
|
|
|
5052
4549
|
margin: result.margin,
|
|
5053
4550
|
reason: result.reason ?? reason,
|
|
5054
4551
|
};
|
|
5055
|
-
}
|
|
4552
|
+
}
|
|
5056
4553
|
}
|
|
5057
4554
|
|
|
5058
4555
|
class SpatialHashGrid {
|
|
@@ -5405,10 +4902,10 @@
|
|
|
5405
4902
|
}
|
|
5406
4903
|
this.#resizeFactor = undefined;
|
|
5407
4904
|
}
|
|
5408
|
-
#addToPool
|
|
4905
|
+
#addToPool(...particles) {
|
|
5409
4906
|
this.#pool.push(...particles);
|
|
5410
|
-
}
|
|
5411
|
-
#applyDensity
|
|
4907
|
+
}
|
|
4908
|
+
#applyDensity(options, pluginsCount, group, groupOptions) {
|
|
5412
4909
|
const numberOptions = options.number;
|
|
5413
4910
|
if (!numberOptions.density.enable) {
|
|
5414
4911
|
if (group === undefined) {
|
|
@@ -5432,36 +4929,19 @@
|
|
|
5432
4929
|
else if (particlesCount > particlesNumber) {
|
|
5433
4930
|
this.removeQuantity(particlesCount - particlesNumber, group);
|
|
5434
4931
|
}
|
|
5435
|
-
}
|
|
5436
|
-
#createBuckets
|
|
4932
|
+
}
|
|
4933
|
+
#createBuckets(zLayers) {
|
|
5437
4934
|
const bucketCount = Math.max(Math.floor(zLayers), one);
|
|
5438
4935
|
return Array.from({ length: bucketCount }, () => []);
|
|
5439
|
-
}
|
|
5440
|
-
#getBucketIndex
|
|
4936
|
+
}
|
|
4937
|
+
#getBucketIndex(zIndex) {
|
|
5441
4938
|
const maxBucketIndex = this.#zBuckets.length - one;
|
|
5442
4939
|
if (maxBucketIndex <= minIndex) {
|
|
5443
4940
|
return minIndex;
|
|
5444
4941
|
}
|
|
5445
4942
|
return Math.min(Math.max(Math.floor(zIndex), minIndex), maxBucketIndex);
|
|
5446
|
-
}
|
|
5447
|
-
#
|
|
5448
|
-
let start = minIndex, end = bucket.length;
|
|
5449
|
-
while (start < end) {
|
|
5450
|
-
const middle = Math.floor((start + end) / double), middleParticle = bucket[middle];
|
|
5451
|
-
if (!middleParticle) {
|
|
5452
|
-
end = middle;
|
|
5453
|
-
continue;
|
|
5454
|
-
}
|
|
5455
|
-
if (middleParticle.id < particleId) {
|
|
5456
|
-
start = middle + one;
|
|
5457
|
-
}
|
|
5458
|
-
else {
|
|
5459
|
-
end = middle;
|
|
5460
|
-
}
|
|
5461
|
-
}
|
|
5462
|
-
return start;
|
|
5463
|
-
};
|
|
5464
|
-
#initDensityFactor = densityOptions => {
|
|
4943
|
+
}
|
|
4944
|
+
#initDensityFactor(densityOptions) {
|
|
5465
4945
|
const container = this.#container;
|
|
5466
4946
|
if (!densityOptions.enable) {
|
|
5467
4947
|
return defaultDensityFactor;
|
|
@@ -5471,16 +4951,16 @@
|
|
|
5471
4951
|
return defaultDensityFactor;
|
|
5472
4952
|
}
|
|
5473
4953
|
return ((canvasSize.width * canvasSize.height) / (densityOptions.height * densityOptions.width * pxRatio ** squareExp));
|
|
5474
|
-
}
|
|
5475
|
-
#insertParticleIntoBucket
|
|
4954
|
+
}
|
|
4955
|
+
#insertParticleIntoBucket(particle) {
|
|
5476
4956
|
const bucketIndex = this.#getBucketIndex(particle.position.z), bucket = this.#zBuckets[bucketIndex];
|
|
5477
4957
|
if (!bucket) {
|
|
5478
4958
|
return;
|
|
5479
4959
|
}
|
|
5480
|
-
bucket.
|
|
4960
|
+
bucket.push(particle);
|
|
5481
4961
|
this.#particleBuckets.set(particle.id, bucketIndex);
|
|
5482
|
-
}
|
|
5483
|
-
#removeParticle
|
|
4962
|
+
}
|
|
4963
|
+
#removeParticle(index, group, override) {
|
|
5484
4964
|
const particle = this.#array[index];
|
|
5485
4965
|
if (!particle) {
|
|
5486
4966
|
return false;
|
|
@@ -5496,22 +4976,20 @@
|
|
|
5496
4976
|
});
|
|
5497
4977
|
this.#addToPool(particle);
|
|
5498
4978
|
return true;
|
|
5499
|
-
}
|
|
5500
|
-
#removeParticleFromBucket
|
|
4979
|
+
}
|
|
4980
|
+
#removeParticleFromBucket(particle) {
|
|
5501
4981
|
const bucketIndex = this.#particleBuckets.get(particle.id) ?? this.#getBucketIndex(particle.position.z), bucket = this.#zBuckets[bucketIndex];
|
|
5502
4982
|
if (!bucket) {
|
|
5503
4983
|
this.#particleBuckets.delete(particle.id);
|
|
5504
4984
|
return;
|
|
5505
4985
|
}
|
|
5506
|
-
const
|
|
5507
|
-
if (
|
|
5508
|
-
|
|
5509
|
-
return;
|
|
4986
|
+
const idx = bucket.findIndex(p => p.id === particle.id);
|
|
4987
|
+
if (idx >= minIndex) {
|
|
4988
|
+
bucket.splice(idx, deleteCount);
|
|
5510
4989
|
}
|
|
5511
|
-
bucket.splice(particleIndex, deleteCount);
|
|
5512
4990
|
this.#particleBuckets.delete(particle.id);
|
|
5513
|
-
}
|
|
5514
|
-
#resetBuckets
|
|
4991
|
+
}
|
|
4992
|
+
#resetBuckets(zLayers) {
|
|
5515
4993
|
const bucketCount = Math.max(Math.floor(zLayers), one);
|
|
5516
4994
|
if (this.#zBuckets.length !== bucketCount) {
|
|
5517
4995
|
this.#zBuckets = this.#createBuckets(bucketCount);
|
|
@@ -5520,8 +4998,8 @@
|
|
|
5520
4998
|
for (const bucket of this.#zBuckets) {
|
|
5521
4999
|
bucket.length = minIndex;
|
|
5522
5000
|
}
|
|
5523
|
-
}
|
|
5524
|
-
#updateParticleBucket
|
|
5001
|
+
}
|
|
5002
|
+
#updateParticleBucket(particle) {
|
|
5525
5003
|
const newBucketIndex = this.#getBucketIndex(particle.position.z), currentBucketIndex = this.#particleBuckets.get(particle.id);
|
|
5526
5004
|
if (currentBucketIndex === undefined) {
|
|
5527
5005
|
this.#insertParticleIntoBucket(particle);
|
|
@@ -5532,9 +5010,9 @@
|
|
|
5532
5010
|
}
|
|
5533
5011
|
const currentBucket = this.#zBuckets[currentBucketIndex];
|
|
5534
5012
|
if (currentBucket) {
|
|
5535
|
-
const
|
|
5536
|
-
if (
|
|
5537
|
-
currentBucket.splice(
|
|
5013
|
+
const idx = currentBucket.findIndex(p => p.id === particle.id);
|
|
5014
|
+
if (idx >= minIndex) {
|
|
5015
|
+
currentBucket.splice(idx, deleteCount);
|
|
5538
5016
|
}
|
|
5539
5017
|
}
|
|
5540
5018
|
const newBucket = this.#zBuckets[newBucketIndex];
|
|
@@ -5542,10 +5020,16 @@
|
|
|
5542
5020
|
this.#particleBuckets.set(particle.id, newBucketIndex);
|
|
5543
5021
|
return;
|
|
5544
5022
|
}
|
|
5545
|
-
newBucket.
|
|
5023
|
+
newBucket.push(particle);
|
|
5024
|
+
if (newBucket.length >= double) {
|
|
5025
|
+
const prev = newBucket[newBucket.length - double];
|
|
5026
|
+
if (prev && particle.id < prev.id) {
|
|
5027
|
+
newBucket.sort((a, b) => a.id - b.id);
|
|
5028
|
+
}
|
|
5029
|
+
}
|
|
5546
5030
|
this.#particleBuckets.set(particle.id, newBucketIndex);
|
|
5547
|
-
}
|
|
5548
|
-
#updateParticlesPhase1
|
|
5031
|
+
}
|
|
5032
|
+
#updateParticlesPhase1(delta) {
|
|
5549
5033
|
const particlesToDelete = new Set(), resizeFactor = this.#resizeFactor;
|
|
5550
5034
|
for (const particle of this.#array) {
|
|
5551
5035
|
if (resizeFactor && !particle.ignoresResizeRatio) {
|
|
@@ -5571,8 +5055,8 @@
|
|
|
5571
5055
|
this.grid.insert(particle);
|
|
5572
5056
|
}
|
|
5573
5057
|
return particlesToDelete;
|
|
5574
|
-
}
|
|
5575
|
-
#updateParticlesPhase2
|
|
5058
|
+
}
|
|
5059
|
+
#updateParticlesPhase2(delta, particlesToDelete) {
|
|
5576
5060
|
for (const particle of this.#array) {
|
|
5577
5061
|
if (particle.destroyed) {
|
|
5578
5062
|
particlesToDelete.add(particle);
|
|
@@ -5588,7 +5072,7 @@
|
|
|
5588
5072
|
}
|
|
5589
5073
|
this.#updateParticleBucket(particle);
|
|
5590
5074
|
}
|
|
5591
|
-
}
|
|
5075
|
+
}
|
|
5592
5076
|
}
|
|
5593
5077
|
|
|
5594
5078
|
class Retina {
|
|
@@ -5950,7 +5434,7 @@
|
|
|
5950
5434
|
}
|
|
5951
5435
|
return refresh;
|
|
5952
5436
|
}
|
|
5953
|
-
#nextFrame
|
|
5437
|
+
#nextFrame(timestamp) {
|
|
5954
5438
|
try {
|
|
5955
5439
|
if (!this.#smooth &&
|
|
5956
5440
|
this.#lastFrameTime !== undefined &&
|
|
@@ -5978,7 +5462,7 @@
|
|
|
5978
5462
|
catch (e) {
|
|
5979
5463
|
getLogger().error("error in animation loop", e);
|
|
5980
5464
|
}
|
|
5981
|
-
}
|
|
5465
|
+
}
|
|
5982
5466
|
}
|
|
5983
5467
|
|
|
5984
5468
|
var Container$1 = /*#__PURE__*/Object.freeze({
|
|
@@ -6024,7 +5508,7 @@
|
|
|
6024
5508
|
BlendPluginInstance: BlendPluginInstance
|
|
6025
5509
|
});
|
|
6026
5510
|
|
|
6027
|
-
const
|
|
5511
|
+
const moveSpeedFactor = 60, minSpinRadius = 0, spinFactor = 0.01, defaultPathDelay = 0, noDecay = 1;
|
|
6028
5512
|
function applyDistance(particle) {
|
|
6029
5513
|
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;
|
|
6030
5514
|
if (!hDistance && !vDistance) {
|