@tsparticles/updater-color
Advanced tools
Comparing version 3.0.3 to 3.1.0
@@ -1,3 +0,2 @@ | ||
import { getHslAnimationFromHsl, rangeColorToHsl, } from "@tsparticles/engine"; | ||
import { updateColor } from "./Utils.js"; | ||
import { getHslAnimationFromHsl, rangeColorToHsl, updateColor, } from "@tsparticles/engine"; | ||
export class ColorUpdater { | ||
@@ -22,4 +21,4 @@ constructor(container) { | ||
update(particle, delta) { | ||
updateColor(particle, delta); | ||
updateColor(particle.color, delta); | ||
} | ||
} |
@@ -5,3 +5,2 @@ "use strict"; | ||
const engine_1 = require("@tsparticles/engine"); | ||
const Utils_js_1 = require("./Utils.js"); | ||
class ColorUpdater { | ||
@@ -26,5 +25,5 @@ constructor(container) { | ||
update(particle, delta) { | ||
(0, Utils_js_1.updateColor)(particle, delta); | ||
(0, engine_1.updateColor)(particle.color, delta); | ||
} | ||
} | ||
exports.ColorUpdater = ColorUpdater; |
@@ -1,3 +0,2 @@ | ||
import { getHslAnimationFromHsl, rangeColorToHsl, } from "@tsparticles/engine"; | ||
import { updateColor } from "./Utils.js"; | ||
import { getHslAnimationFromHsl, rangeColorToHsl, updateColor, } from "@tsparticles/engine"; | ||
export class ColorUpdater { | ||
@@ -22,4 +21,4 @@ constructor(container) { | ||
update(particle, delta) { | ||
updateColor(particle, delta); | ||
updateColor(particle.color, delta); | ||
} | ||
} |
{ | ||
"name": "@tsparticles/updater-color", | ||
"version": "3.0.3", | ||
"version": "3.1.0", | ||
"description": "tsParticles particles color updater", | ||
@@ -90,3 +90,3 @@ "homepage": "https://particles.js.org", | ||
"dependencies": { | ||
"@tsparticles/engine": "^3.0.3" | ||
"@tsparticles/engine": "^3.1.0" | ||
}, | ||
@@ -93,0 +93,0 @@ "publishConfig": { |
@@ -7,3 +7,3 @@ /*! | ||
* How to use? : Check the GitHub README | ||
* v3.0.3 | ||
* v3.1.0 | ||
*/ | ||
@@ -100,80 +100,4 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
var engine_root_window_ = __webpack_require__(533); | ||
;// CONCATENATED MODULE: ./dist/browser/Utils.js | ||
function updateColorValue(delta, colorValue, valueAnimation, max, decrease) { | ||
if (!colorValue || !valueAnimation.enable || (colorValue.maxLoops ?? 0) > 0 && (colorValue.loops ?? 0) > (colorValue.maxLoops ?? 0)) { | ||
return; | ||
} | ||
if (!colorValue.time) { | ||
colorValue.time = 0; | ||
} | ||
if ((colorValue.delayTime ?? 0) > 0 && colorValue.time < (colorValue.delayTime ?? 0)) { | ||
colorValue.time += delta.value; | ||
} | ||
if ((colorValue.delayTime ?? 0) > 0 && colorValue.time < (colorValue.delayTime ?? 0)) { | ||
return; | ||
} | ||
const offset = (0,engine_root_window_.randomInRange)(valueAnimation.offset), | ||
velocity = (colorValue.velocity ?? 0) * delta.factor + offset * 3.6, | ||
decay = colorValue.decay ?? 1; | ||
if (!decrease || colorValue.status === "increasing") { | ||
colorValue.value += velocity; | ||
if (colorValue.value > max) { | ||
if (!colorValue.loops) { | ||
colorValue.loops = 0; | ||
} | ||
colorValue.loops++; | ||
if (decrease) { | ||
colorValue.status = "decreasing"; | ||
colorValue.value -= colorValue.value % max; | ||
} | ||
} | ||
} else { | ||
colorValue.value -= velocity; | ||
if (colorValue.value < 0) { | ||
if (!colorValue.loops) { | ||
colorValue.loops = 0; | ||
} | ||
colorValue.loops++; | ||
colorValue.status = "increasing"; | ||
colorValue.value += colorValue.value; | ||
} | ||
} | ||
if (colorValue.velocity && decay !== 1) { | ||
colorValue.velocity *= decay; | ||
} | ||
if (colorValue.value > max) { | ||
colorValue.value %= max; | ||
} | ||
} | ||
function updateColor(particle, delta) { | ||
const { | ||
h: hAnimation, | ||
s: sAnimation, | ||
l: lAnimation | ||
} = particle.options.color.animation, | ||
{ | ||
color | ||
} = particle; | ||
if (!color) { | ||
return; | ||
} | ||
const { | ||
h, | ||
s, | ||
l | ||
} = color; | ||
if (h) { | ||
updateColorValue(delta, h, hAnimation, 360, false); | ||
} | ||
if (s) { | ||
updateColorValue(delta, s, sAnimation, 100, true); | ||
} | ||
if (l) { | ||
updateColorValue(delta, l, lAnimation, 100, true); | ||
} | ||
} | ||
;// CONCATENATED MODULE: ./dist/browser/ColorUpdater.js | ||
class ColorUpdater { | ||
@@ -201,3 +125,3 @@ constructor(container) { | ||
update(particle, delta) { | ||
updateColor(particle, delta); | ||
(0,engine_root_window_.updateColor)(particle.color, delta); | ||
} | ||
@@ -204,0 +128,0 @@ } |
/*! For license information please see tsparticles.updater.color.min.js.LICENSE.txt */ | ||
!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 n=t[e];if(void 0!==n)return n.exports;var i=t[e]={exports:{}};return o[e](i,i.exports,r),i.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 n={};return(()=>{r.r(n),r.d(n,{loadColorUpdater:()=>i});var e=r(533);function o(o,t,r,n,i){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;i&&"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>n&&(t.loops||(t.loops=0),t.loops++,i&&(t.status="decreasing",t.value-=t.value%n))),t.velocity&&1!==s&&(t.velocity*=s),t.value>n&&(t.value%=n)}class t{constructor(e){this.container=e}init(o){const t=(0,e.rangeColorToHsl)(o.options.color,o.id,o.options.reduceDuplicates);t&&(o.color=(0,e.getHslAnimationFromHsl)(t,o.options.color.animation,this.container.retina.reduceFactor))}isEnabled(e){const{h:o,s:t,l:r}=e.options.color.animation,{color:n}=e;return!e.destroyed&&!e.spawning&&(void 0!==n?.h.value&&o.enable||void 0!==n?.s.value&&t.enable||void 0!==n?.l.value&&r.enable)}update(e,t){!function(e,t){const{h:r,s:n,l:i}=e.options.color.animation,{color:a}=e;if(!a)return;const{h:l,s,l:c}=a;l&&o(t,l,r,360,!1),s&&o(t,s,n,100,!0),c&&o(t,c,i,100,!0)}(e,t)}}async function i(e,o=!0){await e.addParticleUpdater("color",(e=>new t(e)),o)}})(),n})())); | ||
!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 n=t[e];if(void 0!==n)return n.exports;var i=t[e]={exports:{}};return o[e](i,i.exports,r),i.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 n={};return(()=>{r.r(n),r.d(n,{loadColorUpdater:()=>t});var e=r(533);class o{constructor(e){this.container=e}init(o){const t=(0,e.rangeColorToHsl)(o.options.color,o.id,o.options.reduceDuplicates);t&&(o.color=(0,e.getHslAnimationFromHsl)(t,o.options.color.animation,this.container.retina.reduceFactor))}isEnabled(e){const{h:o,s:t,l:r}=e.options.color.animation,{color:n}=e;return!e.destroyed&&!e.spawning&&(void 0!==n?.h.value&&o.enable||void 0!==n?.s.value&&t.enable||void 0!==n?.l.value&&r.enable)}update(o,t){(0,e.updateColor)(o.color,t)}}async function t(e,t=!0){await e.addParticleUpdater("color",(e=>new o(e)),t)}})(),n})())); |
@@ -1,1 +0,1 @@ | ||
/*! tsParticles Color Updater v3.0.3 by Matteo Bruni */ | ||
/*! tsParticles Color Updater v3.1.0 by Matteo Bruni */ |
@@ -7,3 +7,3 @@ (function (factory) { | ||
else if (typeof define === "function" && define.amd) { | ||
define(["require", "exports", "@tsparticles/engine", "./Utils.js"], factory); | ||
define(["require", "exports", "@tsparticles/engine"], factory); | ||
} | ||
@@ -15,3 +15,2 @@ })(function (require, exports) { | ||
const engine_1 = require("@tsparticles/engine"); | ||
const Utils_js_1 = require("./Utils.js"); | ||
class ColorUpdater { | ||
@@ -36,3 +35,3 @@ constructor(container) { | ||
update(particle, delta) { | ||
(0, Utils_js_1.updateColor)(particle, delta); | ||
(0, engine_1.updateColor)(particle.color, delta); | ||
} | ||
@@ -39,0 +38,0 @@ } |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
295058
20
281
Updated@tsparticles/engine@^3.1.0