@tsparticles/updater-gradient 3.9.1 → 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 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, randomInRange, rangeColorToHsl, } from "@tsparticles/engine";
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
- fillGradient.addColorStop(stop, getStyleFromHsl({
17
+ const hsl = {
19
18
  h: value.h.value,
20
19
  s: value.s.value,
21
20
  l: value.l.value,
22
- }, cOpacity?.value ?? opacity));
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 = randomInRange(addOpacity);
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
- import { GradientUpdater } from "./GradientUpdater.js";
2
- export async function loadGradientUpdater(engine, refresh = true) {
3
- engine.checkVersion("3.9.1");
4
- await engine.addParticleUpdater("gradient", () => {
5
- return Promise.resolve(new GradientUpdater(engine));
6
- }, 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
+ });
7
9
  }
@@ -1,11 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GradientUpdater = void 0;
4
- const engine_1 = require("@tsparticles/engine");
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 === engine_1.GradientType.radial
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
- fillGradient.addColorStop(stop, (0, engine_1.getStyleFromHsl)({
17
+ const hsl = {
22
18
  h: value.h.value,
23
19
  s: value.s.value,
24
20
  l: value.l.value,
25
- }, cOpacity?.value ?? opacity));
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 = (0, engine_1.itemFromSingleOrMultiple)(particle.options.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: (0, engine_1.getRangeValue)(angle.value),
34
+ value: getRangeValue(angle.value),
38
35
  enable: angle.animation.enable,
39
- velocity: ((0, engine_1.getRangeValue)(angle.animation.speed) / speedFactor) * particle.container.retina.reduceFactor,
40
- decay: delayOffset - (0, engine_1.getRangeValue)(angle.animation.decay),
41
- delayTime: (0, engine_1.getRangeValue)(angle.animation.delay) * engine_1.millisecondsToSeconds,
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 === engine_1.RotateDirection.random) {
51
- rotateDirection = (0, engine_1.getRandom)() > engine_1.half ? engine_1.RotateDirection.counterClockwise : engine_1.RotateDirection.clockwise;
47
+ if (rotateDirection === RotateDirection.random) {
48
+ rotateDirection = getRandom() > half ? RotateDirection.counterClockwise : RotateDirection.clockwise;
52
49
  }
53
50
  switch (rotateDirection) {
54
- case engine_1.RotateDirection.counterClockwise:
51
+ case RotateDirection.counterClockwise:
55
52
  case "counterClockwise":
56
- particle.gradient.angle.status = engine_1.AnimationStatus.decreasing;
53
+ particle.gradient.angle.status = AnimationStatus.decreasing;
57
54
  break;
58
- case engine_1.RotateDirection.clockwise:
59
- particle.gradient.angle.status = engine_1.AnimationStatus.increasing;
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 = (0, engine_1.rangeColorToHsl)(this._engine, grColor.value, particle.id, reduceDuplicates);
61
+ const grHslColor = rangeColorToHsl(this._engine, grColor.value, particle.id, reduceDuplicates);
65
62
  if (!grHslColor) {
66
63
  continue;
67
64
  }
68
- const grHslAnimation = (0, engine_1.getHslAnimationFromHsl)(grHslColor, grColor.value.animation, particle.container.retina.reduceFactor), addColor = {
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: (0, engine_1.getRangeMax)(grColor.opacity.value),
75
- min: (0, engine_1.getRangeMin)(grColor.opacity.value),
76
- status: engine_1.AnimationStatus.increasing,
77
- value: (0, engine_1.getRangeValue)(grColor.opacity.value),
78
- velocity: ((0, engine_1.getRangeValue)(grColor.opacity.animation.speed) / engine_1.percentDenominator) *
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 - (0, engine_1.getRangeValue)(grColor.opacity.animation.decay),
81
- delayTime: (0, engine_1.getRangeValue)(grColor.opacity.animation.delay) * engine_1.millisecondsToSeconds,
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 = (0, engine_1.getRangeMin)(opacityRange);
90
- addOpacity.max = (0, engine_1.getRangeMax)(opacityRange);
86
+ addOpacity.min = getRangeMin(opacityRange);
87
+ addOpacity.max = getRangeMax(opacityRange);
91
88
  const opacityAnimation = grColor.opacity.animation;
92
89
  switch (opacityAnimation.startValue) {
93
- case engine_1.StartValueType.min:
90
+ case StartValueType.min:
94
91
  addOpacity.value = addOpacity.min;
95
- addOpacity.status = engine_1.AnimationStatus.increasing;
92
+ addOpacity.status = AnimationStatus.increasing;
96
93
  break;
97
- case engine_1.StartValueType.max:
94
+ case StartValueType.max:
98
95
  addOpacity.value = addOpacity.max;
99
- addOpacity.status = engine_1.AnimationStatus.decreasing;
96
+ addOpacity.status = AnimationStatus.decreasing;
100
97
  break;
101
- case engine_1.StartValueType.random:
98
+ case StartValueType.random:
102
99
  default:
103
- addOpacity.value = (0, engine_1.randomInRange)(addOpacity);
100
+ addOpacity.value = randomInRangeValue(addOpacity);
104
101
  addOpacity.status =
105
- (0, engine_1.getRandom)() >= engine_1.half ? engine_1.AnimationStatus.increasing : engine_1.AnimationStatus.decreasing;
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
- if (!gradientToLoad) {
126
- continue;
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
- (0, Utils_js_1.updateGradient)(particle, delta);
130
+ updateGradient(particle, delta);
137
131
  }
138
132
  }
139
- exports.GradientUpdater = GradientUpdater;
@@ -1,23 +1,20 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AnimatableGradient = void 0;
4
- const engine_1 = require("@tsparticles/engine");
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 GradientAngle_js_1.GradientAngle();
6
+ this.angle = new GradientAngle();
10
7
  this.colors = [];
11
- this.type = engine_1.GradientType.random;
8
+ this.type = GradientType.random;
12
9
  }
13
10
  load(data) {
14
- if ((0, engine_1.isNull)(data)) {
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 AnimatableGradientColor_js_1.AnimatableGradientColor();
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
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AnimatableGradientColor = void 0;
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 engine_1.AnimatableColor();
6
+ this.value = new AnimatableColor();
10
7
  }
11
8
  load(data) {
12
- if ((0, engine_1.isNull)(data)) {
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 = engine_1.AnimatableColor.create(this.value, data.value);
15
+ this.value = AnimatableColor.create(this.value, data.value);
19
16
  if (data.opacity !== undefined) {
20
- this.opacity = new GradientColorOpacity_js_1.GradientColorOpacity();
21
- if ((0, engine_1.isNumber)(data.opacity)) {
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
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GradientAngle = void 0;
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 GradientAngleAnimation_js_1.GradientAngleAnimation();
10
- this.direction = engine_1.RotateDirection.clockwise;
6
+ this.animation = new GradientAngleAnimation();
7
+ this.direction = RotateDirection.clockwise;
11
8
  }
12
9
  load(data) {
13
- if ((0, engine_1.isNull)(data)) {
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 = (0, engine_1.setRangeValue)(data.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
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
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 ((0, engine_1.isNull)(data)) {
12
+ if (isNull(data)) {
16
13
  return;
17
14
  }
18
15
  if (data.count !== undefined) {
19
- this.count = (0, engine_1.setRangeValue)(data.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 = (0, engine_1.setRangeValue)(data.speed);
22
+ this.speed = setRangeValue(data.speed);
26
23
  }
27
24
  if (data.decay !== undefined) {
28
- this.decay = (0, engine_1.setRangeValue)(data.decay);
25
+ this.decay = setRangeValue(data.decay);
29
26
  }
30
27
  if (data.delay !== undefined) {
31
- this.delay = (0, engine_1.setRangeValue)(data.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
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GradientColorOpacity = void 0;
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 GradientColorOpacityAnimation_js_1.GradientColorOpacityAnimation();
6
+ this.animation = new GradientColorOpacityAnimation();
10
7
  }
11
8
  load(data) {
12
- if ((0, engine_1.isNull)(data)) {
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 = (0, engine_1.setRangeValue)(data.value);
14
+ this.value = setRangeValue(data.value);
18
15
  }
19
16
  }
20
17
  }
21
- exports.GradientColorOpacity = GradientColorOpacity;
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
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 = engine_1.StartValueType.random;
10
+ this.startValue = StartValueType.random;
14
11
  }
15
12
  load(data) {
16
- if ((0, engine_1.isNull)(data)) {
13
+ if (isNull(data)) {
17
14
  return;
18
15
  }
19
16
  if (data.count !== undefined) {
20
- this.count = (0, engine_1.setRangeValue)(data.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 = (0, engine_1.setRangeValue)(data.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 = (0, engine_1.setRangeValue)(data.decay);
32
+ this.decay = setRangeValue(data.decay);
36
33
  }
37
34
  if (data.delay !== undefined) {
38
- this.delay = (0, engine_1.setRangeValue)(data.delay);
35
+ this.delay = setRangeValue(data.delay);
39
36
  }
40
37
  }
41
38
  }
42
- exports.GradientColorOpacityAnimation = GradientColorOpacityAnimation;
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
package/cjs/Types.js CHANGED
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
package/cjs/Utils.js CHANGED
@@ -1,17 +1,14 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
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
- (0, engine_1.updateAnimation)(particle, gradient.angle, false, engine_1.DestroyType.none, delta);
7
+ updateAnimation(particle, gradient.angle, false, DestroyType.none, delta);
11
8
  for (const color of gradient.colors) {
12
- (0, engine_1.updateColor)(color.value, delta);
9
+ updateColor(color.value, delta);
13
10
  if (color.opacity) {
14
- (0, engine_1.updateAnimation)(particle, color.opacity, true, engine_1.DestroyType.none, delta);
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
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.loadGradientUpdater = loadGradientUpdater;
4
- const GradientUpdater_js_1 = require("./GradientUpdater.js");
5
- async function loadGradientUpdater(engine, refresh = true) {
6
- engine.checkVersion("3.9.1");
7
- await engine.addParticleUpdater("gradient", () => {
8
- return Promise.resolve(new GradientUpdater_js_1.GradientUpdater(engine));
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
  }