@tsparticles/updater-stroke-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.
@@ -4,7 +4,7 @@
4
4
  * Demo / Generator : https://particles.js.org/
5
5
  * GitHub : https://www.github.com/matteobruni/tsparticles
6
6
  * How to use? : Check the GitHub README
7
- * v3.0.0-alpha.1
7
+ * v3.0.0-beta.0
8
8
  */
9
9
  (function webpackUniversalModuleDefinition(root, factory) {
10
10
  if(typeof exports === 'object' && typeof module === 'object')
@@ -91,22 +91,29 @@ __webpack_require__.r(__webpack_exports__);
91
91
 
92
92
  // EXPORTS
93
93
  __webpack_require__.d(__webpack_exports__, {
94
- "loadStrokeColorUpdater": () => (/* binding */ loadStrokeColorUpdater)
94
+ loadStrokeColorUpdater: () => (/* binding */ loadStrokeColorUpdater)
95
95
  });
96
96
 
97
97
  // EXTERNAL MODULE: external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"}
98
98
  var engine_root_window_ = __webpack_require__(533);
99
- ;// CONCATENATED MODULE: ./dist/browser/StrokeColorUpdater.js
99
+ ;// CONCATENATED MODULE: ./dist/browser/Utils.js
100
100
 
101
- function updateColorValue(delta, value, valueAnimation, max, decrease) {
102
- var _a, _b;
103
- const colorValue = value;
104
- if (!colorValue || !colorValue.enable || colorValue.loops !== undefined && colorValue.maxLoops !== undefined && colorValue.maxLoops > 0 && colorValue.loops >= colorValue.maxLoops) {
101
+ function updateColorValue(delta, colorValue, valueAnimation, max, decrease) {
102
+ if (!colorValue || !valueAnimation.enable || (colorValue.maxLoops ?? 0) > 0 && (colorValue.loops ?? 0) > (colorValue.maxLoops ?? 0)) {
103
+ return;
104
+ }
105
+ if (!colorValue.time) {
106
+ colorValue.time = 0;
107
+ }
108
+ if ((colorValue.delayTime ?? 0) > 0 && colorValue.time < (colorValue.delayTime ?? 0)) {
109
+ colorValue.time += delta.value;
110
+ }
111
+ if ((colorValue.delayTime ?? 0) > 0 && colorValue.time < (colorValue.delayTime ?? 0)) {
105
112
  return;
106
113
  }
107
114
  const offset = (0,engine_root_window_.randomInRange)(valueAnimation.offset),
108
- velocity = ((_a = value.velocity) !== null && _a !== void 0 ? _a : 0) * delta.factor + offset * 3.6,
109
- decay = (_b = value.decay) !== null && _b !== void 0 ? _b : 1;
115
+ velocity = (colorValue.velocity ?? 0) * delta.factor + offset * 3.6,
116
+ decay = colorValue.decay ?? 1;
110
117
  if (!decrease || colorValue.status === "increasing") {
111
118
  colorValue.value += velocity;
112
119
  if (colorValue.value > max) {
@@ -141,39 +148,51 @@ function updateStrokeColor(particle, delta) {
141
148
  if (!particle.strokeColor || !particle.strokeAnimation) {
142
149
  return;
143
150
  }
144
- const h = particle.strokeColor.h;
151
+ const {
152
+ h,
153
+ s,
154
+ l
155
+ } = particle.strokeColor,
156
+ {
157
+ h: hAnimation,
158
+ s: sAnimation,
159
+ l: lAnimation
160
+ } = particle.strokeAnimation;
145
161
  if (h) {
146
- updateColorValue(delta, h, particle.strokeAnimation.h, 360, false);
162
+ updateColorValue(delta, h, hAnimation, 360, false);
147
163
  }
148
- const s = particle.strokeColor.s;
149
164
  if (s) {
150
- updateColorValue(delta, s, particle.strokeAnimation.s, 100, true);
165
+ updateColorValue(delta, s, sAnimation, 100, true);
151
166
  }
152
- const l = particle.strokeColor.l;
153
167
  if (l) {
154
- updateColorValue(delta, l, particle.strokeAnimation.l, 100, true);
168
+ updateColorValue(delta, l, lAnimation, 100, true);
155
169
  }
156
170
  }
171
+ ;// CONCATENATED MODULE: ./dist/browser/StrokeColorUpdater.js
172
+
173
+
157
174
  class StrokeColorUpdater {
158
175
  constructor(container) {
159
176
  this.container = container;
160
177
  }
161
178
  init(particle) {
162
- var _a, _b, _c;
163
- const container = this.container;
164
- const stroke = (0,engine_root_window_.itemFromSingleOrMultiple)(particle.options.stroke, particle.id, particle.options.reduceDuplicates);
179
+ const container = this.container,
180
+ options = particle.options;
181
+ const stroke = (0,engine_root_window_.itemFromSingleOrMultiple)(options.stroke, particle.id, options.reduceDuplicates);
165
182
  particle.strokeWidth = (0,engine_root_window_.getRangeValue)(stroke.width) * container.retina.pixelRatio;
166
- particle.strokeOpacity = (0,engine_root_window_.getRangeValue)((_a = stroke.opacity) !== null && _a !== void 0 ? _a : 1);
167
- particle.strokeAnimation = (_b = stroke.color) === null || _b === void 0 ? void 0 : _b.animation;
168
- const strokeHslColor = (_c = (0,engine_root_window_.rangeColorToHsl)(stroke.color)) !== null && _c !== void 0 ? _c : particle.getFillColor();
183
+ particle.strokeOpacity = (0,engine_root_window_.getRangeValue)(stroke.opacity ?? 1);
184
+ particle.strokeAnimation = stroke.color?.animation;
185
+ const strokeHslColor = (0,engine_root_window_.rangeColorToHsl)(stroke.color) ?? particle.getFillColor();
169
186
  if (strokeHslColor) {
170
187
  particle.strokeColor = (0,engine_root_window_.getHslAnimationFromHsl)(strokeHslColor, particle.strokeAnimation, container.retina.reduceFactor);
171
188
  }
172
189
  }
173
190
  isEnabled(particle) {
174
- var _a, _b, _c;
175
- const color = particle.strokeAnimation;
176
- return !particle.destroyed && !particle.spawning && !!color && (((_a = particle.strokeColor) === null || _a === void 0 ? void 0 : _a.h.value) !== undefined && particle.strokeColor.h.enable || ((_b = particle.strokeColor) === null || _b === void 0 ? void 0 : _b.s.value) !== undefined && particle.strokeColor.s.enable || ((_c = particle.strokeColor) === null || _c === void 0 ? void 0 : _c.l.value) !== undefined && particle.strokeColor.l.enable);
191
+ const color = particle.strokeAnimation,
192
+ {
193
+ strokeColor
194
+ } = particle;
195
+ return !particle.destroyed && !particle.spawning && !!color && (strokeColor?.h.value !== undefined && strokeColor.h.enable || strokeColor?.s.value !== undefined && strokeColor.s.enable || strokeColor?.l.value !== undefined && strokeColor.l.enable);
177
196
  }
178
197
  update(particle, delta) {
179
198
  if (!this.isEnabled(particle)) {
@@ -184,8 +203,8 @@ class StrokeColorUpdater {
184
203
  }
185
204
  ;// CONCATENATED MODULE: ./dist/browser/index.js
186
205
 
187
- async function loadStrokeColorUpdater(engine) {
188
- await engine.addParticleUpdater("strokeColor", container => new StrokeColorUpdater(container));
206
+ async function loadStrokeColorUpdater(engine, refresh = true) {
207
+ await engine.addParticleUpdater("strokeColor", container => new StrokeColorUpdater(container), refresh);
189
208
  }
190
209
  })();
191
210
 
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see tsparticles.updater.stroke-color.min.js.LICENSE.txt */
2
- !function(o,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],e);else{var t="object"==typeof exports?e(require("@tsparticles/engine")):e(o.window);for(var r in t)("object"==typeof exports?exports:o)[r]=t[r]}}(this,(o=>(()=>{"use strict";var e={533:e=>{e.exports=o}},t={};function r(o){var i=t[o];if(void 0!==i)return i.exports;var n=t[o]={exports:{}};return e[o](n,n.exports,r),n.exports}r.d=(o,e)=>{for(var t in e)r.o(e,t)&&!r.o(o,t)&&Object.defineProperty(o,t,{enumerable:!0,get:e[t]})},r.o=(o,e)=>Object.prototype.hasOwnProperty.call(o,e),r.r=o=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(o,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(o,"__esModule",{value:!0})};var i={};return(()=>{r.r(i),r.d(i,{loadStrokeColorUpdater:()=>n});var o=r(533);function e(e,t,r,i,n){var l,s;const a=t;if(!a||!a.enable||void 0!==a.loops&&void 0!==a.maxLoops&&a.maxLoops>0&&a.loops>=a.maxLoops)return;const u=(0,o.randomInRange)(r.offset),d=(null!==(l=t.velocity)&&void 0!==l?l:0)*e.factor+3.6*u,c=null!==(s=t.decay)&&void 0!==s?s:1;n&&"increasing"!==a.status?(a.value-=d,a.value<0&&(a.loops||(a.loops=0),a.loops++,a.status="increasing",a.value+=a.value)):(a.value+=d,a.value>i&&(a.loops||(a.loops=0),a.loops++,n&&(a.status="decreasing",a.value-=a.value%i))),a.velocity&&1!==c&&(a.velocity*=c),a.value>i&&(a.value%=i)}class t{constructor(o){this.container=o}init(e){var t,r,i;const n=this.container,l=(0,o.itemFromSingleOrMultiple)(e.options.stroke,e.id,e.options.reduceDuplicates);e.strokeWidth=(0,o.getRangeValue)(l.width)*n.retina.pixelRatio,e.strokeOpacity=(0,o.getRangeValue)(null!==(t=l.opacity)&&void 0!==t?t:1),e.strokeAnimation=null===(r=l.color)||void 0===r?void 0:r.animation;const s=null!==(i=(0,o.rangeColorToHsl)(l.color))&&void 0!==i?i:e.getFillColor();s&&(e.strokeColor=(0,o.getHslAnimationFromHsl)(s,e.strokeAnimation,n.retina.reduceFactor))}isEnabled(o){var e,t,r;const i=o.strokeAnimation;return!o.destroyed&&!o.spawning&&!!i&&(void 0!==(null===(e=o.strokeColor)||void 0===e?void 0:e.h.value)&&o.strokeColor.h.enable||void 0!==(null===(t=o.strokeColor)||void 0===t?void 0:t.s.value)&&o.strokeColor.s.enable||void 0!==(null===(r=o.strokeColor)||void 0===r?void 0:r.l.value)&&o.strokeColor.l.enable)}update(o,t){this.isEnabled(o)&&function(o,t){if(!o.strokeColor||!o.strokeAnimation)return;const r=o.strokeColor.h;r&&e(t,r,o.strokeAnimation.h,360,!1);const i=o.strokeColor.s;i&&e(t,i,o.strokeAnimation.s,100,!0);const n=o.strokeColor.l;n&&e(t,n,o.strokeAnimation.l,100,!0)}(o,t)}}async function n(o){await o.addParticleUpdater("strokeColor",(o=>new t(o)))}})(),i})()));
2
+ !function(e,o){if("object"==typeof exports&&"object"==typeof module)module.exports=o(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],o);else{var t="object"==typeof exports?o(require("@tsparticles/engine")):o(e.window);for(var r in t)("object"==typeof exports?exports:e)[r]=t[r]}}(this,(e=>(()=>{"use strict";var o={533:o=>{o.exports=e}},t={};function r(e){var i=t[e];if(void 0!==i)return i.exports;var n=t[e]={exports:{}};return o[e](n,n.exports,r),n.exports}r.d=(e,o)=>{for(var t in o)r.o(o,t)&&!r.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:o[t]})},r.o=(e,o)=>Object.prototype.hasOwnProperty.call(e,o),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};return(()=>{r.r(i),r.d(i,{loadStrokeColorUpdater:()=>n});var e=r(533);function o(o,t,r,i,n){if(!t||!r.enable||(t.maxLoops??0)>0&&(t.loops??0)>(t.maxLoops??0))return;if(t.time||(t.time=0),(t.delayTime??0)>0&&t.time<(t.delayTime??0)&&(t.time+=o.value),(t.delayTime??0)>0&&t.time<(t.delayTime??0))return;const a=(0,e.randomInRange)(r.offset),l=(t.velocity??0)*o.factor+3.6*a,s=t.decay??1;n&&"increasing"!==t.status?(t.value-=l,t.value<0&&(t.loops||(t.loops=0),t.loops++,t.status="increasing",t.value+=t.value)):(t.value+=l,t.value>i&&(t.loops||(t.loops=0),t.loops++,n&&(t.status="decreasing",t.value-=t.value%i))),t.velocity&&1!==s&&(t.velocity*=s),t.value>i&&(t.value%=i)}class t{constructor(e){this.container=e}init(o){const t=this.container,r=o.options,i=(0,e.itemFromSingleOrMultiple)(r.stroke,o.id,r.reduceDuplicates);o.strokeWidth=(0,e.getRangeValue)(i.width)*t.retina.pixelRatio,o.strokeOpacity=(0,e.getRangeValue)(i.opacity??1),o.strokeAnimation=i.color?.animation;const n=(0,e.rangeColorToHsl)(i.color)??o.getFillColor();n&&(o.strokeColor=(0,e.getHslAnimationFromHsl)(n,o.strokeAnimation,t.retina.reduceFactor))}isEnabled(e){const o=e.strokeAnimation,{strokeColor:t}=e;return!e.destroyed&&!e.spawning&&!!o&&(void 0!==t?.h.value&&t.h.enable||void 0!==t?.s.value&&t.s.enable||void 0!==t?.l.value&&t.l.enable)}update(e,t){this.isEnabled(e)&&function(e,t){if(!e.strokeColor||!e.strokeAnimation)return;const{h:r,s:i,l:n}=e.strokeColor,{h:a,s:l,l:s}=e.strokeAnimation;r&&o(t,r,a,360,!1),i&&o(t,i,l,100,!0),n&&o(t,n,s,100,!0)}(e,t)}}async function n(e,o=!0){await e.addParticleUpdater("strokeColor",(e=>new t(e)),o)}})(),i})()));
@@ -1,8 +1 @@
1
- /*!
2
- * Author : Matteo Bruni
3
- * MIT license: https://opensource.org/licenses/MIT
4
- * Demo / Generator : https://particles.js.org/
5
- * GitHub : https://www.github.com/matteobruni/tsparticles
6
- * How to use? : Check the GitHub README
7
- * v3.0.0-alpha.1
8
- */
1
+ /*! tsParticles Stroke Color Updater v3.0.0-beta.0 by Matteo Bruni */
@@ -1,7 +1,5 @@
1
- import type { Container, HslAnimation, IDelta, IParticleUpdater, Particle } from "@tsparticles/engine";
2
- type StrokeParticle = Particle & {
3
- strokeAnimation?: HslAnimation;
4
- };
1
+ import { type Container, type IDelta, type IParticleUpdater, type Particle } from "@tsparticles/engine";
2
+ import type { StrokeParticle } from "./Types";
5
3
  export declare class StrokeColorUpdater implements IParticleUpdater {
6
4
  private readonly container;
7
5
  constructor(container: Container);
@@ -9,4 +7,3 @@ export declare class StrokeColorUpdater implements IParticleUpdater {
9
7
  isEnabled(particle: StrokeParticle): boolean;
10
8
  update(particle: Particle, delta: IDelta): void;
11
9
  }
12
- export {};
@@ -0,0 +1,4 @@
1
+ import { type HslAnimation, type Particle } from "@tsparticles/engine";
2
+ export type StrokeParticle = Particle & {
3
+ strokeAnimation?: HslAnimation;
4
+ };
@@ -0,0 +1,3 @@
1
+ import { type IDelta } from "@tsparticles/engine";
2
+ import type { StrokeParticle } from "./Types";
3
+ export declare function updateStrokeColor(particle: StrokeParticle, delta: IDelta): void;
package/types/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  import type { Engine } from "@tsparticles/engine";
2
- export declare function loadStrokeColorUpdater(engine: Engine): Promise<void>;
2
+ export declare function loadStrokeColorUpdater(engine: Engine, refresh?: boolean): Promise<void>;
@@ -4,104 +4,43 @@
4
4
  if (v !== undefined) module.exports = v;
5
5
  }
6
6
  else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports", "@tsparticles/engine"], factory);
7
+ define(["require", "exports", "@tsparticles/engine", "./Utils"], factory);
8
8
  }
9
9
  })(function (require, exports) {
10
10
  "use strict";
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.StrokeColorUpdater = void 0;
13
13
  const engine_1 = require("@tsparticles/engine");
14
- function updateColorValue(delta, value, valueAnimation, max, decrease) {
15
- var _a, _b;
16
- const colorValue = value;
17
- if (!colorValue ||
18
- !colorValue.enable ||
19
- (colorValue.loops !== undefined &&
20
- colorValue.maxLoops !== undefined &&
21
- colorValue.maxLoops > 0 &&
22
- colorValue.loops >= colorValue.maxLoops)) {
23
- return;
24
- }
25
- 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;
26
- if (!decrease || colorValue.status === "increasing") {
27
- colorValue.value += velocity;
28
- if (colorValue.value > max) {
29
- if (!colorValue.loops) {
30
- colorValue.loops = 0;
31
- }
32
- colorValue.loops++;
33
- if (decrease) {
34
- colorValue.status = "decreasing";
35
- colorValue.value -= colorValue.value % max;
36
- }
37
- }
38
- }
39
- else {
40
- colorValue.value -= velocity;
41
- if (colorValue.value < 0) {
42
- if (!colorValue.loops) {
43
- colorValue.loops = 0;
44
- }
45
- colorValue.loops++;
46
- colorValue.status = "increasing";
47
- colorValue.value += colorValue.value;
48
- }
49
- }
50
- if (colorValue.velocity && decay !== 1) {
51
- colorValue.velocity *= decay;
52
- }
53
- if (colorValue.value > max) {
54
- colorValue.value %= max;
55
- }
56
- }
57
- function updateStrokeColor(particle, delta) {
58
- if (!particle.strokeColor || !particle.strokeAnimation) {
59
- return;
60
- }
61
- const h = particle.strokeColor.h;
62
- if (h) {
63
- updateColorValue(delta, h, particle.strokeAnimation.h, 360, false);
64
- }
65
- const s = particle.strokeColor.s;
66
- if (s) {
67
- updateColorValue(delta, s, particle.strokeAnimation.s, 100, true);
68
- }
69
- const l = particle.strokeColor.l;
70
- if (l) {
71
- updateColorValue(delta, l, particle.strokeAnimation.l, 100, true);
72
- }
73
- }
14
+ const Utils_1 = require("./Utils");
74
15
  class StrokeColorUpdater {
75
16
  constructor(container) {
76
17
  this.container = container;
77
18
  }
78
19
  init(particle) {
79
- var _a, _b, _c;
80
- const container = this.container;
81
- const stroke = (0, engine_1.itemFromSingleOrMultiple)(particle.options.stroke, particle.id, particle.options.reduceDuplicates);
20
+ const container = this.container, options = particle.options;
21
+ const stroke = (0, engine_1.itemFromSingleOrMultiple)(options.stroke, particle.id, options.reduceDuplicates);
82
22
  particle.strokeWidth = (0, engine_1.getRangeValue)(stroke.width) * container.retina.pixelRatio;
83
- particle.strokeOpacity = (0, engine_1.getRangeValue)((_a = stroke.opacity) !== null && _a !== void 0 ? _a : 1);
84
- particle.strokeAnimation = (_b = stroke.color) === null || _b === void 0 ? void 0 : _b.animation;
85
- const strokeHslColor = (_c = (0, engine_1.rangeColorToHsl)(stroke.color)) !== null && _c !== void 0 ? _c : particle.getFillColor();
23
+ particle.strokeOpacity = (0, engine_1.getRangeValue)(stroke.opacity ?? 1);
24
+ particle.strokeAnimation = stroke.color?.animation;
25
+ const strokeHslColor = (0, engine_1.rangeColorToHsl)(stroke.color) ?? particle.getFillColor();
86
26
  if (strokeHslColor) {
87
27
  particle.strokeColor = (0, engine_1.getHslAnimationFromHsl)(strokeHslColor, particle.strokeAnimation, container.retina.reduceFactor);
88
28
  }
89
29
  }
90
30
  isEnabled(particle) {
91
- var _a, _b, _c;
92
- const color = particle.strokeAnimation;
31
+ const color = particle.strokeAnimation, { strokeColor } = particle;
93
32
  return (!particle.destroyed &&
94
33
  !particle.spawning &&
95
34
  !!color &&
96
- ((((_a = particle.strokeColor) === null || _a === void 0 ? void 0 : _a.h.value) !== undefined && particle.strokeColor.h.enable) ||
97
- (((_b = particle.strokeColor) === null || _b === void 0 ? void 0 : _b.s.value) !== undefined && particle.strokeColor.s.enable) ||
98
- (((_c = particle.strokeColor) === null || _c === void 0 ? void 0 : _c.l.value) !== undefined && particle.strokeColor.l.enable)));
35
+ ((strokeColor?.h.value !== undefined && strokeColor.h.enable) ||
36
+ (strokeColor?.s.value !== undefined && strokeColor.s.enable) ||
37
+ (strokeColor?.l.value !== undefined && strokeColor.l.enable)));
99
38
  }
100
39
  update(particle, delta) {
101
40
  if (!this.isEnabled(particle)) {
102
41
  return;
103
42
  }
104
- updateStrokeColor(particle, delta);
43
+ (0, Utils_1.updateStrokeColor)(particle, delta);
105
44
  }
106
45
  }
107
46
  exports.StrokeColorUpdater = StrokeColorUpdater;
package/umd/Types.js ADDED
@@ -0,0 +1,12 @@
1
+ (function (factory) {
2
+ if (typeof module === "object" && typeof module.exports === "object") {
3
+ var v = factory(require, exports);
4
+ if (v !== undefined) module.exports = v;
5
+ }
6
+ else if (typeof define === "function" && define.amd) {
7
+ define(["require", "exports"], factory);
8
+ }
9
+ })(function (require, exports) {
10
+ "use strict";
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ });
package/umd/Utils.js ADDED
@@ -0,0 +1,77 @@
1
+ (function (factory) {
2
+ if (typeof module === "object" && typeof module.exports === "object") {
3
+ var v = factory(require, exports);
4
+ if (v !== undefined) module.exports = v;
5
+ }
6
+ else if (typeof define === "function" && define.amd) {
7
+ define(["require", "exports", "@tsparticles/engine"], factory);
8
+ }
9
+ })(function (require, exports) {
10
+ "use strict";
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.updateStrokeColor = void 0;
13
+ const engine_1 = require("@tsparticles/engine");
14
+ function updateColorValue(delta, colorValue, valueAnimation, max, decrease) {
15
+ if (!colorValue ||
16
+ !valueAnimation.enable ||
17
+ ((colorValue.maxLoops ?? 0) > 0 && (colorValue.loops ?? 0) > (colorValue.maxLoops ?? 0))) {
18
+ return;
19
+ }
20
+ if (!colorValue.time) {
21
+ colorValue.time = 0;
22
+ }
23
+ if ((colorValue.delayTime ?? 0) > 0 && colorValue.time < (colorValue.delayTime ?? 0)) {
24
+ colorValue.time += delta.value;
25
+ }
26
+ if ((colorValue.delayTime ?? 0) > 0 && colorValue.time < (colorValue.delayTime ?? 0)) {
27
+ return;
28
+ }
29
+ const offset = (0, engine_1.randomInRange)(valueAnimation.offset), velocity = (colorValue.velocity ?? 0) * delta.factor + offset * 3.6, decay = colorValue.decay ?? 1;
30
+ if (!decrease || colorValue.status === "increasing") {
31
+ colorValue.value += velocity;
32
+ if (colorValue.value > max) {
33
+ if (!colorValue.loops) {
34
+ colorValue.loops = 0;
35
+ }
36
+ colorValue.loops++;
37
+ if (decrease) {
38
+ colorValue.status = "decreasing";
39
+ colorValue.value -= colorValue.value % max;
40
+ }
41
+ }
42
+ }
43
+ else {
44
+ colorValue.value -= velocity;
45
+ if (colorValue.value < 0) {
46
+ if (!colorValue.loops) {
47
+ colorValue.loops = 0;
48
+ }
49
+ colorValue.loops++;
50
+ colorValue.status = "increasing";
51
+ colorValue.value += colorValue.value;
52
+ }
53
+ }
54
+ if (colorValue.velocity && decay !== 1) {
55
+ colorValue.velocity *= decay;
56
+ }
57
+ if (colorValue.value > max) {
58
+ colorValue.value %= max;
59
+ }
60
+ }
61
+ function updateStrokeColor(particle, delta) {
62
+ if (!particle.strokeColor || !particle.strokeAnimation) {
63
+ return;
64
+ }
65
+ const { h, s, l } = particle.strokeColor, { h: hAnimation, s: sAnimation, l: lAnimation } = particle.strokeAnimation;
66
+ if (h) {
67
+ updateColorValue(delta, h, hAnimation, 360, false);
68
+ }
69
+ if (s) {
70
+ updateColorValue(delta, s, sAnimation, 100, true);
71
+ }
72
+ if (l) {
73
+ updateColorValue(delta, l, lAnimation, 100, true);
74
+ }
75
+ }
76
+ exports.updateStrokeColor = updateStrokeColor;
77
+ });
package/umd/index.js CHANGED
@@ -11,8 +11,8 @@
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.loadStrokeColorUpdater = void 0;
13
13
  const StrokeColorUpdater_1 = require("./StrokeColorUpdater");
14
- async function loadStrokeColorUpdater(engine) {
15
- await engine.addParticleUpdater("strokeColor", (container) => new StrokeColorUpdater_1.StrokeColorUpdater(container));
14
+ async function loadStrokeColorUpdater(engine, refresh = true) {
15
+ await engine.addParticleUpdater("strokeColor", (container) => new StrokeColorUpdater_1.StrokeColorUpdater(container), refresh);
16
16
  }
17
17
  exports.loadStrokeColorUpdater = loadStrokeColorUpdater;
18
18
  });