@tsparticles/preset-matrix 4.1.3 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
(function(g){g.__tsParticlesInternals=g.__tsParticlesInternals||{};g.__tsParticlesInternals.bundles=g.__tsParticlesInternals.bundles||{};g.__tsParticlesInternals.effects=g.__tsParticlesInternals.effects||{};g.__tsParticlesInternals.engine=g.__tsParticlesInternals.engine||{};g.__tsParticlesInternals.interactions=g.__tsParticlesInternals.interactions||{};g.__tsParticlesInternals.palettes=g.__tsParticlesInternals.palettes||{};g.__tsParticlesInternals.paths=g.__tsParticlesInternals.paths||{};g.__tsParticlesInternals.plugins=g.__tsParticlesInternals.plugins||{};g.__tsParticlesInternals.plugins=g.__tsParticlesInternals.plugins||{};g.__tsParticlesInternals.plugins.emittersShapes=g.__tsParticlesInternals.plugins.emittersShapes||{};g.__tsParticlesInternals.presets=g.__tsParticlesInternals.presets||{};g.__tsParticlesInternals.shapes=g.__tsParticlesInternals.shapes||{};g.__tsParticlesInternals.updaters=g.__tsParticlesInternals.updaters||{};g.__tsParticlesInternals.utils=g.__tsParticlesInternals.utils||{};g.__tsParticlesInternals.canvas=g.__tsParticlesInternals.canvas||{};g.__tsParticlesInternals.canvas=g.__tsParticlesInternals.canvas||{};g.__tsParticlesInternals.canvas.utils=g.__tsParticlesInternals.canvas.utils||{};g.__tsParticlesInternals.path=g.__tsParticlesInternals.path||{};g.__tsParticlesInternals.path=g.__tsParticlesInternals.path||{};g.__tsParticlesInternals.path.utils=g.__tsParticlesInternals.path.utils||{};var __tsProxyFactory=typeof Proxy!=="undefined"?function(obj){return new Proxy(obj,{get:function(target,key){if(!(key in target)){target[key]={};}return target[key];}});}:function(obj){return obj;};g.__tsParticlesInternals.bundles=__tsProxyFactory(g.__tsParticlesInternals.bundles);g.__tsParticlesInternals.effects=__tsProxyFactory(g.__tsParticlesInternals.effects);g.__tsParticlesInternals.interactions=__tsProxyFactory(g.__tsParticlesInternals.interactions);g.__tsParticlesInternals.palettes=__tsProxyFactory(g.__tsParticlesInternals.palettes);g.__tsParticlesInternals.paths=__tsProxyFactory(g.__tsParticlesInternals.paths);g.__tsParticlesInternals.plugins=__tsProxyFactory(g.__tsParticlesInternals.plugins);g.__tsParticlesInternals.plugins.emittersShapes=__tsProxyFactory(g.__tsParticlesInternals.plugins.emittersShapes);g.__tsParticlesInternals.presets=__tsProxyFactory(g.__tsParticlesInternals.presets);g.__tsParticlesInternals.shapes=__tsProxyFactory(g.__tsParticlesInternals.shapes);g.__tsParticlesInternals.updaters=__tsProxyFactory(g.__tsParticlesInternals.updaters);g.__tsParticlesInternals.utils=__tsProxyFactory(g.__tsParticlesInternals.utils);g.__tsParticlesInternals.canvas=__tsProxyFactory(g.__tsParticlesInternals.canvas);g.__tsParticlesInternals.path=__tsProxyFactory(g.__tsParticlesInternals.path);g.tsparticlesInternalExports=g.tsparticlesInternalExports||{};})(typeof globalThis!=="undefined"?globalThis:typeof window!=="undefined"?window:this);
|
|
2
|
-
/* Preset v4.
|
|
2
|
+
/* Preset v4.2.0 */
|
|
3
3
|
(function (global, factory) {
|
|
4
4
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
5
5
|
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
b: 0,
|
|
16
16
|
c: 0,
|
|
17
17
|
d: 1,
|
|
18
|
-
}, randomColorValue = "random", double = 2, doublePI = Math.PI * double, defaultFps = 60, generatedTrue = "true", generatedFalse = "false", canvasTag = "canvas", defaultRetryCount = 0, squareExp = 2, spatialHashGridCellSize = 100, defaultRemoveQuantity = 1, defaultRatio = 1, defaultReduceFactor = 1, inverseFactorNumerator = 1, rgbMax = 255, hMax = 360, sMax = 100, lMax = 100, hMin = 0, sMin = 0, hPhase = 60, empty = 0, quarter = 0.25, threeQuarter = half + quarter, defaultTransformValue = 1, minimumSize = 0, zIndexFactorOffset = 1, defaultOpacity$1 = 1, removeDeleteCount = 1, removeMinIndex = 0, defaultFpsLimit = 120, minFpsLimit = 0, canvasFirstIndex = 0, loadRandomFactor = 10000, loadMinIndex = 0, one = 1, none = 0, decayOffset = 1, tryCountIncrement = 1, minZ = 0, minLimit = 0, countOffset = 1, minCount = 0, minIndex = 0, defaultDensityFactor = 1, deleteCount = 1, defaultAngle = 0, identity
|
|
18
|
+
}, randomColorValue = "random", double = 2, doublePI = Math.PI * double, defaultFps = 60, generatedTrue = "true", generatedFalse = "false", canvasTag = "canvas", defaultRetryCount = 0, squareExp = 2, spatialHashGridCellSize = 100, defaultRemoveQuantity = 1, defaultRatio = 1, defaultReduceFactor = 1, inverseFactorNumerator = 1, rgbMax = 255, hMax = 360, sMax = 100, lMax = 100, hMin = 0, sMin = 0, hPhase = 60, empty = 0, quarter = 0.25, threeQuarter = half + quarter, minVelocity = 0, minDistance = 0, defaultTransformValue = 1, minimumSize = 0, zIndexFactorOffset = 1, defaultOpacity$1 = 1, removeDeleteCount = 1, removeMinIndex = 0, defaultFpsLimit = 120, minFpsLimit = 0, canvasFirstIndex = 0, loadRandomFactor = 10000, loadMinIndex = 0, one = 1, none = 0, decayOffset = 1, tryCountIncrement = 1, minZ = 0, minLimit = 0, countOffset = 1, minCount = 0, minIndex = 0, defaultDensityFactor = 1, deleteCount = 1, defaultAngle = 0, identity = 1, minStrokeWidth = 0, lFactor = 1, lMin = 0, maxNits = 400, triple = 3, sextuple = 6, sNormalizedOffset = 1, phaseNumerator = 1, defaultRgbMin = 0, defaultVelocity = 0, defaultLoops = 0, defaultTime = 0, defaultZoom = 1;
|
|
19
19
|
|
|
20
20
|
var MoveDirection;
|
|
21
21
|
(function (MoveDirection) {
|
|
@@ -82,11 +82,6 @@
|
|
|
82
82
|
div(n) {
|
|
83
83
|
return Vector3d.create(this.x / n, this.y / n, this.z / n);
|
|
84
84
|
}
|
|
85
|
-
divTo(n) {
|
|
86
|
-
this.x /= n;
|
|
87
|
-
this.y /= n;
|
|
88
|
-
this.z /= n;
|
|
89
|
-
}
|
|
90
85
|
getLengthSq() {
|
|
91
86
|
return this.x ** squareExp + this.y ** squareExp;
|
|
92
87
|
}
|
|
@@ -282,27 +277,6 @@
|
|
|
282
277
|
return input.endsWith("%") ? parseFloat(input) / percentDenominator : parseFloat(input);
|
|
283
278
|
}
|
|
284
279
|
|
|
285
|
-
var AnimationMode;
|
|
286
|
-
(function (AnimationMode) {
|
|
287
|
-
AnimationMode["auto"] = "auto";
|
|
288
|
-
AnimationMode["increase"] = "increase";
|
|
289
|
-
AnimationMode["decrease"] = "decrease";
|
|
290
|
-
AnimationMode["random"] = "random";
|
|
291
|
-
})(AnimationMode || (AnimationMode = {}));
|
|
292
|
-
|
|
293
|
-
var AnimationStatus;
|
|
294
|
-
(function (AnimationStatus) {
|
|
295
|
-
AnimationStatus["increasing"] = "increasing";
|
|
296
|
-
AnimationStatus["decreasing"] = "decreasing";
|
|
297
|
-
})(AnimationStatus || (AnimationStatus = {}));
|
|
298
|
-
|
|
299
|
-
var DestroyType;
|
|
300
|
-
(function (DestroyType) {
|
|
301
|
-
DestroyType["none"] = "none";
|
|
302
|
-
DestroyType["max"] = "max";
|
|
303
|
-
DestroyType["min"] = "min";
|
|
304
|
-
})(DestroyType || (DestroyType = {}));
|
|
305
|
-
|
|
306
280
|
var OutModeDirection;
|
|
307
281
|
(function (OutModeDirection) {
|
|
308
282
|
OutModeDirection["bottom"] = "bottom";
|
|
@@ -317,67 +291,7 @@
|
|
|
317
291
|
PixelMode["percent"] = "percent";
|
|
318
292
|
})(PixelMode || (PixelMode = {}));
|
|
319
293
|
|
|
320
|
-
var StartValueType;
|
|
321
|
-
(function (StartValueType) {
|
|
322
|
-
StartValueType["max"] = "max";
|
|
323
|
-
StartValueType["min"] = "min";
|
|
324
|
-
StartValueType["random"] = "random";
|
|
325
|
-
})(StartValueType || (StartValueType = {}));
|
|
326
|
-
|
|
327
294
|
const minRadius = 0;
|
|
328
|
-
function memoize(fn, options) {
|
|
329
|
-
const cache = new Map(), stableStringify = (obj, seen = new WeakSet()) => {
|
|
330
|
-
if (obj === null) {
|
|
331
|
-
return "null";
|
|
332
|
-
}
|
|
333
|
-
const t = typeof obj;
|
|
334
|
-
if (t === "undefined") {
|
|
335
|
-
return "undefined";
|
|
336
|
-
}
|
|
337
|
-
if (t === "number" || t === "boolean" || t === "string") {
|
|
338
|
-
return JSON.stringify(obj);
|
|
339
|
-
}
|
|
340
|
-
if (t === "function") {
|
|
341
|
-
try {
|
|
342
|
-
const fn = obj;
|
|
343
|
-
return fn.toString();
|
|
344
|
-
}
|
|
345
|
-
catch {
|
|
346
|
-
return '"[Function]"';
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
if (t === "symbol") {
|
|
350
|
-
try {
|
|
351
|
-
return obj.toString();
|
|
352
|
-
}
|
|
353
|
-
catch {
|
|
354
|
-
return '"[Symbol]"';
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
if (Array.isArray(obj)) {
|
|
358
|
-
return `[${obj.map(i => stableStringify(i, seen)).join(",")}]`;
|
|
359
|
-
}
|
|
360
|
-
if (seen.has(obj)) {
|
|
361
|
-
return '"[Circular]"';
|
|
362
|
-
}
|
|
363
|
-
seen.add(obj);
|
|
364
|
-
const keys = Object.keys(obj).sort();
|
|
365
|
-
return `{${keys.map(k => `${JSON.stringify(k)}:${stableStringify(obj[k], seen)}`).join(",")}}`;
|
|
366
|
-
}, defaultKeyer = (args) => stableStringify(args), makeKey = (args) => (defaultKeyer(args));
|
|
367
|
-
return (...args) => {
|
|
368
|
-
const key = makeKey(args), now = Date.now(), entry = cache.get(key);
|
|
369
|
-
if (entry !== undefined) {
|
|
370
|
-
{
|
|
371
|
-
cache.delete(key);
|
|
372
|
-
cache.set(key, { value: entry.value, ts: entry.ts });
|
|
373
|
-
return entry.value;
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
const result = fn(...args);
|
|
377
|
-
cache.set(key, { value: result, ts: now });
|
|
378
|
-
return result;
|
|
379
|
-
};
|
|
380
|
-
}
|
|
381
295
|
function hasMatchMedia() {
|
|
382
296
|
return typeof matchMedia !== "undefined";
|
|
383
297
|
}
|
|
@@ -399,11 +313,8 @@
|
|
|
399
313
|
function isInArray(value, array) {
|
|
400
314
|
return value === array || (isArray(array) && array.includes(value));
|
|
401
315
|
}
|
|
402
|
-
function arrayRandomIndex(array) {
|
|
403
|
-
return Math.floor(getRandom() * array.length);
|
|
404
|
-
}
|
|
405
316
|
function itemFromArray(array, index, useIndex = true) {
|
|
406
|
-
return array[index !== undefined && useIndex ? index % array.length :
|
|
317
|
+
return array[index !== undefined && useIndex ? index % array.length : Math.floor(getRandom() * array.length)];
|
|
407
318
|
}
|
|
408
319
|
function isPointInside(point, size, offset, radius, direction) {
|
|
409
320
|
return areBoundsInside(calculateBounds(point, radius ?? minRadius), size, offset, direction);
|
|
@@ -487,56 +398,6 @@
|
|
|
487
398
|
function itemFromSingleOrMultiple(obj, index, useIndex) {
|
|
488
399
|
return isArray(obj) ? itemFromArray(obj, index, useIndex) : obj;
|
|
489
400
|
}
|
|
490
|
-
function initParticleNumericAnimationValue(options, pxRatio) {
|
|
491
|
-
const valueRange = options.value, animationOptions = options.animation, res = {
|
|
492
|
-
delayTime: getRangeValue(animationOptions.delay) * millisecondsToSeconds,
|
|
493
|
-
enable: animationOptions.enable,
|
|
494
|
-
value: getRangeValue(options.value) * pxRatio,
|
|
495
|
-
max: getRangeMax(valueRange) * pxRatio,
|
|
496
|
-
min: getRangeMin(valueRange) * pxRatio,
|
|
497
|
-
loops: 0,
|
|
498
|
-
maxLoops: getRangeValue(animationOptions.count),
|
|
499
|
-
time: 0,
|
|
500
|
-
}, decayOffset = 1;
|
|
501
|
-
if (animationOptions.enable) {
|
|
502
|
-
res.decay = decayOffset - getRangeValue(animationOptions.decay);
|
|
503
|
-
switch (animationOptions.mode) {
|
|
504
|
-
case AnimationMode.increase:
|
|
505
|
-
res.status = AnimationStatus.increasing;
|
|
506
|
-
break;
|
|
507
|
-
case AnimationMode.decrease:
|
|
508
|
-
res.status = AnimationStatus.decreasing;
|
|
509
|
-
break;
|
|
510
|
-
case AnimationMode.random:
|
|
511
|
-
res.status = getRandom() >= half ? AnimationStatus.increasing : AnimationStatus.decreasing;
|
|
512
|
-
break;
|
|
513
|
-
}
|
|
514
|
-
const autoStatus = animationOptions.mode === AnimationMode.auto;
|
|
515
|
-
switch (animationOptions.startValue) {
|
|
516
|
-
case StartValueType.min:
|
|
517
|
-
res.value = res.min;
|
|
518
|
-
if (autoStatus) {
|
|
519
|
-
res.status = AnimationStatus.increasing;
|
|
520
|
-
}
|
|
521
|
-
break;
|
|
522
|
-
case StartValueType.max:
|
|
523
|
-
res.value = res.max;
|
|
524
|
-
if (autoStatus) {
|
|
525
|
-
res.status = AnimationStatus.decreasing;
|
|
526
|
-
}
|
|
527
|
-
break;
|
|
528
|
-
case StartValueType.random:
|
|
529
|
-
default:
|
|
530
|
-
res.value = randomInRangeValue(res);
|
|
531
|
-
if (autoStatus) {
|
|
532
|
-
res.status = getRandom() >= half ? AnimationStatus.increasing : AnimationStatus.decreasing;
|
|
533
|
-
}
|
|
534
|
-
break;
|
|
535
|
-
}
|
|
536
|
-
}
|
|
537
|
-
res.initialValue = res.value;
|
|
538
|
-
return res;
|
|
539
|
-
}
|
|
540
401
|
function getPositionOrSize(positionOrSize, canvasSize) {
|
|
541
402
|
const isPercent = positionOrSize.mode === PixelMode.percent;
|
|
542
403
|
if (!isPercent) {
|
|
@@ -560,71 +421,6 @@
|
|
|
560
421
|
function getPosition(position, canvasSize) {
|
|
561
422
|
return getPositionOrSize(position, canvasSize);
|
|
562
423
|
}
|
|
563
|
-
function checkDestroy(particle, destroyType, value, minValue, maxValue) {
|
|
564
|
-
switch (destroyType) {
|
|
565
|
-
case DestroyType.max:
|
|
566
|
-
if (value >= maxValue) {
|
|
567
|
-
particle.destroy();
|
|
568
|
-
}
|
|
569
|
-
break;
|
|
570
|
-
case DestroyType.min:
|
|
571
|
-
if (value <= minValue) {
|
|
572
|
-
particle.destroy();
|
|
573
|
-
}
|
|
574
|
-
break;
|
|
575
|
-
}
|
|
576
|
-
}
|
|
577
|
-
function updateAnimation(particle, data, changeDirection, destroyType, delta) {
|
|
578
|
-
const minLoops = 0, minDelay = 0, identity = 1, minVelocity = 0, minDecay = 1;
|
|
579
|
-
if (particle.destroyed ||
|
|
580
|
-
!data.enable ||
|
|
581
|
-
((data.maxLoops ?? minLoops) > minLoops && (data.loops ?? minLoops) > (data.maxLoops ?? minLoops))) {
|
|
582
|
-
return;
|
|
583
|
-
}
|
|
584
|
-
const velocity = (data.velocity ?? minVelocity) * delta.factor, minValue = data.min, maxValue = data.max, decay = data.decay ?? minDecay;
|
|
585
|
-
data.time ??= 0;
|
|
586
|
-
if ((data.delayTime ?? minDelay) > minDelay && data.time < (data.delayTime ?? minDelay)) {
|
|
587
|
-
data.time += delta.value;
|
|
588
|
-
}
|
|
589
|
-
if ((data.delayTime ?? minDelay) > minDelay && data.time < (data.delayTime ?? minDelay)) {
|
|
590
|
-
return;
|
|
591
|
-
}
|
|
592
|
-
switch (data.status) {
|
|
593
|
-
case AnimationStatus.increasing:
|
|
594
|
-
data.value += velocity;
|
|
595
|
-
break;
|
|
596
|
-
case AnimationStatus.decreasing:
|
|
597
|
-
data.value -= velocity;
|
|
598
|
-
break;
|
|
599
|
-
}
|
|
600
|
-
if (data.velocity && decay !== identity) {
|
|
601
|
-
data.velocity *= decay;
|
|
602
|
-
}
|
|
603
|
-
switch (data.status) {
|
|
604
|
-
case AnimationStatus.increasing:
|
|
605
|
-
if (data.value >= maxValue) {
|
|
606
|
-
{
|
|
607
|
-
data.status = AnimationStatus.decreasing;
|
|
608
|
-
}
|
|
609
|
-
data.loops ??= minLoops;
|
|
610
|
-
data.loops++;
|
|
611
|
-
}
|
|
612
|
-
break;
|
|
613
|
-
case AnimationStatus.decreasing:
|
|
614
|
-
if (data.value <= minValue) {
|
|
615
|
-
{
|
|
616
|
-
data.status = AnimationStatus.increasing;
|
|
617
|
-
}
|
|
618
|
-
data.loops ??= minLoops;
|
|
619
|
-
data.loops++;
|
|
620
|
-
}
|
|
621
|
-
break;
|
|
622
|
-
}
|
|
623
|
-
checkDestroy(particle, destroyType, data.value, minValue, maxValue);
|
|
624
|
-
if (!particle.destroyed) {
|
|
625
|
-
data.value = clamp(data.value, minValue, maxValue);
|
|
626
|
-
}
|
|
627
|
-
}
|
|
628
424
|
function cloneStyle(style) {
|
|
629
425
|
const clonedStyle = safeDocument().createElement("div").style;
|
|
630
426
|
for (const key in style) {
|
|
@@ -646,30 +442,34 @@
|
|
|
646
442
|
}
|
|
647
443
|
return clonedStyle;
|
|
648
444
|
}
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
445
|
+
let _cachedZIndex, _cachedStyle;
|
|
446
|
+
function getFullScreenStyle(zIndex) {
|
|
447
|
+
if (_cachedZIndex !== zIndex || !_cachedStyle) {
|
|
448
|
+
_cachedZIndex = zIndex;
|
|
449
|
+
const fullScreenStyle = safeDocument().createElement("div").style, radix = 10, style = {
|
|
450
|
+
width: "100%",
|
|
451
|
+
height: "100%",
|
|
452
|
+
margin: "0",
|
|
453
|
+
padding: "0",
|
|
454
|
+
borderWidth: "0",
|
|
455
|
+
position: "fixed",
|
|
456
|
+
zIndex: zIndex.toString(radix),
|
|
457
|
+
"z-index": zIndex.toString(radix),
|
|
458
|
+
top: "0",
|
|
459
|
+
left: "0",
|
|
460
|
+
"pointer-events": "none",
|
|
461
|
+
};
|
|
462
|
+
for (const key in style) {
|
|
463
|
+
const value = style[key];
|
|
464
|
+
if (value === undefined) {
|
|
465
|
+
continue;
|
|
466
|
+
}
|
|
467
|
+
fullScreenStyle.setProperty(key, value);
|
|
667
468
|
}
|
|
668
|
-
fullScreenStyle
|
|
469
|
+
_cachedStyle = fullScreenStyle;
|
|
669
470
|
}
|
|
670
|
-
return
|
|
471
|
+
return _cachedStyle;
|
|
671
472
|
}
|
|
672
|
-
const getFullScreenStyle = memoize(computeFullScreenStyle);
|
|
673
473
|
function manageListener(element, event, handler, add, options) {
|
|
674
474
|
if (add) {
|
|
675
475
|
let addOptions = { passive: true };
|
|
@@ -996,7 +796,7 @@
|
|
|
996
796
|
return this.#domArray;
|
|
997
797
|
}
|
|
998
798
|
get version() {
|
|
999
|
-
return "4.
|
|
799
|
+
return "4.2.0";
|
|
1000
800
|
}
|
|
1001
801
|
addEventListener(type, listener) {
|
|
1002
802
|
this.#eventDispatcher.addEventListener(type, listener);
|
|
@@ -1166,6 +966,14 @@
|
|
|
1166
966
|
RotateDirection["random"] = "random";
|
|
1167
967
|
})(RotateDirection || (RotateDirection = {}));
|
|
1168
968
|
|
|
969
|
+
var AnimationMode;
|
|
970
|
+
(function (AnimationMode) {
|
|
971
|
+
AnimationMode["auto"] = "auto";
|
|
972
|
+
AnimationMode["increase"] = "increase";
|
|
973
|
+
AnimationMode["decrease"] = "decrease";
|
|
974
|
+
AnimationMode["random"] = "random";
|
|
975
|
+
})(AnimationMode || (AnimationMode = {}));
|
|
976
|
+
|
|
1169
977
|
var LimitMode;
|
|
1170
978
|
(function (LimitMode) {
|
|
1171
979
|
LimitMode["delete"] = "delete";
|
|
@@ -1187,6 +995,13 @@
|
|
|
1187
995
|
AlterType["enlighten"] = "enlighten";
|
|
1188
996
|
})(AlterType || (AlterType = {}));
|
|
1189
997
|
|
|
998
|
+
var DestroyType;
|
|
999
|
+
(function (DestroyType) {
|
|
1000
|
+
DestroyType["none"] = "none";
|
|
1001
|
+
DestroyType["max"] = "max";
|
|
1002
|
+
DestroyType["min"] = "min";
|
|
1003
|
+
})(DestroyType || (DestroyType = {}));
|
|
1004
|
+
|
|
1190
1005
|
var GradientType;
|
|
1191
1006
|
(function (GradientType) {
|
|
1192
1007
|
GradientType["linear"] = "linear";
|
|
@@ -1201,160 +1016,121 @@
|
|
|
1201
1016
|
ParticleOutType["outside"] = "outside";
|
|
1202
1017
|
})(ParticleOutType || (ParticleOutType = {}));
|
|
1203
1018
|
|
|
1204
|
-
var
|
|
1205
|
-
(function (
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
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 = {}));
|
|
1249
|
-
|
|
1250
|
-
class AnimationOptions {
|
|
1251
|
-
count;
|
|
1252
|
-
decay;
|
|
1253
|
-
delay;
|
|
1254
|
-
enable;
|
|
1255
|
-
speed;
|
|
1256
|
-
sync;
|
|
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
|
-
}
|
|
1019
|
+
var StartValueType;
|
|
1020
|
+
(function (StartValueType) {
|
|
1021
|
+
StartValueType["max"] = "max";
|
|
1022
|
+
StartValueType["min"] = "min";
|
|
1023
|
+
StartValueType["random"] = "random";
|
|
1024
|
+
})(StartValueType || (StartValueType = {}));
|
|
1025
|
+
|
|
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
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
if (data.sizeRate !== undefined) {
|
|
2032
|
-
this.sizeRate = data.sizeRate;
|
|
2033
|
-
}
|
|
2034
|
-
if (data.velocityRate !== undefined) {
|
|
2035
|
-
this.velocityRate = data.velocityRate;
|
|
2036
|
-
}
|
|
2037
|
-
}
|
|
2038
|
-
}
|
|
2039
|
-
|
|
2040
|
-
class ParticlesOptions {
|
|
2041
|
-
bounce;
|
|
2042
|
-
effect;
|
|
2043
|
-
groups;
|
|
2044
|
-
move;
|
|
2045
|
-
number;
|
|
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);
|
|
1512
|
+
}
|
|
1513
|
+
}
|
|
1514
|
+
|
|
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
|
-
}
|
|
2422
|
-
}
|
|
2423
|
-
function drawShapeAfterDraw(drawer, data) {
|
|
2424
|
-
if (!drawer?.afterDraw) {
|
|
2425
|
-
return;
|
|
2426
1738
|
}
|
|
2427
|
-
|
|
2428
|
-
|
|
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
|
});
|
|
@@ -2951,7 +2234,7 @@
|
|
|
2951
2234
|
}
|
|
2952
2235
|
|
|
2953
2236
|
async function loadMovePlugin(engine) {
|
|
2954
|
-
engine.checkVersion("4.
|
|
2237
|
+
engine.checkVersion("4.2.0");
|
|
2955
2238
|
await engine.pluginManager.register(e => {
|
|
2956
2239
|
const moveEngine = e, movePluginManager = moveEngine.pluginManager;
|
|
2957
2240
|
movePluginManager.initializers.pathGenerators ??= new Map();
|
|
@@ -2969,31 +2252,137 @@
|
|
|
2969
2252
|
});
|
|
2970
2253
|
}
|
|
2971
2254
|
|
|
2255
|
+
function checkDestroy(particle, destroyType, value, minValue, maxValue) {
|
|
2256
|
+
switch (destroyType) {
|
|
2257
|
+
case DestroyType.max:
|
|
2258
|
+
if (value >= maxValue) {
|
|
2259
|
+
particle.destroy();
|
|
2260
|
+
}
|
|
2261
|
+
break;
|
|
2262
|
+
case DestroyType.min:
|
|
2263
|
+
if (value <= minValue) {
|
|
2264
|
+
particle.destroy();
|
|
2265
|
+
}
|
|
2266
|
+
break;
|
|
2267
|
+
}
|
|
2268
|
+
}
|
|
2269
|
+
function initParticleNumericAnimationValue(options, pxRatio) {
|
|
2270
|
+
const valueRange = options.value, animationOptions = options.animation, res = {
|
|
2271
|
+
delayTime: getRangeValue(animationOptions.delay) * millisecondsToSeconds,
|
|
2272
|
+
enable: animationOptions.enable,
|
|
2273
|
+
value: getRangeValue(options.value) * pxRatio,
|
|
2274
|
+
max: getRangeMax(valueRange) * pxRatio,
|
|
2275
|
+
min: getRangeMin(valueRange) * pxRatio,
|
|
2276
|
+
loops: 0,
|
|
2277
|
+
maxLoops: getRangeValue(animationOptions.count),
|
|
2278
|
+
time: 0,
|
|
2279
|
+
}, decayOffset = 1;
|
|
2280
|
+
if (animationOptions.enable) {
|
|
2281
|
+
res.decay = decayOffset - getRangeValue(animationOptions.decay);
|
|
2282
|
+
switch (animationOptions.mode) {
|
|
2283
|
+
case AnimationMode.increase:
|
|
2284
|
+
res.status = AnimationStatus.increasing;
|
|
2285
|
+
break;
|
|
2286
|
+
case AnimationMode.decrease:
|
|
2287
|
+
res.status = AnimationStatus.decreasing;
|
|
2288
|
+
break;
|
|
2289
|
+
case AnimationMode.random:
|
|
2290
|
+
res.status = getRandom() >= half ? AnimationStatus.increasing : AnimationStatus.decreasing;
|
|
2291
|
+
break;
|
|
2292
|
+
}
|
|
2293
|
+
const autoStatus = animationOptions.mode === AnimationMode.auto;
|
|
2294
|
+
switch (animationOptions.startValue) {
|
|
2295
|
+
case StartValueType.min:
|
|
2296
|
+
res.value = res.min;
|
|
2297
|
+
if (autoStatus) {
|
|
2298
|
+
res.status = AnimationStatus.increasing;
|
|
2299
|
+
}
|
|
2300
|
+
break;
|
|
2301
|
+
case StartValueType.max:
|
|
2302
|
+
res.value = res.max;
|
|
2303
|
+
if (autoStatus) {
|
|
2304
|
+
res.status = AnimationStatus.decreasing;
|
|
2305
|
+
}
|
|
2306
|
+
break;
|
|
2307
|
+
case StartValueType.random:
|
|
2308
|
+
default:
|
|
2309
|
+
res.value = randomInRangeValue(res);
|
|
2310
|
+
if (autoStatus) {
|
|
2311
|
+
res.status = getRandom() >= half ? AnimationStatus.increasing : AnimationStatus.decreasing;
|
|
2312
|
+
}
|
|
2313
|
+
break;
|
|
2314
|
+
}
|
|
2315
|
+
}
|
|
2316
|
+
res.initialValue = res.value;
|
|
2317
|
+
return res;
|
|
2318
|
+
}
|
|
2319
|
+
function updateAnimation(particle, data, changeDirection, destroyType, delta) {
|
|
2320
|
+
const minLoops = 0, minDelay = 0, identity = 1, minVelocity = 0, minDecay = 1;
|
|
2321
|
+
if (particle.destroyed ||
|
|
2322
|
+
!data.enable ||
|
|
2323
|
+
((data.maxLoops ?? minLoops) > minLoops && (data.loops ?? minLoops) > (data.maxLoops ?? minLoops))) {
|
|
2324
|
+
return;
|
|
2325
|
+
}
|
|
2326
|
+
const velocity = (data.velocity ?? minVelocity) * delta.factor, minValue = data.min, maxValue = data.max, decay = data.decay ?? minDecay;
|
|
2327
|
+
data.time ??= 0;
|
|
2328
|
+
const delayTime = data.delayTime ?? minDelay;
|
|
2329
|
+
if (delayTime > minDelay && data.time < delayTime) {
|
|
2330
|
+
data.time += delta.value;
|
|
2331
|
+
if (data.time < delayTime) {
|
|
2332
|
+
return;
|
|
2333
|
+
}
|
|
2334
|
+
}
|
|
2335
|
+
switch (data.status) {
|
|
2336
|
+
case AnimationStatus.increasing:
|
|
2337
|
+
data.value += velocity;
|
|
2338
|
+
break;
|
|
2339
|
+
case AnimationStatus.decreasing:
|
|
2340
|
+
data.value -= velocity;
|
|
2341
|
+
break;
|
|
2342
|
+
}
|
|
2343
|
+
if (data.velocity && decay !== identity) {
|
|
2344
|
+
data.velocity *= decay;
|
|
2345
|
+
}
|
|
2346
|
+
switch (data.status) {
|
|
2347
|
+
case AnimationStatus.increasing:
|
|
2348
|
+
if (data.value >= maxValue) {
|
|
2349
|
+
{
|
|
2350
|
+
data.status = AnimationStatus.decreasing;
|
|
2351
|
+
}
|
|
2352
|
+
data.loops ??= minLoops;
|
|
2353
|
+
data.loops++;
|
|
2354
|
+
}
|
|
2355
|
+
break;
|
|
2356
|
+
case AnimationStatus.decreasing:
|
|
2357
|
+
if (data.value <= minValue) {
|
|
2358
|
+
{
|
|
2359
|
+
data.status = AnimationStatus.increasing;
|
|
2360
|
+
}
|
|
2361
|
+
data.loops ??= minLoops;
|
|
2362
|
+
data.loops++;
|
|
2363
|
+
}
|
|
2364
|
+
break;
|
|
2365
|
+
}
|
|
2366
|
+
checkDestroy(particle, destroyType, data.value, minValue, maxValue);
|
|
2367
|
+
if (!particle.destroyed) {
|
|
2368
|
+
data.value = clamp(data.value, minValue, maxValue);
|
|
2369
|
+
}
|
|
2370
|
+
}
|
|
2371
|
+
|
|
2972
2372
|
class OpacityAnimation extends RangedAnimationOptions {
|
|
2973
|
-
destroy;
|
|
2974
|
-
constructor() {
|
|
2975
|
-
super();
|
|
2976
|
-
this.destroy = DestroyType.none;
|
|
2977
|
-
this.speed = 2;
|
|
2978
|
-
}
|
|
2373
|
+
destroy = DestroyType.none;
|
|
2979
2374
|
load(data) {
|
|
2980
2375
|
super.load(data);
|
|
2981
2376
|
if (isNull(data)) {
|
|
2982
2377
|
return;
|
|
2983
2378
|
}
|
|
2984
|
-
|
|
2985
|
-
this.destroy = data.destroy;
|
|
2986
|
-
}
|
|
2379
|
+
loadProperty(this, "destroy", data.destroy);
|
|
2987
2380
|
}
|
|
2988
2381
|
}
|
|
2989
2382
|
|
|
2990
2383
|
class Opacity extends RangedAnimationValueWithRandom {
|
|
2991
|
-
animation;
|
|
2992
|
-
|
|
2993
|
-
super();
|
|
2994
|
-
this.animation = new OpacityAnimation();
|
|
2995
|
-
this.value = 1;
|
|
2996
|
-
}
|
|
2384
|
+
animation = new OpacityAnimation();
|
|
2385
|
+
value = 1;
|
|
2997
2386
|
load(data) {
|
|
2998
2387
|
if (isNull(data)) {
|
|
2999
2388
|
return;
|
|
@@ -3037,10 +2426,7 @@
|
|
|
3037
2426
|
(particle.opacity.loops ?? none) < (particle.opacity.maxLoops ?? none))));
|
|
3038
2427
|
}
|
|
3039
2428
|
loadOptions(options, ...sources) {
|
|
3040
|
-
options
|
|
3041
|
-
for (const source of sources) {
|
|
3042
|
-
options.opacity.load(source?.opacity);
|
|
3043
|
-
}
|
|
2429
|
+
loadOptionProperty(options, "opacity", Opacity, ...sources);
|
|
3044
2430
|
}
|
|
3045
2431
|
reset(particle) {
|
|
3046
2432
|
if (!particle.opacity) {
|
|
@@ -3058,7 +2444,7 @@
|
|
|
3058
2444
|
}
|
|
3059
2445
|
|
|
3060
2446
|
async function loadOpacityUpdater(engine) {
|
|
3061
|
-
engine.checkVersion("4.
|
|
2447
|
+
engine.checkVersion("4.2.0");
|
|
3062
2448
|
await engine.pluginManager.register(e => {
|
|
3063
2449
|
e.pluginManager.addParticleUpdater("opacity", container => {
|
|
3064
2450
|
return Promise.resolve(new OpacityUpdater(container));
|
|
@@ -3066,7 +2452,7 @@
|
|
|
3066
2452
|
});
|
|
3067
2453
|
}
|
|
3068
2454
|
|
|
3069
|
-
const
|
|
2455
|
+
const boundsMin = 0;
|
|
3070
2456
|
function bounceHorizontal(data) {
|
|
3071
2457
|
if ((data.outMode !== OutMode.bounce && data.outMode !== OutMode.split) ||
|
|
3072
2458
|
(data.direction !== OutModeDirection.left && data.direction !== OutModeDirection.right)) {
|
|
@@ -3081,8 +2467,8 @@
|
|
|
3081
2467
|
const velocity = data.particle.velocity.x;
|
|
3082
2468
|
let bounced = false;
|
|
3083
2469
|
if (data.outOfCanvas &&
|
|
3084
|
-
((data.direction === OutModeDirection.right && velocity > minVelocity
|
|
3085
|
-
(data.direction === OutModeDirection.left && velocity < minVelocity
|
|
2470
|
+
((data.direction === OutModeDirection.right && velocity > minVelocity) ||
|
|
2471
|
+
(data.direction === OutModeDirection.left && velocity < minVelocity))) {
|
|
3086
2472
|
const newVelocity = getRangeValue(data.particle.options.bounce.horizontal.value);
|
|
3087
2473
|
data.particle.velocity.x *= -newVelocity;
|
|
3088
2474
|
bounced = true;
|
|
@@ -3115,8 +2501,8 @@
|
|
|
3115
2501
|
const velocity = data.particle.velocity.y;
|
|
3116
2502
|
let bounced = false;
|
|
3117
2503
|
if (data.outOfCanvas &&
|
|
3118
|
-
((data.direction === OutModeDirection.bottom && velocity > minVelocity
|
|
3119
|
-
(data.direction === OutModeDirection.top && velocity < minVelocity
|
|
2504
|
+
((data.direction === OutModeDirection.bottom && velocity > minVelocity) ||
|
|
2505
|
+
(data.direction === OutModeDirection.top && velocity < minVelocity))) {
|
|
3120
2506
|
const newVelocity = getRangeValue(data.particle.options.bounce.vertical.value);
|
|
3121
2507
|
data.particle.velocity.y *= -newVelocity;
|
|
3122
2508
|
bounced = true;
|
|
@@ -3169,7 +2555,6 @@
|
|
|
3169
2555
|
}
|
|
3170
2556
|
}
|
|
3171
2557
|
|
|
3172
|
-
const minVelocity$3 = 0;
|
|
3173
2558
|
class DestroyOutMode {
|
|
3174
2559
|
modes;
|
|
3175
2560
|
constructor(_container) {
|
|
@@ -3188,10 +2573,10 @@
|
|
|
3188
2573
|
break;
|
|
3189
2574
|
case ParticleOutType.inside: {
|
|
3190
2575
|
const { dx, dy } = getDistances(particle.position, particle.moveCenter), { x: vx, y: vy } = particle.velocity;
|
|
3191
|
-
if ((vx < minVelocity
|
|
3192
|
-
(vy < minVelocity
|
|
3193
|
-
(vx >= minVelocity
|
|
3194
|
-
(vy >= minVelocity
|
|
2576
|
+
if ((vx < minVelocity && dx > particle.moveCenter.radius) ||
|
|
2577
|
+
(vy < minVelocity && dy > particle.moveCenter.radius) ||
|
|
2578
|
+
(vx >= minVelocity && dx < -particle.moveCenter.radius) ||
|
|
2579
|
+
(vy >= minVelocity && dy < -particle.moveCenter.radius)) {
|
|
3195
2580
|
return;
|
|
3196
2581
|
}
|
|
3197
2582
|
break;
|
|
@@ -3201,7 +2586,6 @@
|
|
|
3201
2586
|
}
|
|
3202
2587
|
}
|
|
3203
2588
|
|
|
3204
|
-
const minVelocity$2 = 0;
|
|
3205
2589
|
class NoneOutMode {
|
|
3206
2590
|
modes;
|
|
3207
2591
|
#container;
|
|
@@ -3221,10 +2605,10 @@
|
|
|
3221
2605
|
}
|
|
3222
2606
|
const gravityOptions = particle.options.move.gravity, container = this.#container, canvasSize = container.canvas.size, pRadius = particle.getRadius();
|
|
3223
2607
|
if (!gravityOptions.enable) {
|
|
3224
|
-
if ((particle.velocity.y > minVelocity
|
|
3225
|
-
(particle.velocity.y < minVelocity
|
|
3226
|
-
(particle.velocity.x > minVelocity
|
|
3227
|
-
(particle.velocity.x < minVelocity
|
|
2608
|
+
if ((particle.velocity.y > minVelocity && particle.position.y <= canvasSize.height + pRadius) ||
|
|
2609
|
+
(particle.velocity.y < minVelocity && particle.position.y >= -pRadius) ||
|
|
2610
|
+
(particle.velocity.x > minVelocity && particle.position.x <= canvasSize.width + pRadius) ||
|
|
2611
|
+
(particle.velocity.x < minVelocity && particle.position.x >= -pRadius)) {
|
|
3228
2612
|
return;
|
|
3229
2613
|
}
|
|
3230
2614
|
if (!isPointInside(particle.position, container.canvas.size, originPoint, pRadius, direction)) {
|
|
@@ -3243,7 +2627,7 @@
|
|
|
3243
2627
|
}
|
|
3244
2628
|
}
|
|
3245
2629
|
|
|
3246
|
-
const
|
|
2630
|
+
const updateVector = Vector.origin;
|
|
3247
2631
|
class OutOutMode {
|
|
3248
2632
|
modes;
|
|
3249
2633
|
#container;
|
|
@@ -3264,10 +2648,10 @@
|
|
|
3264
2648
|
updateVector.angle = particle.velocity.angle + Math.PI;
|
|
3265
2649
|
updateVector.addTo(particle.moveCenter);
|
|
3266
2650
|
const { dx, dy } = getDistances(particle.position, updateVector);
|
|
3267
|
-
if ((vx <= minVelocity
|
|
3268
|
-
(vy <= minVelocity
|
|
3269
|
-
(vx >= minVelocity
|
|
3270
|
-
(vy >= minVelocity
|
|
2651
|
+
if ((vx <= minVelocity && dx >= minDistance) ||
|
|
2652
|
+
(vy <= minVelocity && dy >= minDistance) ||
|
|
2653
|
+
(vx >= minVelocity && dx <= minDistance) ||
|
|
2654
|
+
(vy >= minVelocity && dy <= minDistance)) {
|
|
3271
2655
|
return;
|
|
3272
2656
|
}
|
|
3273
2657
|
particle.position.x = Math.floor(randomInRangeValue({
|
|
@@ -3391,21 +2775,21 @@
|
|
|
3391
2775
|
this.#updateOutMode(particle, delta, outModes.right ?? outModes.default, OutModeDirection.right);
|
|
3392
2776
|
this.#updateOutMode(particle, delta, outModes.top ?? outModes.default, OutModeDirection.top);
|
|
3393
2777
|
}
|
|
3394
|
-
#addUpdaterIfMissing
|
|
2778
|
+
#addUpdaterIfMissing(particle, outMode, getUpdater) {
|
|
3395
2779
|
const outModes = particle.options.move.outModes;
|
|
3396
2780
|
if (!this.updaters.has(outMode) && checkOutMode(outModes, outMode)) {
|
|
3397
2781
|
this.updaters.set(outMode, getUpdater(this.#container));
|
|
3398
2782
|
}
|
|
3399
|
-
}
|
|
3400
|
-
#updateOutMode
|
|
2783
|
+
}
|
|
2784
|
+
#updateOutMode(particle, delta, outMode, direction) {
|
|
3401
2785
|
for (const updater of this.updaters.values()) {
|
|
3402
2786
|
updater.update(particle, direction, delta, outMode);
|
|
3403
2787
|
}
|
|
3404
|
-
}
|
|
2788
|
+
}
|
|
3405
2789
|
}
|
|
3406
2790
|
|
|
3407
2791
|
async function loadOutModesUpdater(engine) {
|
|
3408
|
-
engine.checkVersion("4.
|
|
2792
|
+
engine.checkVersion("4.2.0");
|
|
3409
2793
|
await engine.pluginManager.register(e => {
|
|
3410
2794
|
e.pluginManager.addParticleUpdater("outModes", container => {
|
|
3411
2795
|
return Promise.resolve(new OutOfCanvasUpdater(container));
|
|
@@ -3476,7 +2860,7 @@
|
|
|
3476
2860
|
}
|
|
3477
2861
|
|
|
3478
2862
|
async function loadPaintUpdater(engine) {
|
|
3479
|
-
engine.checkVersion("4.
|
|
2863
|
+
engine.checkVersion("4.2.0");
|
|
3480
2864
|
await engine.pluginManager.register(e => {
|
|
3481
2865
|
e.pluginManager.addParticleUpdater("paint", container => {
|
|
3482
2866
|
return Promise.resolve(new PaintUpdater(e.pluginManager, container));
|
|
@@ -3531,37 +2915,26 @@
|
|
|
3531
2915
|
}
|
|
3532
2916
|
|
|
3533
2917
|
async function loadRgbColorPlugin(engine) {
|
|
3534
|
-
engine.checkVersion("4.
|
|
2918
|
+
engine.checkVersion("4.2.0");
|
|
3535
2919
|
await engine.pluginManager.register(e => {
|
|
3536
2920
|
e.pluginManager.addColorManager("rgb", new RgbColorManager());
|
|
3537
2921
|
});
|
|
3538
2922
|
}
|
|
3539
2923
|
|
|
3540
2924
|
class SizeAnimation extends RangedAnimationOptions {
|
|
3541
|
-
destroy;
|
|
3542
|
-
constructor() {
|
|
3543
|
-
super();
|
|
3544
|
-
this.destroy = DestroyType.none;
|
|
3545
|
-
this.speed = 5;
|
|
3546
|
-
}
|
|
2925
|
+
destroy = DestroyType.none;
|
|
3547
2926
|
load(data) {
|
|
3548
2927
|
super.load(data);
|
|
3549
2928
|
if (isNull(data)) {
|
|
3550
2929
|
return;
|
|
3551
2930
|
}
|
|
3552
|
-
|
|
3553
|
-
this.destroy = data.destroy;
|
|
3554
|
-
}
|
|
2931
|
+
loadProperty(this, "destroy", data.destroy);
|
|
3555
2932
|
}
|
|
3556
2933
|
}
|
|
3557
2934
|
|
|
3558
2935
|
class Size extends RangedAnimationValueWithRandom {
|
|
3559
|
-
animation;
|
|
3560
|
-
|
|
3561
|
-
super();
|
|
3562
|
-
this.animation = new SizeAnimation();
|
|
3563
|
-
this.value = 3;
|
|
3564
|
-
}
|
|
2936
|
+
animation = new SizeAnimation();
|
|
2937
|
+
value = 3;
|
|
3565
2938
|
load(data) {
|
|
3566
2939
|
super.load(data);
|
|
3567
2940
|
if (isNull(data)) {
|
|
@@ -3604,10 +2977,7 @@
|
|
|
3604
2977
|
(particle.size.loops ?? minLoops) < (particle.size.maxLoops ?? minLoops))));
|
|
3605
2978
|
}
|
|
3606
2979
|
loadOptions(options, ...sources) {
|
|
3607
|
-
options
|
|
3608
|
-
for (const source of sources) {
|
|
3609
|
-
options.size.load(source?.size);
|
|
3610
|
-
}
|
|
2980
|
+
loadOptionProperty(options, "size", Size, ...sources);
|
|
3611
2981
|
}
|
|
3612
2982
|
preInit(particle) {
|
|
3613
2983
|
const pxRatio = this.#container.retina.pixelRatio, options = particle.options, sizeOptions = options.size;
|
|
@@ -3630,7 +3000,7 @@
|
|
|
3630
3000
|
}
|
|
3631
3001
|
|
|
3632
3002
|
async function loadSizeUpdater(engine) {
|
|
3633
|
-
engine.checkVersion("4.
|
|
3003
|
+
engine.checkVersion("4.2.0");
|
|
3634
3004
|
await engine.pluginManager.register(e => {
|
|
3635
3005
|
e.pluginManager.addParticleUpdater("size", container => {
|
|
3636
3006
|
return Promise.resolve(new SizeUpdater(container));
|
|
@@ -3639,7 +3009,7 @@
|
|
|
3639
3009
|
}
|
|
3640
3010
|
|
|
3641
3011
|
async function loadBasic(engine) {
|
|
3642
|
-
engine.checkVersion("4.
|
|
3012
|
+
engine.checkVersion("4.2.0");
|
|
3643
3013
|
await engine.pluginManager.register(async (e) => {
|
|
3644
3014
|
await Promise.all([
|
|
3645
3015
|
loadBlendPlugin(e),
|
|
@@ -3657,7 +3027,7 @@
|
|
|
3657
3027
|
}
|
|
3658
3028
|
|
|
3659
3029
|
const matrixChars = [
|
|
3660
|
-
"
|
|
3030
|
+
"ア",
|
|
3661
3031
|
"\u30A4",
|
|
3662
3032
|
"\u30A6",
|
|
3663
3033
|
"\u30A8",
|
|
@@ -3871,41 +3241,26 @@
|
|
|
3871
3241
|
}
|
|
3872
3242
|
|
|
3873
3243
|
async function loadMatrixShape(engine) {
|
|
3874
|
-
engine.checkVersion("4.
|
|
3244
|
+
engine.checkVersion("4.2.0");
|
|
3875
3245
|
await engine.pluginManager.register(e => {
|
|
3876
3246
|
e.pluginManager.addShape(["matrix"], () => Promise.resolve(new MatrixDrawer()));
|
|
3877
3247
|
});
|
|
3878
3248
|
}
|
|
3879
3249
|
|
|
3880
3250
|
class Poisson {
|
|
3881
|
-
dimensions;
|
|
3882
|
-
enable;
|
|
3883
|
-
radius;
|
|
3884
|
-
retries;
|
|
3885
|
-
steps;
|
|
3886
|
-
constructor() {
|
|
3887
|
-
this.enable = false;
|
|
3888
|
-
this.dimensions = 2;
|
|
3889
|
-
this.radius = 0;
|
|
3890
|
-
this.retries = 30;
|
|
3891
|
-
this.steps = 0;
|
|
3892
|
-
}
|
|
3251
|
+
dimensions = 2;
|
|
3252
|
+
enable = false;
|
|
3253
|
+
radius = 0;
|
|
3254
|
+
retries = 30;
|
|
3255
|
+
steps = 0;
|
|
3893
3256
|
load(data) {
|
|
3894
3257
|
if (isNull(data)) {
|
|
3895
3258
|
return;
|
|
3896
3259
|
}
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
this.dimensions = data.dimensions;
|
|
3902
|
-
}
|
|
3903
|
-
if (data.radius !== undefined) {
|
|
3904
|
-
this.radius = data.radius;
|
|
3905
|
-
}
|
|
3906
|
-
if (data.retries !== undefined) {
|
|
3907
|
-
this.retries = data.retries;
|
|
3908
|
-
}
|
|
3260
|
+
loadProperty(this, "enable", data.enable);
|
|
3261
|
+
loadProperty(this, "dimensions", data.dimensions);
|
|
3262
|
+
loadProperty(this, "radius", data.radius);
|
|
3263
|
+
loadProperty(this, "retries", data.retries);
|
|
3909
3264
|
}
|
|
3910
3265
|
}
|
|
3911
3266
|
|
|
@@ -3931,7 +3286,7 @@
|
|
|
3931
3286
|
}
|
|
3932
3287
|
|
|
3933
3288
|
async function loadPoissonDiscPlugin(engine) {
|
|
3934
|
-
engine.checkVersion("4.
|
|
3289
|
+
engine.checkVersion("4.2.0");
|
|
3935
3290
|
await engine.pluginManager.register(e => {
|
|
3936
3291
|
e.pluginManager.addPlugin(new PoissonDiscPlugin());
|
|
3937
3292
|
});
|
|
@@ -3969,7 +3324,7 @@
|
|
|
3969
3324
|
}
|
|
3970
3325
|
|
|
3971
3326
|
async function loadShadowEffect(engine) {
|
|
3972
|
-
engine.checkVersion("4.
|
|
3327
|
+
engine.checkVersion("4.2.0");
|
|
3973
3328
|
await engine.pluginManager.register(e => {
|
|
3974
3329
|
e.pluginManager.addEffect("shadow", container => {
|
|
3975
3330
|
return Promise.resolve(new ShadowDrawer(e.pluginManager, container));
|
|
@@ -3987,34 +3342,23 @@
|
|
|
3987
3342
|
if (data.color !== undefined) {
|
|
3988
3343
|
this.color = OptionsColor.create(this.color, data.color);
|
|
3989
3344
|
}
|
|
3990
|
-
|
|
3991
|
-
this.image = data.image;
|
|
3992
|
-
}
|
|
3345
|
+
loadProperty(this, "image", data.image);
|
|
3993
3346
|
}
|
|
3994
3347
|
}
|
|
3995
3348
|
|
|
3996
3349
|
class Trail {
|
|
3997
|
-
enable;
|
|
3998
|
-
fill;
|
|
3999
|
-
length;
|
|
4000
|
-
constructor() {
|
|
4001
|
-
this.enable = false;
|
|
4002
|
-
this.length = 10;
|
|
4003
|
-
this.fill = new TrailFill();
|
|
4004
|
-
}
|
|
3350
|
+
enable = false;
|
|
3351
|
+
fill = new TrailFill();
|
|
3352
|
+
length = 10;
|
|
4005
3353
|
load(data) {
|
|
4006
3354
|
if (isNull(data)) {
|
|
4007
3355
|
return;
|
|
4008
3356
|
}
|
|
4009
|
-
|
|
4010
|
-
this.enable = data.enable;
|
|
4011
|
-
}
|
|
3357
|
+
loadProperty(this, "enable", data.enable);
|
|
4012
3358
|
if (data.fill !== undefined) {
|
|
4013
3359
|
this.fill.load(data.fill);
|
|
4014
3360
|
}
|
|
4015
|
-
|
|
4016
|
-
this.length = data.length;
|
|
4017
|
-
}
|
|
3361
|
+
loadProperty(this, "length", data.length);
|
|
4018
3362
|
}
|
|
4019
3363
|
}
|
|
4020
3364
|
|
|
@@ -4044,7 +3388,7 @@
|
|
|
4044
3388
|
}
|
|
4045
3389
|
|
|
4046
3390
|
async function loadTrailPlugin(engine) {
|
|
4047
|
-
engine.checkVersion("4.
|
|
3391
|
+
engine.checkVersion("4.2.0");
|
|
4048
3392
|
await engine.pluginManager.register(e => {
|
|
4049
3393
|
e.pluginManager.addPlugin(new TrailPlugin(e.pluginManager));
|
|
4050
3394
|
});
|
|
@@ -4200,7 +3544,7 @@
|
|
|
4200
3544
|
return;
|
|
4201
3545
|
}
|
|
4202
3546
|
this.draw(ctx => {
|
|
4203
|
-
|
|
3547
|
+
ctx.clearRect(originPoint.x, originPoint.y, this.#canvasManager.size.width, this.#canvasManager.size.height);
|
|
4204
3548
|
});
|
|
4205
3549
|
}
|
|
4206
3550
|
clear() {
|
|
@@ -4262,7 +3606,7 @@
|
|
|
4262
3606
|
plugin.drawParticleSetup?.(context, particle, delta);
|
|
4263
3607
|
}
|
|
4264
3608
|
this.#applyPreDrawUpdaters(context, particle, radius, opacity, colorStyles, transform);
|
|
4265
|
-
drawParticle({
|
|
3609
|
+
this.#drawParticle({
|
|
4266
3610
|
container,
|
|
4267
3611
|
context,
|
|
4268
3612
|
particle,
|
|
@@ -4281,7 +3625,7 @@
|
|
|
4281
3625
|
drawParticlePlugins(particle, delta) {
|
|
4282
3626
|
this.draw(ctx => {
|
|
4283
3627
|
for (const plugin of this.#drawParticlePlugins) {
|
|
4284
|
-
drawParticlePlugin(ctx, plugin, particle, delta);
|
|
3628
|
+
this.#drawParticlePlugin(ctx, plugin, particle, delta);
|
|
4285
3629
|
}
|
|
4286
3630
|
});
|
|
4287
3631
|
}
|
|
@@ -4381,12 +3725,19 @@
|
|
|
4381
3725
|
}
|
|
4382
3726
|
paintBase(baseColor) {
|
|
4383
3727
|
this.draw(ctx => {
|
|
4384
|
-
|
|
3728
|
+
ctx.fillStyle = baseColor ?? "rgba(0,0,0,0)";
|
|
3729
|
+
ctx.fillRect(originPoint.x, originPoint.y, this.#canvasManager.size.width, this.#canvasManager.size.height);
|
|
4385
3730
|
});
|
|
4386
3731
|
}
|
|
4387
3732
|
paintImage(image, opacity) {
|
|
4388
3733
|
this.draw(ctx => {
|
|
4389
|
-
|
|
3734
|
+
if (!image) {
|
|
3735
|
+
return;
|
|
3736
|
+
}
|
|
3737
|
+
const prevAlpha = ctx.globalAlpha;
|
|
3738
|
+
ctx.globalAlpha = opacity;
|
|
3739
|
+
ctx.drawImage(image, originPoint.x, originPoint.y, this.#canvasManager.size.width, this.#canvasManager.size.height);
|
|
3740
|
+
ctx.globalAlpha = prevAlpha;
|
|
4390
3741
|
});
|
|
4391
3742
|
}
|
|
4392
3743
|
setContext(context) {
|
|
@@ -4400,15 +3751,15 @@
|
|
|
4400
3751
|
}
|
|
4401
3752
|
stop() {
|
|
4402
3753
|
this.draw(ctx => {
|
|
4403
|
-
|
|
3754
|
+
ctx.clearRect(originPoint.x, originPoint.y, this.#canvasManager.size.width, this.#canvasManager.size.height);
|
|
4404
3755
|
});
|
|
4405
3756
|
}
|
|
4406
|
-
#applyPostDrawUpdaters
|
|
3757
|
+
#applyPostDrawUpdaters(particle) {
|
|
4407
3758
|
for (const updater of this.#postDrawUpdaters) {
|
|
4408
3759
|
updater.afterDraw?.(particle);
|
|
4409
3760
|
}
|
|
4410
|
-
}
|
|
4411
|
-
#applyPreDrawUpdaters
|
|
3761
|
+
}
|
|
3762
|
+
#applyPreDrawUpdaters(ctx, particle, radius, zOpacity, colorStyles, transform) {
|
|
4412
3763
|
for (const updater of this.#preDrawUpdaters) {
|
|
4413
3764
|
if (updater.getColorStyles) {
|
|
4414
3765
|
const { fill, stroke } = updater.getColorStyles(particle, ctx, radius, zOpacity);
|
|
@@ -4427,8 +3778,114 @@
|
|
|
4427
3778
|
}
|
|
4428
3779
|
updater.beforeDraw?.(particle);
|
|
4429
3780
|
}
|
|
4430
|
-
}
|
|
4431
|
-
#
|
|
3781
|
+
}
|
|
3782
|
+
#drawAfterEffect(drawer, data) {
|
|
3783
|
+
if (!drawer?.drawAfter) {
|
|
3784
|
+
return;
|
|
3785
|
+
}
|
|
3786
|
+
const { particle } = data;
|
|
3787
|
+
if (!particle.effect) {
|
|
3788
|
+
return;
|
|
3789
|
+
}
|
|
3790
|
+
drawer.drawAfter(data);
|
|
3791
|
+
}
|
|
3792
|
+
#drawBeforeEffect(drawer, data) {
|
|
3793
|
+
if (!drawer?.drawBefore) {
|
|
3794
|
+
return;
|
|
3795
|
+
}
|
|
3796
|
+
const { particle } = data;
|
|
3797
|
+
if (!particle.effect) {
|
|
3798
|
+
return;
|
|
3799
|
+
}
|
|
3800
|
+
drawer.drawBefore(data);
|
|
3801
|
+
}
|
|
3802
|
+
#drawParticle(data) {
|
|
3803
|
+
const { container, context, particle, delta, colorStyles, radius, opacity, transform } = data, { effectDrawers, shapeDrawers } = container, pos = particle.getPosition(), transformData = particle.getTransformData(transform), drawScale = defaultZoom, drawPosition = {
|
|
3804
|
+
x: pos.x,
|
|
3805
|
+
y: pos.y,
|
|
3806
|
+
};
|
|
3807
|
+
context.setTransform(transformData.a, transformData.b, transformData.c, transformData.d, pos.x, pos.y);
|
|
3808
|
+
if (colorStyles.fill) {
|
|
3809
|
+
context.fillStyle = colorStyles.fill;
|
|
3810
|
+
}
|
|
3811
|
+
const fillEnabled = !!particle.fillEnabled, strokeWidth = particle.strokeWidth ?? minStrokeWidth;
|
|
3812
|
+
context.lineWidth = strokeWidth;
|
|
3813
|
+
if (colorStyles.stroke) {
|
|
3814
|
+
context.strokeStyle = colorStyles.stroke;
|
|
3815
|
+
}
|
|
3816
|
+
const drawData = {
|
|
3817
|
+
context,
|
|
3818
|
+
particle,
|
|
3819
|
+
radius,
|
|
3820
|
+
drawRadius: radius * drawScale,
|
|
3821
|
+
opacity,
|
|
3822
|
+
delta,
|
|
3823
|
+
pixelRatio: container.retina.pixelRatio,
|
|
3824
|
+
fill: fillEnabled,
|
|
3825
|
+
stroke: strokeWidth > minStrokeWidth,
|
|
3826
|
+
transformData,
|
|
3827
|
+
position: { ...pos },
|
|
3828
|
+
drawPosition,
|
|
3829
|
+
drawScale,
|
|
3830
|
+
};
|
|
3831
|
+
for (const plugin of container.plugins) {
|
|
3832
|
+
plugin.drawParticleTransform?.(drawData);
|
|
3833
|
+
}
|
|
3834
|
+
const effect = particle.effect ? effectDrawers.get(particle.effect) : undefined, shape = particle.shape ? shapeDrawers.get(particle.shape) : undefined;
|
|
3835
|
+
this.#drawBeforeEffect(effect, drawData);
|
|
3836
|
+
this.#drawShapeBeforeDraw(shape, drawData);
|
|
3837
|
+
this.#drawShape(shape, drawData);
|
|
3838
|
+
this.#drawShapeAfterDraw(shape, drawData);
|
|
3839
|
+
this.#drawAfterEffect(effect, drawData);
|
|
3840
|
+
context.resetTransform();
|
|
3841
|
+
}
|
|
3842
|
+
#drawParticlePlugin(context, plugin, particle, delta) {
|
|
3843
|
+
if (!plugin.drawParticle) {
|
|
3844
|
+
return;
|
|
3845
|
+
}
|
|
3846
|
+
plugin.drawParticle(context, particle, delta);
|
|
3847
|
+
}
|
|
3848
|
+
#drawShape(drawer, data) {
|
|
3849
|
+
if (!drawer) {
|
|
3850
|
+
return;
|
|
3851
|
+
}
|
|
3852
|
+
const { context, fill, particle, stroke } = data;
|
|
3853
|
+
if (!particle.shape) {
|
|
3854
|
+
return;
|
|
3855
|
+
}
|
|
3856
|
+
context.beginPath();
|
|
3857
|
+
drawer.draw(data);
|
|
3858
|
+
if (particle.shapeClose) {
|
|
3859
|
+
context.closePath();
|
|
3860
|
+
}
|
|
3861
|
+
if (fill) {
|
|
3862
|
+
context.fill();
|
|
3863
|
+
}
|
|
3864
|
+
if (stroke) {
|
|
3865
|
+
context.stroke();
|
|
3866
|
+
}
|
|
3867
|
+
}
|
|
3868
|
+
#drawShapeAfterDraw(drawer, data) {
|
|
3869
|
+
if (!drawer?.afterDraw) {
|
|
3870
|
+
return;
|
|
3871
|
+
}
|
|
3872
|
+
const { particle } = data;
|
|
3873
|
+
if (!particle.shape) {
|
|
3874
|
+
return;
|
|
3875
|
+
}
|
|
3876
|
+
drawer.afterDraw(data);
|
|
3877
|
+
}
|
|
3878
|
+
#drawShapeBeforeDraw(drawer, data) {
|
|
3879
|
+
if (!drawer?.beforeDraw) {
|
|
3880
|
+
return;
|
|
3881
|
+
}
|
|
3882
|
+
const { particle } = data;
|
|
3883
|
+
if (!particle.shape) {
|
|
3884
|
+
return;
|
|
3885
|
+
}
|
|
3886
|
+
drawer.beforeDraw(data);
|
|
3887
|
+
}
|
|
3888
|
+
#getPluginParticleColors(particle) {
|
|
4432
3889
|
let fColor, sColor;
|
|
4433
3890
|
for (const plugin of this.#colorPlugins) {
|
|
4434
3891
|
if (!fColor && plugin.particleFillColor) {
|
|
@@ -4444,7 +3901,7 @@
|
|
|
4444
3901
|
this.#reusablePluginColors[fColorIndex] = fColor;
|
|
4445
3902
|
this.#reusablePluginColors[sColorIndex] = sColor;
|
|
4446
3903
|
return this.#reusablePluginColors;
|
|
4447
|
-
}
|
|
3904
|
+
}
|
|
4448
3905
|
}
|
|
4449
3906
|
|
|
4450
3907
|
const transferredCanvases = new WeakMap(), getTransferredCanvas = (canvas) => {
|
|
@@ -4576,6 +4033,7 @@
|
|
|
4576
4033
|
obs.observe(element, { attributes: true });
|
|
4577
4034
|
});
|
|
4578
4035
|
this.initPlugins();
|
|
4036
|
+
this.#initContext();
|
|
4579
4037
|
this.render.init();
|
|
4580
4038
|
}
|
|
4581
4039
|
initBackground() {
|
|
@@ -4585,7 +4043,7 @@
|
|
|
4585
4043
|
}
|
|
4586
4044
|
const elementStyle = element.style, color = rangeColorToRgb(this.#pluginManager, background.color);
|
|
4587
4045
|
if (color) {
|
|
4588
|
-
elementStyle.backgroundColor = getStyleFromRgb(color, container.hdr, background.opacity);
|
|
4046
|
+
elementStyle.backgroundColor = getStyleFromRgb(color, container.actualOptions.hdr, background.opacity);
|
|
4589
4047
|
}
|
|
4590
4048
|
else {
|
|
4591
4049
|
elementStyle.backgroundColor = "";
|
|
@@ -4607,7 +4065,7 @@
|
|
|
4607
4065
|
if (this.#generated && this.domElement) {
|
|
4608
4066
|
this.domElement.remove();
|
|
4609
4067
|
}
|
|
4610
|
-
const
|
|
4068
|
+
const domCanvas = isHtmlCanvasElement(canvas) ? canvas : undefined;
|
|
4611
4069
|
this.domElement = domCanvas;
|
|
4612
4070
|
this.#generated = domCanvas ? domCanvas.dataset[generatedAttribute] === "true" : false;
|
|
4613
4071
|
this.renderCanvas = domCanvas ? getTransferredCanvas(domCanvas) : canvas;
|
|
@@ -4628,26 +4086,6 @@
|
|
|
4628
4086
|
const pxRatio = this.#container.retina.pixelRatio, retinaSize = this.size;
|
|
4629
4087
|
renderCanvas.height = retinaSize.height = standardSize.height * pxRatio;
|
|
4630
4088
|
renderCanvas.width = retinaSize.width = standardSize.width * pxRatio;
|
|
4631
|
-
const canSupportHdrQuery = safeMatchMedia("(color-gamut: p3)");
|
|
4632
|
-
this.render.setContextSettings({
|
|
4633
|
-
alpha: true,
|
|
4634
|
-
colorSpace: canSupportHdrQuery?.matches && container.hdr ? "display-p3" : "srgb",
|
|
4635
|
-
desynchronized: true,
|
|
4636
|
-
willReadFrequently: false,
|
|
4637
|
-
});
|
|
4638
|
-
this.render.setContext(renderCanvas.getContext("2d", this.render.settings));
|
|
4639
|
-
this.#safeMutationObserver(obs => {
|
|
4640
|
-
obs.disconnect();
|
|
4641
|
-
});
|
|
4642
|
-
container.retina.init();
|
|
4643
|
-
this.initBackground();
|
|
4644
|
-
this.#safeMutationObserver(obs => {
|
|
4645
|
-
const element = this.domElement;
|
|
4646
|
-
if (!element || !(element instanceof Node)) {
|
|
4647
|
-
return;
|
|
4648
|
-
}
|
|
4649
|
-
obs.observe(element, { attributes: true });
|
|
4650
|
-
});
|
|
4651
4089
|
}
|
|
4652
4090
|
resize() {
|
|
4653
4091
|
const element = this.domElement;
|
|
@@ -4715,12 +4153,30 @@
|
|
|
4715
4153
|
await container.refresh();
|
|
4716
4154
|
}
|
|
4717
4155
|
}
|
|
4718
|
-
#applyResizePlugins
|
|
4156
|
+
#applyResizePlugins() {
|
|
4719
4157
|
for (const plugin of this.#resizePlugins) {
|
|
4720
4158
|
plugin.resize?.();
|
|
4721
4159
|
}
|
|
4722
|
-
}
|
|
4723
|
-
#
|
|
4160
|
+
}
|
|
4161
|
+
#initContext() {
|
|
4162
|
+
const container = this.#container, canSupportHdr = container.actualOptions.hdr &&
|
|
4163
|
+
safeMatchMedia("(color-gamut: p3)")?.matches &&
|
|
4164
|
+
safeMatchMedia("(dynamic-range: high)")?.matches;
|
|
4165
|
+
this.render.setContextSettings({
|
|
4166
|
+
alpha: true,
|
|
4167
|
+
desynchronized: true,
|
|
4168
|
+
willReadFrequently: false,
|
|
4169
|
+
...(canSupportHdr
|
|
4170
|
+
? { colorSpace: "display-p3", colorType: "float16" }
|
|
4171
|
+
: { colorSpace: "srgb" }),
|
|
4172
|
+
});
|
|
4173
|
+
const renderCanvas = this.renderCanvas;
|
|
4174
|
+
if (!renderCanvas) {
|
|
4175
|
+
return;
|
|
4176
|
+
}
|
|
4177
|
+
this.render.setContext(renderCanvas.getContext("2d", this.render.settings));
|
|
4178
|
+
}
|
|
4179
|
+
#initStyle() {
|
|
4724
4180
|
const element = this.domElement, options = this.#container.actualOptions;
|
|
4725
4181
|
if (!element) {
|
|
4726
4182
|
return;
|
|
@@ -4741,8 +4197,8 @@
|
|
|
4741
4197
|
}
|
|
4742
4198
|
element.style.setProperty(key, value, "important");
|
|
4743
4199
|
}
|
|
4744
|
-
}
|
|
4745
|
-
#repairStyle
|
|
4200
|
+
}
|
|
4201
|
+
#repairStyle() {
|
|
4746
4202
|
const element = this.domElement;
|
|
4747
4203
|
if (!element) {
|
|
4748
4204
|
return;
|
|
@@ -4761,27 +4217,27 @@
|
|
|
4761
4217
|
}
|
|
4762
4218
|
observer.observe(element, { attributes: true });
|
|
4763
4219
|
});
|
|
4764
|
-
}
|
|
4765
|
-
#resetOriginalStyle
|
|
4220
|
+
}
|
|
4221
|
+
#resetOriginalStyle() {
|
|
4766
4222
|
const element = this.domElement, originalStyle = this.#originalStyle;
|
|
4767
4223
|
if (!element || !originalStyle) {
|
|
4768
4224
|
return;
|
|
4769
4225
|
}
|
|
4770
4226
|
setStyle(element, originalStyle, true);
|
|
4771
|
-
}
|
|
4772
|
-
#safeMutationObserver
|
|
4227
|
+
}
|
|
4228
|
+
#safeMutationObserver(callback) {
|
|
4773
4229
|
if (!this.#mutationObserver) {
|
|
4774
4230
|
return;
|
|
4775
4231
|
}
|
|
4776
4232
|
callback(this.#mutationObserver);
|
|
4777
|
-
}
|
|
4778
|
-
#setFullScreenStyle
|
|
4233
|
+
}
|
|
4234
|
+
#setFullScreenStyle() {
|
|
4779
4235
|
const element = this.domElement;
|
|
4780
4236
|
if (!element) {
|
|
4781
4237
|
return;
|
|
4782
4238
|
}
|
|
4783
4239
|
setStyle(element, getFullScreenStyle(this.#container.actualOptions.fullScreen.zIndex), true);
|
|
4784
|
-
}
|
|
4240
|
+
}
|
|
4785
4241
|
}
|
|
4786
4242
|
|
|
4787
4243
|
class EventListeners {
|
|
@@ -4806,7 +4262,7 @@
|
|
|
4806
4262
|
removeListeners() {
|
|
4807
4263
|
this.#manageListeners(false);
|
|
4808
4264
|
}
|
|
4809
|
-
#handleVisibilityChange
|
|
4265
|
+
#handleVisibilityChange() {
|
|
4810
4266
|
const container = this.#container, options = container.actualOptions;
|
|
4811
4267
|
if (!options.pauseOnBlur) {
|
|
4812
4268
|
return;
|
|
@@ -4824,8 +4280,8 @@
|
|
|
4824
4280
|
container.draw(true);
|
|
4825
4281
|
}
|
|
4826
4282
|
}
|
|
4827
|
-
}
|
|
4828
|
-
#handleWindowResize
|
|
4283
|
+
}
|
|
4284
|
+
#handleWindowResize() {
|
|
4829
4285
|
if (this.#resizeTimeout) {
|
|
4830
4286
|
clearTimeout(this.#resizeTimeout);
|
|
4831
4287
|
this.#resizeTimeout = undefined;
|
|
@@ -4835,13 +4291,13 @@
|
|
|
4835
4291
|
await canvas.windowResize();
|
|
4836
4292
|
};
|
|
4837
4293
|
this.#resizeTimeout = setTimeout(() => void handleResize(), this.#container.actualOptions.resize.delay * millisecondsToSeconds);
|
|
4838
|
-
}
|
|
4839
|
-
#manageListeners
|
|
4294
|
+
}
|
|
4295
|
+
#manageListeners(add) {
|
|
4840
4296
|
const handlers = this.#handlers;
|
|
4841
4297
|
this.#manageResize(add);
|
|
4842
4298
|
manageListener(document, visibilityChangeEvent, handlers.visibilityChange, add, false);
|
|
4843
|
-
}
|
|
4844
|
-
#manageResize
|
|
4299
|
+
}
|
|
4300
|
+
#manageResize(add) {
|
|
4845
4301
|
const handlers = this.#handlers, container = this.#container, options = container.actualOptions;
|
|
4846
4302
|
if (!options.resize.enable) {
|
|
4847
4303
|
return;
|
|
@@ -4868,7 +4324,7 @@
|
|
|
4868
4324
|
});
|
|
4869
4325
|
this.#resizeObserver.observe(canvasEl);
|
|
4870
4326
|
}
|
|
4871
|
-
}
|
|
4327
|
+
}
|
|
4872
4328
|
}
|
|
4873
4329
|
|
|
4874
4330
|
function loadEffectData(effect, effectOptions, id, reduceDuplicates) {
|
|
@@ -4895,6 +4351,131 @@
|
|
|
4895
4351
|
data.setCb(data.radius);
|
|
4896
4352
|
}
|
|
4897
4353
|
}
|
|
4354
|
+
function normalizeAngle(angle, modulus) {
|
|
4355
|
+
const normalized = angle % modulus;
|
|
4356
|
+
return normalized < defaultAngle ? normalized + modulus : normalized;
|
|
4357
|
+
}
|
|
4358
|
+
function initParticleState(particle, id, group) {
|
|
4359
|
+
particle.id = id;
|
|
4360
|
+
particle.group = group;
|
|
4361
|
+
particle.justWarped = false;
|
|
4362
|
+
particle.effectClose = true;
|
|
4363
|
+
particle.shapeClose = true;
|
|
4364
|
+
particle.pathRotation = false;
|
|
4365
|
+
particle.lastPathTime = 0;
|
|
4366
|
+
particle.destroyed = false;
|
|
4367
|
+
particle.unbreakable = false;
|
|
4368
|
+
particle.isRotating = false;
|
|
4369
|
+
particle.rotation = 0;
|
|
4370
|
+
particle.misplaced = false;
|
|
4371
|
+
particle.retina = {
|
|
4372
|
+
maxDistance: {},
|
|
4373
|
+
maxSpeed: 0,
|
|
4374
|
+
moveDrift: 0,
|
|
4375
|
+
moveSpeed: 0,
|
|
4376
|
+
sizeAnimationSpeed: 0,
|
|
4377
|
+
};
|
|
4378
|
+
particle.size = {
|
|
4379
|
+
value: 1,
|
|
4380
|
+
max: 1,
|
|
4381
|
+
min: 1,
|
|
4382
|
+
enable: false,
|
|
4383
|
+
};
|
|
4384
|
+
particle.outType = ParticleOutType.normal;
|
|
4385
|
+
particle.ignoresResizeRatio = true;
|
|
4386
|
+
}
|
|
4387
|
+
function resolveParticleOptions(particle, container, pluginManager, overrideOptions) {
|
|
4388
|
+
const mainOptions = container.actualOptions, particlesOptions = loadParticlesOptions(pluginManager, container, mainOptions.particles), reduceDuplicates = particlesOptions.reduceDuplicates;
|
|
4389
|
+
particle.effect = itemFromSingleOrMultiple(particlesOptions.effect.type, particle.id, reduceDuplicates);
|
|
4390
|
+
particle.shape = itemFromSingleOrMultiple(particlesOptions.shape.type, particle.id, reduceDuplicates);
|
|
4391
|
+
const effectOptions = particlesOptions.effect, shapeOptions = particlesOptions.shape;
|
|
4392
|
+
if (overrideOptions) {
|
|
4393
|
+
if (overrideOptions.effect) {
|
|
4394
|
+
const overrideEffectType = overrideOptions.effect.type;
|
|
4395
|
+
if (overrideEffectType && overrideEffectType !== particle.effect) {
|
|
4396
|
+
const effect = itemFromSingleOrMultiple(overrideEffectType, particle.id, reduceDuplicates);
|
|
4397
|
+
if (effect) {
|
|
4398
|
+
particle.effect = effect;
|
|
4399
|
+
}
|
|
4400
|
+
}
|
|
4401
|
+
effectOptions.load(overrideOptions.effect);
|
|
4402
|
+
}
|
|
4403
|
+
if (overrideOptions.shape) {
|
|
4404
|
+
const overrideShapeType = overrideOptions.shape.type;
|
|
4405
|
+
if (overrideShapeType && overrideShapeType !== particle.shape) {
|
|
4406
|
+
const shape = itemFromSingleOrMultiple(overrideShapeType, particle.id, reduceDuplicates);
|
|
4407
|
+
if (shape) {
|
|
4408
|
+
particle.shape = shape;
|
|
4409
|
+
}
|
|
4410
|
+
}
|
|
4411
|
+
shapeOptions.load(overrideOptions.shape);
|
|
4412
|
+
}
|
|
4413
|
+
}
|
|
4414
|
+
if (particle.effect === randomColorValue) {
|
|
4415
|
+
const availableEffects = [...container.effectDrawers.keys()];
|
|
4416
|
+
particle.effect = availableEffects[Math.floor(getRandom() * availableEffects.length)];
|
|
4417
|
+
}
|
|
4418
|
+
if (particle.shape === randomColorValue) {
|
|
4419
|
+
const availableShapes = [...container.shapeDrawers.keys()];
|
|
4420
|
+
particle.shape = availableShapes[Math.floor(getRandom() * availableShapes.length)];
|
|
4421
|
+
}
|
|
4422
|
+
particle.effectData = particle.effect
|
|
4423
|
+
? loadEffectData(particle.effect, effectOptions, particle.id, reduceDuplicates)
|
|
4424
|
+
: undefined;
|
|
4425
|
+
particle.shapeData = particle.shape
|
|
4426
|
+
? loadShapeData(particle.shape, shapeOptions, particle.id, reduceDuplicates)
|
|
4427
|
+
: undefined;
|
|
4428
|
+
particlesOptions.load(overrideOptions);
|
|
4429
|
+
const effectData = particle.effectData, shapeData = particle.shapeData;
|
|
4430
|
+
if (effectData) {
|
|
4431
|
+
particlesOptions.load(effectData.particles);
|
|
4432
|
+
}
|
|
4433
|
+
if (shapeData) {
|
|
4434
|
+
particlesOptions.load(shapeData.particles);
|
|
4435
|
+
}
|
|
4436
|
+
particle.effectClose = effectData?.close ?? particlesOptions.effect.close;
|
|
4437
|
+
particle.shapeClose = shapeData?.close ?? particlesOptions.shape.close;
|
|
4438
|
+
return particlesOptions;
|
|
4439
|
+
}
|
|
4440
|
+
function initParticleDrawers(particle, container) {
|
|
4441
|
+
let effectDrawer, shapeDrawer;
|
|
4442
|
+
if (particle.effect) {
|
|
4443
|
+
effectDrawer = container.effectDrawers.get(particle.effect);
|
|
4444
|
+
}
|
|
4445
|
+
if (effectDrawer?.loadEffect) {
|
|
4446
|
+
effectDrawer.loadEffect(particle);
|
|
4447
|
+
}
|
|
4448
|
+
if (particle.shape) {
|
|
4449
|
+
shapeDrawer = container.shapeDrawers.get(particle.shape);
|
|
4450
|
+
}
|
|
4451
|
+
if (shapeDrawer?.loadShape) {
|
|
4452
|
+
shapeDrawer.loadShape(particle);
|
|
4453
|
+
}
|
|
4454
|
+
const sideCountFunc = shapeDrawer?.getSidesCount;
|
|
4455
|
+
if (sideCountFunc) {
|
|
4456
|
+
particle.sides = sideCountFunc(particle);
|
|
4457
|
+
}
|
|
4458
|
+
}
|
|
4459
|
+
function runUpdaterPreInit(updaters, particle) {
|
|
4460
|
+
for (const updater of updaters) {
|
|
4461
|
+
updater.preInit?.(particle);
|
|
4462
|
+
}
|
|
4463
|
+
}
|
|
4464
|
+
function runUpdaterInit(updaters, particle) {
|
|
4465
|
+
for (const updater of updaters) {
|
|
4466
|
+
updater.init(particle);
|
|
4467
|
+
}
|
|
4468
|
+
}
|
|
4469
|
+
function runDrawerInit(container, particle) {
|
|
4470
|
+
const shapeDrawer = particle.shape ? container.shapeDrawers.get(particle.shape) : undefined, effectDrawer = particle.effect ? container.effectDrawers.get(particle.effect) : undefined;
|
|
4471
|
+
effectDrawer?.particleInit?.(container, particle);
|
|
4472
|
+
shapeDrawer?.particleInit?.(container, particle);
|
|
4473
|
+
}
|
|
4474
|
+
function runParticleCreatedPlugins(container, particle) {
|
|
4475
|
+
for (const plugin of container.particleCreatedPlugins) {
|
|
4476
|
+
plugin.particleCreated?.(particle);
|
|
4477
|
+
}
|
|
4478
|
+
}
|
|
4898
4479
|
class Particle {
|
|
4899
4480
|
backColor;
|
|
4900
4481
|
bubble;
|
|
@@ -5020,94 +4601,20 @@
|
|
|
5020
4601
|
const rotateData = this.getRotateData(), rotating = this.isRotating;
|
|
5021
4602
|
this.#cachedTransform.a = rotateData.cos * (externalTransform.a ?? defaultTransform.a);
|
|
5022
4603
|
this.#cachedTransform.b = rotating
|
|
5023
|
-
? rotateData.sin * (externalTransform.b ?? identity
|
|
4604
|
+
? rotateData.sin * (externalTransform.b ?? identity)
|
|
5024
4605
|
: (externalTransform.b ?? defaultTransform.b);
|
|
5025
4606
|
this.#cachedTransform.c = rotating
|
|
5026
|
-
? -rotateData.sin * (externalTransform.c ?? identity
|
|
4607
|
+
? -rotateData.sin * (externalTransform.c ?? identity)
|
|
5027
4608
|
: (externalTransform.c ?? defaultTransform.c);
|
|
5028
4609
|
this.#cachedTransform.d = rotateData.cos * (externalTransform.d ?? defaultTransform.d);
|
|
5029
4610
|
return this.#cachedTransform;
|
|
5030
4611
|
}
|
|
5031
4612
|
init(id, position, overrideOptions, group) {
|
|
5032
4613
|
const container = this.#container;
|
|
5033
|
-
this
|
|
5034
|
-
this.
|
|
5035
|
-
this.justWarped = false;
|
|
5036
|
-
this.effectClose = true;
|
|
5037
|
-
this.shapeClose = true;
|
|
5038
|
-
this.pathRotation = false;
|
|
5039
|
-
this.lastPathTime = 0;
|
|
5040
|
-
this.destroyed = false;
|
|
5041
|
-
this.unbreakable = false;
|
|
5042
|
-
this.isRotating = false;
|
|
5043
|
-
this.rotation = 0;
|
|
5044
|
-
this.misplaced = false;
|
|
5045
|
-
this.retina = {
|
|
5046
|
-
maxDistance: {},
|
|
5047
|
-
maxSpeed: 0,
|
|
5048
|
-
moveDrift: 0,
|
|
5049
|
-
moveSpeed: 0,
|
|
5050
|
-
sizeAnimationSpeed: 0,
|
|
5051
|
-
};
|
|
5052
|
-
this.size = {
|
|
5053
|
-
value: 1,
|
|
5054
|
-
max: 1,
|
|
5055
|
-
min: 1,
|
|
5056
|
-
enable: false,
|
|
5057
|
-
};
|
|
5058
|
-
this.outType = ParticleOutType.normal;
|
|
5059
|
-
this.ignoresResizeRatio = true;
|
|
5060
|
-
const mainOptions = container.actualOptions, particlesOptions = loadParticlesOptions(this.#pluginManager, container, mainOptions.particles), reduceDuplicates = particlesOptions.reduceDuplicates, effectType = particlesOptions.effect.type, shapeType = particlesOptions.shape.type;
|
|
5061
|
-
this.effect = itemFromSingleOrMultiple(effectType, this.id, reduceDuplicates);
|
|
5062
|
-
this.shape = itemFromSingleOrMultiple(shapeType, this.id, reduceDuplicates);
|
|
5063
|
-
const effectOptions = particlesOptions.effect, shapeOptions = particlesOptions.shape;
|
|
5064
|
-
if (overrideOptions) {
|
|
5065
|
-
if (overrideOptions.effect) {
|
|
5066
|
-
const overrideEffectType = overrideOptions.effect.type;
|
|
5067
|
-
if (overrideEffectType && overrideEffectType !== this.effect) {
|
|
5068
|
-
const effect = itemFromSingleOrMultiple(overrideEffectType, this.id, reduceDuplicates);
|
|
5069
|
-
if (effect) {
|
|
5070
|
-
this.effect = effect;
|
|
5071
|
-
}
|
|
5072
|
-
}
|
|
5073
|
-
effectOptions.load(overrideOptions.effect);
|
|
5074
|
-
}
|
|
5075
|
-
if (overrideOptions.shape) {
|
|
5076
|
-
const overrideShapeType = overrideOptions.shape.type;
|
|
5077
|
-
if (overrideShapeType && overrideShapeType !== this.shape) {
|
|
5078
|
-
const shape = itemFromSingleOrMultiple(overrideShapeType, this.id, reduceDuplicates);
|
|
5079
|
-
if (shape) {
|
|
5080
|
-
this.shape = shape;
|
|
5081
|
-
}
|
|
5082
|
-
}
|
|
5083
|
-
shapeOptions.load(overrideOptions.shape);
|
|
5084
|
-
}
|
|
5085
|
-
}
|
|
5086
|
-
if (this.effect === randomColorValue) {
|
|
5087
|
-
const availableEffects = [...this.#container.effectDrawers.keys()];
|
|
5088
|
-
this.effect = availableEffects[Math.floor(getRandom() * availableEffects.length)];
|
|
5089
|
-
}
|
|
5090
|
-
if (this.shape === randomColorValue) {
|
|
5091
|
-
const availableShapes = [...this.#container.shapeDrawers.keys()];
|
|
5092
|
-
this.shape = availableShapes[Math.floor(getRandom() * availableShapes.length)];
|
|
5093
|
-
}
|
|
5094
|
-
this.effectData = this.effect ? loadEffectData(this.effect, effectOptions, this.id, reduceDuplicates) : undefined;
|
|
5095
|
-
this.shapeData = this.shape ? loadShapeData(this.shape, shapeOptions, this.id, reduceDuplicates) : undefined;
|
|
5096
|
-
particlesOptions.load(overrideOptions);
|
|
5097
|
-
const effectData = this.effectData, shapeData = this.shapeData;
|
|
5098
|
-
if (effectData) {
|
|
5099
|
-
particlesOptions.load(effectData.particles);
|
|
5100
|
-
}
|
|
5101
|
-
if (shapeData) {
|
|
5102
|
-
particlesOptions.load(shapeData.particles);
|
|
5103
|
-
}
|
|
5104
|
-
this.effectClose = effectData?.close ?? particlesOptions.effect.close;
|
|
5105
|
-
this.shapeClose = shapeData?.close ?? particlesOptions.shape.close;
|
|
5106
|
-
this.options = particlesOptions;
|
|
4614
|
+
initParticleState(this, id, group);
|
|
4615
|
+
this.options = resolveParticleOptions(this, container, this.#pluginManager, overrideOptions);
|
|
5107
4616
|
container.retina.initParticle(this);
|
|
5108
|
-
|
|
5109
|
-
updater.preInit?.(this);
|
|
5110
|
-
}
|
|
4617
|
+
runUpdaterPreInit(container.particleUpdaters, this);
|
|
5111
4618
|
this.bubble = {
|
|
5112
4619
|
inRange: false,
|
|
5113
4620
|
};
|
|
@@ -5120,32 +4627,11 @@
|
|
|
5120
4627
|
this.velocity = this.initialVelocity.copy();
|
|
5121
4628
|
this.zIndexFactor = this.position.z / container.zLayers;
|
|
5122
4629
|
this.sides = 24;
|
|
5123
|
-
|
|
5124
|
-
if (this.effect) {
|
|
5125
|
-
effectDrawer = container.effectDrawers.get(this.effect);
|
|
5126
|
-
}
|
|
5127
|
-
if (effectDrawer?.loadEffect) {
|
|
5128
|
-
effectDrawer.loadEffect(this);
|
|
5129
|
-
}
|
|
5130
|
-
if (this.shape) {
|
|
5131
|
-
shapeDrawer = container.shapeDrawers.get(this.shape);
|
|
5132
|
-
}
|
|
5133
|
-
if (shapeDrawer?.loadShape) {
|
|
5134
|
-
shapeDrawer.loadShape(this);
|
|
5135
|
-
}
|
|
5136
|
-
const sideCountFunc = shapeDrawer?.getSidesCount;
|
|
5137
|
-
if (sideCountFunc) {
|
|
5138
|
-
this.sides = sideCountFunc(this);
|
|
5139
|
-
}
|
|
4630
|
+
initParticleDrawers(this, container);
|
|
5140
4631
|
this.spawning = false;
|
|
5141
|
-
|
|
5142
|
-
|
|
5143
|
-
|
|
5144
|
-
effectDrawer?.particleInit?.(container, this);
|
|
5145
|
-
shapeDrawer?.particleInit?.(container, this);
|
|
5146
|
-
for (const plugin of container.particleCreatedPlugins) {
|
|
5147
|
-
plugin.particleCreated?.(this);
|
|
5148
|
-
}
|
|
4632
|
+
runUpdaterInit(container.particleUpdaters, this);
|
|
4633
|
+
runDrawerInit(container, this);
|
|
4634
|
+
runParticleCreatedPlugins(container, this);
|
|
5149
4635
|
}
|
|
5150
4636
|
isInsideCanvas(direction) {
|
|
5151
4637
|
return this.#getInsideCanvasResult({ direction }).inside;
|
|
@@ -5159,15 +4645,15 @@
|
|
|
5159
4645
|
}
|
|
5160
4646
|
const angle = this.roll.angle;
|
|
5161
4647
|
if (this.roll.horizontal && this.roll.vertical) {
|
|
5162
|
-
const
|
|
4648
|
+
const adjustedAngle = normalizeAngle(angle, doublePI);
|
|
5163
4649
|
return adjustedAngle >= Math.PI * half && adjustedAngle < Math.PI * triple * half;
|
|
5164
4650
|
}
|
|
5165
4651
|
if (this.roll.horizontal) {
|
|
5166
|
-
const
|
|
4652
|
+
const adjustedAngle = normalizeAngle(angle + Math.PI * half, doublePI);
|
|
5167
4653
|
return adjustedAngle >= Math.PI && adjustedAngle < Math.PI * double;
|
|
5168
4654
|
}
|
|
5169
4655
|
if (this.roll.vertical) {
|
|
5170
|
-
const
|
|
4656
|
+
const adjustedAngle = normalizeAngle(angle, doublePI);
|
|
5171
4657
|
return adjustedAngle >= Math.PI && adjustedAngle < Math.PI * double;
|
|
5172
4658
|
}
|
|
5173
4659
|
return false;
|
|
@@ -5180,10 +4666,10 @@
|
|
|
5180
4666
|
updater.reset?.(this);
|
|
5181
4667
|
}
|
|
5182
4668
|
}
|
|
5183
|
-
#calcPosition
|
|
4669
|
+
#calcPosition(position, zIndex) {
|
|
5184
4670
|
let tryCount = defaultRetryCount, posVec = position ? Vector3d.create(position.x, position.y, zIndex) : undefined;
|
|
5185
|
-
const container = this.#container, plugins = container.particlePositionPlugins, outModes = this.options.move.outModes, radius = this.getRadius(), canvasSize = container.canvas.size
|
|
5186
|
-
|
|
4671
|
+
const container = this.#container, plugins = container.particlePositionPlugins, outModes = this.options.move.outModes, radius = this.getRadius(), canvasSize = container.canvas.size;
|
|
4672
|
+
for (;;) {
|
|
5187
4673
|
for (const plugin of plugins) {
|
|
5188
4674
|
const pluginPos = plugin.particlePosition?.(posVec, this);
|
|
5189
4675
|
if (pluginPos) {
|
|
@@ -5211,9 +4697,8 @@
|
|
|
5211
4697
|
tryCount += tryCountIncrement;
|
|
5212
4698
|
posVec = undefined;
|
|
5213
4699
|
}
|
|
5214
|
-
|
|
5215
|
-
|
|
5216
|
-
#calculateVelocity = () => {
|
|
4700
|
+
}
|
|
4701
|
+
#calculateVelocity() {
|
|
5217
4702
|
const moveOptions = this.options.move, baseVelocity = getParticleBaseVelocity(this.direction), res = baseVelocity.copy();
|
|
5218
4703
|
if (moveOptions.direction === MoveDirection.inside || moveOptions.direction === MoveDirection.outside) {
|
|
5219
4704
|
return res;
|
|
@@ -5229,8 +4714,8 @@
|
|
|
5229
4714
|
res.length *= getRandom();
|
|
5230
4715
|
}
|
|
5231
4716
|
return res;
|
|
5232
|
-
}
|
|
5233
|
-
#fixHorizontal
|
|
4717
|
+
}
|
|
4718
|
+
#fixHorizontal(pos, radius, outMode) {
|
|
5234
4719
|
fixOutMode({
|
|
5235
4720
|
outMode,
|
|
5236
4721
|
checkModes: [OutMode.bounce],
|
|
@@ -5239,8 +4724,8 @@
|
|
|
5239
4724
|
setCb: (value) => (pos.x += value),
|
|
5240
4725
|
radius,
|
|
5241
4726
|
});
|
|
5242
|
-
}
|
|
5243
|
-
#fixVertical
|
|
4727
|
+
}
|
|
4728
|
+
#fixVertical(pos, radius, outMode) {
|
|
5244
4729
|
fixOutMode({
|
|
5245
4730
|
outMode,
|
|
5246
4731
|
checkModes: [OutMode.bounce],
|
|
@@ -5249,8 +4734,8 @@
|
|
|
5249
4734
|
setCb: (value) => (pos.y += value),
|
|
5250
4735
|
radius,
|
|
5251
4736
|
});
|
|
5252
|
-
}
|
|
5253
|
-
#getDefaultInsideCanvasResult
|
|
4737
|
+
}
|
|
4738
|
+
#getDefaultInsideCanvasResult(direction, outMode) {
|
|
5254
4739
|
const radius = this.getRadius(), canvasSize = this.#container.canvas.size, position = this.position, isBounce = outMode === OutMode.bounce;
|
|
5255
4740
|
if (direction === OutModeDirection.bottom) {
|
|
5256
4741
|
return {
|
|
@@ -5283,8 +4768,8 @@
|
|
|
5283
4768
|
position.x <= canvasSize.width + radius,
|
|
5284
4769
|
reason: "default",
|
|
5285
4770
|
};
|
|
5286
|
-
}
|
|
5287
|
-
#getInsideCanvasCallbackData
|
|
4771
|
+
}
|
|
4772
|
+
#getInsideCanvasCallbackData(direction, outMode) {
|
|
5288
4773
|
return {
|
|
5289
4774
|
canvasSize: this.#container.canvas.size,
|
|
5290
4775
|
direction,
|
|
@@ -5292,8 +4777,8 @@
|
|
|
5292
4777
|
particle: this,
|
|
5293
4778
|
radius: this.getRadius(),
|
|
5294
4779
|
};
|
|
5295
|
-
}
|
|
5296
|
-
#getInsideCanvasResult
|
|
4780
|
+
}
|
|
4781
|
+
#getInsideCanvasResult(data) {
|
|
5297
4782
|
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;
|
|
5298
4783
|
if (!shapeCheck && !effectCheck) {
|
|
5299
4784
|
return defaultResult;
|
|
@@ -5308,8 +4793,8 @@
|
|
|
5308
4793
|
};
|
|
5309
4794
|
}
|
|
5310
4795
|
return shapeResult ?? effectResult ?? defaultResult;
|
|
5311
|
-
}
|
|
5312
|
-
#getRollColor
|
|
4796
|
+
}
|
|
4797
|
+
#getRollColor(color) {
|
|
5313
4798
|
if (!color || !this.roll || (!this.backColor && !this.roll.alter)) {
|
|
5314
4799
|
return color;
|
|
5315
4800
|
}
|
|
@@ -5323,8 +4808,8 @@
|
|
|
5323
4808
|
return alterHsl(color, this.roll.alter.type, this.roll.alter.value);
|
|
5324
4809
|
}
|
|
5325
4810
|
return color;
|
|
5326
|
-
}
|
|
5327
|
-
#initPosition
|
|
4811
|
+
}
|
|
4812
|
+
#initPosition(position) {
|
|
5328
4813
|
const container = this.#container, zIndexValue = Math.floor(getRangeValue(this.options.zIndex.value)), initialPosition = this.#calcPosition(position, clamp(zIndexValue, minZ, container.zLayers));
|
|
5329
4814
|
if (!initialPosition) {
|
|
5330
4815
|
throw new Error("a valid position cannot be found for particle");
|
|
@@ -5347,8 +4832,8 @@
|
|
|
5347
4832
|
break;
|
|
5348
4833
|
}
|
|
5349
4834
|
this.offset = Vector.origin;
|
|
5350
|
-
}
|
|
5351
|
-
#normalizeInsideCanvasResult
|
|
4835
|
+
}
|
|
4836
|
+
#normalizeInsideCanvasResult(result, reason) {
|
|
5352
4837
|
if (typeof result === "boolean") {
|
|
5353
4838
|
return {
|
|
5354
4839
|
inside: result,
|
|
@@ -5360,7 +4845,7 @@
|
|
|
5360
4845
|
margin: result.margin,
|
|
5361
4846
|
reason: result.reason ?? reason,
|
|
5362
4847
|
};
|
|
5363
|
-
}
|
|
4848
|
+
}
|
|
5364
4849
|
}
|
|
5365
4850
|
|
|
5366
4851
|
class SpatialHashGrid {
|
|
@@ -5713,10 +5198,10 @@
|
|
|
5713
5198
|
}
|
|
5714
5199
|
this.#resizeFactor = undefined;
|
|
5715
5200
|
}
|
|
5716
|
-
#addToPool
|
|
5201
|
+
#addToPool(...particles) {
|
|
5717
5202
|
this.#pool.push(...particles);
|
|
5718
|
-
}
|
|
5719
|
-
#applyDensity
|
|
5203
|
+
}
|
|
5204
|
+
#applyDensity(options, pluginsCount, group, groupOptions) {
|
|
5720
5205
|
const numberOptions = options.number;
|
|
5721
5206
|
if (!numberOptions.density.enable) {
|
|
5722
5207
|
if (group === undefined) {
|
|
@@ -5740,36 +5225,19 @@
|
|
|
5740
5225
|
else if (particlesCount > particlesNumber) {
|
|
5741
5226
|
this.removeQuantity(particlesCount - particlesNumber, group);
|
|
5742
5227
|
}
|
|
5743
|
-
}
|
|
5744
|
-
#createBuckets
|
|
5228
|
+
}
|
|
5229
|
+
#createBuckets(zLayers) {
|
|
5745
5230
|
const bucketCount = Math.max(Math.floor(zLayers), one);
|
|
5746
5231
|
return Array.from({ length: bucketCount }, () => []);
|
|
5747
|
-
}
|
|
5748
|
-
#getBucketIndex
|
|
5232
|
+
}
|
|
5233
|
+
#getBucketIndex(zIndex) {
|
|
5749
5234
|
const maxBucketIndex = this.#zBuckets.length - one;
|
|
5750
5235
|
if (maxBucketIndex <= minIndex) {
|
|
5751
5236
|
return minIndex;
|
|
5752
5237
|
}
|
|
5753
5238
|
return Math.min(Math.max(Math.floor(zIndex), minIndex), maxBucketIndex);
|
|
5754
|
-
}
|
|
5755
|
-
#
|
|
5756
|
-
let start = minIndex, end = bucket.length;
|
|
5757
|
-
while (start < end) {
|
|
5758
|
-
const middle = Math.floor((start + end) / double), middleParticle = bucket[middle];
|
|
5759
|
-
if (!middleParticle) {
|
|
5760
|
-
end = middle;
|
|
5761
|
-
continue;
|
|
5762
|
-
}
|
|
5763
|
-
if (middleParticle.id < particleId) {
|
|
5764
|
-
start = middle + one;
|
|
5765
|
-
}
|
|
5766
|
-
else {
|
|
5767
|
-
end = middle;
|
|
5768
|
-
}
|
|
5769
|
-
}
|
|
5770
|
-
return start;
|
|
5771
|
-
};
|
|
5772
|
-
#initDensityFactor = densityOptions => {
|
|
5239
|
+
}
|
|
5240
|
+
#initDensityFactor(densityOptions) {
|
|
5773
5241
|
const container = this.#container;
|
|
5774
5242
|
if (!densityOptions.enable) {
|
|
5775
5243
|
return defaultDensityFactor;
|
|
@@ -5779,16 +5247,16 @@
|
|
|
5779
5247
|
return defaultDensityFactor;
|
|
5780
5248
|
}
|
|
5781
5249
|
return ((canvasSize.width * canvasSize.height) / (densityOptions.height * densityOptions.width * pxRatio ** squareExp));
|
|
5782
|
-
}
|
|
5783
|
-
#insertParticleIntoBucket
|
|
5250
|
+
}
|
|
5251
|
+
#insertParticleIntoBucket(particle) {
|
|
5784
5252
|
const bucketIndex = this.#getBucketIndex(particle.position.z), bucket = this.#zBuckets[bucketIndex];
|
|
5785
5253
|
if (!bucket) {
|
|
5786
5254
|
return;
|
|
5787
5255
|
}
|
|
5788
|
-
bucket.
|
|
5256
|
+
bucket.push(particle);
|
|
5789
5257
|
this.#particleBuckets.set(particle.id, bucketIndex);
|
|
5790
|
-
}
|
|
5791
|
-
#removeParticle
|
|
5258
|
+
}
|
|
5259
|
+
#removeParticle(index, group, override) {
|
|
5792
5260
|
const particle = this.#array[index];
|
|
5793
5261
|
if (!particle) {
|
|
5794
5262
|
return false;
|
|
@@ -5804,22 +5272,20 @@
|
|
|
5804
5272
|
});
|
|
5805
5273
|
this.#addToPool(particle);
|
|
5806
5274
|
return true;
|
|
5807
|
-
}
|
|
5808
|
-
#removeParticleFromBucket
|
|
5275
|
+
}
|
|
5276
|
+
#removeParticleFromBucket(particle) {
|
|
5809
5277
|
const bucketIndex = this.#particleBuckets.get(particle.id) ?? this.#getBucketIndex(particle.position.z), bucket = this.#zBuckets[bucketIndex];
|
|
5810
5278
|
if (!bucket) {
|
|
5811
5279
|
this.#particleBuckets.delete(particle.id);
|
|
5812
5280
|
return;
|
|
5813
5281
|
}
|
|
5814
|
-
const
|
|
5815
|
-
if (
|
|
5816
|
-
|
|
5817
|
-
return;
|
|
5282
|
+
const idx = bucket.findIndex(p => p.id === particle.id);
|
|
5283
|
+
if (idx >= minIndex) {
|
|
5284
|
+
bucket.splice(idx, deleteCount);
|
|
5818
5285
|
}
|
|
5819
|
-
bucket.splice(particleIndex, deleteCount);
|
|
5820
5286
|
this.#particleBuckets.delete(particle.id);
|
|
5821
|
-
}
|
|
5822
|
-
#resetBuckets
|
|
5287
|
+
}
|
|
5288
|
+
#resetBuckets(zLayers) {
|
|
5823
5289
|
const bucketCount = Math.max(Math.floor(zLayers), one);
|
|
5824
5290
|
if (this.#zBuckets.length !== bucketCount) {
|
|
5825
5291
|
this.#zBuckets = this.#createBuckets(bucketCount);
|
|
@@ -5828,8 +5294,8 @@
|
|
|
5828
5294
|
for (const bucket of this.#zBuckets) {
|
|
5829
5295
|
bucket.length = minIndex;
|
|
5830
5296
|
}
|
|
5831
|
-
}
|
|
5832
|
-
#updateParticleBucket
|
|
5297
|
+
}
|
|
5298
|
+
#updateParticleBucket(particle) {
|
|
5833
5299
|
const newBucketIndex = this.#getBucketIndex(particle.position.z), currentBucketIndex = this.#particleBuckets.get(particle.id);
|
|
5834
5300
|
if (currentBucketIndex === undefined) {
|
|
5835
5301
|
this.#insertParticleIntoBucket(particle);
|
|
@@ -5840,9 +5306,9 @@
|
|
|
5840
5306
|
}
|
|
5841
5307
|
const currentBucket = this.#zBuckets[currentBucketIndex];
|
|
5842
5308
|
if (currentBucket) {
|
|
5843
|
-
const
|
|
5844
|
-
if (
|
|
5845
|
-
currentBucket.splice(
|
|
5309
|
+
const idx = currentBucket.findIndex(p => p.id === particle.id);
|
|
5310
|
+
if (idx >= minIndex) {
|
|
5311
|
+
currentBucket.splice(idx, deleteCount);
|
|
5846
5312
|
}
|
|
5847
5313
|
}
|
|
5848
5314
|
const newBucket = this.#zBuckets[newBucketIndex];
|
|
@@ -5850,10 +5316,16 @@
|
|
|
5850
5316
|
this.#particleBuckets.set(particle.id, newBucketIndex);
|
|
5851
5317
|
return;
|
|
5852
5318
|
}
|
|
5853
|
-
newBucket.
|
|
5319
|
+
newBucket.push(particle);
|
|
5320
|
+
if (newBucket.length >= double) {
|
|
5321
|
+
const prev = newBucket[newBucket.length - double];
|
|
5322
|
+
if (prev && particle.id < prev.id) {
|
|
5323
|
+
newBucket.sort((a, b) => a.id - b.id);
|
|
5324
|
+
}
|
|
5325
|
+
}
|
|
5854
5326
|
this.#particleBuckets.set(particle.id, newBucketIndex);
|
|
5855
|
-
}
|
|
5856
|
-
#updateParticlesPhase1
|
|
5327
|
+
}
|
|
5328
|
+
#updateParticlesPhase1(delta) {
|
|
5857
5329
|
const particlesToDelete = new Set(), resizeFactor = this.#resizeFactor;
|
|
5858
5330
|
for (const particle of this.#array) {
|
|
5859
5331
|
if (resizeFactor && !particle.ignoresResizeRatio) {
|
|
@@ -5879,8 +5351,8 @@
|
|
|
5879
5351
|
this.grid.insert(particle);
|
|
5880
5352
|
}
|
|
5881
5353
|
return particlesToDelete;
|
|
5882
|
-
}
|
|
5883
|
-
#updateParticlesPhase2
|
|
5354
|
+
}
|
|
5355
|
+
#updateParticlesPhase2(delta, particlesToDelete) {
|
|
5884
5356
|
for (const particle of this.#array) {
|
|
5885
5357
|
if (particle.destroyed) {
|
|
5886
5358
|
particlesToDelete.add(particle);
|
|
@@ -5896,7 +5368,7 @@
|
|
|
5896
5368
|
}
|
|
5897
5369
|
this.#updateParticleBucket(particle);
|
|
5898
5370
|
}
|
|
5899
|
-
}
|
|
5371
|
+
}
|
|
5900
5372
|
}
|
|
5901
5373
|
|
|
5902
5374
|
class Retina {
|
|
@@ -6258,7 +5730,7 @@
|
|
|
6258
5730
|
}
|
|
6259
5731
|
return refresh;
|
|
6260
5732
|
}
|
|
6261
|
-
#nextFrame
|
|
5733
|
+
#nextFrame(timestamp) {
|
|
6262
5734
|
try {
|
|
6263
5735
|
if (!this.#smooth &&
|
|
6264
5736
|
this.#lastFrameTime !== undefined &&
|
|
@@ -6286,7 +5758,7 @@
|
|
|
6286
5758
|
catch (e) {
|
|
6287
5759
|
getLogger().error("error in animation loop", e);
|
|
6288
5760
|
}
|
|
6289
|
-
}
|
|
5761
|
+
}
|
|
6290
5762
|
}
|
|
6291
5763
|
|
|
6292
5764
|
var Container$1 = /*#__PURE__*/Object.freeze({
|
|
@@ -6332,7 +5804,7 @@
|
|
|
6332
5804
|
BlendPluginInstance: BlendPluginInstance
|
|
6333
5805
|
});
|
|
6334
5806
|
|
|
6335
|
-
const
|
|
5807
|
+
const moveSpeedFactor = 60, minSpinRadius = 0, spinFactor = 0.01, defaultPathDelay = 0, noDecay = 1;
|
|
6336
5808
|
function applyDistance(particle) {
|
|
6337
5809
|
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;
|
|
6338
5810
|
if (!hDistance && !vDistance) {
|
|
@@ -6650,7 +6122,7 @@
|
|
|
6650
6122
|
getLogger().error(e);
|
|
6651
6123
|
}
|
|
6652
6124
|
}
|
|
6653
|
-
#initTrail
|
|
6125
|
+
async #initTrail() {
|
|
6654
6126
|
const options = this.#container.actualOptions, trail = options.trail;
|
|
6655
6127
|
if (!trail?.enable) {
|
|
6656
6128
|
return;
|
|
@@ -6688,7 +6160,7 @@
|
|
|
6688
6160
|
img.src = trailFill.image;
|
|
6689
6161
|
});
|
|
6690
6162
|
}
|
|
6691
|
-
}
|
|
6163
|
+
}
|
|
6692
6164
|
}
|
|
6693
6165
|
|
|
6694
6166
|
var TrailPluginInstance$1 = /*#__PURE__*/Object.freeze({
|