@tsparticles/updater-gradient 4.0.4 → 4.1.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/browser/GradientUpdater.js +7 -7
- package/browser/index.js +1 -1
- package/browser/index.lazy.js +1 -1
- package/cjs/GradientUpdater.js +7 -7
- package/cjs/index.js +1 -1
- package/cjs/index.lazy.js +1 -1
- package/esm/GradientUpdater.js +7 -7
- package/esm/index.js +1 -1
- package/esm/index.lazy.js +1 -1
- package/package.json +2 -2
- package/report.html +1 -1
- package/tsparticles.updater.gradient.js +9 -9
- package/tsparticles.updater.gradient.min.js +1 -1
- package/types/GradientUpdater.d.ts +1 -2
|
@@ -2,18 +2,18 @@ import { AnimationStatus, GradientType, RotateDirection, StartValueType, doubleP
|
|
|
2
2
|
import { AnimatableGradient } from "./Options/Classes/AnimatableGradient.js";
|
|
3
3
|
import { updateGradient } from "./Utils.js";
|
|
4
4
|
export class GradientUpdater {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
#container;
|
|
6
|
+
#pluginManager;
|
|
7
7
|
constructor(pluginManager, container) {
|
|
8
|
-
this
|
|
9
|
-
this
|
|
8
|
+
this.#pluginManager = pluginManager;
|
|
9
|
+
this.#container = container;
|
|
10
10
|
}
|
|
11
11
|
getColorStyles(particle, context, radius, opacity) {
|
|
12
12
|
const gradient = particle.gradient;
|
|
13
13
|
if (!gradient) {
|
|
14
14
|
return {};
|
|
15
15
|
}
|
|
16
|
-
const
|
|
16
|
+
const container = this.#container, gradientAngle = gradient.angle.value, origin = { x: 0, y: 0 }, minRadius = 0, fillGradient = gradient.type === GradientType.radial
|
|
17
17
|
? context.createRadialGradient(origin.x, origin.y, minRadius, origin.x, origin.y, radius)
|
|
18
18
|
: context.createLinearGradient(Math.cos(gradientAngle) * -radius, Math.sin(gradientAngle) * -radius, Math.cos(gradientAngle) * radius, Math.sin(gradientAngle) * radius);
|
|
19
19
|
for (const { stop, value, opacity: cOpacity } of gradient.colors) {
|
|
@@ -31,7 +31,7 @@ export class GradientUpdater {
|
|
|
31
31
|
if (!gradient) {
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
|
-
const container = this
|
|
34
|
+
const container = this.#container, { angle } = gradient, speedFactor = 360, delayOffset = 1;
|
|
35
35
|
particle.gradient = {
|
|
36
36
|
angle: {
|
|
37
37
|
value: getRangeValue(angle.value),
|
|
@@ -63,7 +63,7 @@ export class GradientUpdater {
|
|
|
63
63
|
}
|
|
64
64
|
const reduceDuplicates = particle.options.reduceDuplicates;
|
|
65
65
|
for (const grColor of gradient.colors) {
|
|
66
|
-
const grHslColor = rangeColorToHsl(this
|
|
66
|
+
const grHslColor = rangeColorToHsl(this.#pluginManager, grColor.value, particle.id, reduceDuplicates);
|
|
67
67
|
if (!grHslColor) {
|
|
68
68
|
continue;
|
|
69
69
|
}
|
package/browser/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GradientUpdater } from "./GradientUpdater.js";
|
|
2
2
|
export async function loadGradientUpdater(engine) {
|
|
3
|
-
engine.checkVersion("4.0
|
|
3
|
+
engine.checkVersion("4.1.0");
|
|
4
4
|
await engine.pluginManager.register(e => {
|
|
5
5
|
e.pluginManager.addParticleUpdater("gradient", container => {
|
|
6
6
|
return Promise.resolve(new GradientUpdater(e.pluginManager, container));
|
package/browser/index.lazy.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export async function loadGradientUpdater(engine) {
|
|
2
|
-
engine.checkVersion("4.0
|
|
2
|
+
engine.checkVersion("4.1.0");
|
|
3
3
|
await engine.pluginManager.register(e => {
|
|
4
4
|
e.pluginManager.addParticleUpdater("gradient", async (container) => {
|
|
5
5
|
const { GradientUpdater } = await import("./GradientUpdater.js");
|
package/cjs/GradientUpdater.js
CHANGED
|
@@ -2,18 +2,18 @@ import { AnimationStatus, GradientType, RotateDirection, StartValueType, doubleP
|
|
|
2
2
|
import { AnimatableGradient } from "./Options/Classes/AnimatableGradient.js";
|
|
3
3
|
import { updateGradient } from "./Utils.js";
|
|
4
4
|
export class GradientUpdater {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
#container;
|
|
6
|
+
#pluginManager;
|
|
7
7
|
constructor(pluginManager, container) {
|
|
8
|
-
this
|
|
9
|
-
this
|
|
8
|
+
this.#pluginManager = pluginManager;
|
|
9
|
+
this.#container = container;
|
|
10
10
|
}
|
|
11
11
|
getColorStyles(particle, context, radius, opacity) {
|
|
12
12
|
const gradient = particle.gradient;
|
|
13
13
|
if (!gradient) {
|
|
14
14
|
return {};
|
|
15
15
|
}
|
|
16
|
-
const
|
|
16
|
+
const container = this.#container, gradientAngle = gradient.angle.value, origin = { x: 0, y: 0 }, minRadius = 0, fillGradient = gradient.type === GradientType.radial
|
|
17
17
|
? context.createRadialGradient(origin.x, origin.y, minRadius, origin.x, origin.y, radius)
|
|
18
18
|
: context.createLinearGradient(Math.cos(gradientAngle) * -radius, Math.sin(gradientAngle) * -radius, Math.cos(gradientAngle) * radius, Math.sin(gradientAngle) * radius);
|
|
19
19
|
for (const { stop, value, opacity: cOpacity } of gradient.colors) {
|
|
@@ -31,7 +31,7 @@ export class GradientUpdater {
|
|
|
31
31
|
if (!gradient) {
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
|
-
const container = this
|
|
34
|
+
const container = this.#container, { angle } = gradient, speedFactor = 360, delayOffset = 1;
|
|
35
35
|
particle.gradient = {
|
|
36
36
|
angle: {
|
|
37
37
|
value: getRangeValue(angle.value),
|
|
@@ -63,7 +63,7 @@ export class GradientUpdater {
|
|
|
63
63
|
}
|
|
64
64
|
const reduceDuplicates = particle.options.reduceDuplicates;
|
|
65
65
|
for (const grColor of gradient.colors) {
|
|
66
|
-
const grHslColor = rangeColorToHsl(this
|
|
66
|
+
const grHslColor = rangeColorToHsl(this.#pluginManager, grColor.value, particle.id, reduceDuplicates);
|
|
67
67
|
if (!grHslColor) {
|
|
68
68
|
continue;
|
|
69
69
|
}
|
package/cjs/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GradientUpdater } from "./GradientUpdater.js";
|
|
2
2
|
export async function loadGradientUpdater(engine) {
|
|
3
|
-
engine.checkVersion("4.0
|
|
3
|
+
engine.checkVersion("4.1.0");
|
|
4
4
|
await engine.pluginManager.register(e => {
|
|
5
5
|
e.pluginManager.addParticleUpdater("gradient", container => {
|
|
6
6
|
return Promise.resolve(new GradientUpdater(e.pluginManager, container));
|
package/cjs/index.lazy.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export async function loadGradientUpdater(engine) {
|
|
2
|
-
engine.checkVersion("4.0
|
|
2
|
+
engine.checkVersion("4.1.0");
|
|
3
3
|
await engine.pluginManager.register(e => {
|
|
4
4
|
e.pluginManager.addParticleUpdater("gradient", async (container) => {
|
|
5
5
|
const { GradientUpdater } = await import("./GradientUpdater.js");
|
package/esm/GradientUpdater.js
CHANGED
|
@@ -2,18 +2,18 @@ import { AnimationStatus, GradientType, RotateDirection, StartValueType, doubleP
|
|
|
2
2
|
import { AnimatableGradient } from "./Options/Classes/AnimatableGradient.js";
|
|
3
3
|
import { updateGradient } from "./Utils.js";
|
|
4
4
|
export class GradientUpdater {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
#container;
|
|
6
|
+
#pluginManager;
|
|
7
7
|
constructor(pluginManager, container) {
|
|
8
|
-
this
|
|
9
|
-
this
|
|
8
|
+
this.#pluginManager = pluginManager;
|
|
9
|
+
this.#container = container;
|
|
10
10
|
}
|
|
11
11
|
getColorStyles(particle, context, radius, opacity) {
|
|
12
12
|
const gradient = particle.gradient;
|
|
13
13
|
if (!gradient) {
|
|
14
14
|
return {};
|
|
15
15
|
}
|
|
16
|
-
const
|
|
16
|
+
const container = this.#container, gradientAngle = gradient.angle.value, origin = { x: 0, y: 0 }, minRadius = 0, fillGradient = gradient.type === GradientType.radial
|
|
17
17
|
? context.createRadialGradient(origin.x, origin.y, minRadius, origin.x, origin.y, radius)
|
|
18
18
|
: context.createLinearGradient(Math.cos(gradientAngle) * -radius, Math.sin(gradientAngle) * -radius, Math.cos(gradientAngle) * radius, Math.sin(gradientAngle) * radius);
|
|
19
19
|
for (const { stop, value, opacity: cOpacity } of gradient.colors) {
|
|
@@ -31,7 +31,7 @@ export class GradientUpdater {
|
|
|
31
31
|
if (!gradient) {
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
|
-
const container = this
|
|
34
|
+
const container = this.#container, { angle } = gradient, speedFactor = 360, delayOffset = 1;
|
|
35
35
|
particle.gradient = {
|
|
36
36
|
angle: {
|
|
37
37
|
value: getRangeValue(angle.value),
|
|
@@ -63,7 +63,7 @@ export class GradientUpdater {
|
|
|
63
63
|
}
|
|
64
64
|
const reduceDuplicates = particle.options.reduceDuplicates;
|
|
65
65
|
for (const grColor of gradient.colors) {
|
|
66
|
-
const grHslColor = rangeColorToHsl(this
|
|
66
|
+
const grHslColor = rangeColorToHsl(this.#pluginManager, grColor.value, particle.id, reduceDuplicates);
|
|
67
67
|
if (!grHslColor) {
|
|
68
68
|
continue;
|
|
69
69
|
}
|
package/esm/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GradientUpdater } from "./GradientUpdater.js";
|
|
2
2
|
export async function loadGradientUpdater(engine) {
|
|
3
|
-
engine.checkVersion("4.0
|
|
3
|
+
engine.checkVersion("4.1.0");
|
|
4
4
|
await engine.pluginManager.register(e => {
|
|
5
5
|
e.pluginManager.addParticleUpdater("gradient", container => {
|
|
6
6
|
return Promise.resolve(new GradientUpdater(e.pluginManager, container));
|
package/esm/index.lazy.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export async function loadGradientUpdater(engine) {
|
|
2
|
-
engine.checkVersion("4.0
|
|
2
|
+
engine.checkVersion("4.1.0");
|
|
3
3
|
await engine.pluginManager.register(e => {
|
|
4
4
|
e.pluginManager.addParticleUpdater("gradient", async (container) => {
|
|
5
5
|
const { GradientUpdater } = await import("./GradientUpdater.js");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsparticles/updater-gradient",
|
|
3
|
-
"version": "4.0
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "tsParticles particles gradient updater",
|
|
5
5
|
"homepage": "https://particles.js.org",
|
|
6
6
|
"repository": {
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
"./package.json": "./package.json"
|
|
108
108
|
},
|
|
109
109
|
"peerDependencies": {
|
|
110
|
-
"@tsparticles/engine": "4.0
|
|
110
|
+
"@tsparticles/engine": "4.1.0"
|
|
111
111
|
},
|
|
112
112
|
"publishConfig": {
|
|
113
113
|
"access": "public"
|
package/report.html
CHANGED
|
@@ -4930,7 +4930,7 @@ var drawChart = (function (exports) {
|
|
|
4930
4930
|
</script>
|
|
4931
4931
|
<script>
|
|
4932
4932
|
/*<!--*/
|
|
4933
|
-
const data = {"version":2,"tree":{"name":"root","children":[{"name":"tsparticles.updater.gradient.js","children":[{"name":"dist/browser","children":[{"name":"Options/Classes","children":[{"uid":"
|
|
4933
|
+
const data = {"version":2,"tree":{"name":"root","children":[{"name":"tsparticles.updater.gradient.js","children":[{"name":"dist/browser","children":[{"name":"Options/Classes","children":[{"uid":"d3a68c52-1","name":"GradientColorOpacityAnimation.js"},{"uid":"d3a68c52-3","name":"GradientColorOpacity.js"},{"uid":"d3a68c52-5","name":"AnimatableGradientColor.js"},{"uid":"d3a68c52-7","name":"GradientAngleAnimation.js"},{"uid":"d3a68c52-9","name":"GradientAngle.js"},{"uid":"d3a68c52-11","name":"AnimatableGradient.js"}]},{"uid":"d3a68c52-13","name":"Utils.js"},{"uid":"d3a68c52-15","name":"GradientUpdater.js"},{"uid":"d3a68c52-17","name":"index.js"},{"uid":"d3a68c52-19","name":"browser.js"}]}]}],"isRoot":true},"nodeParts":{"d3a68c52-1":{"renderedLength":1331,"gzipLength":0,"brotliLength":0,"metaUid":"d3a68c52-0"},"d3a68c52-3":{"renderedLength":478,"gzipLength":0,"brotliLength":0,"metaUid":"d3a68c52-2"},"d3a68c52-5":{"renderedLength":826,"gzipLength":0,"brotliLength":0,"metaUid":"d3a68c52-4"},"d3a68c52-7":{"renderedLength":1130,"gzipLength":0,"brotliLength":0,"metaUid":"d3a68c52-6"},"d3a68c52-9":{"renderedLength":657,"gzipLength":0,"brotliLength":0,"metaUid":"d3a68c52-8"},"d3a68c52-11":{"renderedLength":748,"gzipLength":0,"brotliLength":0,"metaUid":"d3a68c52-10"},"d3a68c52-13":{"renderedLength":502,"gzipLength":0,"brotliLength":0,"metaUid":"d3a68c52-12"},"d3a68c52-15":{"renderedLength":6816,"gzipLength":0,"brotliLength":0,"metaUid":"d3a68c52-14"},"d3a68c52-17":{"renderedLength":334,"gzipLength":0,"brotliLength":0,"metaUid":"d3a68c52-16"},"d3a68c52-19":{"renderedLength":181,"gzipLength":0,"brotliLength":0,"metaUid":"d3a68c52-18"}},"nodeMetas":{"d3a68c52-0":{"id":"/dist/browser/Options/Classes/GradientColorOpacityAnimation.js","moduleParts":{"tsparticles.updater.gradient.js":"d3a68c52-1"},"imported":[{"uid":"d3a68c52-20"}],"importedBy":[{"uid":"d3a68c52-2"}]},"d3a68c52-2":{"id":"/dist/browser/Options/Classes/GradientColorOpacity.js","moduleParts":{"tsparticles.updater.gradient.js":"d3a68c52-3"},"imported":[{"uid":"d3a68c52-20"},{"uid":"d3a68c52-0"}],"importedBy":[{"uid":"d3a68c52-4"}]},"d3a68c52-4":{"id":"/dist/browser/Options/Classes/AnimatableGradientColor.js","moduleParts":{"tsparticles.updater.gradient.js":"d3a68c52-5"},"imported":[{"uid":"d3a68c52-20"},{"uid":"d3a68c52-2"}],"importedBy":[{"uid":"d3a68c52-10"}]},"d3a68c52-6":{"id":"/dist/browser/Options/Classes/GradientAngleAnimation.js","moduleParts":{"tsparticles.updater.gradient.js":"d3a68c52-7"},"imported":[{"uid":"d3a68c52-20"}],"importedBy":[{"uid":"d3a68c52-8"}]},"d3a68c52-8":{"id":"/dist/browser/Options/Classes/GradientAngle.js","moduleParts":{"tsparticles.updater.gradient.js":"d3a68c52-9"},"imported":[{"uid":"d3a68c52-20"},{"uid":"d3a68c52-6"}],"importedBy":[{"uid":"d3a68c52-10"}]},"d3a68c52-10":{"id":"/dist/browser/Options/Classes/AnimatableGradient.js","moduleParts":{"tsparticles.updater.gradient.js":"d3a68c52-11"},"imported":[{"uid":"d3a68c52-20"},{"uid":"d3a68c52-4"},{"uid":"d3a68c52-8"}],"importedBy":[{"uid":"d3a68c52-14"}]},"d3a68c52-12":{"id":"/dist/browser/Utils.js","moduleParts":{"tsparticles.updater.gradient.js":"d3a68c52-13"},"imported":[{"uid":"d3a68c52-20"}],"importedBy":[{"uid":"d3a68c52-14"}]},"d3a68c52-14":{"id":"/dist/browser/GradientUpdater.js","moduleParts":{"tsparticles.updater.gradient.js":"d3a68c52-15"},"imported":[{"uid":"d3a68c52-20"},{"uid":"d3a68c52-10"},{"uid":"d3a68c52-12"}],"importedBy":[{"uid":"d3a68c52-16"}]},"d3a68c52-16":{"id":"/dist/browser/index.js","moduleParts":{"tsparticles.updater.gradient.js":"d3a68c52-17"},"imported":[{"uid":"d3a68c52-14"}],"importedBy":[{"uid":"d3a68c52-18"}]},"d3a68c52-18":{"id":"/dist/browser/browser.js","moduleParts":{"tsparticles.updater.gradient.js":"d3a68c52-19"},"imported":[{"uid":"d3a68c52-16"}],"importedBy":[],"isEntry":true},"d3a68c52-20":{"id":"@tsparticles/engine","moduleParts":{},"imported":[],"importedBy":[{"uid":"d3a68c52-14"},{"uid":"d3a68c52-10"},{"uid":"d3a68c52-12"},{"uid":"d3a68c52-4"},{"uid":"d3a68c52-8"},{"uid":"d3a68c52-2"},{"uid":"d3a68c52-6"},{"uid":"d3a68c52-0"}],"isExternal":true}},"env":{"rollup":"4.60.4"},"options":{"gzip":false,"brotli":false,"sourcemap":false}};
|
|
4934
4934
|
|
|
4935
4935
|
const run = () => {
|
|
4936
4936
|
const width = window.innerWidth;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
(function(g){g.__tsParticlesInternals=g.__tsParticlesInternals||{};g.__tsParticlesInternals.bundles=g.__tsParticlesInternals.bundles||{};g.__tsParticlesInternals.effects=g.__tsParticlesInternals.effects||{};g.__tsParticlesInternals.engine=g.__tsParticlesInternals.engine||{};g.__tsParticlesInternals.interactions=g.__tsParticlesInternals.interactions||{};g.__tsParticlesInternals.palettes=g.__tsParticlesInternals.palettes||{};g.__tsParticlesInternals.paths=g.__tsParticlesInternals.paths||{};g.__tsParticlesInternals.plugins=g.__tsParticlesInternals.plugins||{};g.__tsParticlesInternals.plugins=g.__tsParticlesInternals.plugins||{};g.__tsParticlesInternals.plugins.emittersShapes=g.__tsParticlesInternals.plugins.emittersShapes||{};g.__tsParticlesInternals.presets=g.__tsParticlesInternals.presets||{};g.__tsParticlesInternals.shapes=g.__tsParticlesInternals.shapes||{};g.__tsParticlesInternals.updaters=g.__tsParticlesInternals.updaters||{};g.__tsParticlesInternals.utils=g.__tsParticlesInternals.utils||{};g.__tsParticlesInternals.canvas=g.__tsParticlesInternals.canvas||{};g.__tsParticlesInternals.canvas=g.__tsParticlesInternals.canvas||{};g.__tsParticlesInternals.canvas.utils=g.__tsParticlesInternals.canvas.utils||{};g.__tsParticlesInternals.path=g.__tsParticlesInternals.path||{};g.__tsParticlesInternals.path=g.__tsParticlesInternals.path||{};g.__tsParticlesInternals.path.utils=g.__tsParticlesInternals.path.utils||{};var __tsProxyFactory=typeof Proxy!=="undefined"?function(obj){return new Proxy(obj,{get:function(target,key){if(!(key in target)){target[key]={};}return target[key];}});}:function(obj){return obj;};g.__tsParticlesInternals.bundles=__tsProxyFactory(g.__tsParticlesInternals.bundles);g.__tsParticlesInternals.effects=__tsProxyFactory(g.__tsParticlesInternals.effects);g.__tsParticlesInternals.interactions=__tsProxyFactory(g.__tsParticlesInternals.interactions);g.__tsParticlesInternals.palettes=__tsProxyFactory(g.__tsParticlesInternals.palettes);g.__tsParticlesInternals.paths=__tsProxyFactory(g.__tsParticlesInternals.paths);g.__tsParticlesInternals.plugins=__tsProxyFactory(g.__tsParticlesInternals.plugins);g.__tsParticlesInternals.plugins.emittersShapes=__tsProxyFactory(g.__tsParticlesInternals.plugins.emittersShapes);g.__tsParticlesInternals.presets=__tsProxyFactory(g.__tsParticlesInternals.presets);g.__tsParticlesInternals.shapes=__tsProxyFactory(g.__tsParticlesInternals.shapes);g.__tsParticlesInternals.updaters=__tsProxyFactory(g.__tsParticlesInternals.updaters);g.__tsParticlesInternals.utils=__tsProxyFactory(g.__tsParticlesInternals.utils);g.__tsParticlesInternals.canvas=__tsProxyFactory(g.__tsParticlesInternals.canvas);g.__tsParticlesInternals.path=__tsProxyFactory(g.__tsParticlesInternals.path);g.tsparticlesInternalExports=g.tsparticlesInternalExports||{};})(typeof globalThis!=="undefined"?globalThis:typeof window!=="undefined"?window:this);
|
|
2
|
-
/* Updater v4.0
|
|
2
|
+
/* Updater v4.1.0 */
|
|
3
3
|
(function (global, factory) {
|
|
4
4
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tsparticles/engine')) :
|
|
5
5
|
typeof define === 'function' && define.amd ? define(['exports', '@tsparticles/engine'], factory) :
|
|
@@ -202,18 +202,18 @@
|
|
|
202
202
|
}
|
|
203
203
|
|
|
204
204
|
class GradientUpdater {
|
|
205
|
-
|
|
206
|
-
|
|
205
|
+
#container;
|
|
206
|
+
#pluginManager;
|
|
207
207
|
constructor(pluginManager, container) {
|
|
208
|
-
this
|
|
209
|
-
this
|
|
208
|
+
this.#pluginManager = pluginManager;
|
|
209
|
+
this.#container = container;
|
|
210
210
|
}
|
|
211
211
|
getColorStyles(particle, context, radius, opacity) {
|
|
212
212
|
const gradient = particle.gradient;
|
|
213
213
|
if (!gradient) {
|
|
214
214
|
return {};
|
|
215
215
|
}
|
|
216
|
-
const
|
|
216
|
+
const container = this.#container, gradientAngle = gradient.angle.value, origin = { x: 0, y: 0 }, minRadius = 0, fillGradient = gradient.type === engine.GradientType.radial
|
|
217
217
|
? context.createRadialGradient(origin.x, origin.y, minRadius, origin.x, origin.y, radius)
|
|
218
218
|
: context.createLinearGradient(Math.cos(gradientAngle) * -radius, Math.sin(gradientAngle) * -radius, Math.cos(gradientAngle) * radius, Math.sin(gradientAngle) * radius);
|
|
219
219
|
for (const { stop, value, opacity: cOpacity } of gradient.colors) {
|
|
@@ -231,7 +231,7 @@
|
|
|
231
231
|
if (!gradient) {
|
|
232
232
|
return;
|
|
233
233
|
}
|
|
234
|
-
const container = this
|
|
234
|
+
const container = this.#container, { angle } = gradient, speedFactor = 360, delayOffset = 1;
|
|
235
235
|
particle.gradient = {
|
|
236
236
|
angle: {
|
|
237
237
|
value: engine.getRangeValue(angle.value),
|
|
@@ -261,7 +261,7 @@
|
|
|
261
261
|
}
|
|
262
262
|
const reduceDuplicates = particle.options.reduceDuplicates;
|
|
263
263
|
for (const grColor of gradient.colors) {
|
|
264
|
-
const grHslColor = engine.rangeColorToHsl(this
|
|
264
|
+
const grHslColor = engine.rangeColorToHsl(this.#pluginManager, grColor.value, particle.id, reduceDuplicates);
|
|
265
265
|
if (!grHslColor) {
|
|
266
266
|
continue;
|
|
267
267
|
}
|
|
@@ -331,7 +331,7 @@
|
|
|
331
331
|
}
|
|
332
332
|
|
|
333
333
|
async function loadGradientUpdater(engine) {
|
|
334
|
-
engine.checkVersion("4.0
|
|
334
|
+
engine.checkVersion("4.1.0");
|
|
335
335
|
await engine.pluginManager.register(e => {
|
|
336
336
|
e.pluginManager.addParticleUpdater("gradient", container => {
|
|
337
337
|
return Promise.resolve(new GradientUpdater(e.pluginManager, container));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t){t.__tsParticlesInternals=t.__tsParticlesInternals||{},t.__tsParticlesInternals.bundles=t.__tsParticlesInternals.bundles||{},t.__tsParticlesInternals.effects=t.__tsParticlesInternals.effects||{},t.__tsParticlesInternals.engine=t.__tsParticlesInternals.engine||{},t.__tsParticlesInternals.interactions=t.__tsParticlesInternals.interactions||{},t.__tsParticlesInternals.palettes=t.__tsParticlesInternals.palettes||{},t.__tsParticlesInternals.paths=t.__tsParticlesInternals.paths||{},t.__tsParticlesInternals.plugins=t.__tsParticlesInternals.plugins||{},t.__tsParticlesInternals.plugins=t.__tsParticlesInternals.plugins||{},t.__tsParticlesInternals.plugins.emittersShapes=t.__tsParticlesInternals.plugins.emittersShapes||{},t.__tsParticlesInternals.presets=t.__tsParticlesInternals.presets||{},t.__tsParticlesInternals.shapes=t.__tsParticlesInternals.shapes||{},t.__tsParticlesInternals.updaters=t.__tsParticlesInternals.updaters||{},t.__tsParticlesInternals.utils=t.__tsParticlesInternals.utils||{},t.__tsParticlesInternals.canvas=t.__tsParticlesInternals.canvas||{},t.__tsParticlesInternals.canvas=t.__tsParticlesInternals.canvas||{},t.__tsParticlesInternals.canvas.utils=t.__tsParticlesInternals.canvas.utils||{},t.__tsParticlesInternals.path=t.__tsParticlesInternals.path||{},t.__tsParticlesInternals.path=t.__tsParticlesInternals.path||{},t.__tsParticlesInternals.path.utils=t.__tsParticlesInternals.path.utils||{};var e="undefined"!=typeof Proxy?function(t){return new Proxy(t,{get:function(t,e){return e in t||(t[e]={}),t[e]}})}:function(t){return t};t.__tsParticlesInternals.bundles=e(t.__tsParticlesInternals.bundles),t.__tsParticlesInternals.effects=e(t.__tsParticlesInternals.effects),t.__tsParticlesInternals.interactions=e(t.__tsParticlesInternals.interactions),t.__tsParticlesInternals.palettes=e(t.__tsParticlesInternals.palettes),t.__tsParticlesInternals.paths=e(t.__tsParticlesInternals.paths),t.__tsParticlesInternals.plugins=e(t.__tsParticlesInternals.plugins),t.__tsParticlesInternals.plugins.emittersShapes=e(t.__tsParticlesInternals.plugins.emittersShapes),t.__tsParticlesInternals.presets=e(t.__tsParticlesInternals.presets),t.__tsParticlesInternals.shapes=e(t.__tsParticlesInternals.shapes),t.__tsParticlesInternals.updaters=e(t.__tsParticlesInternals.updaters),t.__tsParticlesInternals.utils=e(t.__tsParticlesInternals.utils),t.__tsParticlesInternals.canvas=e(t.__tsParticlesInternals.canvas),t.__tsParticlesInternals.path=e(t.__tsParticlesInternals.path),t.tsparticlesInternalExports=t.tsparticlesInternalExports||{}}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:this),function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@tsparticles/engine")):"function"==typeof define&&define.amd?define(["exports","@tsparticles/engine"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).__tsParticlesInternals=t.__tsParticlesInternals||{},t.__tsParticlesInternals.updaters=t.__tsParticlesInternals.updaters||{},t.__tsParticlesInternals.updaters.gradient=t.__tsParticlesInternals.updaters.gradient||{}),t.__tsParticlesInternals.engine)}(this,function(t,e){"use strict";class a{count;decay;delay;enable;speed;startValue;sync;constructor(){this.count=0,this.enable=!1,this.speed=0,this.decay=0,this.delay=0,this.sync=!1,this.startValue=e.StartValueType.random}load(t){e.isNull(t)||(void 0!==t.count&&(this.count=e.setRangeValue(t.count)),void 0!==t.enable&&(this.enable=t.enable),void 0!==t.speed&&(this.speed=e.setRangeValue(t.speed)),void 0!==t.sync&&(this.sync=t.sync),void 0!==t.startValue&&(this.startValue=t.startValue),void 0!==t.decay&&(this.decay=e.setRangeValue(t.decay)),void 0!==t.delay&&(this.delay=e.setRangeValue(t.delay)))}}class s{animation;value;constructor(){this.value=0,this.animation=new a}load(t){e.isNull(t)||(this.animation.load(t.animation),void 0!==t.value&&(this.value=e.setRangeValue(t.value)))}}class n{opacity;stop;value;constructor(){this.stop=0,this.value=new e.AnimatableColor}load(t){e.isNull(t)||(void 0!==t.stop&&(this.stop=t.stop),this.value=e.AnimatableColor.create(this.value,t.value),void 0!==t.opacity&&(this.opacity=new s,e.isNumber(t.opacity)?this.opacity.value=t.opacity:this.opacity.load(t.opacity)))}}class i{count;decay;delay;enable;speed;sync;constructor(){this.count=0,this.enable=!1,this.speed=0,this.decay=0,this.delay=0,this.sync=!1}load(t){e.isNull(t)||(void 0!==t.count&&(this.count=e.setRangeValue(t.count)),void 0!==t.enable&&(this.enable=t.enable),void 0!==t.speed&&(this.speed=e.setRangeValue(t.speed)),void 0!==t.decay&&(this.decay=e.setRangeValue(t.decay)),void 0!==t.delay&&(this.delay=e.setRangeValue(t.delay)),void 0!==t.sync&&(this.sync=t.sync))}}class l{animation;direction;value;constructor(){this.value=0,this.animation=new i,this.direction=e.RotateDirection.clockwise}load(t){e.isNull(t)||(this.animation.load(t.animation),void 0!==t.value&&(this.value=e.setRangeValue(t.value)),void 0!==t.direction&&(this.direction=t.direction))}}class r{angle;colors;type;constructor(){this.angle=new l,this.colors=[],this.type=e.GradientType.random}load(t){e.isNull(t)||(this.angle.load(t.angle),void 0!==t.colors&&(this.colors=t.colors.map(t=>{const e=new n;return e.load(t),e})),void 0!==t.type&&(this.type=t.type))}}class o{
|
|
1
|
+
!function(t){t.__tsParticlesInternals=t.__tsParticlesInternals||{},t.__tsParticlesInternals.bundles=t.__tsParticlesInternals.bundles||{},t.__tsParticlesInternals.effects=t.__tsParticlesInternals.effects||{},t.__tsParticlesInternals.engine=t.__tsParticlesInternals.engine||{},t.__tsParticlesInternals.interactions=t.__tsParticlesInternals.interactions||{},t.__tsParticlesInternals.palettes=t.__tsParticlesInternals.palettes||{},t.__tsParticlesInternals.paths=t.__tsParticlesInternals.paths||{},t.__tsParticlesInternals.plugins=t.__tsParticlesInternals.plugins||{},t.__tsParticlesInternals.plugins=t.__tsParticlesInternals.plugins||{},t.__tsParticlesInternals.plugins.emittersShapes=t.__tsParticlesInternals.plugins.emittersShapes||{},t.__tsParticlesInternals.presets=t.__tsParticlesInternals.presets||{},t.__tsParticlesInternals.shapes=t.__tsParticlesInternals.shapes||{},t.__tsParticlesInternals.updaters=t.__tsParticlesInternals.updaters||{},t.__tsParticlesInternals.utils=t.__tsParticlesInternals.utils||{},t.__tsParticlesInternals.canvas=t.__tsParticlesInternals.canvas||{},t.__tsParticlesInternals.canvas=t.__tsParticlesInternals.canvas||{},t.__tsParticlesInternals.canvas.utils=t.__tsParticlesInternals.canvas.utils||{},t.__tsParticlesInternals.path=t.__tsParticlesInternals.path||{},t.__tsParticlesInternals.path=t.__tsParticlesInternals.path||{},t.__tsParticlesInternals.path.utils=t.__tsParticlesInternals.path.utils||{};var e="undefined"!=typeof Proxy?function(t){return new Proxy(t,{get:function(t,e){return e in t||(t[e]={}),t[e]}})}:function(t){return t};t.__tsParticlesInternals.bundles=e(t.__tsParticlesInternals.bundles),t.__tsParticlesInternals.effects=e(t.__tsParticlesInternals.effects),t.__tsParticlesInternals.interactions=e(t.__tsParticlesInternals.interactions),t.__tsParticlesInternals.palettes=e(t.__tsParticlesInternals.palettes),t.__tsParticlesInternals.paths=e(t.__tsParticlesInternals.paths),t.__tsParticlesInternals.plugins=e(t.__tsParticlesInternals.plugins),t.__tsParticlesInternals.plugins.emittersShapes=e(t.__tsParticlesInternals.plugins.emittersShapes),t.__tsParticlesInternals.presets=e(t.__tsParticlesInternals.presets),t.__tsParticlesInternals.shapes=e(t.__tsParticlesInternals.shapes),t.__tsParticlesInternals.updaters=e(t.__tsParticlesInternals.updaters),t.__tsParticlesInternals.utils=e(t.__tsParticlesInternals.utils),t.__tsParticlesInternals.canvas=e(t.__tsParticlesInternals.canvas),t.__tsParticlesInternals.path=e(t.__tsParticlesInternals.path),t.tsparticlesInternalExports=t.tsparticlesInternalExports||{}}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:this),function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@tsparticles/engine")):"function"==typeof define&&define.amd?define(["exports","@tsparticles/engine"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).__tsParticlesInternals=t.__tsParticlesInternals||{},t.__tsParticlesInternals.updaters=t.__tsParticlesInternals.updaters||{},t.__tsParticlesInternals.updaters.gradient=t.__tsParticlesInternals.updaters.gradient||{}),t.__tsParticlesInternals.engine)}(this,function(t,e){"use strict";class a{count;decay;delay;enable;speed;startValue;sync;constructor(){this.count=0,this.enable=!1,this.speed=0,this.decay=0,this.delay=0,this.sync=!1,this.startValue=e.StartValueType.random}load(t){e.isNull(t)||(void 0!==t.count&&(this.count=e.setRangeValue(t.count)),void 0!==t.enable&&(this.enable=t.enable),void 0!==t.speed&&(this.speed=e.setRangeValue(t.speed)),void 0!==t.sync&&(this.sync=t.sync),void 0!==t.startValue&&(this.startValue=t.startValue),void 0!==t.decay&&(this.decay=e.setRangeValue(t.decay)),void 0!==t.delay&&(this.delay=e.setRangeValue(t.delay)))}}class s{animation;value;constructor(){this.value=0,this.animation=new a}load(t){e.isNull(t)||(this.animation.load(t.animation),void 0!==t.value&&(this.value=e.setRangeValue(t.value)))}}class n{opacity;stop;value;constructor(){this.stop=0,this.value=new e.AnimatableColor}load(t){e.isNull(t)||(void 0!==t.stop&&(this.stop=t.stop),this.value=e.AnimatableColor.create(this.value,t.value),void 0!==t.opacity&&(this.opacity=new s,e.isNumber(t.opacity)?this.opacity.value=t.opacity:this.opacity.load(t.opacity)))}}class i{count;decay;delay;enable;speed;sync;constructor(){this.count=0,this.enable=!1,this.speed=0,this.decay=0,this.delay=0,this.sync=!1}load(t){e.isNull(t)||(void 0!==t.count&&(this.count=e.setRangeValue(t.count)),void 0!==t.enable&&(this.enable=t.enable),void 0!==t.speed&&(this.speed=e.setRangeValue(t.speed)),void 0!==t.decay&&(this.decay=e.setRangeValue(t.decay)),void 0!==t.delay&&(this.delay=e.setRangeValue(t.delay)),void 0!==t.sync&&(this.sync=t.sync))}}class l{animation;direction;value;constructor(){this.value=0,this.animation=new i,this.direction=e.RotateDirection.clockwise}load(t){e.isNull(t)||(this.animation.load(t.animation),void 0!==t.value&&(this.value=e.setRangeValue(t.value)),void 0!==t.direction&&(this.direction=t.direction))}}class r{angle;colors;type;constructor(){this.angle=new l,this.colors=[],this.type=e.GradientType.random}load(t){e.isNull(t)||(this.angle.load(t.angle),void 0!==t.colors&&(this.colors=t.colors.map(t=>{const e=new n;return e.load(t),e})),void 0!==t.type&&(this.type=t.type))}}class o{#t;#e;constructor(t,e){this.#e=t,this.#t=e}getColorStyles(t,a,s,n){const i=t.gradient;if(!i)return{};const l=this.#t,r=i.angle.value,o=0,c=0,u=i.type===e.GradientType.radial?a.createRadialGradient(o,c,0,o,c,s):a.createLinearGradient(Math.cos(r)*-s,Math.sin(r)*-s,Math.cos(r)*s,Math.sin(r)*s);for(const{stop:t,value:a,opacity:s}of i.colors){const i={h:a.h.value,s:a.s.value,l:a.l.value};u.addColorStop(t,e.getStyleFromHsl(i,l.hdr,s?.value??n))}return{fill:u}}init(t){const a=e.itemFromSingleOrMultiple(t.options.gradient);if(!a)return;const s=this.#t,{angle:n}=a;t.gradient={angle:{value:e.getRangeValue(n.value),enable:n.animation.enable,velocity:e.getRangeValue(n.animation.speed)/360*s.retina.reduceFactor,decay:1-e.getRangeValue(n.animation.decay),delayTime:e.getRangeValue(n.animation.delay)*e.millisecondsToSeconds,max:e.doublePI,min:0,time:0},type:a.type,colors:[]};let i=a.angle.direction;switch(i===e.RotateDirection.random&&(i=e.getRandom()>e.half?e.RotateDirection.counterClockwise:e.RotateDirection.clockwise),i){case e.RotateDirection.counterClockwise:case"counterClockwise":t.gradient.angle.status=e.AnimationStatus.decreasing;break;case e.RotateDirection.clockwise:t.gradient.angle.status=e.AnimationStatus.increasing}const l=t.options.reduceDuplicates;for(const n of a.colors){const a=e.rangeColorToHsl(this.#e,n.value,t.id,l);if(!a)continue;const i=e.getHslAnimationFromHsl(a,n.value.animation,s.retina.reduceFactor),r={stop:n.stop,value:i,opacity:n.opacity?{enable:n.opacity.animation.enable,max:e.getRangeMax(n.opacity.value),min:e.getRangeMin(n.opacity.value),status:e.AnimationStatus.increasing,value:e.getRangeValue(n.opacity.value),velocity:e.getRangeValue(n.opacity.animation.speed)/e.percentDenominator*s.retina.reduceFactor,decay:1-e.getRangeValue(n.opacity.animation.decay),delayTime:e.getRangeValue(n.opacity.animation.delay)*e.millisecondsToSeconds,time:0}:void 0},{opacity:o}=r;if(n.opacity&&o){const t=n.opacity.value;o.min=e.getRangeMin(t),o.max=e.getRangeMax(t);switch(n.opacity.animation.startValue){case e.StartValueType.min:o.value=o.min,o.status=e.AnimationStatus.increasing;break;case e.StartValueType.max:o.value=o.max,o.status=e.AnimationStatus.decreasing;break;case e.StartValueType.random:default:o.value=e.randomInRangeValue(o),o.status=e.getRandom()>=e.half?e.AnimationStatus.increasing:e.AnimationStatus.decreasing}}t.gradient.colors.push(r)}}isEnabled(t){return!t.destroyed&&!t.spawning&&(!!t.gradient?.angle.enable||(t.gradient?.colors.some(t=>t.value.h.enable||t.value.s.enable||t.value.l.enable)??!1))}loadOptions(t,...a){for(const s of a){if(!s?.gradient)continue;const a=s.gradient;t.gradient=e.executeOnSingleOrMultiple(a,t=>{const e=new r;return e.load(t),e})}}update(t,a){!function(t,a){const{gradient:s}=t;if(s){e.updateAnimation(t,s.angle,!1,e.DestroyType.none,a);for(const n of s.colors)e.updateColor(n.value,a),n.opacity&&e.updateAnimation(t,n.opacity,!0,e.DestroyType.none,a)}}(t,a)}}async function c(t){t.checkVersion("4.1.0"),await t.pluginManager.register(t=>{t.pluginManager.addParticleUpdater("gradient",e=>Promise.resolve(new o(t.pluginManager,e)))})}const u=globalThis;u.__tsParticlesInternals=u.__tsParticlesInternals??{},u.loadGradientUpdater=c,t.loadGradientUpdater=c}),Object.assign(globalThis.window||globalThis,{loadGradientUpdater:(globalThis.__tsParticlesInternals.updaters.gradient||{}).loadGradientUpdater}),delete(globalThis.window||globalThis).tsparticlesInternalExports;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { type Container, type IDelta, type IParticleColorStyle, type IParticleUpdater, type PluginManager, type RecursivePartial } from "@tsparticles/engine";
|
|
2
2
|
import type { GradientParticle, GradientParticlesOptions, IGradientParticlesOptions } from "./Types.js";
|
|
3
3
|
export declare class GradientUpdater implements IParticleUpdater {
|
|
4
|
-
private
|
|
5
|
-
private readonly _pluginManager;
|
|
4
|
+
#private;
|
|
6
5
|
constructor(pluginManager: PluginManager, container: Container);
|
|
7
6
|
getColorStyles(particle: GradientParticle, context: OffscreenCanvasRenderingContext2D, radius: number, opacity: number): IParticleColorStyle;
|
|
8
7
|
init(particle: GradientParticle): void;
|