@tsparticles/updater-color 3.0.0-alpha.1 → 3.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  # tsParticles Color Updater
4
4
 
5
- [![jsDelivr](https://data.jsdelivr.com/v1/package/npm/tsparticles-updater-color/badge)](https://www.jsdelivr.com/package/npm/tsparticles-updater-color)
6
- [![npmjs](https://badge.fury.io/js/tsparticles-updater-color.svg)](https://www.npmjs.com/package/tsparticles-updater-color)
7
- [![npmjs](https://img.shields.io/npm/dt/tsparticles-updater-color)](https://www.npmjs.com/package/tsparticles-updater-color) [![GitHub Sponsors](https://img.shields.io/github/sponsors/matteobruni)](https://github.com/sponsors/matteobruni)
5
+ [![jsDelivr](https://data.jsdelivr.com/v1/package/npm/@tsparticles/updater-color/badge)](https://www.jsdelivr.com/package/npm/@tsparticles/updater-color)
6
+ [![npmjs](https://badge.fury.io/js/@tsparticles/updater-color.svg)](https://www.npmjs.com/package/@tsparticles/updater-color)
7
+ [![npmjs](https://img.shields.io/npm/dt/@tsparticles/updater-color)](https://www.npmjs.com/package/@tsparticles/updater-color) [![GitHub Sponsors](https://img.shields.io/github/sponsors/matteobruni)](https://github.com/sponsors/matteobruni)
8
8
 
9
9
  [tsParticles](https://github.com/matteobruni/tsparticles) updater plugin for color animations.
10
10
 
@@ -26,7 +26,7 @@ Once the scripts are loaded you can set up `tsParticles` and the updater plugin
26
26
 
27
27
  ```javascript
28
28
  (async () => {
29
- await loadColorUpdater();
29
+ await loadColorUpdater(tsParticles);
30
30
 
31
31
  await tsParticles.load({
32
32
  id: "tsparticles",
@@ -42,29 +42,33 @@ Once the scripts are loaded you can set up `tsParticles` and the updater plugin
42
42
  This package is compatible also with ES or CommonJS modules, firstly this needs to be installed, like this:
43
43
 
44
44
  ```shell
45
- $ npm install tsparticles-updater-color
45
+ $ npm install @tsparticles/updater-color
46
46
  ```
47
47
 
48
48
  or
49
49
 
50
50
  ```shell
51
- $ yarn add tsparticles-updater-color
51
+ $ yarn add @tsparticles/updater-color
52
52
  ```
53
53
 
54
54
  Then you need to import it in the app, like this:
55
55
 
56
56
  ```javascript
57
- const { tsParticles } = require("tsparticles-engine");
58
- const { loadColorUpdater } = require("tsparticles-updater-color");
57
+ const { tsParticles } = require("@tsparticles/engine");
58
+ const { loadColorUpdater } = require("@tsparticles/updater-color");
59
59
 
60
- loadColorUpdater(tsParticles);
60
+ (async () => {
61
+ await loadColorUpdater(tsParticles);
62
+ })();
61
63
  ```
62
64
 
63
65
  or
64
66
 
65
67
  ```javascript
66
- import { tsParticles } from "tsparticles-engine";
67
- import { loadColorUpdater } from "tsparticles-updater-color";
68
+ import { tsParticles } from "@tsparticles/engine";
69
+ import { loadColorUpdater } from "@tsparticles/updater-color";
68
70
 
69
- loadColorUpdater(tsParticles);
71
+ (async () => {
72
+ await loadColorUpdater(tsParticles);
73
+ })();
70
74
  ```
@@ -1,61 +1,5 @@
1
- import { getHslAnimationFromHsl, randomInRange, rangeColorToHsl } from "@tsparticles/engine";
2
- function updateColorValue(delta, value, valueAnimation, max, decrease) {
3
- var _a, _b;
4
- const colorValue = value;
5
- if (!colorValue ||
6
- !valueAnimation.enable ||
7
- (colorValue.loops !== undefined &&
8
- colorValue.maxLoops !== undefined &&
9
- colorValue.maxLoops > 0 &&
10
- colorValue.loops >= colorValue.maxLoops)) {
11
- return;
12
- }
13
- const offset = randomInRange(valueAnimation.offset), velocity = ((_a = value.velocity) !== null && _a !== void 0 ? _a : 0) * delta.factor + offset * 3.6, decay = (_b = value.decay) !== null && _b !== void 0 ? _b : 1;
14
- if (!decrease || colorValue.status === "increasing") {
15
- colorValue.value += velocity;
16
- if (colorValue.value > max) {
17
- if (!colorValue.loops) {
18
- colorValue.loops = 0;
19
- }
20
- colorValue.loops++;
21
- if (decrease) {
22
- colorValue.status = "decreasing";
23
- colorValue.value -= colorValue.value % max;
24
- }
25
- }
26
- }
27
- else {
28
- colorValue.value -= velocity;
29
- if (colorValue.value < 0) {
30
- if (!colorValue.loops) {
31
- colorValue.loops = 0;
32
- }
33
- colorValue.loops++;
34
- colorValue.status = "increasing";
35
- colorValue.value += colorValue.value;
36
- }
37
- }
38
- if (colorValue.velocity && decay !== 1) {
39
- colorValue.velocity *= decay;
40
- }
41
- if (colorValue.value > max) {
42
- colorValue.value %= max;
43
- }
44
- }
45
- function updateColor(particle, delta) {
46
- var _a, _b, _c;
47
- const animationOptions = particle.options.color.animation;
48
- const h = (_a = particle.color) === null || _a === void 0 ? void 0 : _a.h, s = (_b = particle.color) === null || _b === void 0 ? void 0 : _b.s, l = (_c = particle.color) === null || _c === void 0 ? void 0 : _c.l;
49
- if (h) {
50
- updateColorValue(delta, h, animationOptions.h, 360, false);
51
- }
52
- if (s) {
53
- updateColorValue(delta, s, animationOptions.s, 100, true);
54
- }
55
- if (l) {
56
- updateColorValue(delta, l, animationOptions.l, 100, true);
57
- }
58
- }
1
+ import { getHslAnimationFromHsl, rangeColorToHsl, } from "@tsparticles/engine";
2
+ import { updateColor } from "./Utils";
59
3
  export class ColorUpdater {
60
4
  constructor(container) {
61
5
  this.container = container;
@@ -67,13 +11,12 @@ export class ColorUpdater {
67
11
  }
68
12
  }
69
13
  isEnabled(particle) {
70
- var _a, _b, _c;
71
- const animationOptions = particle.options.color.animation;
14
+ const { h: hAnimation, s: sAnimation, l: lAnimation } = particle.options.color.animation, { color } = particle;
72
15
  return (!particle.destroyed &&
73
16
  !particle.spawning &&
74
- ((((_a = particle.color) === null || _a === void 0 ? void 0 : _a.h.value) !== undefined && animationOptions.h.enable) ||
75
- (((_b = particle.color) === null || _b === void 0 ? void 0 : _b.s.value) !== undefined && animationOptions.s.enable) ||
76
- (((_c = particle.color) === null || _c === void 0 ? void 0 : _c.l.value) !== undefined && animationOptions.l.enable)));
17
+ ((color?.h.value !== undefined && hAnimation.enable) ||
18
+ (color?.s.value !== undefined && sAnimation.enable) ||
19
+ (color?.l.value !== undefined && lAnimation.enable)));
77
20
  }
78
21
  update(particle, delta) {
79
22
  updateColor(particle, delta);
@@ -0,0 +1,64 @@
1
+ import { randomInRange, } from "@tsparticles/engine";
2
+ function updateColorValue(delta, colorValue, valueAnimation, max, decrease) {
3
+ if (!colorValue ||
4
+ !valueAnimation.enable ||
5
+ ((colorValue.maxLoops ?? 0) > 0 && (colorValue.loops ?? 0) > (colorValue.maxLoops ?? 0))) {
6
+ return;
7
+ }
8
+ if (!colorValue.time) {
9
+ colorValue.time = 0;
10
+ }
11
+ if ((colorValue.delayTime ?? 0) > 0 && colorValue.time < (colorValue.delayTime ?? 0)) {
12
+ colorValue.time += delta.value;
13
+ }
14
+ if ((colorValue.delayTime ?? 0) > 0 && colorValue.time < (colorValue.delayTime ?? 0)) {
15
+ return;
16
+ }
17
+ const offset = randomInRange(valueAnimation.offset), velocity = (colorValue.velocity ?? 0) * delta.factor + offset * 3.6, decay = colorValue.decay ?? 1;
18
+ if (!decrease || colorValue.status === "increasing") {
19
+ colorValue.value += velocity;
20
+ if (colorValue.value > max) {
21
+ if (!colorValue.loops) {
22
+ colorValue.loops = 0;
23
+ }
24
+ colorValue.loops++;
25
+ if (decrease) {
26
+ colorValue.status = "decreasing";
27
+ colorValue.value -= colorValue.value % max;
28
+ }
29
+ }
30
+ }
31
+ else {
32
+ colorValue.value -= velocity;
33
+ if (colorValue.value < 0) {
34
+ if (!colorValue.loops) {
35
+ colorValue.loops = 0;
36
+ }
37
+ colorValue.loops++;
38
+ colorValue.status = "increasing";
39
+ colorValue.value += colorValue.value;
40
+ }
41
+ }
42
+ if (colorValue.velocity && decay !== 1) {
43
+ colorValue.velocity *= decay;
44
+ }
45
+ if (colorValue.value > max) {
46
+ colorValue.value %= max;
47
+ }
48
+ }
49
+ export function updateColor(particle, delta) {
50
+ const { h: hAnimation, s: sAnimation, l: lAnimation } = particle.options.color.animation, { color } = particle;
51
+ if (!color) {
52
+ return;
53
+ }
54
+ const { h, s, l } = color;
55
+ if (h) {
56
+ updateColorValue(delta, h, hAnimation, 360, false);
57
+ }
58
+ if (s) {
59
+ updateColorValue(delta, s, sAnimation, 100, true);
60
+ }
61
+ if (l) {
62
+ updateColorValue(delta, l, lAnimation, 100, true);
63
+ }
64
+ }
package/browser/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  import { ColorUpdater } from "./ColorUpdater";
2
- export async function loadColorUpdater(engine) {
3
- await engine.addParticleUpdater("color", (container) => new ColorUpdater(container));
2
+ export async function loadColorUpdater(engine, refresh = true) {
3
+ await engine.addParticleUpdater("color", (container) => new ColorUpdater(container), refresh);
4
4
  }
@@ -2,63 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ColorUpdater = void 0;
4
4
  const engine_1 = require("@tsparticles/engine");
5
- function updateColorValue(delta, value, valueAnimation, max, decrease) {
6
- var _a, _b;
7
- const colorValue = value;
8
- if (!colorValue ||
9
- !valueAnimation.enable ||
10
- (colorValue.loops !== undefined &&
11
- colorValue.maxLoops !== undefined &&
12
- colorValue.maxLoops > 0 &&
13
- colorValue.loops >= colorValue.maxLoops)) {
14
- return;
15
- }
16
- const offset = (0, engine_1.randomInRange)(valueAnimation.offset), velocity = ((_a = value.velocity) !== null && _a !== void 0 ? _a : 0) * delta.factor + offset * 3.6, decay = (_b = value.decay) !== null && _b !== void 0 ? _b : 1;
17
- if (!decrease || colorValue.status === "increasing") {
18
- colorValue.value += velocity;
19
- if (colorValue.value > max) {
20
- if (!colorValue.loops) {
21
- colorValue.loops = 0;
22
- }
23
- colorValue.loops++;
24
- if (decrease) {
25
- colorValue.status = "decreasing";
26
- colorValue.value -= colorValue.value % max;
27
- }
28
- }
29
- }
30
- else {
31
- colorValue.value -= velocity;
32
- if (colorValue.value < 0) {
33
- if (!colorValue.loops) {
34
- colorValue.loops = 0;
35
- }
36
- colorValue.loops++;
37
- colorValue.status = "increasing";
38
- colorValue.value += colorValue.value;
39
- }
40
- }
41
- if (colorValue.velocity && decay !== 1) {
42
- colorValue.velocity *= decay;
43
- }
44
- if (colorValue.value > max) {
45
- colorValue.value %= max;
46
- }
47
- }
48
- function updateColor(particle, delta) {
49
- var _a, _b, _c;
50
- const animationOptions = particle.options.color.animation;
51
- const h = (_a = particle.color) === null || _a === void 0 ? void 0 : _a.h, s = (_b = particle.color) === null || _b === void 0 ? void 0 : _b.s, l = (_c = particle.color) === null || _c === void 0 ? void 0 : _c.l;
52
- if (h) {
53
- updateColorValue(delta, h, animationOptions.h, 360, false);
54
- }
55
- if (s) {
56
- updateColorValue(delta, s, animationOptions.s, 100, true);
57
- }
58
- if (l) {
59
- updateColorValue(delta, l, animationOptions.l, 100, true);
60
- }
61
- }
5
+ const Utils_1 = require("./Utils");
62
6
  class ColorUpdater {
63
7
  constructor(container) {
64
8
  this.container = container;
@@ -70,16 +14,15 @@ class ColorUpdater {
70
14
  }
71
15
  }
72
16
  isEnabled(particle) {
73
- var _a, _b, _c;
74
- const animationOptions = particle.options.color.animation;
17
+ const { h: hAnimation, s: sAnimation, l: lAnimation } = particle.options.color.animation, { color } = particle;
75
18
  return (!particle.destroyed &&
76
19
  !particle.spawning &&
77
- ((((_a = particle.color) === null || _a === void 0 ? void 0 : _a.h.value) !== undefined && animationOptions.h.enable) ||
78
- (((_b = particle.color) === null || _b === void 0 ? void 0 : _b.s.value) !== undefined && animationOptions.s.enable) ||
79
- (((_c = particle.color) === null || _c === void 0 ? void 0 : _c.l.value) !== undefined && animationOptions.l.enable)));
20
+ ((color?.h.value !== undefined && hAnimation.enable) ||
21
+ (color?.s.value !== undefined && sAnimation.enable) ||
22
+ (color?.l.value !== undefined && lAnimation.enable)));
80
23
  }
81
24
  update(particle, delta) {
82
- updateColor(particle, delta);
25
+ (0, Utils_1.updateColor)(particle, delta);
83
26
  }
84
27
  }
85
28
  exports.ColorUpdater = ColorUpdater;
package/cjs/Utils.js ADDED
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateColor = void 0;
4
+ const engine_1 = require("@tsparticles/engine");
5
+ function updateColorValue(delta, colorValue, valueAnimation, max, decrease) {
6
+ if (!colorValue ||
7
+ !valueAnimation.enable ||
8
+ ((colorValue.maxLoops ?? 0) > 0 && (colorValue.loops ?? 0) > (colorValue.maxLoops ?? 0))) {
9
+ return;
10
+ }
11
+ if (!colorValue.time) {
12
+ colorValue.time = 0;
13
+ }
14
+ if ((colorValue.delayTime ?? 0) > 0 && colorValue.time < (colorValue.delayTime ?? 0)) {
15
+ colorValue.time += delta.value;
16
+ }
17
+ if ((colorValue.delayTime ?? 0) > 0 && colorValue.time < (colorValue.delayTime ?? 0)) {
18
+ return;
19
+ }
20
+ const offset = (0, engine_1.randomInRange)(valueAnimation.offset), velocity = (colorValue.velocity ?? 0) * delta.factor + offset * 3.6, decay = colorValue.decay ?? 1;
21
+ if (!decrease || colorValue.status === "increasing") {
22
+ colorValue.value += velocity;
23
+ if (colorValue.value > max) {
24
+ if (!colorValue.loops) {
25
+ colorValue.loops = 0;
26
+ }
27
+ colorValue.loops++;
28
+ if (decrease) {
29
+ colorValue.status = "decreasing";
30
+ colorValue.value -= colorValue.value % max;
31
+ }
32
+ }
33
+ }
34
+ else {
35
+ colorValue.value -= velocity;
36
+ if (colorValue.value < 0) {
37
+ if (!colorValue.loops) {
38
+ colorValue.loops = 0;
39
+ }
40
+ colorValue.loops++;
41
+ colorValue.status = "increasing";
42
+ colorValue.value += colorValue.value;
43
+ }
44
+ }
45
+ if (colorValue.velocity && decay !== 1) {
46
+ colorValue.velocity *= decay;
47
+ }
48
+ if (colorValue.value > max) {
49
+ colorValue.value %= max;
50
+ }
51
+ }
52
+ function updateColor(particle, delta) {
53
+ const { h: hAnimation, s: sAnimation, l: lAnimation } = particle.options.color.animation, { color } = particle;
54
+ if (!color) {
55
+ return;
56
+ }
57
+ const { h, s, l } = color;
58
+ if (h) {
59
+ updateColorValue(delta, h, hAnimation, 360, false);
60
+ }
61
+ if (s) {
62
+ updateColorValue(delta, s, sAnimation, 100, true);
63
+ }
64
+ if (l) {
65
+ updateColorValue(delta, l, lAnimation, 100, true);
66
+ }
67
+ }
68
+ exports.updateColor = updateColor;
package/cjs/index.js CHANGED
@@ -1,19 +1,8 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.loadColorUpdater = void 0;
13
4
  const ColorUpdater_1 = require("./ColorUpdater");
14
- function loadColorUpdater(engine) {
15
- return __awaiter(this, void 0, void 0, function* () {
16
- yield engine.addParticleUpdater("color", (container) => new ColorUpdater_1.ColorUpdater(container));
17
- });
5
+ async function loadColorUpdater(engine, refresh = true) {
6
+ await engine.addParticleUpdater("color", (container) => new ColorUpdater_1.ColorUpdater(container), refresh);
18
7
  }
19
8
  exports.loadColorUpdater = loadColorUpdater;
@@ -1,61 +1,5 @@
1
- import { getHslAnimationFromHsl, randomInRange, rangeColorToHsl } from "@tsparticles/engine";
2
- function updateColorValue(delta, value, valueAnimation, max, decrease) {
3
- var _a, _b;
4
- const colorValue = value;
5
- if (!colorValue ||
6
- !valueAnimation.enable ||
7
- (colorValue.loops !== undefined &&
8
- colorValue.maxLoops !== undefined &&
9
- colorValue.maxLoops > 0 &&
10
- colorValue.loops >= colorValue.maxLoops)) {
11
- return;
12
- }
13
- const offset = randomInRange(valueAnimation.offset), velocity = ((_a = value.velocity) !== null && _a !== void 0 ? _a : 0) * delta.factor + offset * 3.6, decay = (_b = value.decay) !== null && _b !== void 0 ? _b : 1;
14
- if (!decrease || colorValue.status === "increasing") {
15
- colorValue.value += velocity;
16
- if (colorValue.value > max) {
17
- if (!colorValue.loops) {
18
- colorValue.loops = 0;
19
- }
20
- colorValue.loops++;
21
- if (decrease) {
22
- colorValue.status = "decreasing";
23
- colorValue.value -= colorValue.value % max;
24
- }
25
- }
26
- }
27
- else {
28
- colorValue.value -= velocity;
29
- if (colorValue.value < 0) {
30
- if (!colorValue.loops) {
31
- colorValue.loops = 0;
32
- }
33
- colorValue.loops++;
34
- colorValue.status = "increasing";
35
- colorValue.value += colorValue.value;
36
- }
37
- }
38
- if (colorValue.velocity && decay !== 1) {
39
- colorValue.velocity *= decay;
40
- }
41
- if (colorValue.value > max) {
42
- colorValue.value %= max;
43
- }
44
- }
45
- function updateColor(particle, delta) {
46
- var _a, _b, _c;
47
- const animationOptions = particle.options.color.animation;
48
- const h = (_a = particle.color) === null || _a === void 0 ? void 0 : _a.h, s = (_b = particle.color) === null || _b === void 0 ? void 0 : _b.s, l = (_c = particle.color) === null || _c === void 0 ? void 0 : _c.l;
49
- if (h) {
50
- updateColorValue(delta, h, animationOptions.h, 360, false);
51
- }
52
- if (s) {
53
- updateColorValue(delta, s, animationOptions.s, 100, true);
54
- }
55
- if (l) {
56
- updateColorValue(delta, l, animationOptions.l, 100, true);
57
- }
58
- }
1
+ import { getHslAnimationFromHsl, rangeColorToHsl, } from "@tsparticles/engine";
2
+ import { updateColor } from "./Utils";
59
3
  export class ColorUpdater {
60
4
  constructor(container) {
61
5
  this.container = container;
@@ -67,13 +11,12 @@ export class ColorUpdater {
67
11
  }
68
12
  }
69
13
  isEnabled(particle) {
70
- var _a, _b, _c;
71
- const animationOptions = particle.options.color.animation;
14
+ const { h: hAnimation, s: sAnimation, l: lAnimation } = particle.options.color.animation, { color } = particle;
72
15
  return (!particle.destroyed &&
73
16
  !particle.spawning &&
74
- ((((_a = particle.color) === null || _a === void 0 ? void 0 : _a.h.value) !== undefined && animationOptions.h.enable) ||
75
- (((_b = particle.color) === null || _b === void 0 ? void 0 : _b.s.value) !== undefined && animationOptions.s.enable) ||
76
- (((_c = particle.color) === null || _c === void 0 ? void 0 : _c.l.value) !== undefined && animationOptions.l.enable)));
17
+ ((color?.h.value !== undefined && hAnimation.enable) ||
18
+ (color?.s.value !== undefined && sAnimation.enable) ||
19
+ (color?.l.value !== undefined && lAnimation.enable)));
77
20
  }
78
21
  update(particle, delta) {
79
22
  updateColor(particle, delta);
package/esm/Utils.js ADDED
@@ -0,0 +1,64 @@
1
+ import { randomInRange, } from "@tsparticles/engine";
2
+ function updateColorValue(delta, colorValue, valueAnimation, max, decrease) {
3
+ if (!colorValue ||
4
+ !valueAnimation.enable ||
5
+ ((colorValue.maxLoops ?? 0) > 0 && (colorValue.loops ?? 0) > (colorValue.maxLoops ?? 0))) {
6
+ return;
7
+ }
8
+ if (!colorValue.time) {
9
+ colorValue.time = 0;
10
+ }
11
+ if ((colorValue.delayTime ?? 0) > 0 && colorValue.time < (colorValue.delayTime ?? 0)) {
12
+ colorValue.time += delta.value;
13
+ }
14
+ if ((colorValue.delayTime ?? 0) > 0 && colorValue.time < (colorValue.delayTime ?? 0)) {
15
+ return;
16
+ }
17
+ const offset = randomInRange(valueAnimation.offset), velocity = (colorValue.velocity ?? 0) * delta.factor + offset * 3.6, decay = colorValue.decay ?? 1;
18
+ if (!decrease || colorValue.status === "increasing") {
19
+ colorValue.value += velocity;
20
+ if (colorValue.value > max) {
21
+ if (!colorValue.loops) {
22
+ colorValue.loops = 0;
23
+ }
24
+ colorValue.loops++;
25
+ if (decrease) {
26
+ colorValue.status = "decreasing";
27
+ colorValue.value -= colorValue.value % max;
28
+ }
29
+ }
30
+ }
31
+ else {
32
+ colorValue.value -= velocity;
33
+ if (colorValue.value < 0) {
34
+ if (!colorValue.loops) {
35
+ colorValue.loops = 0;
36
+ }
37
+ colorValue.loops++;
38
+ colorValue.status = "increasing";
39
+ colorValue.value += colorValue.value;
40
+ }
41
+ }
42
+ if (colorValue.velocity && decay !== 1) {
43
+ colorValue.velocity *= decay;
44
+ }
45
+ if (colorValue.value > max) {
46
+ colorValue.value %= max;
47
+ }
48
+ }
49
+ export function updateColor(particle, delta) {
50
+ const { h: hAnimation, s: sAnimation, l: lAnimation } = particle.options.color.animation, { color } = particle;
51
+ if (!color) {
52
+ return;
53
+ }
54
+ const { h, s, l } = color;
55
+ if (h) {
56
+ updateColorValue(delta, h, hAnimation, 360, false);
57
+ }
58
+ if (s) {
59
+ updateColorValue(delta, s, sAnimation, 100, true);
60
+ }
61
+ if (l) {
62
+ updateColorValue(delta, l, lAnimation, 100, true);
63
+ }
64
+ }
package/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  import { ColorUpdater } from "./ColorUpdater";
2
- export async function loadColorUpdater(engine) {
3
- await engine.addParticleUpdater("color", (container) => new ColorUpdater(container));
2
+ export async function loadColorUpdater(engine, refresh = true) {
3
+ await engine.addParticleUpdater("color", (container) => new ColorUpdater(container), refresh);
4
4
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsparticles/updater-color",
3
- "version": "3.0.0-alpha.1",
3
+ "version": "3.0.0-beta.0",
4
4
  "description": "tsParticles particles color updater",
5
5
  "homepage": "https://particles.js.org",
6
6
  "repository": {
@@ -73,10 +73,11 @@
73
73
  "unpkg": "tsparticles.updater.color.min.js",
74
74
  "module": "esm/index.js",
75
75
  "types": "types/index.d.ts",
76
+ "sideEffects": false,
77
+ "dependencies": {
78
+ "@tsparticles/engine": "^3.0.0-beta.0"
79
+ },
76
80
  "publishConfig": {
77
81
  "access": "public"
78
- },
79
- "dependencies": {
80
- "@tsparticles/engine": "^3.0.0-alpha.1"
81
82
  }
82
- }
83
+ }