@tsparticles/updater-gradient 3.9.0 → 4.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/285.min.js +2 -0
- package/285.min.js.LICENSE.txt +1 -0
- package/browser/GradientUpdater.js +6 -9
- package/browser/index.js +8 -6
- package/cjs/GradientUpdater.js +40 -47
- package/cjs/Options/Classes/AnimatableGradient.js +8 -12
- package/cjs/Options/Classes/AnimatableGradientColor.js +8 -12
- package/cjs/Options/Classes/GradientAngle.js +7 -11
- package/cjs/Options/Classes/GradientAngleAnimation.js +7 -11
- package/cjs/Options/Classes/GradientColorOpacity.js +6 -10
- package/cjs/Options/Classes/GradientColorOpacityAnimation.js +8 -12
- package/cjs/Options/Interfaces/Gradients.js +1 -2
- package/cjs/Options/Interfaces/IAnimatableGradient.js +1 -2
- package/cjs/Options/Interfaces/IOptionsGradient.js +1 -2
- package/cjs/Types.js +1 -2
- package/cjs/Utils.js +5 -8
- package/cjs/index.js +8 -9
- package/dist_browser_GradientUpdater_js.js +100 -0
- package/esm/GradientUpdater.js +6 -9
- package/esm/index.js +8 -6
- package/package.json +4 -3
- package/report.html +5 -4
- package/tsparticles.updater.gradient.js +209 -100
- package/tsparticles.updater.gradient.min.js +1 -1
- package/tsparticles.updater.gradient.min.js.LICENSE.txt +1 -1
- package/types/index.d.ts +1 -1
- package/umd/GradientUpdater.js +6 -9
- package/umd/index.js +43 -7
package/285.min.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! For license information please see 285.min.js.LICENSE.txt */
|
|
2
|
+
(this.webpackChunk_tsparticles_updater_gradient=this.webpackChunk_tsparticles_updater_gradient||[]).push([[285],{285(e,a,t){t.d(a,{GradientUpdater:()=>u});var i=t(303);class n{constructor(){this.count=0,this.enable=!1,this.speed=0,this.decay=0,this.delay=0,this.sync=!1,this.startValue=i.StartValueType.random}load(e){(0,i.isNull)(e)||(void 0!==e.count&&(this.count=(0,i.setRangeValue)(e.count)),void 0!==e.enable&&(this.enable=e.enable),void 0!==e.speed&&(this.speed=(0,i.setRangeValue)(e.speed)),void 0!==e.sync&&(this.sync=e.sync),void 0!==e.startValue&&(this.startValue=e.startValue),void 0!==e.decay&&(this.decay=(0,i.setRangeValue)(e.decay)),void 0!==e.delay&&(this.delay=(0,i.setRangeValue)(e.delay)))}}class o{constructor(){this.value=0,this.animation=new n}load(e){(0,i.isNull)(e)||(this.animation.load(e.animation),void 0!==e.value&&(this.value=(0,i.setRangeValue)(e.value)))}}class s{constructor(){this.stop=0,this.value=new i.AnimatableColor}load(e){(0,i.isNull)(e)||(void 0!==e.stop&&(this.stop=e.stop),this.value=i.AnimatableColor.create(this.value,e.value),void 0!==e.opacity&&(this.opacity=new o,(0,i.isNumber)(e.opacity)?this.opacity.value=e.opacity:this.opacity.load(e.opacity)))}}class l{constructor(){this.count=0,this.enable=!1,this.speed=0,this.decay=0,this.delay=0,this.sync=!1}load(e){(0,i.isNull)(e)||(void 0!==e.count&&(this.count=(0,i.setRangeValue)(e.count)),void 0!==e.enable&&(this.enable=e.enable),void 0!==e.speed&&(this.speed=(0,i.setRangeValue)(e.speed)),void 0!==e.decay&&(this.decay=(0,i.setRangeValue)(e.decay)),void 0!==e.delay&&(this.delay=(0,i.setRangeValue)(e.delay)),void 0!==e.sync&&(this.sync=e.sync))}}class c{constructor(){this.value=0,this.animation=new l,this.direction=i.RotateDirection.clockwise}load(e){(0,i.isNull)(e)||(this.animation.load(e.animation),void 0!==e.value&&(this.value=(0,i.setRangeValue)(e.value)),void 0!==e.direction&&(this.direction=e.direction))}}class r{constructor(){this.angle=new c,this.colors=[],this.type=i.GradientType.random}load(e){(0,i.isNull)(e)||(this.angle.load(e.angle),void 0!==e.colors&&(this.colors=e.colors.map((e=>{const a=new s;return a.load(e),a}))),void 0!==e.type&&(this.type=e.type))}}class u{constructor(e){this._engine=e}getColorStyles(e,a,t,n){const o=e.gradient;if(!o)return{};const{container:s}=e,l=o.angle.value,c=0,r=0,u=o.type===i.GradientType.radial?a.createRadialGradient(c,r,0,c,r,t):a.createLinearGradient(Math.cos(l)*-t,Math.sin(l)*-t,Math.cos(l)*t,Math.sin(l)*t);for(const{stop:e,value:a,opacity:t}of o.colors){const o={h:a.h.value,s:a.s.value,l:a.l.value};u.addColorStop(e,(0,i.getStyleFromHsl)(o,s.hdr,t?.value??n))}return{fill:u}}init(e){const a=(0,i.itemFromSingleOrMultiple)(e.options.gradient);if(!a)return;const{angle:t}=a;e.gradient={angle:{value:(0,i.getRangeValue)(t.value),enable:t.animation.enable,velocity:(0,i.getRangeValue)(t.animation.speed)/360*e.container.retina.reduceFactor,decay:1-(0,i.getRangeValue)(t.animation.decay),delayTime:(0,i.getRangeValue)(t.animation.delay)*i.millisecondsToSeconds,max:i.doublePI,min:0,time:0},type:a.type,colors:[]};let n=a.angle.direction;switch(n===i.RotateDirection.random&&(n=(0,i.getRandom)()>i.half?i.RotateDirection.counterClockwise:i.RotateDirection.clockwise),n){case i.RotateDirection.counterClockwise:case"counterClockwise":e.gradient.angle.status=i.AnimationStatus.decreasing;break;case i.RotateDirection.clockwise:e.gradient.angle.status=i.AnimationStatus.increasing}const o=e.options.reduceDuplicates;for(const t of a.colors){const a=(0,i.rangeColorToHsl)(this._engine,t.value,e.id,o);if(!a)continue;const n=(0,i.getHslAnimationFromHsl)(a,t.value.animation,e.container.retina.reduceFactor),s={stop:t.stop,value:n,opacity:t.opacity?{enable:t.opacity.animation.enable,max:(0,i.getRangeMax)(t.opacity.value),min:(0,i.getRangeMin)(t.opacity.value),status:i.AnimationStatus.increasing,value:(0,i.getRangeValue)(t.opacity.value),velocity:(0,i.getRangeValue)(t.opacity.animation.speed)/i.percentDenominator*e.container.retina.reduceFactor,decay:1-(0,i.getRangeValue)(t.opacity.animation.decay),delayTime:(0,i.getRangeValue)(t.opacity.animation.delay)*i.millisecondsToSeconds,time:0}:void 0},{opacity:l}=s;if(t.opacity&&l){const e=t.opacity.value;l.min=(0,i.getRangeMin)(e),l.max=(0,i.getRangeMax)(e);switch(t.opacity.animation.startValue){case i.StartValueType.min:l.value=l.min,l.status=i.AnimationStatus.increasing;break;case i.StartValueType.max:l.value=l.max,l.status=i.AnimationStatus.decreasing;break;case i.StartValueType.random:default:l.value=(0,i.randomInRangeValue)(l),l.status=(0,i.getRandom)()>=i.half?i.AnimationStatus.increasing:i.AnimationStatus.decreasing}}e.gradient.colors.push(s)}}isEnabled(e){return!e.destroyed&&!e.spawning&&(!!e.gradient?.angle.enable||(e.gradient?.colors.some((e=>e.value.h.enable||e.value.s.enable||e.value.l.enable))??!1))}loadOptions(e,...a){for(const t of a){if(!t?.gradient)continue;const a=t.gradient;e.gradient=(0,i.executeOnSingleOrMultiple)(a,(e=>{const a=new r;return a.load(e),a}))}}update(e,a){!function(e,a){const{gradient:t}=e;if(t){(0,i.updateAnimation)(e,t.angle,!1,i.DestroyType.none,a);for(const n of t.colors)(0,i.updateColor)(n.value,a),n.opacity&&(0,i.updateAnimation)(e,n.opacity,!0,i.DestroyType.none,a)}}(e,a)}}}}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/*! tsParticles Gradient Updater v4.0.0-alpha.0 by Matteo Bruni */
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { AnimationStatus, GradientType, RotateDirection, StartValueType, executeOnSingleOrMultiple, getHslAnimationFromHsl, getRandom, getRangeMax, getRangeMin, getRangeValue, getStyleFromHsl, half, itemFromSingleOrMultiple, millisecondsToSeconds, percentDenominator,
|
|
1
|
+
import { AnimationStatus, GradientType, RotateDirection, StartValueType, doublePI, executeOnSingleOrMultiple, getHslAnimationFromHsl, getRandom, getRangeMax, getRangeMin, getRangeValue, getStyleFromHsl, half, itemFromSingleOrMultiple, millisecondsToSeconds, percentDenominator, randomInRangeValue, rangeColorToHsl, } from "@tsparticles/engine";
|
|
2
2
|
import { AnimatableGradient } from "./Options/Classes/AnimatableGradient.js";
|
|
3
3
|
import { updateGradient } from "./Utils.js";
|
|
4
|
-
const double = 2, doublePI = Math.PI * double;
|
|
5
4
|
export class GradientUpdater {
|
|
6
5
|
constructor(engine) {
|
|
7
6
|
this._engine = engine;
|
|
@@ -11,15 +10,16 @@ export class GradientUpdater {
|
|
|
11
10
|
if (!gradient) {
|
|
12
11
|
return {};
|
|
13
12
|
}
|
|
14
|
-
const gradientAngle = gradient.angle.value, origin = { x: 0, y: 0 }, minRadius = 0, fillGradient = gradient.type === GradientType.radial
|
|
13
|
+
const { container } = particle, gradientAngle = gradient.angle.value, origin = { x: 0, y: 0 }, minRadius = 0, fillGradient = gradient.type === GradientType.radial
|
|
15
14
|
? context.createRadialGradient(origin.x, origin.y, minRadius, origin.x, origin.y, radius)
|
|
16
15
|
: context.createLinearGradient(Math.cos(gradientAngle) * -radius, Math.sin(gradientAngle) * -radius, Math.cos(gradientAngle) * radius, Math.sin(gradientAngle) * radius);
|
|
17
16
|
for (const { stop, value, opacity: cOpacity } of gradient.colors) {
|
|
18
|
-
|
|
17
|
+
const hsl = {
|
|
19
18
|
h: value.h.value,
|
|
20
19
|
s: value.s.value,
|
|
21
20
|
l: value.l.value,
|
|
22
|
-
}
|
|
21
|
+
};
|
|
22
|
+
fillGradient.addColorStop(stop, getStyleFromHsl(hsl, container.hdr, cOpacity?.value ?? opacity));
|
|
23
23
|
}
|
|
24
24
|
return { fill: fillGradient };
|
|
25
25
|
}
|
|
@@ -97,7 +97,7 @@ export class GradientUpdater {
|
|
|
97
97
|
break;
|
|
98
98
|
case StartValueType.random:
|
|
99
99
|
default:
|
|
100
|
-
addOpacity.value =
|
|
100
|
+
addOpacity.value = randomInRangeValue(addOpacity);
|
|
101
101
|
addOpacity.status =
|
|
102
102
|
getRandom() >= half ? AnimationStatus.increasing : AnimationStatus.decreasing;
|
|
103
103
|
break;
|
|
@@ -119,9 +119,6 @@ export class GradientUpdater {
|
|
|
119
119
|
continue;
|
|
120
120
|
}
|
|
121
121
|
const gradientToLoad = source.gradient;
|
|
122
|
-
if (!gradientToLoad) {
|
|
123
|
-
continue;
|
|
124
|
-
}
|
|
125
122
|
options.gradient = executeOnSingleOrMultiple(gradientToLoad, gradient => {
|
|
126
123
|
const tmp = new AnimatableGradient();
|
|
127
124
|
tmp.load(gradient);
|
package/browser/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
engine.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
export function loadGradientUpdater(engine) {
|
|
2
|
+
engine.checkVersion("4.0.0-alpha.0");
|
|
3
|
+
engine.register(e => {
|
|
4
|
+
e.addParticleUpdater("gradient", async () => {
|
|
5
|
+
const { GradientUpdater } = await import("./GradientUpdater.js");
|
|
6
|
+
return new GradientUpdater(e);
|
|
7
|
+
});
|
|
8
|
+
});
|
|
7
9
|
}
|
package/cjs/GradientUpdater.js
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const AnimatableGradient_js_1 = require("./Options/Classes/AnimatableGradient.js");
|
|
6
|
-
const Utils_js_1 = require("./Utils.js");
|
|
7
|
-
const double = 2, doublePI = Math.PI * double;
|
|
8
|
-
class GradientUpdater {
|
|
1
|
+
import { AnimationStatus, GradientType, RotateDirection, StartValueType, doublePI, executeOnSingleOrMultiple, getHslAnimationFromHsl, getRandom, getRangeMax, getRangeMin, getRangeValue, getStyleFromHsl, half, itemFromSingleOrMultiple, millisecondsToSeconds, percentDenominator, randomInRangeValue, rangeColorToHsl, } from "@tsparticles/engine";
|
|
2
|
+
import { AnimatableGradient } from "./Options/Classes/AnimatableGradient.js";
|
|
3
|
+
import { updateGradient } from "./Utils.js";
|
|
4
|
+
export class GradientUpdater {
|
|
9
5
|
constructor(engine) {
|
|
10
6
|
this._engine = engine;
|
|
11
7
|
}
|
|
@@ -14,31 +10,32 @@ class GradientUpdater {
|
|
|
14
10
|
if (!gradient) {
|
|
15
11
|
return {};
|
|
16
12
|
}
|
|
17
|
-
const gradientAngle = gradient.angle.value, origin = { x: 0, y: 0 }, minRadius = 0, fillGradient = gradient.type ===
|
|
13
|
+
const { container } = particle, gradientAngle = gradient.angle.value, origin = { x: 0, y: 0 }, minRadius = 0, fillGradient = gradient.type === GradientType.radial
|
|
18
14
|
? context.createRadialGradient(origin.x, origin.y, minRadius, origin.x, origin.y, radius)
|
|
19
15
|
: context.createLinearGradient(Math.cos(gradientAngle) * -radius, Math.sin(gradientAngle) * -radius, Math.cos(gradientAngle) * radius, Math.sin(gradientAngle) * radius);
|
|
20
16
|
for (const { stop, value, opacity: cOpacity } of gradient.colors) {
|
|
21
|
-
|
|
17
|
+
const hsl = {
|
|
22
18
|
h: value.h.value,
|
|
23
19
|
s: value.s.value,
|
|
24
20
|
l: value.l.value,
|
|
25
|
-
}
|
|
21
|
+
};
|
|
22
|
+
fillGradient.addColorStop(stop, getStyleFromHsl(hsl, container.hdr, cOpacity?.value ?? opacity));
|
|
26
23
|
}
|
|
27
24
|
return { fill: fillGradient };
|
|
28
25
|
}
|
|
29
26
|
init(particle) {
|
|
30
|
-
const gradient =
|
|
27
|
+
const gradient = itemFromSingleOrMultiple(particle.options.gradient);
|
|
31
28
|
if (!gradient) {
|
|
32
29
|
return;
|
|
33
30
|
}
|
|
34
31
|
const { angle } = gradient, speedFactor = 360, delayOffset = 1;
|
|
35
32
|
particle.gradient = {
|
|
36
33
|
angle: {
|
|
37
|
-
value:
|
|
34
|
+
value: getRangeValue(angle.value),
|
|
38
35
|
enable: angle.animation.enable,
|
|
39
|
-
velocity: (
|
|
40
|
-
decay: delayOffset -
|
|
41
|
-
delayTime:
|
|
36
|
+
velocity: (getRangeValue(angle.animation.speed) / speedFactor) * particle.container.retina.reduceFactor,
|
|
37
|
+
decay: delayOffset - getRangeValue(angle.animation.decay),
|
|
38
|
+
delayTime: getRangeValue(angle.animation.delay) * millisecondsToSeconds,
|
|
42
39
|
max: doublePI,
|
|
43
40
|
min: 0,
|
|
44
41
|
time: 0,
|
|
@@ -47,38 +44,38 @@ class GradientUpdater {
|
|
|
47
44
|
colors: [],
|
|
48
45
|
};
|
|
49
46
|
let rotateDirection = gradient.angle.direction;
|
|
50
|
-
if (rotateDirection ===
|
|
51
|
-
rotateDirection =
|
|
47
|
+
if (rotateDirection === RotateDirection.random) {
|
|
48
|
+
rotateDirection = getRandom() > half ? RotateDirection.counterClockwise : RotateDirection.clockwise;
|
|
52
49
|
}
|
|
53
50
|
switch (rotateDirection) {
|
|
54
|
-
case
|
|
51
|
+
case RotateDirection.counterClockwise:
|
|
55
52
|
case "counterClockwise":
|
|
56
|
-
particle.gradient.angle.status =
|
|
53
|
+
particle.gradient.angle.status = AnimationStatus.decreasing;
|
|
57
54
|
break;
|
|
58
|
-
case
|
|
59
|
-
particle.gradient.angle.status =
|
|
55
|
+
case RotateDirection.clockwise:
|
|
56
|
+
particle.gradient.angle.status = AnimationStatus.increasing;
|
|
60
57
|
break;
|
|
61
58
|
}
|
|
62
59
|
const reduceDuplicates = particle.options.reduceDuplicates;
|
|
63
60
|
for (const grColor of gradient.colors) {
|
|
64
|
-
const grHslColor =
|
|
61
|
+
const grHslColor = rangeColorToHsl(this._engine, grColor.value, particle.id, reduceDuplicates);
|
|
65
62
|
if (!grHslColor) {
|
|
66
63
|
continue;
|
|
67
64
|
}
|
|
68
|
-
const grHslAnimation =
|
|
65
|
+
const grHslAnimation = getHslAnimationFromHsl(grHslColor, grColor.value.animation, particle.container.retina.reduceFactor), addColor = {
|
|
69
66
|
stop: grColor.stop,
|
|
70
67
|
value: grHslAnimation,
|
|
71
68
|
opacity: grColor.opacity
|
|
72
69
|
? {
|
|
73
70
|
enable: grColor.opacity.animation.enable,
|
|
74
|
-
max:
|
|
75
|
-
min:
|
|
76
|
-
status:
|
|
77
|
-
value:
|
|
78
|
-
velocity: (
|
|
71
|
+
max: getRangeMax(grColor.opacity.value),
|
|
72
|
+
min: getRangeMin(grColor.opacity.value),
|
|
73
|
+
status: AnimationStatus.increasing,
|
|
74
|
+
value: getRangeValue(grColor.opacity.value),
|
|
75
|
+
velocity: (getRangeValue(grColor.opacity.animation.speed) / percentDenominator) *
|
|
79
76
|
particle.container.retina.reduceFactor,
|
|
80
|
-
decay: delayOffset -
|
|
81
|
-
delayTime:
|
|
77
|
+
decay: delayOffset - getRangeValue(grColor.opacity.animation.decay),
|
|
78
|
+
delayTime: getRangeValue(grColor.opacity.animation.delay) * millisecondsToSeconds,
|
|
82
79
|
time: 0,
|
|
83
80
|
}
|
|
84
81
|
: undefined,
|
|
@@ -86,23 +83,23 @@ class GradientUpdater {
|
|
|
86
83
|
const { opacity: addOpacity } = addColor;
|
|
87
84
|
if (grColor.opacity && addOpacity) {
|
|
88
85
|
const opacityRange = grColor.opacity.value;
|
|
89
|
-
addOpacity.min =
|
|
90
|
-
addOpacity.max =
|
|
86
|
+
addOpacity.min = getRangeMin(opacityRange);
|
|
87
|
+
addOpacity.max = getRangeMax(opacityRange);
|
|
91
88
|
const opacityAnimation = grColor.opacity.animation;
|
|
92
89
|
switch (opacityAnimation.startValue) {
|
|
93
|
-
case
|
|
90
|
+
case StartValueType.min:
|
|
94
91
|
addOpacity.value = addOpacity.min;
|
|
95
|
-
addOpacity.status =
|
|
92
|
+
addOpacity.status = AnimationStatus.increasing;
|
|
96
93
|
break;
|
|
97
|
-
case
|
|
94
|
+
case StartValueType.max:
|
|
98
95
|
addOpacity.value = addOpacity.max;
|
|
99
|
-
addOpacity.status =
|
|
96
|
+
addOpacity.status = AnimationStatus.decreasing;
|
|
100
97
|
break;
|
|
101
|
-
case
|
|
98
|
+
case StartValueType.random:
|
|
102
99
|
default:
|
|
103
|
-
addOpacity.value = (
|
|
100
|
+
addOpacity.value = randomInRangeValue(addOpacity);
|
|
104
101
|
addOpacity.status =
|
|
105
|
-
|
|
102
|
+
getRandom() >= half ? AnimationStatus.increasing : AnimationStatus.decreasing;
|
|
106
103
|
break;
|
|
107
104
|
}
|
|
108
105
|
}
|
|
@@ -122,18 +119,14 @@ class GradientUpdater {
|
|
|
122
119
|
continue;
|
|
123
120
|
}
|
|
124
121
|
const gradientToLoad = source.gradient;
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
options.gradient = (0, engine_1.executeOnSingleOrMultiple)(gradientToLoad, gradient => {
|
|
129
|
-
const tmp = new AnimatableGradient_js_1.AnimatableGradient();
|
|
122
|
+
options.gradient = executeOnSingleOrMultiple(gradientToLoad, gradient => {
|
|
123
|
+
const tmp = new AnimatableGradient();
|
|
130
124
|
tmp.load(gradient);
|
|
131
125
|
return tmp;
|
|
132
126
|
});
|
|
133
127
|
}
|
|
134
128
|
}
|
|
135
129
|
update(particle, delta) {
|
|
136
|
-
|
|
130
|
+
updateGradient(particle, delta);
|
|
137
131
|
}
|
|
138
132
|
}
|
|
139
|
-
exports.GradientUpdater = GradientUpdater;
|
|
@@ -1,23 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const AnimatableGradientColor_js_1 = require("./AnimatableGradientColor.js");
|
|
6
|
-
const GradientAngle_js_1 = require("./GradientAngle.js");
|
|
7
|
-
class AnimatableGradient {
|
|
1
|
+
import { GradientType, isNull } from "@tsparticles/engine";
|
|
2
|
+
import { AnimatableGradientColor } from "./AnimatableGradientColor.js";
|
|
3
|
+
import { GradientAngle } from "./GradientAngle.js";
|
|
4
|
+
export class AnimatableGradient {
|
|
8
5
|
constructor() {
|
|
9
|
-
this.angle = new
|
|
6
|
+
this.angle = new GradientAngle();
|
|
10
7
|
this.colors = [];
|
|
11
|
-
this.type =
|
|
8
|
+
this.type = GradientType.random;
|
|
12
9
|
}
|
|
13
10
|
load(data) {
|
|
14
|
-
if (
|
|
11
|
+
if (isNull(data)) {
|
|
15
12
|
return;
|
|
16
13
|
}
|
|
17
14
|
this.angle.load(data.angle);
|
|
18
15
|
if (data.colors !== undefined) {
|
|
19
16
|
this.colors = data.colors.map(s => {
|
|
20
|
-
const tmp = new
|
|
17
|
+
const tmp = new AnimatableGradientColor();
|
|
21
18
|
tmp.load(s);
|
|
22
19
|
return tmp;
|
|
23
20
|
});
|
|
@@ -27,4 +24,3 @@ class AnimatableGradient {
|
|
|
27
24
|
}
|
|
28
25
|
}
|
|
29
26
|
}
|
|
30
|
-
exports.AnimatableGradient = AnimatableGradient;
|
|
@@ -1,24 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const engine_1 = require("@tsparticles/engine");
|
|
5
|
-
const GradientColorOpacity_js_1 = require("./GradientColorOpacity.js");
|
|
6
|
-
class AnimatableGradientColor {
|
|
1
|
+
import { AnimatableColor, isNull, isNumber } from "@tsparticles/engine";
|
|
2
|
+
import { GradientColorOpacity } from "./GradientColorOpacity.js";
|
|
3
|
+
export class AnimatableGradientColor {
|
|
7
4
|
constructor() {
|
|
8
5
|
this.stop = 0;
|
|
9
|
-
this.value = new
|
|
6
|
+
this.value = new AnimatableColor();
|
|
10
7
|
}
|
|
11
8
|
load(data) {
|
|
12
|
-
if (
|
|
9
|
+
if (isNull(data)) {
|
|
13
10
|
return;
|
|
14
11
|
}
|
|
15
12
|
if (data.stop !== undefined) {
|
|
16
13
|
this.stop = data.stop;
|
|
17
14
|
}
|
|
18
|
-
this.value =
|
|
15
|
+
this.value = AnimatableColor.create(this.value, data.value);
|
|
19
16
|
if (data.opacity !== undefined) {
|
|
20
|
-
this.opacity = new
|
|
21
|
-
if (
|
|
17
|
+
this.opacity = new GradientColorOpacity();
|
|
18
|
+
if (isNumber(data.opacity)) {
|
|
22
19
|
this.opacity.value = data.opacity;
|
|
23
20
|
}
|
|
24
21
|
else {
|
|
@@ -27,4 +24,3 @@ class AnimatableGradientColor {
|
|
|
27
24
|
}
|
|
28
25
|
}
|
|
29
26
|
}
|
|
30
|
-
exports.AnimatableGradientColor = AnimatableGradientColor;
|
|
@@ -1,25 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const engine_1 = require("@tsparticles/engine");
|
|
5
|
-
const GradientAngleAnimation_js_1 = require("./GradientAngleAnimation.js");
|
|
6
|
-
class GradientAngle {
|
|
1
|
+
import { RotateDirection, isNull, setRangeValue, } from "@tsparticles/engine";
|
|
2
|
+
import { GradientAngleAnimation } from "./GradientAngleAnimation.js";
|
|
3
|
+
export class GradientAngle {
|
|
7
4
|
constructor() {
|
|
8
5
|
this.value = 0;
|
|
9
|
-
this.animation = new
|
|
10
|
-
this.direction =
|
|
6
|
+
this.animation = new GradientAngleAnimation();
|
|
7
|
+
this.direction = RotateDirection.clockwise;
|
|
11
8
|
}
|
|
12
9
|
load(data) {
|
|
13
|
-
if (
|
|
10
|
+
if (isNull(data)) {
|
|
14
11
|
return;
|
|
15
12
|
}
|
|
16
13
|
this.animation.load(data.animation);
|
|
17
14
|
if (data.value !== undefined) {
|
|
18
|
-
this.value =
|
|
15
|
+
this.value = setRangeValue(data.value);
|
|
19
16
|
}
|
|
20
17
|
if (data.direction !== undefined) {
|
|
21
18
|
this.direction = data.direction;
|
|
22
19
|
}
|
|
23
20
|
}
|
|
24
21
|
}
|
|
25
|
-
exports.GradientAngle = GradientAngle;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.GradientAngleAnimation = void 0;
|
|
4
|
-
const engine_1 = require("@tsparticles/engine");
|
|
5
|
-
class GradientAngleAnimation {
|
|
1
|
+
import { isNull, setRangeValue, } from "@tsparticles/engine";
|
|
2
|
+
export class GradientAngleAnimation {
|
|
6
3
|
constructor() {
|
|
7
4
|
this.count = 0;
|
|
8
5
|
this.enable = false;
|
|
@@ -12,27 +9,26 @@ class GradientAngleAnimation {
|
|
|
12
9
|
this.sync = false;
|
|
13
10
|
}
|
|
14
11
|
load(data) {
|
|
15
|
-
if (
|
|
12
|
+
if (isNull(data)) {
|
|
16
13
|
return;
|
|
17
14
|
}
|
|
18
15
|
if (data.count !== undefined) {
|
|
19
|
-
this.count =
|
|
16
|
+
this.count = setRangeValue(data.count);
|
|
20
17
|
}
|
|
21
18
|
if (data.enable !== undefined) {
|
|
22
19
|
this.enable = data.enable;
|
|
23
20
|
}
|
|
24
21
|
if (data.speed !== undefined) {
|
|
25
|
-
this.speed =
|
|
22
|
+
this.speed = setRangeValue(data.speed);
|
|
26
23
|
}
|
|
27
24
|
if (data.decay !== undefined) {
|
|
28
|
-
this.decay =
|
|
25
|
+
this.decay = setRangeValue(data.decay);
|
|
29
26
|
}
|
|
30
27
|
if (data.delay !== undefined) {
|
|
31
|
-
this.delay =
|
|
28
|
+
this.delay = setRangeValue(data.delay);
|
|
32
29
|
}
|
|
33
30
|
if (data.sync !== undefined) {
|
|
34
31
|
this.sync = data.sync;
|
|
35
32
|
}
|
|
36
33
|
}
|
|
37
34
|
}
|
|
38
|
-
exports.GradientAngleAnimation = GradientAngleAnimation;
|
|
@@ -1,21 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const engine_1 = require("@tsparticles/engine");
|
|
5
|
-
const GradientColorOpacityAnimation_js_1 = require("./GradientColorOpacityAnimation.js");
|
|
6
|
-
class GradientColorOpacity {
|
|
1
|
+
import { isNull, setRangeValue, } from "@tsparticles/engine";
|
|
2
|
+
import { GradientColorOpacityAnimation } from "./GradientColorOpacityAnimation.js";
|
|
3
|
+
export class GradientColorOpacity {
|
|
7
4
|
constructor() {
|
|
8
5
|
this.value = 0;
|
|
9
|
-
this.animation = new
|
|
6
|
+
this.animation = new GradientColorOpacityAnimation();
|
|
10
7
|
}
|
|
11
8
|
load(data) {
|
|
12
|
-
if (
|
|
9
|
+
if (isNull(data)) {
|
|
13
10
|
return;
|
|
14
11
|
}
|
|
15
12
|
this.animation.load(data.animation);
|
|
16
13
|
if (data.value !== undefined) {
|
|
17
|
-
this.value =
|
|
14
|
+
this.value = setRangeValue(data.value);
|
|
18
15
|
}
|
|
19
16
|
}
|
|
20
17
|
}
|
|
21
|
-
exports.GradientColorOpacity = GradientColorOpacity;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.GradientColorOpacityAnimation = void 0;
|
|
4
|
-
const engine_1 = require("@tsparticles/engine");
|
|
5
|
-
class GradientColorOpacityAnimation {
|
|
1
|
+
import { StartValueType, isNull, setRangeValue, } from "@tsparticles/engine";
|
|
2
|
+
export class GradientColorOpacityAnimation {
|
|
6
3
|
constructor() {
|
|
7
4
|
this.count = 0;
|
|
8
5
|
this.enable = false;
|
|
@@ -10,20 +7,20 @@ class GradientColorOpacityAnimation {
|
|
|
10
7
|
this.decay = 0;
|
|
11
8
|
this.delay = 0;
|
|
12
9
|
this.sync = false;
|
|
13
|
-
this.startValue =
|
|
10
|
+
this.startValue = StartValueType.random;
|
|
14
11
|
}
|
|
15
12
|
load(data) {
|
|
16
|
-
if (
|
|
13
|
+
if (isNull(data)) {
|
|
17
14
|
return;
|
|
18
15
|
}
|
|
19
16
|
if (data.count !== undefined) {
|
|
20
|
-
this.count =
|
|
17
|
+
this.count = setRangeValue(data.count);
|
|
21
18
|
}
|
|
22
19
|
if (data.enable !== undefined) {
|
|
23
20
|
this.enable = data.enable;
|
|
24
21
|
}
|
|
25
22
|
if (data.speed !== undefined) {
|
|
26
|
-
this.speed =
|
|
23
|
+
this.speed = setRangeValue(data.speed);
|
|
27
24
|
}
|
|
28
25
|
if (data.sync !== undefined) {
|
|
29
26
|
this.sync = data.sync;
|
|
@@ -32,11 +29,10 @@ class GradientColorOpacityAnimation {
|
|
|
32
29
|
this.startValue = data.startValue;
|
|
33
30
|
}
|
|
34
31
|
if (data.decay !== undefined) {
|
|
35
|
-
this.decay =
|
|
32
|
+
this.decay = setRangeValue(data.decay);
|
|
36
33
|
}
|
|
37
34
|
if (data.delay !== undefined) {
|
|
38
|
-
this.delay =
|
|
35
|
+
this.delay = setRangeValue(data.delay);
|
|
39
36
|
}
|
|
40
37
|
}
|
|
41
38
|
}
|
|
42
|
-
exports.GradientColorOpacityAnimation = GradientColorOpacityAnimation;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/cjs/Types.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/cjs/Utils.js
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.updateGradient = updateGradient;
|
|
4
|
-
const engine_1 = require("@tsparticles/engine");
|
|
5
|
-
function updateGradient(particle, delta) {
|
|
1
|
+
import { DestroyType, updateAnimation, updateColor } from "@tsparticles/engine";
|
|
2
|
+
export function updateGradient(particle, delta) {
|
|
6
3
|
const { gradient } = particle;
|
|
7
4
|
if (!gradient) {
|
|
8
5
|
return;
|
|
9
6
|
}
|
|
10
|
-
|
|
7
|
+
updateAnimation(particle, gradient.angle, false, DestroyType.none, delta);
|
|
11
8
|
for (const color of gradient.colors) {
|
|
12
|
-
|
|
9
|
+
updateColor(color.value, delta);
|
|
13
10
|
if (color.opacity) {
|
|
14
|
-
|
|
11
|
+
updateAnimation(particle, color.opacity, true, DestroyType.none, delta);
|
|
15
12
|
}
|
|
16
13
|
}
|
|
17
14
|
}
|
package/cjs/index.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}, refresh);
|
|
1
|
+
export function loadGradientUpdater(engine) {
|
|
2
|
+
engine.checkVersion("4.0.0-alpha.0");
|
|
3
|
+
engine.register(e => {
|
|
4
|
+
e.addParticleUpdater("gradient", async () => {
|
|
5
|
+
const { GradientUpdater } = await import("./GradientUpdater.js");
|
|
6
|
+
return new GradientUpdater(e);
|
|
7
|
+
});
|
|
8
|
+
});
|
|
10
9
|
}
|