@tsparticles/preset-stars 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 +3 -3
- package/report.html +1 -1
- package/tsparticles.preset.stars.bundle.js +925 -1421
- package/tsparticles.preset.stars.bundle.min.js +1 -1
- package/tsparticles.preset.stars.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
|
-
}
|
|
2407
|
-
const { context, fill, particle, stroke } = data;
|
|
2408
|
-
if (!particle.shape) {
|
|
2409
|
-
return;
|
|
2410
|
-
}
|
|
2411
|
-
context.beginPath();
|
|
2412
|
-
drawer.draw(data);
|
|
2413
|
-
if (particle.shapeClose) {
|
|
2414
|
-
context.closePath();
|
|
2415
|
-
}
|
|
2416
|
-
if (fill) {
|
|
2417
|
-
context.fill();
|
|
2418
|
-
}
|
|
2419
|
-
if (stroke) {
|
|
2420
|
-
context.stroke();
|
|
2421
1738
|
}
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
if (!drawer?.afterDraw) {
|
|
2425
|
-
return;
|
|
2426
|
-
}
|
|
2427
|
-
const { particle } = data;
|
|
2428
|
-
if (!particle.shape) {
|
|
2429
|
-
return;
|
|
2430
|
-
}
|
|
2431
|
-
drawer.afterDraw(data);
|
|
2432
|
-
}
|
|
2433
|
-
function drawShapeBeforeDraw(drawer, data) {
|
|
2434
|
-
if (!drawer?.beforeDraw) {
|
|
2435
|
-
return;
|
|
2436
|
-
}
|
|
2437
|
-
const { particle } = data;
|
|
2438
|
-
if (!particle.shape) {
|
|
2439
|
-
return;
|
|
2440
|
-
}
|
|
2441
|
-
drawer.beforeDraw(data);
|
|
2442
|
-
}
|
|
2443
|
-
function drawParticlePlugin(context, plugin, particle, delta) {
|
|
2444
|
-
if (!plugin.drawParticle) {
|
|
2445
|
-
return;
|
|
1739
|
+
#importPreset(preset) {
|
|
1740
|
+
this.load(this.#pluginManager.getPreset(preset));
|
|
2446
1741
|
}
|
|
2447
|
-
plugin.drawParticle(context, particle, delta);
|
|
2448
1742
|
}
|
|
2449
1743
|
|
|
2450
|
-
const styleCache = new Map(),
|
|
1744
|
+
const styleCache = new Map(), maxStyleCacheSize = 2000, rgbFixedPrecision = 2, hslFixedPrecision = 2, sdrReferenceWhiteNits = 203;
|
|
2451
1745
|
function getCachedStyle(key, generator) {
|
|
2452
1746
|
let cached = styleCache.get(key);
|
|
2453
1747
|
if (!cached) {
|
|
2454
1748
|
cached = generator();
|
|
2455
|
-
if (styleCache.size
|
|
2456
|
-
|
|
2457
|
-
keysToDelete.forEach(k => styleCache.delete(k));
|
|
1749
|
+
if (styleCache.size > maxStyleCacheSize) {
|
|
1750
|
+
styleCache.clear();
|
|
2458
1751
|
}
|
|
2459
1752
|
styleCache.set(key, cached);
|
|
2460
1753
|
}
|
|
@@ -2557,34 +1850,35 @@
|
|
|
2557
1850
|
function stringToRgb(pluginManager, input) {
|
|
2558
1851
|
return stringToRgba(pluginManager, input);
|
|
2559
1852
|
}
|
|
1853
|
+
function hslChannel(temp1, temp2, temp3) {
|
|
1854
|
+
const temp3Min = 0, temp3Max = 1;
|
|
1855
|
+
if (temp3 < temp3Min) {
|
|
1856
|
+
temp3++;
|
|
1857
|
+
}
|
|
1858
|
+
if (temp3 > temp3Max) {
|
|
1859
|
+
temp3--;
|
|
1860
|
+
}
|
|
1861
|
+
if (temp3 * sextuple < temp3Max) {
|
|
1862
|
+
return temp1 + (temp2 - temp1) * sextuple * temp3;
|
|
1863
|
+
}
|
|
1864
|
+
if (temp3 * double < temp3Max) {
|
|
1865
|
+
return temp2;
|
|
1866
|
+
}
|
|
1867
|
+
if (temp3 * triple < temp3Max * double) {
|
|
1868
|
+
const temp3Offset = double / triple;
|
|
1869
|
+
return temp1 + (temp2 - temp1) * (temp3Offset - temp3) * sextuple;
|
|
1870
|
+
}
|
|
1871
|
+
return temp1;
|
|
1872
|
+
}
|
|
2560
1873
|
function hslToRgb(hsl) {
|
|
2561
1874
|
const h = ((hsl.h % hMax) + hMax) % hMax, s = Math.max(sMin, Math.min(sMax, hsl.s)), l = Math.max(lMin, Math.min(lMax, hsl.l)), hNormalized = h / hMax, sNormalized = s / sMax, lNormalized = l / lMax;
|
|
2562
1875
|
if (s === sMin) {
|
|
2563
1876
|
const grayscaleValue = Math.round(lNormalized * rgbMax);
|
|
2564
1877
|
return { r: grayscaleValue, g: grayscaleValue, b: grayscaleValue };
|
|
2565
1878
|
}
|
|
2566
|
-
const
|
|
2567
|
-
const temp3Min = 0, temp3Max = 1;
|
|
2568
|
-
if (temp3 < temp3Min) {
|
|
2569
|
-
temp3++;
|
|
2570
|
-
}
|
|
2571
|
-
if (temp3 > temp3Max) {
|
|
2572
|
-
temp3--;
|
|
2573
|
-
}
|
|
2574
|
-
if (temp3 * sextuple < temp3Max) {
|
|
2575
|
-
return temp1 + (temp2 - temp1) * sextuple * temp3;
|
|
2576
|
-
}
|
|
2577
|
-
if (temp3 * double < temp3Max) {
|
|
2578
|
-
return temp2;
|
|
2579
|
-
}
|
|
2580
|
-
if (temp3 * triple < temp3Max * double) {
|
|
2581
|
-
const temp3Offset = double / triple;
|
|
2582
|
-
return temp1 + (temp2 - temp1) * (temp3Offset - temp3) * sextuple;
|
|
2583
|
-
}
|
|
2584
|
-
return temp1;
|
|
2585
|
-
}, temp1 = lNormalized < half
|
|
1879
|
+
const temp1 = lNormalized < half
|
|
2586
1880
|
? lNormalized * (sNormalizedOffset + sNormalized)
|
|
2587
|
-
: lNormalized + sNormalized - lNormalized * sNormalized, temp2 = double * lNormalized - temp1, phaseThird = phaseNumerator / triple, red = Math.min(rgbMax, rgbMax *
|
|
1881
|
+
: lNormalized + sNormalized - lNormalized * sNormalized, temp2 = double * lNormalized - temp1, phaseThird = phaseNumerator / triple, red = Math.min(rgbMax, rgbMax * hslChannel(temp2, temp1, hNormalized + phaseThird)), green = Math.min(rgbMax, rgbMax * hslChannel(temp2, temp1, hNormalized)), blue = Math.min(rgbMax, rgbMax * hslChannel(temp2, temp1, hNormalized - phaseThird));
|
|
2588
1882
|
return { r: Math.round(red), g: Math.round(green), b: Math.round(blue) };
|
|
2589
1883
|
}
|
|
2590
1884
|
function hslaToRgba(hsla) {
|
|
@@ -2597,7 +1891,7 @@
|
|
|
2597
1891
|
};
|
|
2598
1892
|
}
|
|
2599
1893
|
function getRandomRgbColor(min) {
|
|
2600
|
-
const fixedMin = defaultRgbMin, fixedMax = rgbMax + identity
|
|
1894
|
+
const fixedMin = defaultRgbMin, fixedMax = rgbMax + identity, getRgbInRangeValue = () => Math.floor(getRandomInRange(fixedMin, fixedMax));
|
|
2601
1895
|
return {
|
|
2602
1896
|
b: getRgbInRangeValue(),
|
|
2603
1897
|
g: getRgbInRangeValue(),
|
|
@@ -2608,21 +1902,18 @@
|
|
|
2608
1902
|
const op = opacity ?? defaultOpacity$1, key = `rgb-${color.r.toFixed(rgbFixedPrecision)}-${color.g.toFixed(rgbFixedPrecision)}-${color.b.toFixed(rgbFixedPrecision)}-${hdr ? "hdr" : "sdr"}-${op.toString()}`;
|
|
2609
1903
|
return getCachedStyle(key, () => (hdr ? getHdrStyleFromRgb(color, opacity) : getSdrStyleFromRgb(color, opacity)));
|
|
2610
1904
|
}
|
|
2611
|
-
function getHdrStyleFromRgb(color, opacity) {
|
|
2612
|
-
|
|
1905
|
+
function getHdrStyleFromRgb(color, opacity, peakNits = maxNits) {
|
|
1906
|
+
const headroom = peakNits / sdrReferenceWhiteNits;
|
|
1907
|
+
return `color(display-p3 ${((color.r / rgbMax) * headroom).toString()} ${((color.g / rgbMax) * headroom).toString()} ${((color.b / rgbMax) * headroom).toString()} / ${(opacity ?? defaultOpacity$1).toString()})`;
|
|
2613
1908
|
}
|
|
2614
1909
|
function getSdrStyleFromRgb(color, opacity) {
|
|
2615
1910
|
return `rgba(${color.r.toString()}, ${color.g.toString()}, ${color.b.toString()}, ${(opacity ?? defaultOpacity$1).toString()})`;
|
|
2616
1911
|
}
|
|
2617
1912
|
function getStyleFromHsl(color, hdr, opacity) {
|
|
2618
1913
|
const op = opacity ?? defaultOpacity$1, key = `hsl-${color.h.toFixed(hslFixedPrecision)}-${color.s.toFixed(hslFixedPrecision)}-${color.l.toFixed(hslFixedPrecision)}-${hdr ? "hdr" : "sdr"}-${op.toString()}`;
|
|
2619
|
-
return getCachedStyle(key, () =>
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
return getHdrStyleFromRgb(hslToRgb(color), opacity);
|
|
2623
|
-
}
|
|
2624
|
-
function getSdrStyleFromHsl(color, opacity) {
|
|
2625
|
-
return `hsla(${color.h.toString()}, ${color.s.toString()}%, ${color.l.toString()}%, ${(opacity ?? defaultOpacity$1).toString()})`;
|
|
1914
|
+
return getCachedStyle(key, () => hdr
|
|
1915
|
+
? getStyleFromRgb(hslToRgb(color), true, opacity)
|
|
1916
|
+
: `hsla(${color.h.toString()}, ${color.s.toString()}%, ${color.l.toString()}%, ${op.toString()})`);
|
|
2626
1917
|
}
|
|
2627
1918
|
function getHslFromAnimation(animation) {
|
|
2628
1919
|
return animation === undefined
|
|
@@ -2744,22 +2035,14 @@
|
|
|
2744
2035
|
const tsParticles = initEngine();
|
|
2745
2036
|
|
|
2746
2037
|
class Blend {
|
|
2747
|
-
enable;
|
|
2748
|
-
mode;
|
|
2749
|
-
constructor() {
|
|
2750
|
-
this.mode = "destination-out";
|
|
2751
|
-
this.enable = false;
|
|
2752
|
-
}
|
|
2038
|
+
enable = false;
|
|
2039
|
+
mode = "destination-out";
|
|
2753
2040
|
load(data) {
|
|
2754
2041
|
if (isNull(data)) {
|
|
2755
2042
|
return;
|
|
2756
2043
|
}
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
}
|
|
2760
|
-
if (data.enable !== undefined) {
|
|
2761
|
-
this.enable = data.enable;
|
|
2762
|
-
}
|
|
2044
|
+
loadProperty(this, "mode", data.mode);
|
|
2045
|
+
loadProperty(this, "enable", data.enable);
|
|
2763
2046
|
}
|
|
2764
2047
|
}
|
|
2765
2048
|
|
|
@@ -2789,7 +2072,7 @@
|
|
|
2789
2072
|
}
|
|
2790
2073
|
|
|
2791
2074
|
async function loadBlendPlugin(engine) {
|
|
2792
|
-
engine.checkVersion("4.
|
|
2075
|
+
engine.checkVersion("4.2.0");
|
|
2793
2076
|
await engine.pluginManager.register(e => {
|
|
2794
2077
|
e.pluginManager.addPlugin(new BlendPlugin());
|
|
2795
2078
|
});
|
|
@@ -2826,7 +2109,7 @@
|
|
|
2826
2109
|
}
|
|
2827
2110
|
|
|
2828
2111
|
async function loadCircleShape(engine) {
|
|
2829
|
-
engine.checkVersion("4.
|
|
2112
|
+
engine.checkVersion("4.2.0");
|
|
2830
2113
|
await engine.pluginManager.register(e => {
|
|
2831
2114
|
e.pluginManager.addShape(["circle"], () => {
|
|
2832
2115
|
return Promise.resolve(new CircleDrawer());
|
|
@@ -2874,7 +2157,7 @@
|
|
|
2874
2157
|
}
|
|
2875
2158
|
|
|
2876
2159
|
async function loadHexColorPlugin(engine) {
|
|
2877
|
-
engine.checkVersion("4.
|
|
2160
|
+
engine.checkVersion("4.2.0");
|
|
2878
2161
|
await engine.pluginManager.register(e => {
|
|
2879
2162
|
e.pluginManager.addColorManager("hex", new HexColorManager());
|
|
2880
2163
|
});
|
|
@@ -2927,7 +2210,7 @@
|
|
|
2927
2210
|
}
|
|
2928
2211
|
|
|
2929
2212
|
async function loadHslColorPlugin(engine) {
|
|
2930
|
-
engine.checkVersion("4.
|
|
2213
|
+
engine.checkVersion("4.2.0");
|
|
2931
2214
|
await engine.pluginManager.register(e => {
|
|
2932
2215
|
e.pluginManager.addColorManager("hsl", new HslColorManager());
|
|
2933
2216
|
});
|
|
@@ -2945,55 +2228,161 @@
|
|
|
2945
2228
|
}
|
|
2946
2229
|
loadOptions() {
|
|
2947
2230
|
}
|
|
2948
|
-
needsPlugin() {
|
|
2949
|
-
return true;
|
|
2231
|
+
needsPlugin() {
|
|
2232
|
+
return true;
|
|
2233
|
+
}
|
|
2234
|
+
}
|
|
2235
|
+
|
|
2236
|
+
async function loadMovePlugin(engine) {
|
|
2237
|
+
engine.checkVersion("4.2.0");
|
|
2238
|
+
await engine.pluginManager.register(e => {
|
|
2239
|
+
const moveEngine = e, movePluginManager = moveEngine.pluginManager;
|
|
2240
|
+
movePluginManager.initializers.pathGenerators ??= new Map();
|
|
2241
|
+
movePluginManager.pathGenerators ??= new Map();
|
|
2242
|
+
movePluginManager.addPathGenerator = (name, generator) => {
|
|
2243
|
+
movePluginManager.initializers.pathGenerators ??= new Map();
|
|
2244
|
+
movePluginManager.initializers.pathGenerators.set(name, generator);
|
|
2245
|
+
};
|
|
2246
|
+
movePluginManager.getPathGenerators = async (container, force = false) => {
|
|
2247
|
+
movePluginManager.initializers.pathGenerators ??= new Map();
|
|
2248
|
+
movePluginManager.pathGenerators ??= new Map();
|
|
2249
|
+
return getItemMapFromInitializer(container, movePluginManager.pathGenerators, movePluginManager.initializers.pathGenerators, force);
|
|
2250
|
+
};
|
|
2251
|
+
e.pluginManager.addPlugin(new MovePlugin(e.pluginManager));
|
|
2252
|
+
});
|
|
2253
|
+
}
|
|
2254
|
+
|
|
2255
|
+
function checkDestroy(particle, destroyType, value, minValue, maxValue) {
|
|
2256
|
+
switch (destroyType) {
|
|
2257
|
+
case DestroyType.max:
|
|
2258
|
+
if (value >= maxValue) {
|
|
2259
|
+
particle.destroy();
|
|
2260
|
+
}
|
|
2261
|
+
break;
|
|
2262
|
+
case DestroyType.min:
|
|
2263
|
+
if (value <= minValue) {
|
|
2264
|
+
particle.destroy();
|
|
2265
|
+
}
|
|
2266
|
+
break;
|
|
2267
|
+
}
|
|
2268
|
+
}
|
|
2269
|
+
function initParticleNumericAnimationValue(options, pxRatio) {
|
|
2270
|
+
const valueRange = options.value, animationOptions = options.animation, res = {
|
|
2271
|
+
delayTime: getRangeValue(animationOptions.delay) * millisecondsToSeconds,
|
|
2272
|
+
enable: animationOptions.enable,
|
|
2273
|
+
value: getRangeValue(options.value) * pxRatio,
|
|
2274
|
+
max: getRangeMax(valueRange) * pxRatio,
|
|
2275
|
+
min: getRangeMin(valueRange) * pxRatio,
|
|
2276
|
+
loops: 0,
|
|
2277
|
+
maxLoops: getRangeValue(animationOptions.count),
|
|
2278
|
+
time: 0,
|
|
2279
|
+
}, decayOffset = 1;
|
|
2280
|
+
if (animationOptions.enable) {
|
|
2281
|
+
res.decay = decayOffset - getRangeValue(animationOptions.decay);
|
|
2282
|
+
switch (animationOptions.mode) {
|
|
2283
|
+
case AnimationMode.increase:
|
|
2284
|
+
res.status = AnimationStatus.increasing;
|
|
2285
|
+
break;
|
|
2286
|
+
case AnimationMode.decrease:
|
|
2287
|
+
res.status = AnimationStatus.decreasing;
|
|
2288
|
+
break;
|
|
2289
|
+
case AnimationMode.random:
|
|
2290
|
+
res.status = getRandom() >= half ? AnimationStatus.increasing : AnimationStatus.decreasing;
|
|
2291
|
+
break;
|
|
2292
|
+
}
|
|
2293
|
+
const autoStatus = animationOptions.mode === AnimationMode.auto;
|
|
2294
|
+
switch (animationOptions.startValue) {
|
|
2295
|
+
case StartValueType.min:
|
|
2296
|
+
res.value = res.min;
|
|
2297
|
+
if (autoStatus) {
|
|
2298
|
+
res.status = AnimationStatus.increasing;
|
|
2299
|
+
}
|
|
2300
|
+
break;
|
|
2301
|
+
case StartValueType.max:
|
|
2302
|
+
res.value = res.max;
|
|
2303
|
+
if (autoStatus) {
|
|
2304
|
+
res.status = AnimationStatus.decreasing;
|
|
2305
|
+
}
|
|
2306
|
+
break;
|
|
2307
|
+
case StartValueType.random:
|
|
2308
|
+
default:
|
|
2309
|
+
res.value = randomInRangeValue(res);
|
|
2310
|
+
if (autoStatus) {
|
|
2311
|
+
res.status = getRandom() >= half ? AnimationStatus.increasing : AnimationStatus.decreasing;
|
|
2312
|
+
}
|
|
2313
|
+
break;
|
|
2314
|
+
}
|
|
2315
|
+
}
|
|
2316
|
+
res.initialValue = res.value;
|
|
2317
|
+
return res;
|
|
2318
|
+
}
|
|
2319
|
+
function updateAnimation(particle, data, changeDirection, destroyType, delta) {
|
|
2320
|
+
const minLoops = 0, minDelay = 0, identity = 1, minVelocity = 0, minDecay = 1;
|
|
2321
|
+
if (particle.destroyed ||
|
|
2322
|
+
!data.enable ||
|
|
2323
|
+
((data.maxLoops ?? minLoops) > minLoops && (data.loops ?? minLoops) > (data.maxLoops ?? minLoops))) {
|
|
2324
|
+
return;
|
|
2325
|
+
}
|
|
2326
|
+
const velocity = (data.velocity ?? minVelocity) * delta.factor, minValue = data.min, maxValue = data.max, decay = data.decay ?? minDecay;
|
|
2327
|
+
data.time ??= 0;
|
|
2328
|
+
const delayTime = data.delayTime ?? minDelay;
|
|
2329
|
+
if (delayTime > minDelay && data.time < delayTime) {
|
|
2330
|
+
data.time += delta.value;
|
|
2331
|
+
if (data.time < delayTime) {
|
|
2332
|
+
return;
|
|
2333
|
+
}
|
|
2334
|
+
}
|
|
2335
|
+
switch (data.status) {
|
|
2336
|
+
case AnimationStatus.increasing:
|
|
2337
|
+
data.value += velocity;
|
|
2338
|
+
break;
|
|
2339
|
+
case AnimationStatus.decreasing:
|
|
2340
|
+
data.value -= velocity;
|
|
2341
|
+
break;
|
|
2342
|
+
}
|
|
2343
|
+
if (data.velocity && decay !== identity) {
|
|
2344
|
+
data.velocity *= decay;
|
|
2345
|
+
}
|
|
2346
|
+
switch (data.status) {
|
|
2347
|
+
case AnimationStatus.increasing:
|
|
2348
|
+
if (data.value >= maxValue) {
|
|
2349
|
+
{
|
|
2350
|
+
data.status = AnimationStatus.decreasing;
|
|
2351
|
+
}
|
|
2352
|
+
data.loops ??= minLoops;
|
|
2353
|
+
data.loops++;
|
|
2354
|
+
}
|
|
2355
|
+
break;
|
|
2356
|
+
case AnimationStatus.decreasing:
|
|
2357
|
+
if (data.value <= minValue) {
|
|
2358
|
+
{
|
|
2359
|
+
data.status = AnimationStatus.increasing;
|
|
2360
|
+
}
|
|
2361
|
+
data.loops ??= minLoops;
|
|
2362
|
+
data.loops++;
|
|
2363
|
+
}
|
|
2364
|
+
break;
|
|
2365
|
+
}
|
|
2366
|
+
checkDestroy(particle, destroyType, data.value, minValue, maxValue);
|
|
2367
|
+
if (!particle.destroyed) {
|
|
2368
|
+
data.value = clamp(data.value, minValue, maxValue);
|
|
2950
2369
|
}
|
|
2951
2370
|
}
|
|
2952
2371
|
|
|
2953
|
-
async function loadMovePlugin(engine) {
|
|
2954
|
-
engine.checkVersion("4.1.2");
|
|
2955
|
-
await engine.pluginManager.register(e => {
|
|
2956
|
-
const moveEngine = e, movePluginManager = moveEngine.pluginManager;
|
|
2957
|
-
movePluginManager.initializers.pathGenerators ??= new Map();
|
|
2958
|
-
movePluginManager.pathGenerators ??= new Map();
|
|
2959
|
-
movePluginManager.addPathGenerator = (name, generator) => {
|
|
2960
|
-
movePluginManager.initializers.pathGenerators ??= new Map();
|
|
2961
|
-
movePluginManager.initializers.pathGenerators.set(name, generator);
|
|
2962
|
-
};
|
|
2963
|
-
movePluginManager.getPathGenerators = async (container, force = false) => {
|
|
2964
|
-
movePluginManager.initializers.pathGenerators ??= new Map();
|
|
2965
|
-
movePluginManager.pathGenerators ??= new Map();
|
|
2966
|
-
return getItemMapFromInitializer(container, movePluginManager.pathGenerators, movePluginManager.initializers.pathGenerators, force);
|
|
2967
|
-
};
|
|
2968
|
-
e.pluginManager.addPlugin(new MovePlugin(e.pluginManager));
|
|
2969
|
-
});
|
|
2970
|
-
}
|
|
2971
|
-
|
|
2972
2372
|
class OpacityAnimation extends RangedAnimationOptions {
|
|
2973
|
-
destroy;
|
|
2974
|
-
constructor() {
|
|
2975
|
-
super();
|
|
2976
|
-
this.destroy = DestroyType.none;
|
|
2977
|
-
this.speed = 2;
|
|
2978
|
-
}
|
|
2373
|
+
destroy = DestroyType.none;
|
|
2979
2374
|
load(data) {
|
|
2980
2375
|
super.load(data);
|
|
2981
2376
|
if (isNull(data)) {
|
|
2982
2377
|
return;
|
|
2983
2378
|
}
|
|
2984
|
-
|
|
2985
|
-
this.destroy = data.destroy;
|
|
2986
|
-
}
|
|
2379
|
+
loadProperty(this, "destroy", data.destroy);
|
|
2987
2380
|
}
|
|
2988
2381
|
}
|
|
2989
2382
|
|
|
2990
2383
|
class Opacity extends RangedAnimationValueWithRandom {
|
|
2991
|
-
animation;
|
|
2992
|
-
|
|
2993
|
-
super();
|
|
2994
|
-
this.animation = new OpacityAnimation();
|
|
2995
|
-
this.value = 1;
|
|
2996
|
-
}
|
|
2384
|
+
animation = new OpacityAnimation();
|
|
2385
|
+
value = 1;
|
|
2997
2386
|
load(data) {
|
|
2998
2387
|
if (isNull(data)) {
|
|
2999
2388
|
return;
|
|
@@ -3037,10 +2426,7 @@
|
|
|
3037
2426
|
(particle.opacity.loops ?? none) < (particle.opacity.maxLoops ?? none))));
|
|
3038
2427
|
}
|
|
3039
2428
|
loadOptions(options, ...sources) {
|
|
3040
|
-
options
|
|
3041
|
-
for (const source of sources) {
|
|
3042
|
-
options.opacity.load(source?.opacity);
|
|
3043
|
-
}
|
|
2429
|
+
loadOptionProperty(options, "opacity", Opacity, ...sources);
|
|
3044
2430
|
}
|
|
3045
2431
|
reset(particle) {
|
|
3046
2432
|
if (!particle.opacity) {
|
|
@@ -3058,7 +2444,7 @@
|
|
|
3058
2444
|
}
|
|
3059
2445
|
|
|
3060
2446
|
async function loadOpacityUpdater(engine) {
|
|
3061
|
-
engine.checkVersion("4.
|
|
2447
|
+
engine.checkVersion("4.2.0");
|
|
3062
2448
|
await engine.pluginManager.register(e => {
|
|
3063
2449
|
e.pluginManager.addParticleUpdater("opacity", container => {
|
|
3064
2450
|
return Promise.resolve(new OpacityUpdater(container));
|
|
@@ -3066,7 +2452,7 @@
|
|
|
3066
2452
|
});
|
|
3067
2453
|
}
|
|
3068
2454
|
|
|
3069
|
-
const
|
|
2455
|
+
const boundsMin = 0;
|
|
3070
2456
|
function bounceHorizontal(data) {
|
|
3071
2457
|
if ((data.outMode !== OutMode.bounce && data.outMode !== OutMode.split) ||
|
|
3072
2458
|
(data.direction !== OutModeDirection.left && data.direction !== OutModeDirection.right)) {
|
|
@@ -3081,8 +2467,8 @@
|
|
|
3081
2467
|
const velocity = data.particle.velocity.x;
|
|
3082
2468
|
let bounced = false;
|
|
3083
2469
|
if (data.outOfCanvas &&
|
|
3084
|
-
((data.direction === OutModeDirection.right && velocity > minVelocity
|
|
3085
|
-
(data.direction === OutModeDirection.left && velocity < minVelocity
|
|
2470
|
+
((data.direction === OutModeDirection.right && velocity > minVelocity) ||
|
|
2471
|
+
(data.direction === OutModeDirection.left && velocity < minVelocity))) {
|
|
3086
2472
|
const newVelocity = getRangeValue(data.particle.options.bounce.horizontal.value);
|
|
3087
2473
|
data.particle.velocity.x *= -newVelocity;
|
|
3088
2474
|
bounced = true;
|
|
@@ -3115,8 +2501,8 @@
|
|
|
3115
2501
|
const velocity = data.particle.velocity.y;
|
|
3116
2502
|
let bounced = false;
|
|
3117
2503
|
if (data.outOfCanvas &&
|
|
3118
|
-
((data.direction === OutModeDirection.bottom && velocity > minVelocity
|
|
3119
|
-
(data.direction === OutModeDirection.top && velocity < minVelocity
|
|
2504
|
+
((data.direction === OutModeDirection.bottom && velocity > minVelocity) ||
|
|
2505
|
+
(data.direction === OutModeDirection.top && velocity < minVelocity))) {
|
|
3120
2506
|
const newVelocity = getRangeValue(data.particle.options.bounce.vertical.value);
|
|
3121
2507
|
data.particle.velocity.y *= -newVelocity;
|
|
3122
2508
|
bounced = true;
|
|
@@ -3169,7 +2555,6 @@
|
|
|
3169
2555
|
}
|
|
3170
2556
|
}
|
|
3171
2557
|
|
|
3172
|
-
const minVelocity$3 = 0;
|
|
3173
2558
|
class DestroyOutMode {
|
|
3174
2559
|
modes;
|
|
3175
2560
|
constructor(_container) {
|
|
@@ -3188,10 +2573,10 @@
|
|
|
3188
2573
|
break;
|
|
3189
2574
|
case ParticleOutType.inside: {
|
|
3190
2575
|
const { dx, dy } = getDistances(particle.position, particle.moveCenter), { x: vx, y: vy } = particle.velocity;
|
|
3191
|
-
if ((vx < minVelocity
|
|
3192
|
-
(vy < minVelocity
|
|
3193
|
-
(vx >= minVelocity
|
|
3194
|
-
(vy >= minVelocity
|
|
2576
|
+
if ((vx < minVelocity && dx > particle.moveCenter.radius) ||
|
|
2577
|
+
(vy < minVelocity && dy > particle.moveCenter.radius) ||
|
|
2578
|
+
(vx >= minVelocity && dx < -particle.moveCenter.radius) ||
|
|
2579
|
+
(vy >= minVelocity && dy < -particle.moveCenter.radius)) {
|
|
3195
2580
|
return;
|
|
3196
2581
|
}
|
|
3197
2582
|
break;
|
|
@@ -3201,7 +2586,6 @@
|
|
|
3201
2586
|
}
|
|
3202
2587
|
}
|
|
3203
2588
|
|
|
3204
|
-
const minVelocity$2 = 0;
|
|
3205
2589
|
class NoneOutMode {
|
|
3206
2590
|
modes;
|
|
3207
2591
|
#container;
|
|
@@ -3221,10 +2605,10 @@
|
|
|
3221
2605
|
}
|
|
3222
2606
|
const gravityOptions = particle.options.move.gravity, container = this.#container, canvasSize = container.canvas.size, pRadius = particle.getRadius();
|
|
3223
2607
|
if (!gravityOptions.enable) {
|
|
3224
|
-
if ((particle.velocity.y > minVelocity
|
|
3225
|
-
(particle.velocity.y < minVelocity
|
|
3226
|
-
(particle.velocity.x > minVelocity
|
|
3227
|
-
(particle.velocity.x < minVelocity
|
|
2608
|
+
if ((particle.velocity.y > minVelocity && particle.position.y <= canvasSize.height + pRadius) ||
|
|
2609
|
+
(particle.velocity.y < minVelocity && particle.position.y >= -pRadius) ||
|
|
2610
|
+
(particle.velocity.x > minVelocity && particle.position.x <= canvasSize.width + pRadius) ||
|
|
2611
|
+
(particle.velocity.x < minVelocity && particle.position.x >= -pRadius)) {
|
|
3228
2612
|
return;
|
|
3229
2613
|
}
|
|
3230
2614
|
if (!isPointInside(particle.position, container.canvas.size, originPoint, pRadius, direction)) {
|
|
@@ -3243,7 +2627,7 @@
|
|
|
3243
2627
|
}
|
|
3244
2628
|
}
|
|
3245
2629
|
|
|
3246
|
-
const
|
|
2630
|
+
const updateVector = Vector.origin;
|
|
3247
2631
|
class OutOutMode {
|
|
3248
2632
|
modes;
|
|
3249
2633
|
#container;
|
|
@@ -3264,10 +2648,10 @@
|
|
|
3264
2648
|
updateVector.angle = particle.velocity.angle + Math.PI;
|
|
3265
2649
|
updateVector.addTo(particle.moveCenter);
|
|
3266
2650
|
const { dx, dy } = getDistances(particle.position, updateVector);
|
|
3267
|
-
if ((vx <= minVelocity
|
|
3268
|
-
(vy <= minVelocity
|
|
3269
|
-
(vx >= minVelocity
|
|
3270
|
-
(vy >= minVelocity
|
|
2651
|
+
if ((vx <= minVelocity && dx >= minDistance) ||
|
|
2652
|
+
(vy <= minVelocity && dy >= minDistance) ||
|
|
2653
|
+
(vx >= minVelocity && dx <= minDistance) ||
|
|
2654
|
+
(vy >= minVelocity && dy <= minDistance)) {
|
|
3271
2655
|
return;
|
|
3272
2656
|
}
|
|
3273
2657
|
particle.position.x = Math.floor(randomInRangeValue({
|
|
@@ -3391,21 +2775,21 @@
|
|
|
3391
2775
|
this.#updateOutMode(particle, delta, outModes.right ?? outModes.default, OutModeDirection.right);
|
|
3392
2776
|
this.#updateOutMode(particle, delta, outModes.top ?? outModes.default, OutModeDirection.top);
|
|
3393
2777
|
}
|
|
3394
|
-
#addUpdaterIfMissing
|
|
2778
|
+
#addUpdaterIfMissing(particle, outMode, getUpdater) {
|
|
3395
2779
|
const outModes = particle.options.move.outModes;
|
|
3396
2780
|
if (!this.updaters.has(outMode) && checkOutMode(outModes, outMode)) {
|
|
3397
2781
|
this.updaters.set(outMode, getUpdater(this.#container));
|
|
3398
2782
|
}
|
|
3399
|
-
}
|
|
3400
|
-
#updateOutMode
|
|
2783
|
+
}
|
|
2784
|
+
#updateOutMode(particle, delta, outMode, direction) {
|
|
3401
2785
|
for (const updater of this.updaters.values()) {
|
|
3402
2786
|
updater.update(particle, direction, delta, outMode);
|
|
3403
2787
|
}
|
|
3404
|
-
}
|
|
2788
|
+
}
|
|
3405
2789
|
}
|
|
3406
2790
|
|
|
3407
2791
|
async function loadOutModesUpdater(engine) {
|
|
3408
|
-
engine.checkVersion("4.
|
|
2792
|
+
engine.checkVersion("4.2.0");
|
|
3409
2793
|
await engine.pluginManager.register(e => {
|
|
3410
2794
|
e.pluginManager.addParticleUpdater("outModes", container => {
|
|
3411
2795
|
return Promise.resolve(new OutOfCanvasUpdater(container));
|
|
@@ -3476,7 +2860,7 @@
|
|
|
3476
2860
|
}
|
|
3477
2861
|
|
|
3478
2862
|
async function loadPaintUpdater(engine) {
|
|
3479
|
-
engine.checkVersion("4.
|
|
2863
|
+
engine.checkVersion("4.2.0");
|
|
3480
2864
|
await engine.pluginManager.register(e => {
|
|
3481
2865
|
e.pluginManager.addParticleUpdater("paint", container => {
|
|
3482
2866
|
return Promise.resolve(new PaintUpdater(e.pluginManager, container));
|
|
@@ -3531,37 +2915,26 @@
|
|
|
3531
2915
|
}
|
|
3532
2916
|
|
|
3533
2917
|
async function loadRgbColorPlugin(engine) {
|
|
3534
|
-
engine.checkVersion("4.
|
|
2918
|
+
engine.checkVersion("4.2.0");
|
|
3535
2919
|
await engine.pluginManager.register(e => {
|
|
3536
2920
|
e.pluginManager.addColorManager("rgb", new RgbColorManager());
|
|
3537
2921
|
});
|
|
3538
2922
|
}
|
|
3539
2923
|
|
|
3540
2924
|
class SizeAnimation extends RangedAnimationOptions {
|
|
3541
|
-
destroy;
|
|
3542
|
-
constructor() {
|
|
3543
|
-
super();
|
|
3544
|
-
this.destroy = DestroyType.none;
|
|
3545
|
-
this.speed = 5;
|
|
3546
|
-
}
|
|
2925
|
+
destroy = DestroyType.none;
|
|
3547
2926
|
load(data) {
|
|
3548
2927
|
super.load(data);
|
|
3549
2928
|
if (isNull(data)) {
|
|
3550
2929
|
return;
|
|
3551
2930
|
}
|
|
3552
|
-
|
|
3553
|
-
this.destroy = data.destroy;
|
|
3554
|
-
}
|
|
2931
|
+
loadProperty(this, "destroy", data.destroy);
|
|
3555
2932
|
}
|
|
3556
2933
|
}
|
|
3557
2934
|
|
|
3558
2935
|
class Size extends RangedAnimationValueWithRandom {
|
|
3559
|
-
animation;
|
|
3560
|
-
|
|
3561
|
-
super();
|
|
3562
|
-
this.animation = new SizeAnimation();
|
|
3563
|
-
this.value = 3;
|
|
3564
|
-
}
|
|
2936
|
+
animation = new SizeAnimation();
|
|
2937
|
+
value = 3;
|
|
3565
2938
|
load(data) {
|
|
3566
2939
|
super.load(data);
|
|
3567
2940
|
if (isNull(data)) {
|
|
@@ -3604,10 +2977,7 @@
|
|
|
3604
2977
|
(particle.size.loops ?? minLoops) < (particle.size.maxLoops ?? minLoops))));
|
|
3605
2978
|
}
|
|
3606
2979
|
loadOptions(options, ...sources) {
|
|
3607
|
-
options
|
|
3608
|
-
for (const source of sources) {
|
|
3609
|
-
options.size.load(source?.size);
|
|
3610
|
-
}
|
|
2980
|
+
loadOptionProperty(options, "size", Size, ...sources);
|
|
3611
2981
|
}
|
|
3612
2982
|
preInit(particle) {
|
|
3613
2983
|
const pxRatio = this.#container.retina.pixelRatio, options = particle.options, sizeOptions = options.size;
|
|
@@ -3630,7 +3000,7 @@
|
|
|
3630
3000
|
}
|
|
3631
3001
|
|
|
3632
3002
|
async function loadSizeUpdater(engine) {
|
|
3633
|
-
engine.checkVersion("4.
|
|
3003
|
+
engine.checkVersion("4.2.0");
|
|
3634
3004
|
await engine.pluginManager.register(e => {
|
|
3635
3005
|
e.pluginManager.addParticleUpdater("size", container => {
|
|
3636
3006
|
return Promise.resolve(new SizeUpdater(container));
|
|
@@ -3639,7 +3009,7 @@
|
|
|
3639
3009
|
}
|
|
3640
3010
|
|
|
3641
3011
|
async function loadBasic(engine) {
|
|
3642
|
-
engine.checkVersion("4.
|
|
3012
|
+
engine.checkVersion("4.2.0");
|
|
3643
3013
|
await engine.pluginManager.register(async (e) => {
|
|
3644
3014
|
await Promise.all([
|
|
3645
3015
|
loadBlendPlugin(e),
|
|
@@ -3761,7 +3131,7 @@
|
|
|
3761
3131
|
return;
|
|
3762
3132
|
}
|
|
3763
3133
|
this.draw(ctx => {
|
|
3764
|
-
|
|
3134
|
+
ctx.clearRect(originPoint.x, originPoint.y, this.#canvasManager.size.width, this.#canvasManager.size.height);
|
|
3765
3135
|
});
|
|
3766
3136
|
}
|
|
3767
3137
|
clear() {
|
|
@@ -3823,7 +3193,7 @@
|
|
|
3823
3193
|
plugin.drawParticleSetup?.(context, particle, delta);
|
|
3824
3194
|
}
|
|
3825
3195
|
this.#applyPreDrawUpdaters(context, particle, radius, opacity, colorStyles, transform);
|
|
3826
|
-
drawParticle({
|
|
3196
|
+
this.#drawParticle({
|
|
3827
3197
|
container,
|
|
3828
3198
|
context,
|
|
3829
3199
|
particle,
|
|
@@ -3842,7 +3212,7 @@
|
|
|
3842
3212
|
drawParticlePlugins(particle, delta) {
|
|
3843
3213
|
this.draw(ctx => {
|
|
3844
3214
|
for (const plugin of this.#drawParticlePlugins) {
|
|
3845
|
-
drawParticlePlugin(ctx, plugin, particle, delta);
|
|
3215
|
+
this.#drawParticlePlugin(ctx, plugin, particle, delta);
|
|
3846
3216
|
}
|
|
3847
3217
|
});
|
|
3848
3218
|
}
|
|
@@ -3942,12 +3312,19 @@
|
|
|
3942
3312
|
}
|
|
3943
3313
|
paintBase(baseColor) {
|
|
3944
3314
|
this.draw(ctx => {
|
|
3945
|
-
|
|
3315
|
+
ctx.fillStyle = baseColor ?? "rgba(0,0,0,0)";
|
|
3316
|
+
ctx.fillRect(originPoint.x, originPoint.y, this.#canvasManager.size.width, this.#canvasManager.size.height);
|
|
3946
3317
|
});
|
|
3947
3318
|
}
|
|
3948
3319
|
paintImage(image, opacity) {
|
|
3949
3320
|
this.draw(ctx => {
|
|
3950
|
-
|
|
3321
|
+
if (!image) {
|
|
3322
|
+
return;
|
|
3323
|
+
}
|
|
3324
|
+
const prevAlpha = ctx.globalAlpha;
|
|
3325
|
+
ctx.globalAlpha = opacity;
|
|
3326
|
+
ctx.drawImage(image, originPoint.x, originPoint.y, this.#canvasManager.size.width, this.#canvasManager.size.height);
|
|
3327
|
+
ctx.globalAlpha = prevAlpha;
|
|
3951
3328
|
});
|
|
3952
3329
|
}
|
|
3953
3330
|
setContext(context) {
|
|
@@ -3961,15 +3338,15 @@
|
|
|
3961
3338
|
}
|
|
3962
3339
|
stop() {
|
|
3963
3340
|
this.draw(ctx => {
|
|
3964
|
-
|
|
3341
|
+
ctx.clearRect(originPoint.x, originPoint.y, this.#canvasManager.size.width, this.#canvasManager.size.height);
|
|
3965
3342
|
});
|
|
3966
3343
|
}
|
|
3967
|
-
#applyPostDrawUpdaters
|
|
3344
|
+
#applyPostDrawUpdaters(particle) {
|
|
3968
3345
|
for (const updater of this.#postDrawUpdaters) {
|
|
3969
3346
|
updater.afterDraw?.(particle);
|
|
3970
3347
|
}
|
|
3971
|
-
}
|
|
3972
|
-
#applyPreDrawUpdaters
|
|
3348
|
+
}
|
|
3349
|
+
#applyPreDrawUpdaters(ctx, particle, radius, zOpacity, colorStyles, transform) {
|
|
3973
3350
|
for (const updater of this.#preDrawUpdaters) {
|
|
3974
3351
|
if (updater.getColorStyles) {
|
|
3975
3352
|
const { fill, stroke } = updater.getColorStyles(particle, ctx, radius, zOpacity);
|
|
@@ -3988,8 +3365,114 @@
|
|
|
3988
3365
|
}
|
|
3989
3366
|
updater.beforeDraw?.(particle);
|
|
3990
3367
|
}
|
|
3991
|
-
}
|
|
3992
|
-
#
|
|
3368
|
+
}
|
|
3369
|
+
#drawAfterEffect(drawer, data) {
|
|
3370
|
+
if (!drawer?.drawAfter) {
|
|
3371
|
+
return;
|
|
3372
|
+
}
|
|
3373
|
+
const { particle } = data;
|
|
3374
|
+
if (!particle.effect) {
|
|
3375
|
+
return;
|
|
3376
|
+
}
|
|
3377
|
+
drawer.drawAfter(data);
|
|
3378
|
+
}
|
|
3379
|
+
#drawBeforeEffect(drawer, data) {
|
|
3380
|
+
if (!drawer?.drawBefore) {
|
|
3381
|
+
return;
|
|
3382
|
+
}
|
|
3383
|
+
const { particle } = data;
|
|
3384
|
+
if (!particle.effect) {
|
|
3385
|
+
return;
|
|
3386
|
+
}
|
|
3387
|
+
drawer.drawBefore(data);
|
|
3388
|
+
}
|
|
3389
|
+
#drawParticle(data) {
|
|
3390
|
+
const { container, context, particle, delta, colorStyles, radius, opacity, transform } = data, { effectDrawers, shapeDrawers } = container, pos = particle.getPosition(), transformData = particle.getTransformData(transform), drawScale = defaultZoom, drawPosition = {
|
|
3391
|
+
x: pos.x,
|
|
3392
|
+
y: pos.y,
|
|
3393
|
+
};
|
|
3394
|
+
context.setTransform(transformData.a, transformData.b, transformData.c, transformData.d, pos.x, pos.y);
|
|
3395
|
+
if (colorStyles.fill) {
|
|
3396
|
+
context.fillStyle = colorStyles.fill;
|
|
3397
|
+
}
|
|
3398
|
+
const fillEnabled = !!particle.fillEnabled, strokeWidth = particle.strokeWidth ?? minStrokeWidth;
|
|
3399
|
+
context.lineWidth = strokeWidth;
|
|
3400
|
+
if (colorStyles.stroke) {
|
|
3401
|
+
context.strokeStyle = colorStyles.stroke;
|
|
3402
|
+
}
|
|
3403
|
+
const drawData = {
|
|
3404
|
+
context,
|
|
3405
|
+
particle,
|
|
3406
|
+
radius,
|
|
3407
|
+
drawRadius: radius * drawScale,
|
|
3408
|
+
opacity,
|
|
3409
|
+
delta,
|
|
3410
|
+
pixelRatio: container.retina.pixelRatio,
|
|
3411
|
+
fill: fillEnabled,
|
|
3412
|
+
stroke: strokeWidth > minStrokeWidth,
|
|
3413
|
+
transformData,
|
|
3414
|
+
position: { ...pos },
|
|
3415
|
+
drawPosition,
|
|
3416
|
+
drawScale,
|
|
3417
|
+
};
|
|
3418
|
+
for (const plugin of container.plugins) {
|
|
3419
|
+
plugin.drawParticleTransform?.(drawData);
|
|
3420
|
+
}
|
|
3421
|
+
const effect = particle.effect ? effectDrawers.get(particle.effect) : undefined, shape = particle.shape ? shapeDrawers.get(particle.shape) : undefined;
|
|
3422
|
+
this.#drawBeforeEffect(effect, drawData);
|
|
3423
|
+
this.#drawShapeBeforeDraw(shape, drawData);
|
|
3424
|
+
this.#drawShape(shape, drawData);
|
|
3425
|
+
this.#drawShapeAfterDraw(shape, drawData);
|
|
3426
|
+
this.#drawAfterEffect(effect, drawData);
|
|
3427
|
+
context.resetTransform();
|
|
3428
|
+
}
|
|
3429
|
+
#drawParticlePlugin(context, plugin, particle, delta) {
|
|
3430
|
+
if (!plugin.drawParticle) {
|
|
3431
|
+
return;
|
|
3432
|
+
}
|
|
3433
|
+
plugin.drawParticle(context, particle, delta);
|
|
3434
|
+
}
|
|
3435
|
+
#drawShape(drawer, data) {
|
|
3436
|
+
if (!drawer) {
|
|
3437
|
+
return;
|
|
3438
|
+
}
|
|
3439
|
+
const { context, fill, particle, stroke } = data;
|
|
3440
|
+
if (!particle.shape) {
|
|
3441
|
+
return;
|
|
3442
|
+
}
|
|
3443
|
+
context.beginPath();
|
|
3444
|
+
drawer.draw(data);
|
|
3445
|
+
if (particle.shapeClose) {
|
|
3446
|
+
context.closePath();
|
|
3447
|
+
}
|
|
3448
|
+
if (fill) {
|
|
3449
|
+
context.fill();
|
|
3450
|
+
}
|
|
3451
|
+
if (stroke) {
|
|
3452
|
+
context.stroke();
|
|
3453
|
+
}
|
|
3454
|
+
}
|
|
3455
|
+
#drawShapeAfterDraw(drawer, data) {
|
|
3456
|
+
if (!drawer?.afterDraw) {
|
|
3457
|
+
return;
|
|
3458
|
+
}
|
|
3459
|
+
const { particle } = data;
|
|
3460
|
+
if (!particle.shape) {
|
|
3461
|
+
return;
|
|
3462
|
+
}
|
|
3463
|
+
drawer.afterDraw(data);
|
|
3464
|
+
}
|
|
3465
|
+
#drawShapeBeforeDraw(drawer, data) {
|
|
3466
|
+
if (!drawer?.beforeDraw) {
|
|
3467
|
+
return;
|
|
3468
|
+
}
|
|
3469
|
+
const { particle } = data;
|
|
3470
|
+
if (!particle.shape) {
|
|
3471
|
+
return;
|
|
3472
|
+
}
|
|
3473
|
+
drawer.beforeDraw(data);
|
|
3474
|
+
}
|
|
3475
|
+
#getPluginParticleColors(particle) {
|
|
3993
3476
|
let fColor, sColor;
|
|
3994
3477
|
for (const plugin of this.#colorPlugins) {
|
|
3995
3478
|
if (!fColor && plugin.particleFillColor) {
|
|
@@ -4005,7 +3488,7 @@
|
|
|
4005
3488
|
this.#reusablePluginColors[fColorIndex] = fColor;
|
|
4006
3489
|
this.#reusablePluginColors[sColorIndex] = sColor;
|
|
4007
3490
|
return this.#reusablePluginColors;
|
|
4008
|
-
}
|
|
3491
|
+
}
|
|
4009
3492
|
}
|
|
4010
3493
|
|
|
4011
3494
|
const transferredCanvases = new WeakMap(), getTransferredCanvas = (canvas) => {
|
|
@@ -4137,6 +3620,7 @@
|
|
|
4137
3620
|
obs.observe(element, { attributes: true });
|
|
4138
3621
|
});
|
|
4139
3622
|
this.initPlugins();
|
|
3623
|
+
this.#initContext();
|
|
4140
3624
|
this.render.init();
|
|
4141
3625
|
}
|
|
4142
3626
|
initBackground() {
|
|
@@ -4146,7 +3630,7 @@
|
|
|
4146
3630
|
}
|
|
4147
3631
|
const elementStyle = element.style, color = rangeColorToRgb(this.#pluginManager, background.color);
|
|
4148
3632
|
if (color) {
|
|
4149
|
-
elementStyle.backgroundColor = getStyleFromRgb(color, container.hdr, background.opacity);
|
|
3633
|
+
elementStyle.backgroundColor = getStyleFromRgb(color, container.actualOptions.hdr, background.opacity);
|
|
4150
3634
|
}
|
|
4151
3635
|
else {
|
|
4152
3636
|
elementStyle.backgroundColor = "";
|
|
@@ -4168,7 +3652,7 @@
|
|
|
4168
3652
|
if (this.#generated && this.domElement) {
|
|
4169
3653
|
this.domElement.remove();
|
|
4170
3654
|
}
|
|
4171
|
-
const
|
|
3655
|
+
const domCanvas = isHtmlCanvasElement(canvas) ? canvas : undefined;
|
|
4172
3656
|
this.domElement = domCanvas;
|
|
4173
3657
|
this.#generated = domCanvas ? domCanvas.dataset[generatedAttribute] === "true" : false;
|
|
4174
3658
|
this.renderCanvas = domCanvas ? getTransferredCanvas(domCanvas) : canvas;
|
|
@@ -4189,26 +3673,6 @@
|
|
|
4189
3673
|
const pxRatio = this.#container.retina.pixelRatio, retinaSize = this.size;
|
|
4190
3674
|
renderCanvas.height = retinaSize.height = standardSize.height * pxRatio;
|
|
4191
3675
|
renderCanvas.width = retinaSize.width = standardSize.width * pxRatio;
|
|
4192
|
-
const canSupportHdrQuery = safeMatchMedia("(color-gamut: p3)");
|
|
4193
|
-
this.render.setContextSettings({
|
|
4194
|
-
alpha: true,
|
|
4195
|
-
colorSpace: canSupportHdrQuery?.matches && container.hdr ? "display-p3" : "srgb",
|
|
4196
|
-
desynchronized: true,
|
|
4197
|
-
willReadFrequently: false,
|
|
4198
|
-
});
|
|
4199
|
-
this.render.setContext(renderCanvas.getContext("2d", this.render.settings));
|
|
4200
|
-
this.#safeMutationObserver(obs => {
|
|
4201
|
-
obs.disconnect();
|
|
4202
|
-
});
|
|
4203
|
-
container.retina.init();
|
|
4204
|
-
this.initBackground();
|
|
4205
|
-
this.#safeMutationObserver(obs => {
|
|
4206
|
-
const element = this.domElement;
|
|
4207
|
-
if (!element || !(element instanceof Node)) {
|
|
4208
|
-
return;
|
|
4209
|
-
}
|
|
4210
|
-
obs.observe(element, { attributes: true });
|
|
4211
|
-
});
|
|
4212
3676
|
}
|
|
4213
3677
|
resize() {
|
|
4214
3678
|
const element = this.domElement;
|
|
@@ -4276,12 +3740,30 @@
|
|
|
4276
3740
|
await container.refresh();
|
|
4277
3741
|
}
|
|
4278
3742
|
}
|
|
4279
|
-
#applyResizePlugins
|
|
3743
|
+
#applyResizePlugins() {
|
|
4280
3744
|
for (const plugin of this.#resizePlugins) {
|
|
4281
3745
|
plugin.resize?.();
|
|
4282
3746
|
}
|
|
4283
|
-
}
|
|
4284
|
-
#
|
|
3747
|
+
}
|
|
3748
|
+
#initContext() {
|
|
3749
|
+
const container = this.#container, canSupportHdr = container.actualOptions.hdr &&
|
|
3750
|
+
safeMatchMedia("(color-gamut: p3)")?.matches &&
|
|
3751
|
+
safeMatchMedia("(dynamic-range: high)")?.matches;
|
|
3752
|
+
this.render.setContextSettings({
|
|
3753
|
+
alpha: true,
|
|
3754
|
+
desynchronized: true,
|
|
3755
|
+
willReadFrequently: false,
|
|
3756
|
+
...(canSupportHdr
|
|
3757
|
+
? { colorSpace: "display-p3", colorType: "float16" }
|
|
3758
|
+
: { colorSpace: "srgb" }),
|
|
3759
|
+
});
|
|
3760
|
+
const renderCanvas = this.renderCanvas;
|
|
3761
|
+
if (!renderCanvas) {
|
|
3762
|
+
return;
|
|
3763
|
+
}
|
|
3764
|
+
this.render.setContext(renderCanvas.getContext("2d", this.render.settings));
|
|
3765
|
+
}
|
|
3766
|
+
#initStyle() {
|
|
4285
3767
|
const element = this.domElement, options = this.#container.actualOptions;
|
|
4286
3768
|
if (!element) {
|
|
4287
3769
|
return;
|
|
@@ -4302,8 +3784,8 @@
|
|
|
4302
3784
|
}
|
|
4303
3785
|
element.style.setProperty(key, value, "important");
|
|
4304
3786
|
}
|
|
4305
|
-
}
|
|
4306
|
-
#repairStyle
|
|
3787
|
+
}
|
|
3788
|
+
#repairStyle() {
|
|
4307
3789
|
const element = this.domElement;
|
|
4308
3790
|
if (!element) {
|
|
4309
3791
|
return;
|
|
@@ -4322,27 +3804,27 @@
|
|
|
4322
3804
|
}
|
|
4323
3805
|
observer.observe(element, { attributes: true });
|
|
4324
3806
|
});
|
|
4325
|
-
}
|
|
4326
|
-
#resetOriginalStyle
|
|
3807
|
+
}
|
|
3808
|
+
#resetOriginalStyle() {
|
|
4327
3809
|
const element = this.domElement, originalStyle = this.#originalStyle;
|
|
4328
3810
|
if (!element || !originalStyle) {
|
|
4329
3811
|
return;
|
|
4330
3812
|
}
|
|
4331
3813
|
setStyle(element, originalStyle, true);
|
|
4332
|
-
}
|
|
4333
|
-
#safeMutationObserver
|
|
3814
|
+
}
|
|
3815
|
+
#safeMutationObserver(callback) {
|
|
4334
3816
|
if (!this.#mutationObserver) {
|
|
4335
3817
|
return;
|
|
4336
3818
|
}
|
|
4337
3819
|
callback(this.#mutationObserver);
|
|
4338
|
-
}
|
|
4339
|
-
#setFullScreenStyle
|
|
3820
|
+
}
|
|
3821
|
+
#setFullScreenStyle() {
|
|
4340
3822
|
const element = this.domElement;
|
|
4341
3823
|
if (!element) {
|
|
4342
3824
|
return;
|
|
4343
3825
|
}
|
|
4344
3826
|
setStyle(element, getFullScreenStyle(this.#container.actualOptions.fullScreen.zIndex), true);
|
|
4345
|
-
}
|
|
3827
|
+
}
|
|
4346
3828
|
}
|
|
4347
3829
|
|
|
4348
3830
|
class EventListeners {
|
|
@@ -4367,7 +3849,7 @@
|
|
|
4367
3849
|
removeListeners() {
|
|
4368
3850
|
this.#manageListeners(false);
|
|
4369
3851
|
}
|
|
4370
|
-
#handleVisibilityChange
|
|
3852
|
+
#handleVisibilityChange() {
|
|
4371
3853
|
const container = this.#container, options = container.actualOptions;
|
|
4372
3854
|
if (!options.pauseOnBlur) {
|
|
4373
3855
|
return;
|
|
@@ -4385,8 +3867,8 @@
|
|
|
4385
3867
|
container.draw(true);
|
|
4386
3868
|
}
|
|
4387
3869
|
}
|
|
4388
|
-
}
|
|
4389
|
-
#handleWindowResize
|
|
3870
|
+
}
|
|
3871
|
+
#handleWindowResize() {
|
|
4390
3872
|
if (this.#resizeTimeout) {
|
|
4391
3873
|
clearTimeout(this.#resizeTimeout);
|
|
4392
3874
|
this.#resizeTimeout = undefined;
|
|
@@ -4396,13 +3878,13 @@
|
|
|
4396
3878
|
await canvas.windowResize();
|
|
4397
3879
|
};
|
|
4398
3880
|
this.#resizeTimeout = setTimeout(() => void handleResize(), this.#container.actualOptions.resize.delay * millisecondsToSeconds);
|
|
4399
|
-
}
|
|
4400
|
-
#manageListeners
|
|
3881
|
+
}
|
|
3882
|
+
#manageListeners(add) {
|
|
4401
3883
|
const handlers = this.#handlers;
|
|
4402
3884
|
this.#manageResize(add);
|
|
4403
3885
|
manageListener(document, visibilityChangeEvent, handlers.visibilityChange, add, false);
|
|
4404
|
-
}
|
|
4405
|
-
#manageResize
|
|
3886
|
+
}
|
|
3887
|
+
#manageResize(add) {
|
|
4406
3888
|
const handlers = this.#handlers, container = this.#container, options = container.actualOptions;
|
|
4407
3889
|
if (!options.resize.enable) {
|
|
4408
3890
|
return;
|
|
@@ -4429,7 +3911,7 @@
|
|
|
4429
3911
|
});
|
|
4430
3912
|
this.#resizeObserver.observe(canvasEl);
|
|
4431
3913
|
}
|
|
4432
|
-
}
|
|
3914
|
+
}
|
|
4433
3915
|
}
|
|
4434
3916
|
|
|
4435
3917
|
function loadEffectData(effect, effectOptions, id, reduceDuplicates) {
|
|
@@ -4456,6 +3938,131 @@
|
|
|
4456
3938
|
data.setCb(data.radius);
|
|
4457
3939
|
}
|
|
4458
3940
|
}
|
|
3941
|
+
function normalizeAngle(angle, modulus) {
|
|
3942
|
+
const normalized = angle % modulus;
|
|
3943
|
+
return normalized < defaultAngle ? normalized + modulus : normalized;
|
|
3944
|
+
}
|
|
3945
|
+
function initParticleState(particle, id, group) {
|
|
3946
|
+
particle.id = id;
|
|
3947
|
+
particle.group = group;
|
|
3948
|
+
particle.justWarped = false;
|
|
3949
|
+
particle.effectClose = true;
|
|
3950
|
+
particle.shapeClose = true;
|
|
3951
|
+
particle.pathRotation = false;
|
|
3952
|
+
particle.lastPathTime = 0;
|
|
3953
|
+
particle.destroyed = false;
|
|
3954
|
+
particle.unbreakable = false;
|
|
3955
|
+
particle.isRotating = false;
|
|
3956
|
+
particle.rotation = 0;
|
|
3957
|
+
particle.misplaced = false;
|
|
3958
|
+
particle.retina = {
|
|
3959
|
+
maxDistance: {},
|
|
3960
|
+
maxSpeed: 0,
|
|
3961
|
+
moveDrift: 0,
|
|
3962
|
+
moveSpeed: 0,
|
|
3963
|
+
sizeAnimationSpeed: 0,
|
|
3964
|
+
};
|
|
3965
|
+
particle.size = {
|
|
3966
|
+
value: 1,
|
|
3967
|
+
max: 1,
|
|
3968
|
+
min: 1,
|
|
3969
|
+
enable: false,
|
|
3970
|
+
};
|
|
3971
|
+
particle.outType = ParticleOutType.normal;
|
|
3972
|
+
particle.ignoresResizeRatio = true;
|
|
3973
|
+
}
|
|
3974
|
+
function resolveParticleOptions(particle, container, pluginManager, overrideOptions) {
|
|
3975
|
+
const mainOptions = container.actualOptions, particlesOptions = loadParticlesOptions(pluginManager, container, mainOptions.particles), reduceDuplicates = particlesOptions.reduceDuplicates;
|
|
3976
|
+
particle.effect = itemFromSingleOrMultiple(particlesOptions.effect.type, particle.id, reduceDuplicates);
|
|
3977
|
+
particle.shape = itemFromSingleOrMultiple(particlesOptions.shape.type, particle.id, reduceDuplicates);
|
|
3978
|
+
const effectOptions = particlesOptions.effect, shapeOptions = particlesOptions.shape;
|
|
3979
|
+
if (overrideOptions) {
|
|
3980
|
+
if (overrideOptions.effect) {
|
|
3981
|
+
const overrideEffectType = overrideOptions.effect.type;
|
|
3982
|
+
if (overrideEffectType && overrideEffectType !== particle.effect) {
|
|
3983
|
+
const effect = itemFromSingleOrMultiple(overrideEffectType, particle.id, reduceDuplicates);
|
|
3984
|
+
if (effect) {
|
|
3985
|
+
particle.effect = effect;
|
|
3986
|
+
}
|
|
3987
|
+
}
|
|
3988
|
+
effectOptions.load(overrideOptions.effect);
|
|
3989
|
+
}
|
|
3990
|
+
if (overrideOptions.shape) {
|
|
3991
|
+
const overrideShapeType = overrideOptions.shape.type;
|
|
3992
|
+
if (overrideShapeType && overrideShapeType !== particle.shape) {
|
|
3993
|
+
const shape = itemFromSingleOrMultiple(overrideShapeType, particle.id, reduceDuplicates);
|
|
3994
|
+
if (shape) {
|
|
3995
|
+
particle.shape = shape;
|
|
3996
|
+
}
|
|
3997
|
+
}
|
|
3998
|
+
shapeOptions.load(overrideOptions.shape);
|
|
3999
|
+
}
|
|
4000
|
+
}
|
|
4001
|
+
if (particle.effect === randomColorValue) {
|
|
4002
|
+
const availableEffects = [...container.effectDrawers.keys()];
|
|
4003
|
+
particle.effect = availableEffects[Math.floor(getRandom() * availableEffects.length)];
|
|
4004
|
+
}
|
|
4005
|
+
if (particle.shape === randomColorValue) {
|
|
4006
|
+
const availableShapes = [...container.shapeDrawers.keys()];
|
|
4007
|
+
particle.shape = availableShapes[Math.floor(getRandom() * availableShapes.length)];
|
|
4008
|
+
}
|
|
4009
|
+
particle.effectData = particle.effect
|
|
4010
|
+
? loadEffectData(particle.effect, effectOptions, particle.id, reduceDuplicates)
|
|
4011
|
+
: undefined;
|
|
4012
|
+
particle.shapeData = particle.shape
|
|
4013
|
+
? loadShapeData(particle.shape, shapeOptions, particle.id, reduceDuplicates)
|
|
4014
|
+
: undefined;
|
|
4015
|
+
particlesOptions.load(overrideOptions);
|
|
4016
|
+
const effectData = particle.effectData, shapeData = particle.shapeData;
|
|
4017
|
+
if (effectData) {
|
|
4018
|
+
particlesOptions.load(effectData.particles);
|
|
4019
|
+
}
|
|
4020
|
+
if (shapeData) {
|
|
4021
|
+
particlesOptions.load(shapeData.particles);
|
|
4022
|
+
}
|
|
4023
|
+
particle.effectClose = effectData?.close ?? particlesOptions.effect.close;
|
|
4024
|
+
particle.shapeClose = shapeData?.close ?? particlesOptions.shape.close;
|
|
4025
|
+
return particlesOptions;
|
|
4026
|
+
}
|
|
4027
|
+
function initParticleDrawers(particle, container) {
|
|
4028
|
+
let effectDrawer, shapeDrawer;
|
|
4029
|
+
if (particle.effect) {
|
|
4030
|
+
effectDrawer = container.effectDrawers.get(particle.effect);
|
|
4031
|
+
}
|
|
4032
|
+
if (effectDrawer?.loadEffect) {
|
|
4033
|
+
effectDrawer.loadEffect(particle);
|
|
4034
|
+
}
|
|
4035
|
+
if (particle.shape) {
|
|
4036
|
+
shapeDrawer = container.shapeDrawers.get(particle.shape);
|
|
4037
|
+
}
|
|
4038
|
+
if (shapeDrawer?.loadShape) {
|
|
4039
|
+
shapeDrawer.loadShape(particle);
|
|
4040
|
+
}
|
|
4041
|
+
const sideCountFunc = shapeDrawer?.getSidesCount;
|
|
4042
|
+
if (sideCountFunc) {
|
|
4043
|
+
particle.sides = sideCountFunc(particle);
|
|
4044
|
+
}
|
|
4045
|
+
}
|
|
4046
|
+
function runUpdaterPreInit(updaters, particle) {
|
|
4047
|
+
for (const updater of updaters) {
|
|
4048
|
+
updater.preInit?.(particle);
|
|
4049
|
+
}
|
|
4050
|
+
}
|
|
4051
|
+
function runUpdaterInit(updaters, particle) {
|
|
4052
|
+
for (const updater of updaters) {
|
|
4053
|
+
updater.init(particle);
|
|
4054
|
+
}
|
|
4055
|
+
}
|
|
4056
|
+
function runDrawerInit(container, particle) {
|
|
4057
|
+
const shapeDrawer = particle.shape ? container.shapeDrawers.get(particle.shape) : undefined, effectDrawer = particle.effect ? container.effectDrawers.get(particle.effect) : undefined;
|
|
4058
|
+
effectDrawer?.particleInit?.(container, particle);
|
|
4059
|
+
shapeDrawer?.particleInit?.(container, particle);
|
|
4060
|
+
}
|
|
4061
|
+
function runParticleCreatedPlugins(container, particle) {
|
|
4062
|
+
for (const plugin of container.particleCreatedPlugins) {
|
|
4063
|
+
plugin.particleCreated?.(particle);
|
|
4064
|
+
}
|
|
4065
|
+
}
|
|
4459
4066
|
class Particle {
|
|
4460
4067
|
backColor;
|
|
4461
4068
|
bubble;
|
|
@@ -4581,88 +4188,20 @@
|
|
|
4581
4188
|
const rotateData = this.getRotateData(), rotating = this.isRotating;
|
|
4582
4189
|
this.#cachedTransform.a = rotateData.cos * (externalTransform.a ?? defaultTransform.a);
|
|
4583
4190
|
this.#cachedTransform.b = rotating
|
|
4584
|
-
? rotateData.sin * (externalTransform.b ?? identity
|
|
4191
|
+
? rotateData.sin * (externalTransform.b ?? identity)
|
|
4585
4192
|
: (externalTransform.b ?? defaultTransform.b);
|
|
4586
4193
|
this.#cachedTransform.c = rotating
|
|
4587
|
-
? -rotateData.sin * (externalTransform.c ?? identity
|
|
4194
|
+
? -rotateData.sin * (externalTransform.c ?? identity)
|
|
4588
4195
|
: (externalTransform.c ?? defaultTransform.c);
|
|
4589
4196
|
this.#cachedTransform.d = rotateData.cos * (externalTransform.d ?? defaultTransform.d);
|
|
4590
4197
|
return this.#cachedTransform;
|
|
4591
4198
|
}
|
|
4592
4199
|
init(id, position, overrideOptions, group) {
|
|
4593
4200
|
const container = this.#container;
|
|
4594
|
-
this
|
|
4595
|
-
this.
|
|
4596
|
-
this.justWarped = false;
|
|
4597
|
-
this.effectClose = true;
|
|
4598
|
-
this.shapeClose = true;
|
|
4599
|
-
this.pathRotation = false;
|
|
4600
|
-
this.lastPathTime = 0;
|
|
4601
|
-
this.destroyed = false;
|
|
4602
|
-
this.unbreakable = false;
|
|
4603
|
-
this.isRotating = false;
|
|
4604
|
-
this.rotation = 0;
|
|
4605
|
-
this.misplaced = false;
|
|
4606
|
-
this.retina = {
|
|
4607
|
-
maxDistance: {},
|
|
4608
|
-
maxSpeed: 0,
|
|
4609
|
-
moveDrift: 0,
|
|
4610
|
-
moveSpeed: 0,
|
|
4611
|
-
sizeAnimationSpeed: 0,
|
|
4612
|
-
};
|
|
4613
|
-
this.size = {
|
|
4614
|
-
value: 1,
|
|
4615
|
-
max: 1,
|
|
4616
|
-
min: 1,
|
|
4617
|
-
enable: false,
|
|
4618
|
-
};
|
|
4619
|
-
this.outType = ParticleOutType.normal;
|
|
4620
|
-
this.ignoresResizeRatio = true;
|
|
4621
|
-
const mainOptions = container.actualOptions, particlesOptions = loadParticlesOptions(this.#pluginManager, container, mainOptions.particles), reduceDuplicates = particlesOptions.reduceDuplicates, effectType = particlesOptions.effect.type, shapeType = particlesOptions.shape.type;
|
|
4622
|
-
this.effect = itemFromSingleOrMultiple(effectType, this.id, reduceDuplicates);
|
|
4623
|
-
this.shape = itemFromSingleOrMultiple(shapeType, this.id, reduceDuplicates);
|
|
4624
|
-
const effectOptions = particlesOptions.effect, shapeOptions = particlesOptions.shape;
|
|
4625
|
-
if (overrideOptions) {
|
|
4626
|
-
if (overrideOptions.effect?.type && overrideOptions.effect.type !== this.effect) {
|
|
4627
|
-
const overrideEffectType = overrideOptions.effect.type, effect = itemFromSingleOrMultiple(overrideEffectType, this.id, reduceDuplicates);
|
|
4628
|
-
if (effect) {
|
|
4629
|
-
this.effect = effect;
|
|
4630
|
-
effectOptions.load(overrideOptions.effect);
|
|
4631
|
-
}
|
|
4632
|
-
}
|
|
4633
|
-
if (overrideOptions.shape?.type && overrideOptions.shape.type !== this.shape) {
|
|
4634
|
-
const overrideShapeType = overrideOptions.shape.type, shape = itemFromSingleOrMultiple(overrideShapeType, this.id, reduceDuplicates);
|
|
4635
|
-
if (shape) {
|
|
4636
|
-
this.shape = shape;
|
|
4637
|
-
shapeOptions.load(overrideOptions.shape);
|
|
4638
|
-
}
|
|
4639
|
-
}
|
|
4640
|
-
}
|
|
4641
|
-
if (this.effect === randomColorValue) {
|
|
4642
|
-
const availableEffects = [...this.#container.effectDrawers.keys()];
|
|
4643
|
-
this.effect = availableEffects[Math.floor(getRandom() * availableEffects.length)];
|
|
4644
|
-
}
|
|
4645
|
-
if (this.shape === randomColorValue) {
|
|
4646
|
-
const availableShapes = [...this.#container.shapeDrawers.keys()];
|
|
4647
|
-
this.shape = availableShapes[Math.floor(getRandom() * availableShapes.length)];
|
|
4648
|
-
}
|
|
4649
|
-
this.effectData = this.effect ? loadEffectData(this.effect, effectOptions, this.id, reduceDuplicates) : undefined;
|
|
4650
|
-
this.shapeData = this.shape ? loadShapeData(this.shape, shapeOptions, this.id, reduceDuplicates) : undefined;
|
|
4651
|
-
particlesOptions.load(overrideOptions);
|
|
4652
|
-
const effectData = this.effectData, shapeData = this.shapeData;
|
|
4653
|
-
if (effectData) {
|
|
4654
|
-
particlesOptions.load(effectData.particles);
|
|
4655
|
-
}
|
|
4656
|
-
if (shapeData) {
|
|
4657
|
-
particlesOptions.load(shapeData.particles);
|
|
4658
|
-
}
|
|
4659
|
-
this.effectClose = effectData?.close ?? particlesOptions.effect.close;
|
|
4660
|
-
this.shapeClose = shapeData?.close ?? particlesOptions.shape.close;
|
|
4661
|
-
this.options = particlesOptions;
|
|
4201
|
+
initParticleState(this, id, group);
|
|
4202
|
+
this.options = resolveParticleOptions(this, container, this.#pluginManager, overrideOptions);
|
|
4662
4203
|
container.retina.initParticle(this);
|
|
4663
|
-
|
|
4664
|
-
updater.preInit?.(this);
|
|
4665
|
-
}
|
|
4204
|
+
runUpdaterPreInit(container.particleUpdaters, this);
|
|
4666
4205
|
this.bubble = {
|
|
4667
4206
|
inRange: false,
|
|
4668
4207
|
};
|
|
@@ -4675,32 +4214,11 @@
|
|
|
4675
4214
|
this.velocity = this.initialVelocity.copy();
|
|
4676
4215
|
this.zIndexFactor = this.position.z / container.zLayers;
|
|
4677
4216
|
this.sides = 24;
|
|
4678
|
-
|
|
4679
|
-
if (this.effect) {
|
|
4680
|
-
effectDrawer = container.effectDrawers.get(this.effect);
|
|
4681
|
-
}
|
|
4682
|
-
if (effectDrawer?.loadEffect) {
|
|
4683
|
-
effectDrawer.loadEffect(this);
|
|
4684
|
-
}
|
|
4685
|
-
if (this.shape) {
|
|
4686
|
-
shapeDrawer = container.shapeDrawers.get(this.shape);
|
|
4687
|
-
}
|
|
4688
|
-
if (shapeDrawer?.loadShape) {
|
|
4689
|
-
shapeDrawer.loadShape(this);
|
|
4690
|
-
}
|
|
4691
|
-
const sideCountFunc = shapeDrawer?.getSidesCount;
|
|
4692
|
-
if (sideCountFunc) {
|
|
4693
|
-
this.sides = sideCountFunc(this);
|
|
4694
|
-
}
|
|
4217
|
+
initParticleDrawers(this, container);
|
|
4695
4218
|
this.spawning = false;
|
|
4696
|
-
|
|
4697
|
-
|
|
4698
|
-
|
|
4699
|
-
effectDrawer?.particleInit?.(container, this);
|
|
4700
|
-
shapeDrawer?.particleInit?.(container, this);
|
|
4701
|
-
for (const plugin of container.particleCreatedPlugins) {
|
|
4702
|
-
plugin.particleCreated?.(this);
|
|
4703
|
-
}
|
|
4219
|
+
runUpdaterInit(container.particleUpdaters, this);
|
|
4220
|
+
runDrawerInit(container, this);
|
|
4221
|
+
runParticleCreatedPlugins(container, this);
|
|
4704
4222
|
}
|
|
4705
4223
|
isInsideCanvas(direction) {
|
|
4706
4224
|
return this.#getInsideCanvasResult({ direction }).inside;
|
|
@@ -4714,15 +4232,15 @@
|
|
|
4714
4232
|
}
|
|
4715
4233
|
const angle = this.roll.angle;
|
|
4716
4234
|
if (this.roll.horizontal && this.roll.vertical) {
|
|
4717
|
-
const
|
|
4235
|
+
const adjustedAngle = normalizeAngle(angle, doublePI);
|
|
4718
4236
|
return adjustedAngle >= Math.PI * half && adjustedAngle < Math.PI * triple * half;
|
|
4719
4237
|
}
|
|
4720
4238
|
if (this.roll.horizontal) {
|
|
4721
|
-
const
|
|
4239
|
+
const adjustedAngle = normalizeAngle(angle + Math.PI * half, doublePI);
|
|
4722
4240
|
return adjustedAngle >= Math.PI && adjustedAngle < Math.PI * double;
|
|
4723
4241
|
}
|
|
4724
4242
|
if (this.roll.vertical) {
|
|
4725
|
-
const
|
|
4243
|
+
const adjustedAngle = normalizeAngle(angle, doublePI);
|
|
4726
4244
|
return adjustedAngle >= Math.PI && adjustedAngle < Math.PI * double;
|
|
4727
4245
|
}
|
|
4728
4246
|
return false;
|
|
@@ -4735,10 +4253,10 @@
|
|
|
4735
4253
|
updater.reset?.(this);
|
|
4736
4254
|
}
|
|
4737
4255
|
}
|
|
4738
|
-
#calcPosition
|
|
4256
|
+
#calcPosition(position, zIndex) {
|
|
4739
4257
|
let tryCount = defaultRetryCount, posVec = position ? Vector3d.create(position.x, position.y, zIndex) : undefined;
|
|
4740
|
-
const container = this.#container, plugins = container.particlePositionPlugins, outModes = this.options.move.outModes, radius = this.getRadius(), canvasSize = container.canvas.size
|
|
4741
|
-
|
|
4258
|
+
const container = this.#container, plugins = container.particlePositionPlugins, outModes = this.options.move.outModes, radius = this.getRadius(), canvasSize = container.canvas.size;
|
|
4259
|
+
for (;;) {
|
|
4742
4260
|
for (const plugin of plugins) {
|
|
4743
4261
|
const pluginPos = plugin.particlePosition?.(posVec, this);
|
|
4744
4262
|
if (pluginPos) {
|
|
@@ -4766,9 +4284,8 @@
|
|
|
4766
4284
|
tryCount += tryCountIncrement;
|
|
4767
4285
|
posVec = undefined;
|
|
4768
4286
|
}
|
|
4769
|
-
|
|
4770
|
-
|
|
4771
|
-
#calculateVelocity = () => {
|
|
4287
|
+
}
|
|
4288
|
+
#calculateVelocity() {
|
|
4772
4289
|
const moveOptions = this.options.move, baseVelocity = getParticleBaseVelocity(this.direction), res = baseVelocity.copy();
|
|
4773
4290
|
if (moveOptions.direction === MoveDirection.inside || moveOptions.direction === MoveDirection.outside) {
|
|
4774
4291
|
return res;
|
|
@@ -4784,8 +4301,8 @@
|
|
|
4784
4301
|
res.length *= getRandom();
|
|
4785
4302
|
}
|
|
4786
4303
|
return res;
|
|
4787
|
-
}
|
|
4788
|
-
#fixHorizontal
|
|
4304
|
+
}
|
|
4305
|
+
#fixHorizontal(pos, radius, outMode) {
|
|
4789
4306
|
fixOutMode({
|
|
4790
4307
|
outMode,
|
|
4791
4308
|
checkModes: [OutMode.bounce],
|
|
@@ -4794,8 +4311,8 @@
|
|
|
4794
4311
|
setCb: (value) => (pos.x += value),
|
|
4795
4312
|
radius,
|
|
4796
4313
|
});
|
|
4797
|
-
}
|
|
4798
|
-
#fixVertical
|
|
4314
|
+
}
|
|
4315
|
+
#fixVertical(pos, radius, outMode) {
|
|
4799
4316
|
fixOutMode({
|
|
4800
4317
|
outMode,
|
|
4801
4318
|
checkModes: [OutMode.bounce],
|
|
@@ -4804,8 +4321,8 @@
|
|
|
4804
4321
|
setCb: (value) => (pos.y += value),
|
|
4805
4322
|
radius,
|
|
4806
4323
|
});
|
|
4807
|
-
}
|
|
4808
|
-
#getDefaultInsideCanvasResult
|
|
4324
|
+
}
|
|
4325
|
+
#getDefaultInsideCanvasResult(direction, outMode) {
|
|
4809
4326
|
const radius = this.getRadius(), canvasSize = this.#container.canvas.size, position = this.position, isBounce = outMode === OutMode.bounce;
|
|
4810
4327
|
if (direction === OutModeDirection.bottom) {
|
|
4811
4328
|
return {
|
|
@@ -4838,8 +4355,8 @@
|
|
|
4838
4355
|
position.x <= canvasSize.width + radius,
|
|
4839
4356
|
reason: "default",
|
|
4840
4357
|
};
|
|
4841
|
-
}
|
|
4842
|
-
#getInsideCanvasCallbackData
|
|
4358
|
+
}
|
|
4359
|
+
#getInsideCanvasCallbackData(direction, outMode) {
|
|
4843
4360
|
return {
|
|
4844
4361
|
canvasSize: this.#container.canvas.size,
|
|
4845
4362
|
direction,
|
|
@@ -4847,8 +4364,8 @@
|
|
|
4847
4364
|
particle: this,
|
|
4848
4365
|
radius: this.getRadius(),
|
|
4849
4366
|
};
|
|
4850
|
-
}
|
|
4851
|
-
#getInsideCanvasResult
|
|
4367
|
+
}
|
|
4368
|
+
#getInsideCanvasResult(data) {
|
|
4852
4369
|
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;
|
|
4853
4370
|
if (!shapeCheck && !effectCheck) {
|
|
4854
4371
|
return defaultResult;
|
|
@@ -4863,8 +4380,8 @@
|
|
|
4863
4380
|
};
|
|
4864
4381
|
}
|
|
4865
4382
|
return shapeResult ?? effectResult ?? defaultResult;
|
|
4866
|
-
}
|
|
4867
|
-
#getRollColor
|
|
4383
|
+
}
|
|
4384
|
+
#getRollColor(color) {
|
|
4868
4385
|
if (!color || !this.roll || (!this.backColor && !this.roll.alter)) {
|
|
4869
4386
|
return color;
|
|
4870
4387
|
}
|
|
@@ -4878,8 +4395,8 @@
|
|
|
4878
4395
|
return alterHsl(color, this.roll.alter.type, this.roll.alter.value);
|
|
4879
4396
|
}
|
|
4880
4397
|
return color;
|
|
4881
|
-
}
|
|
4882
|
-
#initPosition
|
|
4398
|
+
}
|
|
4399
|
+
#initPosition(position) {
|
|
4883
4400
|
const container = this.#container, zIndexValue = Math.floor(getRangeValue(this.options.zIndex.value)), initialPosition = this.#calcPosition(position, clamp(zIndexValue, minZ, container.zLayers));
|
|
4884
4401
|
if (!initialPosition) {
|
|
4885
4402
|
throw new Error("a valid position cannot be found for particle");
|
|
@@ -4902,8 +4419,8 @@
|
|
|
4902
4419
|
break;
|
|
4903
4420
|
}
|
|
4904
4421
|
this.offset = Vector.origin;
|
|
4905
|
-
}
|
|
4906
|
-
#normalizeInsideCanvasResult
|
|
4422
|
+
}
|
|
4423
|
+
#normalizeInsideCanvasResult(result, reason) {
|
|
4907
4424
|
if (typeof result === "boolean") {
|
|
4908
4425
|
return {
|
|
4909
4426
|
inside: result,
|
|
@@ -4915,7 +4432,7 @@
|
|
|
4915
4432
|
margin: result.margin,
|
|
4916
4433
|
reason: result.reason ?? reason,
|
|
4917
4434
|
};
|
|
4918
|
-
}
|
|
4435
|
+
}
|
|
4919
4436
|
}
|
|
4920
4437
|
|
|
4921
4438
|
class SpatialHashGrid {
|
|
@@ -5268,10 +4785,10 @@
|
|
|
5268
4785
|
}
|
|
5269
4786
|
this.#resizeFactor = undefined;
|
|
5270
4787
|
}
|
|
5271
|
-
#addToPool
|
|
4788
|
+
#addToPool(...particles) {
|
|
5272
4789
|
this.#pool.push(...particles);
|
|
5273
|
-
}
|
|
5274
|
-
#applyDensity
|
|
4790
|
+
}
|
|
4791
|
+
#applyDensity(options, pluginsCount, group, groupOptions) {
|
|
5275
4792
|
const numberOptions = options.number;
|
|
5276
4793
|
if (!numberOptions.density.enable) {
|
|
5277
4794
|
if (group === undefined) {
|
|
@@ -5295,36 +4812,19 @@
|
|
|
5295
4812
|
else if (particlesCount > particlesNumber) {
|
|
5296
4813
|
this.removeQuantity(particlesCount - particlesNumber, group);
|
|
5297
4814
|
}
|
|
5298
|
-
}
|
|
5299
|
-
#createBuckets
|
|
4815
|
+
}
|
|
4816
|
+
#createBuckets(zLayers) {
|
|
5300
4817
|
const bucketCount = Math.max(Math.floor(zLayers), one);
|
|
5301
4818
|
return Array.from({ length: bucketCount }, () => []);
|
|
5302
|
-
}
|
|
5303
|
-
#getBucketIndex
|
|
4819
|
+
}
|
|
4820
|
+
#getBucketIndex(zIndex) {
|
|
5304
4821
|
const maxBucketIndex = this.#zBuckets.length - one;
|
|
5305
4822
|
if (maxBucketIndex <= minIndex) {
|
|
5306
4823
|
return minIndex;
|
|
5307
4824
|
}
|
|
5308
4825
|
return Math.min(Math.max(Math.floor(zIndex), minIndex), maxBucketIndex);
|
|
5309
|
-
}
|
|
5310
|
-
#
|
|
5311
|
-
let start = minIndex, end = bucket.length;
|
|
5312
|
-
while (start < end) {
|
|
5313
|
-
const middle = Math.floor((start + end) / double), middleParticle = bucket[middle];
|
|
5314
|
-
if (!middleParticle) {
|
|
5315
|
-
end = middle;
|
|
5316
|
-
continue;
|
|
5317
|
-
}
|
|
5318
|
-
if (middleParticle.id < particleId) {
|
|
5319
|
-
start = middle + one;
|
|
5320
|
-
}
|
|
5321
|
-
else {
|
|
5322
|
-
end = middle;
|
|
5323
|
-
}
|
|
5324
|
-
}
|
|
5325
|
-
return start;
|
|
5326
|
-
};
|
|
5327
|
-
#initDensityFactor = densityOptions => {
|
|
4826
|
+
}
|
|
4827
|
+
#initDensityFactor(densityOptions) {
|
|
5328
4828
|
const container = this.#container;
|
|
5329
4829
|
if (!densityOptions.enable) {
|
|
5330
4830
|
return defaultDensityFactor;
|
|
@@ -5334,16 +4834,16 @@
|
|
|
5334
4834
|
return defaultDensityFactor;
|
|
5335
4835
|
}
|
|
5336
4836
|
return ((canvasSize.width * canvasSize.height) / (densityOptions.height * densityOptions.width * pxRatio ** squareExp));
|
|
5337
|
-
}
|
|
5338
|
-
#insertParticleIntoBucket
|
|
4837
|
+
}
|
|
4838
|
+
#insertParticleIntoBucket(particle) {
|
|
5339
4839
|
const bucketIndex = this.#getBucketIndex(particle.position.z), bucket = this.#zBuckets[bucketIndex];
|
|
5340
4840
|
if (!bucket) {
|
|
5341
4841
|
return;
|
|
5342
4842
|
}
|
|
5343
|
-
bucket.
|
|
4843
|
+
bucket.push(particle);
|
|
5344
4844
|
this.#particleBuckets.set(particle.id, bucketIndex);
|
|
5345
|
-
}
|
|
5346
|
-
#removeParticle
|
|
4845
|
+
}
|
|
4846
|
+
#removeParticle(index, group, override) {
|
|
5347
4847
|
const particle = this.#array[index];
|
|
5348
4848
|
if (!particle) {
|
|
5349
4849
|
return false;
|
|
@@ -5359,22 +4859,20 @@
|
|
|
5359
4859
|
});
|
|
5360
4860
|
this.#addToPool(particle);
|
|
5361
4861
|
return true;
|
|
5362
|
-
}
|
|
5363
|
-
#removeParticleFromBucket
|
|
4862
|
+
}
|
|
4863
|
+
#removeParticleFromBucket(particle) {
|
|
5364
4864
|
const bucketIndex = this.#particleBuckets.get(particle.id) ?? this.#getBucketIndex(particle.position.z), bucket = this.#zBuckets[bucketIndex];
|
|
5365
4865
|
if (!bucket) {
|
|
5366
4866
|
this.#particleBuckets.delete(particle.id);
|
|
5367
4867
|
return;
|
|
5368
4868
|
}
|
|
5369
|
-
const
|
|
5370
|
-
if (
|
|
5371
|
-
|
|
5372
|
-
return;
|
|
4869
|
+
const idx = bucket.findIndex(p => p.id === particle.id);
|
|
4870
|
+
if (idx >= minIndex) {
|
|
4871
|
+
bucket.splice(idx, deleteCount);
|
|
5373
4872
|
}
|
|
5374
|
-
bucket.splice(particleIndex, deleteCount);
|
|
5375
4873
|
this.#particleBuckets.delete(particle.id);
|
|
5376
|
-
}
|
|
5377
|
-
#resetBuckets
|
|
4874
|
+
}
|
|
4875
|
+
#resetBuckets(zLayers) {
|
|
5378
4876
|
const bucketCount = Math.max(Math.floor(zLayers), one);
|
|
5379
4877
|
if (this.#zBuckets.length !== bucketCount) {
|
|
5380
4878
|
this.#zBuckets = this.#createBuckets(bucketCount);
|
|
@@ -5383,8 +4881,8 @@
|
|
|
5383
4881
|
for (const bucket of this.#zBuckets) {
|
|
5384
4882
|
bucket.length = minIndex;
|
|
5385
4883
|
}
|
|
5386
|
-
}
|
|
5387
|
-
#updateParticleBucket
|
|
4884
|
+
}
|
|
4885
|
+
#updateParticleBucket(particle) {
|
|
5388
4886
|
const newBucketIndex = this.#getBucketIndex(particle.position.z), currentBucketIndex = this.#particleBuckets.get(particle.id);
|
|
5389
4887
|
if (currentBucketIndex === undefined) {
|
|
5390
4888
|
this.#insertParticleIntoBucket(particle);
|
|
@@ -5395,9 +4893,9 @@
|
|
|
5395
4893
|
}
|
|
5396
4894
|
const currentBucket = this.#zBuckets[currentBucketIndex];
|
|
5397
4895
|
if (currentBucket) {
|
|
5398
|
-
const
|
|
5399
|
-
if (
|
|
5400
|
-
currentBucket.splice(
|
|
4896
|
+
const idx = currentBucket.findIndex(p => p.id === particle.id);
|
|
4897
|
+
if (idx >= minIndex) {
|
|
4898
|
+
currentBucket.splice(idx, deleteCount);
|
|
5401
4899
|
}
|
|
5402
4900
|
}
|
|
5403
4901
|
const newBucket = this.#zBuckets[newBucketIndex];
|
|
@@ -5405,10 +4903,16 @@
|
|
|
5405
4903
|
this.#particleBuckets.set(particle.id, newBucketIndex);
|
|
5406
4904
|
return;
|
|
5407
4905
|
}
|
|
5408
|
-
newBucket.
|
|
4906
|
+
newBucket.push(particle);
|
|
4907
|
+
if (newBucket.length >= double) {
|
|
4908
|
+
const prev = newBucket[newBucket.length - double];
|
|
4909
|
+
if (prev && particle.id < prev.id) {
|
|
4910
|
+
newBucket.sort((a, b) => a.id - b.id);
|
|
4911
|
+
}
|
|
4912
|
+
}
|
|
5409
4913
|
this.#particleBuckets.set(particle.id, newBucketIndex);
|
|
5410
|
-
}
|
|
5411
|
-
#updateParticlesPhase1
|
|
4914
|
+
}
|
|
4915
|
+
#updateParticlesPhase1(delta) {
|
|
5412
4916
|
const particlesToDelete = new Set(), resizeFactor = this.#resizeFactor;
|
|
5413
4917
|
for (const particle of this.#array) {
|
|
5414
4918
|
if (resizeFactor && !particle.ignoresResizeRatio) {
|
|
@@ -5434,8 +4938,8 @@
|
|
|
5434
4938
|
this.grid.insert(particle);
|
|
5435
4939
|
}
|
|
5436
4940
|
return particlesToDelete;
|
|
5437
|
-
}
|
|
5438
|
-
#updateParticlesPhase2
|
|
4941
|
+
}
|
|
4942
|
+
#updateParticlesPhase2(delta, particlesToDelete) {
|
|
5439
4943
|
for (const particle of this.#array) {
|
|
5440
4944
|
if (particle.destroyed) {
|
|
5441
4945
|
particlesToDelete.add(particle);
|
|
@@ -5451,7 +4955,7 @@
|
|
|
5451
4955
|
}
|
|
5452
4956
|
this.#updateParticleBucket(particle);
|
|
5453
4957
|
}
|
|
5454
|
-
}
|
|
4958
|
+
}
|
|
5455
4959
|
}
|
|
5456
4960
|
|
|
5457
4961
|
class Retina {
|
|
@@ -5813,7 +5317,7 @@
|
|
|
5813
5317
|
}
|
|
5814
5318
|
return refresh;
|
|
5815
5319
|
}
|
|
5816
|
-
#nextFrame
|
|
5320
|
+
#nextFrame(timestamp) {
|
|
5817
5321
|
try {
|
|
5818
5322
|
if (!this.#smooth &&
|
|
5819
5323
|
this.#lastFrameTime !== undefined &&
|
|
@@ -5841,7 +5345,7 @@
|
|
|
5841
5345
|
catch (e) {
|
|
5842
5346
|
getLogger().error("error in animation loop", e);
|
|
5843
5347
|
}
|
|
5844
|
-
}
|
|
5348
|
+
}
|
|
5845
5349
|
}
|
|
5846
5350
|
|
|
5847
5351
|
var Container$1 = /*#__PURE__*/Object.freeze({
|
|
@@ -5887,7 +5391,7 @@
|
|
|
5887
5391
|
BlendPluginInstance: BlendPluginInstance
|
|
5888
5392
|
});
|
|
5889
5393
|
|
|
5890
|
-
const
|
|
5394
|
+
const moveSpeedFactor = 60, minSpinRadius = 0, spinFactor = 0.01, defaultPathDelay = 0, noDecay = 1;
|
|
5891
5395
|
function applyDistance(particle) {
|
|
5892
5396
|
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;
|
|
5893
5397
|
if (!hDistance && !vDistance) {
|