@tsparticles/plugin-hsv-color 3.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Matteo Bruni
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,70 @@
1
+ [![banner](https://particles.js.org/images/banner3.png)](https://particles.js.org)
2
+
3
+ # tsParticles HSV Color Plugin
4
+
5
+ [![jsDelivr](https://data.jsdelivr.com/v1/package/npm/tsparticles-plugin-hsv-color/badge)](https://www.jsdelivr.com/package/npm/tsparticles-plugin-hsv-color)
6
+ [![npmjs](https://badge.fury.io/js/tsparticles-plugin-hsv-color.svg)](https://www.npmjs.com/package/tsparticles-plugin-hsv-color)
7
+ [![npmjs](https://img.shields.io/npm/dt/tsparticles-plugin-hsv-color)](https://www.npmjs.com/package/tsparticles-plugin-hsv-color) [![GitHub Sponsors](https://img.shields.io/github/sponsors/matteobruni)](https://github.com/sponsors/matteobruni)
8
+
9
+ [tsParticles](https://github.com/matteobruni/tsparticles) plugin for adding the HSV color support.
10
+
11
+ ## How to use it
12
+
13
+ ### CDN / Vanilla JS / jQuery
14
+
15
+ The CDN/Vanilla version JS has one required file in vanilla configuration:
16
+
17
+ Including the `tsparticles.plugin.hsvColor.min.js` file will export the function to load the plugin:
18
+
19
+ ```text
20
+ loadHsvColorPlugin
21
+ ```
22
+
23
+ ### Usage
24
+
25
+ Once the scripts are loaded you can set up `tsParticles` and the plugin like this:
26
+
27
+ ```javascript
28
+ (async () => {
29
+ await loadHsvColorPlugin();
30
+
31
+ await tsParticles.load({
32
+ id: "tsparticles",
33
+ options: {
34
+ /* options */
35
+ },
36
+ });
37
+ })();
38
+ ```
39
+
40
+ ### ESM / CommonJS
41
+
42
+ This package is compatible also with ES or CommonJS modules, firstly this needs to be installed, like this:
43
+
44
+ ```shell
45
+ $ npm install tsparticles-plugin-hsv-color
46
+ ```
47
+
48
+ or
49
+
50
+ ```shell
51
+ $ yarn add tsparticles-plugin-hsv-color
52
+ ```
53
+
54
+ Then you need to import it in the app, like this:
55
+
56
+ ```javascript
57
+ const { tsParticles } = require("tsparticles-engine");
58
+ const { loadHsvColorPlugin } = require("tsparticles-plugin-hsv-color");
59
+
60
+ loadHsvColorPlugin();
61
+ ```
62
+
63
+ or
64
+
65
+ ```javascript
66
+ import { tsParticles } from "tsparticles-engine";
67
+ import { loadHsvColorPlugin } from "tsparticles-plugin-hsv-color";
68
+
69
+ loadHsvColorPlugin();
70
+ ```
@@ -0,0 +1,150 @@
1
+ import { getRangeValue, getStyleFromHsl, parseAlpha } from "@tsparticles/engine";
2
+ export function rgbToHsv(rgb) {
3
+ const rgbPercent = {
4
+ r: rgb.r / 255,
5
+ g: rgb.g / 255,
6
+ b: rgb.b / 255,
7
+ }, xMax = Math.max(rgbPercent.r, rgbPercent.g, rgbPercent.b), xMin = Math.min(rgbPercent.r, rgbPercent.g, rgbPercent.b), v = xMax, c = xMax - xMin;
8
+ let h = 0;
9
+ if (v === rgbPercent.r) {
10
+ h = 60 * ((rgbPercent.g - rgbPercent.b) / c);
11
+ }
12
+ else if (v === rgbPercent.g) {
13
+ h = 60 * (2 + (rgbPercent.b - rgbPercent.r) / c);
14
+ }
15
+ else if (v === rgbPercent.b) {
16
+ h = 60 * (4 + (rgbPercent.r - rgbPercent.g) / c);
17
+ }
18
+ const s = !v ? 0 : c / v;
19
+ return {
20
+ h,
21
+ s: s * 100,
22
+ v: v * 100,
23
+ };
24
+ }
25
+ export function rgbaToHsva(rgba) {
26
+ return Object.assign({ a: rgba.a }, rgbToHsv(rgba));
27
+ }
28
+ export function getStyleFromHsv(color, opacity) {
29
+ return getStyleFromHsl(hsvToHsl(color), opacity);
30
+ }
31
+ export function hslToHsv(hsl) {
32
+ const l = hsl.l / 100, sl = hsl.s / 100, v = l + sl * Math.min(l, 1 - l), sv = !v ? 0 : 2 * (1 - l / v);
33
+ return {
34
+ h: hsl.h,
35
+ s: sv * 100,
36
+ v: v * 100,
37
+ };
38
+ }
39
+ export function hslaToHsva(hsla) {
40
+ return Object.assign({ a: hsla.a }, hslToHsv(hsla));
41
+ }
42
+ export function hsvToHsl(hsv) {
43
+ const v = hsv.v / 100, sv = hsv.s / 100, l = v * (1 - sv / 2), sl = l === 0 || l === 1 ? 0 : (v - l) / Math.min(l, 1 - l);
44
+ return {
45
+ h: hsv.h,
46
+ l: l * 100,
47
+ s: sl * 100,
48
+ };
49
+ }
50
+ export function hsvaToHsla(hsva) {
51
+ return Object.assign({ a: hsva.a }, hsvToHsl(hsva));
52
+ }
53
+ export function hsvToRgb(hsv) {
54
+ const result = { b: 0, g: 0, r: 0 }, hsvPercent = {
55
+ h: hsv.h / 60,
56
+ s: hsv.s / 100,
57
+ v: hsv.v / 100,
58
+ }, c = hsvPercent.v * hsvPercent.s, x = c * (1 - Math.abs((hsvPercent.h % 2) - 1));
59
+ let tempRgb;
60
+ if (hsvPercent.h >= 0 && hsvPercent.h <= 1) {
61
+ tempRgb = {
62
+ r: c,
63
+ g: x,
64
+ b: 0,
65
+ };
66
+ }
67
+ else if (hsvPercent.h > 1 && hsvPercent.h <= 2) {
68
+ tempRgb = {
69
+ r: x,
70
+ g: c,
71
+ b: 0,
72
+ };
73
+ }
74
+ else if (hsvPercent.h > 2 && hsvPercent.h <= 3) {
75
+ tempRgb = {
76
+ r: 0,
77
+ g: c,
78
+ b: x,
79
+ };
80
+ }
81
+ else if (hsvPercent.h > 3 && hsvPercent.h <= 4) {
82
+ tempRgb = {
83
+ r: 0,
84
+ g: x,
85
+ b: c,
86
+ };
87
+ }
88
+ else if (hsvPercent.h > 4 && hsvPercent.h <= 5) {
89
+ tempRgb = {
90
+ r: x,
91
+ g: 0,
92
+ b: c,
93
+ };
94
+ }
95
+ else if (hsvPercent.h > 5 && hsvPercent.h <= 6) {
96
+ tempRgb = {
97
+ r: c,
98
+ g: 0,
99
+ b: x,
100
+ };
101
+ }
102
+ if (tempRgb) {
103
+ const m = hsvPercent.v - c;
104
+ result.r = Math.floor((tempRgb.r + m) * 255);
105
+ result.g = Math.floor((tempRgb.g + m) * 255);
106
+ result.b = Math.floor((tempRgb.b + m) * 255);
107
+ }
108
+ return result;
109
+ }
110
+ export function hsvaToRgba(hsva) {
111
+ return Object.assign({ a: hsva.a }, hsvToRgb(hsva));
112
+ }
113
+ export class HsvColorManager {
114
+ constructor() {
115
+ this.key = "hsv";
116
+ this.stringPrefix = "hsv";
117
+ }
118
+ handleColor(color) {
119
+ var _a;
120
+ const colorValue = color.value, hsvColor = (_a = colorValue.hsv) !== null && _a !== void 0 ? _a : color.value;
121
+ if (hsvColor.h !== undefined && hsvColor.v !== undefined) {
122
+ return hsvToRgb(hsvColor);
123
+ }
124
+ }
125
+ handleRangeColor(color) {
126
+ var _a;
127
+ const colorValue = color.value, hsvColor = (_a = colorValue.hsv) !== null && _a !== void 0 ? _a : color.value;
128
+ if (hsvColor.h !== undefined && hsvColor.v !== undefined) {
129
+ return hsvToRgb({
130
+ h: getRangeValue(hsvColor.h),
131
+ s: getRangeValue(hsvColor.s),
132
+ v: getRangeValue(hsvColor.v),
133
+ });
134
+ }
135
+ }
136
+ parseString(input) {
137
+ if (!input.startsWith("hsv")) {
138
+ return;
139
+ }
140
+ const regex = /hsva?\(\s*(\d+)°\s*,\s*(\d+)%\s*,\s*(\d+)%\s*(,\s*([\d.%]+)\s*)?\)/i, result = regex.exec(input);
141
+ return result
142
+ ? hsvaToRgba({
143
+ a: result.length > 4 ? parseAlpha(result[5]) : 1,
144
+ h: parseInt(result[1], 10),
145
+ s: parseInt(result[2], 10),
146
+ v: parseInt(result[3], 10),
147
+ })
148
+ : undefined;
149
+ }
150
+ }
@@ -0,0 +1,5 @@
1
+ import { HsvColorManager } from "./HsvColorManager";
2
+ import { addColorManager } from "@tsparticles/engine";
3
+ export function loadHsvColorPlugin() {
4
+ addColorManager(new HsvColorManager());
5
+ }
@@ -0,0 +1,163 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HsvColorManager = exports.hsvaToRgba = exports.hsvToRgb = exports.hsvaToHsla = exports.hsvToHsl = exports.hslaToHsva = exports.hslToHsv = exports.getStyleFromHsv = exports.rgbaToHsva = exports.rgbToHsv = void 0;
4
+ const engine_1 = require("@tsparticles/engine");
5
+ function rgbToHsv(rgb) {
6
+ const rgbPercent = {
7
+ r: rgb.r / 255,
8
+ g: rgb.g / 255,
9
+ b: rgb.b / 255,
10
+ }, xMax = Math.max(rgbPercent.r, rgbPercent.g, rgbPercent.b), xMin = Math.min(rgbPercent.r, rgbPercent.g, rgbPercent.b), v = xMax, c = xMax - xMin;
11
+ let h = 0;
12
+ if (v === rgbPercent.r) {
13
+ h = 60 * ((rgbPercent.g - rgbPercent.b) / c);
14
+ }
15
+ else if (v === rgbPercent.g) {
16
+ h = 60 * (2 + (rgbPercent.b - rgbPercent.r) / c);
17
+ }
18
+ else if (v === rgbPercent.b) {
19
+ h = 60 * (4 + (rgbPercent.r - rgbPercent.g) / c);
20
+ }
21
+ const s = !v ? 0 : c / v;
22
+ return {
23
+ h,
24
+ s: s * 100,
25
+ v: v * 100,
26
+ };
27
+ }
28
+ exports.rgbToHsv = rgbToHsv;
29
+ function rgbaToHsva(rgba) {
30
+ return Object.assign({ a: rgba.a }, rgbToHsv(rgba));
31
+ }
32
+ exports.rgbaToHsva = rgbaToHsva;
33
+ function getStyleFromHsv(color, opacity) {
34
+ return (0, engine_1.getStyleFromHsl)(hsvToHsl(color), opacity);
35
+ }
36
+ exports.getStyleFromHsv = getStyleFromHsv;
37
+ function hslToHsv(hsl) {
38
+ const l = hsl.l / 100, sl = hsl.s / 100, v = l + sl * Math.min(l, 1 - l), sv = !v ? 0 : 2 * (1 - l / v);
39
+ return {
40
+ h: hsl.h,
41
+ s: sv * 100,
42
+ v: v * 100,
43
+ };
44
+ }
45
+ exports.hslToHsv = hslToHsv;
46
+ function hslaToHsva(hsla) {
47
+ return Object.assign({ a: hsla.a }, hslToHsv(hsla));
48
+ }
49
+ exports.hslaToHsva = hslaToHsva;
50
+ function hsvToHsl(hsv) {
51
+ const v = hsv.v / 100, sv = hsv.s / 100, l = v * (1 - sv / 2), sl = l === 0 || l === 1 ? 0 : (v - l) / Math.min(l, 1 - l);
52
+ return {
53
+ h: hsv.h,
54
+ l: l * 100,
55
+ s: sl * 100,
56
+ };
57
+ }
58
+ exports.hsvToHsl = hsvToHsl;
59
+ function hsvaToHsla(hsva) {
60
+ return Object.assign({ a: hsva.a }, hsvToHsl(hsva));
61
+ }
62
+ exports.hsvaToHsla = hsvaToHsla;
63
+ function hsvToRgb(hsv) {
64
+ const result = { b: 0, g: 0, r: 0 }, hsvPercent = {
65
+ h: hsv.h / 60,
66
+ s: hsv.s / 100,
67
+ v: hsv.v / 100,
68
+ }, c = hsvPercent.v * hsvPercent.s, x = c * (1 - Math.abs((hsvPercent.h % 2) - 1));
69
+ let tempRgb;
70
+ if (hsvPercent.h >= 0 && hsvPercent.h <= 1) {
71
+ tempRgb = {
72
+ r: c,
73
+ g: x,
74
+ b: 0,
75
+ };
76
+ }
77
+ else if (hsvPercent.h > 1 && hsvPercent.h <= 2) {
78
+ tempRgb = {
79
+ r: x,
80
+ g: c,
81
+ b: 0,
82
+ };
83
+ }
84
+ else if (hsvPercent.h > 2 && hsvPercent.h <= 3) {
85
+ tempRgb = {
86
+ r: 0,
87
+ g: c,
88
+ b: x,
89
+ };
90
+ }
91
+ else if (hsvPercent.h > 3 && hsvPercent.h <= 4) {
92
+ tempRgb = {
93
+ r: 0,
94
+ g: x,
95
+ b: c,
96
+ };
97
+ }
98
+ else if (hsvPercent.h > 4 && hsvPercent.h <= 5) {
99
+ tempRgb = {
100
+ r: x,
101
+ g: 0,
102
+ b: c,
103
+ };
104
+ }
105
+ else if (hsvPercent.h > 5 && hsvPercent.h <= 6) {
106
+ tempRgb = {
107
+ r: c,
108
+ g: 0,
109
+ b: x,
110
+ };
111
+ }
112
+ if (tempRgb) {
113
+ const m = hsvPercent.v - c;
114
+ result.r = Math.floor((tempRgb.r + m) * 255);
115
+ result.g = Math.floor((tempRgb.g + m) * 255);
116
+ result.b = Math.floor((tempRgb.b + m) * 255);
117
+ }
118
+ return result;
119
+ }
120
+ exports.hsvToRgb = hsvToRgb;
121
+ function hsvaToRgba(hsva) {
122
+ return Object.assign({ a: hsva.a }, hsvToRgb(hsva));
123
+ }
124
+ exports.hsvaToRgba = hsvaToRgba;
125
+ class HsvColorManager {
126
+ constructor() {
127
+ this.key = "hsv";
128
+ this.stringPrefix = "hsv";
129
+ }
130
+ handleColor(color) {
131
+ var _a;
132
+ const colorValue = color.value, hsvColor = (_a = colorValue.hsv) !== null && _a !== void 0 ? _a : color.value;
133
+ if (hsvColor.h !== undefined && hsvColor.v !== undefined) {
134
+ return hsvToRgb(hsvColor);
135
+ }
136
+ }
137
+ handleRangeColor(color) {
138
+ var _a;
139
+ const colorValue = color.value, hsvColor = (_a = colorValue.hsv) !== null && _a !== void 0 ? _a : color.value;
140
+ if (hsvColor.h !== undefined && hsvColor.v !== undefined) {
141
+ return hsvToRgb({
142
+ h: (0, engine_1.getRangeValue)(hsvColor.h),
143
+ s: (0, engine_1.getRangeValue)(hsvColor.s),
144
+ v: (0, engine_1.getRangeValue)(hsvColor.v),
145
+ });
146
+ }
147
+ }
148
+ parseString(input) {
149
+ if (!input.startsWith("hsv")) {
150
+ return;
151
+ }
152
+ const regex = /hsva?\(\s*(\d+)°\s*,\s*(\d+)%\s*,\s*(\d+)%\s*(,\s*([\d.%]+)\s*)?\)/i, result = regex.exec(input);
153
+ return result
154
+ ? hsvaToRgba({
155
+ a: result.length > 4 ? (0, engine_1.parseAlpha)(result[5]) : 1,
156
+ h: parseInt(result[1], 10),
157
+ s: parseInt(result[2], 10),
158
+ v: parseInt(result[3], 10),
159
+ })
160
+ : undefined;
161
+ }
162
+ }
163
+ exports.HsvColorManager = HsvColorManager;
package/cjs/index.js ADDED
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.loadHsvColorPlugin = void 0;
4
+ const HsvColorManager_1 = require("./HsvColorManager");
5
+ const engine_1 = require("@tsparticles/engine");
6
+ function loadHsvColorPlugin() {
7
+ (0, engine_1.addColorManager)(new HsvColorManager_1.HsvColorManager());
8
+ }
9
+ exports.loadHsvColorPlugin = loadHsvColorPlugin;
@@ -0,0 +1,150 @@
1
+ import { getRangeValue, getStyleFromHsl, parseAlpha } from "@tsparticles/engine";
2
+ export function rgbToHsv(rgb) {
3
+ const rgbPercent = {
4
+ r: rgb.r / 255,
5
+ g: rgb.g / 255,
6
+ b: rgb.b / 255,
7
+ }, xMax = Math.max(rgbPercent.r, rgbPercent.g, rgbPercent.b), xMin = Math.min(rgbPercent.r, rgbPercent.g, rgbPercent.b), v = xMax, c = xMax - xMin;
8
+ let h = 0;
9
+ if (v === rgbPercent.r) {
10
+ h = 60 * ((rgbPercent.g - rgbPercent.b) / c);
11
+ }
12
+ else if (v === rgbPercent.g) {
13
+ h = 60 * (2 + (rgbPercent.b - rgbPercent.r) / c);
14
+ }
15
+ else if (v === rgbPercent.b) {
16
+ h = 60 * (4 + (rgbPercent.r - rgbPercent.g) / c);
17
+ }
18
+ const s = !v ? 0 : c / v;
19
+ return {
20
+ h,
21
+ s: s * 100,
22
+ v: v * 100,
23
+ };
24
+ }
25
+ export function rgbaToHsva(rgba) {
26
+ return Object.assign({ a: rgba.a }, rgbToHsv(rgba));
27
+ }
28
+ export function getStyleFromHsv(color, opacity) {
29
+ return getStyleFromHsl(hsvToHsl(color), opacity);
30
+ }
31
+ export function hslToHsv(hsl) {
32
+ const l = hsl.l / 100, sl = hsl.s / 100, v = l + sl * Math.min(l, 1 - l), sv = !v ? 0 : 2 * (1 - l / v);
33
+ return {
34
+ h: hsl.h,
35
+ s: sv * 100,
36
+ v: v * 100,
37
+ };
38
+ }
39
+ export function hslaToHsva(hsla) {
40
+ return Object.assign({ a: hsla.a }, hslToHsv(hsla));
41
+ }
42
+ export function hsvToHsl(hsv) {
43
+ const v = hsv.v / 100, sv = hsv.s / 100, l = v * (1 - sv / 2), sl = l === 0 || l === 1 ? 0 : (v - l) / Math.min(l, 1 - l);
44
+ return {
45
+ h: hsv.h,
46
+ l: l * 100,
47
+ s: sl * 100,
48
+ };
49
+ }
50
+ export function hsvaToHsla(hsva) {
51
+ return Object.assign({ a: hsva.a }, hsvToHsl(hsva));
52
+ }
53
+ export function hsvToRgb(hsv) {
54
+ const result = { b: 0, g: 0, r: 0 }, hsvPercent = {
55
+ h: hsv.h / 60,
56
+ s: hsv.s / 100,
57
+ v: hsv.v / 100,
58
+ }, c = hsvPercent.v * hsvPercent.s, x = c * (1 - Math.abs((hsvPercent.h % 2) - 1));
59
+ let tempRgb;
60
+ if (hsvPercent.h >= 0 && hsvPercent.h <= 1) {
61
+ tempRgb = {
62
+ r: c,
63
+ g: x,
64
+ b: 0,
65
+ };
66
+ }
67
+ else if (hsvPercent.h > 1 && hsvPercent.h <= 2) {
68
+ tempRgb = {
69
+ r: x,
70
+ g: c,
71
+ b: 0,
72
+ };
73
+ }
74
+ else if (hsvPercent.h > 2 && hsvPercent.h <= 3) {
75
+ tempRgb = {
76
+ r: 0,
77
+ g: c,
78
+ b: x,
79
+ };
80
+ }
81
+ else if (hsvPercent.h > 3 && hsvPercent.h <= 4) {
82
+ tempRgb = {
83
+ r: 0,
84
+ g: x,
85
+ b: c,
86
+ };
87
+ }
88
+ else if (hsvPercent.h > 4 && hsvPercent.h <= 5) {
89
+ tempRgb = {
90
+ r: x,
91
+ g: 0,
92
+ b: c,
93
+ };
94
+ }
95
+ else if (hsvPercent.h > 5 && hsvPercent.h <= 6) {
96
+ tempRgb = {
97
+ r: c,
98
+ g: 0,
99
+ b: x,
100
+ };
101
+ }
102
+ if (tempRgb) {
103
+ const m = hsvPercent.v - c;
104
+ result.r = Math.floor((tempRgb.r + m) * 255);
105
+ result.g = Math.floor((tempRgb.g + m) * 255);
106
+ result.b = Math.floor((tempRgb.b + m) * 255);
107
+ }
108
+ return result;
109
+ }
110
+ export function hsvaToRgba(hsva) {
111
+ return Object.assign({ a: hsva.a }, hsvToRgb(hsva));
112
+ }
113
+ export class HsvColorManager {
114
+ constructor() {
115
+ this.key = "hsv";
116
+ this.stringPrefix = "hsv";
117
+ }
118
+ handleColor(color) {
119
+ var _a;
120
+ const colorValue = color.value, hsvColor = (_a = colorValue.hsv) !== null && _a !== void 0 ? _a : color.value;
121
+ if (hsvColor.h !== undefined && hsvColor.v !== undefined) {
122
+ return hsvToRgb(hsvColor);
123
+ }
124
+ }
125
+ handleRangeColor(color) {
126
+ var _a;
127
+ const colorValue = color.value, hsvColor = (_a = colorValue.hsv) !== null && _a !== void 0 ? _a : color.value;
128
+ if (hsvColor.h !== undefined && hsvColor.v !== undefined) {
129
+ return hsvToRgb({
130
+ h: getRangeValue(hsvColor.h),
131
+ s: getRangeValue(hsvColor.s),
132
+ v: getRangeValue(hsvColor.v),
133
+ });
134
+ }
135
+ }
136
+ parseString(input) {
137
+ if (!input.startsWith("hsv")) {
138
+ return;
139
+ }
140
+ const regex = /hsva?\(\s*(\d+)°\s*,\s*(\d+)%\s*,\s*(\d+)%\s*(,\s*([\d.%]+)\s*)?\)/i, result = regex.exec(input);
141
+ return result
142
+ ? hsvaToRgba({
143
+ a: result.length > 4 ? parseAlpha(result[5]) : 1,
144
+ h: parseInt(result[1], 10),
145
+ s: parseInt(result[2], 10),
146
+ v: parseInt(result[3], 10),
147
+ })
148
+ : undefined;
149
+ }
150
+ }
package/esm/index.js ADDED
@@ -0,0 +1,5 @@
1
+ import { HsvColorManager } from "./HsvColorManager";
2
+ import { addColorManager } from "@tsparticles/engine";
3
+ export function loadHsvColorPlugin() {
4
+ addColorManager(new HsvColorManager());
5
+ }
package/package.json ADDED
@@ -0,0 +1,91 @@
1
+ {
2
+ "name": "@tsparticles/plugin-hsv-color",
3
+ "version": "3.0.0-alpha.0",
4
+ "description": "tsParticles HSV color plugin",
5
+ "homepage": "https://particles.js.org",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/matteobruni/tsparticles.git",
9
+ "directory": "plugins/hsvColor"
10
+ },
11
+ "keywords": [
12
+ "front-end",
13
+ "frontend",
14
+ "tsparticles",
15
+ "particles.js",
16
+ "particlesjs",
17
+ "particles",
18
+ "particle",
19
+ "canvas",
20
+ "jsparticles",
21
+ "xparticles",
22
+ "particles-js",
23
+ "particles-bg",
24
+ "particles-bg-vue",
25
+ "particles-ts",
26
+ "particles.ts",
27
+ "react-particles-js",
28
+ "react-particles.js",
29
+ "react-particles",
30
+ "react",
31
+ "reactjs",
32
+ "vue-particles",
33
+ "ngx-particles",
34
+ "angular-particles",
35
+ "particleground",
36
+ "vue",
37
+ "vuejs",
38
+ "preact",
39
+ "preactjs",
40
+ "jquery",
41
+ "angularjs",
42
+ "angular",
43
+ "typescript",
44
+ "javascript",
45
+ "animation",
46
+ "web",
47
+ "html5",
48
+ "web-design",
49
+ "webdesign",
50
+ "css",
51
+ "html",
52
+ "css3",
53
+ "animated",
54
+ "background",
55
+ "confetti",
56
+ "canvas",
57
+ "fireworks",
58
+ "fireworks-js",
59
+ "confetti-js",
60
+ "confettijs",
61
+ "fireworksjs",
62
+ "canvas-confetti",
63
+ "@tsparticles/plugin"
64
+ ],
65
+ "author": "Matteo Bruni <matteo.bruni@me.com>",
66
+ "license": "MIT",
67
+ "bugs": {
68
+ "url": "https://github.com/matteobruni/tsparticles/issues"
69
+ },
70
+ "funding": [
71
+ {
72
+ "type": "github",
73
+ "url": "https://github.com/sponsors/matteobruni"
74
+ },
75
+ {
76
+ "type": "buymeacoffee",
77
+ "url": "https://www.buymeacoffee.com/matteobruni"
78
+ }
79
+ ],
80
+ "main": "cjs/index.js",
81
+ "jsdelivr": "tsparticles.plugin.hsvColor.min.js",
82
+ "unpkg": "tsparticles.plugin.hsvColor.min.js",
83
+ "module": "esm/index.js",
84
+ "types": "types/index.d.ts",
85
+ "publishConfig": {
86
+ "access": "public"
87
+ },
88
+ "dependencies": {
89
+ "@tsparticles/engine": "^3.0.0-alpha.0"
90
+ }
91
+ }