@tsparticles/plugin-hsv-color 3.0.0-alpha.1 → 3.0.0-beta.1

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.1
8
8
  */
9
9
  (function webpackUniversalModuleDefinition(root, factory) {
10
10
  if(typeof exports === 'object' && typeof module === 'object')
@@ -91,7 +91,7 @@ __webpack_require__.r(__webpack_exports__);
91
91
 
92
92
  // EXPORTS
93
93
  __webpack_require__.d(__webpack_exports__, {
94
- "loadHsvColorPlugin": () => (/* binding */ loadHsvColorPlugin)
94
+ loadHsvColorPlugin: () => (/* binding */ loadHsvColorPlugin)
95
95
  });
96
96
 
97
97
  // EXTERNAL MODULE: external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"}
@@ -124,9 +124,10 @@ function rgbToHsv(rgb) {
124
124
  };
125
125
  }
126
126
  function rgbaToHsva(rgba) {
127
- return Object.assign({
128
- a: rgba.a
129
- }, rgbToHsv(rgba));
127
+ return {
128
+ a: rgba.a,
129
+ ...rgbToHsv(rgba)
130
+ };
130
131
  }
131
132
  function getStyleFromHsv(color, opacity) {
132
133
  return getStyleFromHsl(hsvToHsl(color), opacity);
@@ -143,9 +144,10 @@ function hslToHsv(hsl) {
143
144
  };
144
145
  }
145
146
  function hslaToHsva(hsla) {
146
- return Object.assign({
147
- a: hsla.a
148
- }, hslToHsv(hsla));
147
+ return {
148
+ a: hsla.a,
149
+ ...hslToHsv(hsla)
150
+ };
149
151
  }
150
152
  function hsvToHsl(hsv) {
151
153
  const v = hsv.v / 100,
@@ -159,9 +161,10 @@ function hsvToHsl(hsv) {
159
161
  };
160
162
  }
161
163
  function hsvaToHsla(hsva) {
162
- return Object.assign({
163
- a: hsva.a
164
- }, hsvToHsl(hsva));
164
+ return {
165
+ a: hsva.a,
166
+ ...hsvToHsl(hsva)
167
+ };
165
168
  }
166
169
  function hsvToRgb(hsv) {
167
170
  const result = {
@@ -223,9 +226,10 @@ function hsvToRgb(hsv) {
223
226
  return result;
224
227
  }
225
228
  function hsvaToRgba(hsva) {
226
- return Object.assign({
227
- a: hsva.a
228
- }, hsvToRgb(hsva));
229
+ return {
230
+ a: hsva.a,
231
+ ...hsvToRgb(hsva)
232
+ };
229
233
  }
230
234
  class HsvColorManager {
231
235
  constructor() {
@@ -233,17 +237,15 @@ class HsvColorManager {
233
237
  this.stringPrefix = "hsv";
234
238
  }
235
239
  handleColor(color) {
236
- var _a;
237
240
  const colorValue = color.value,
238
- hsvColor = (_a = colorValue.hsv) !== null && _a !== void 0 ? _a : color.value;
241
+ hsvColor = colorValue.hsv ?? color.value;
239
242
  if (hsvColor.h !== undefined && hsvColor.v !== undefined) {
240
243
  return hsvToRgb(hsvColor);
241
244
  }
242
245
  }
243
246
  handleRangeColor(color) {
244
- var _a;
245
247
  const colorValue = color.value,
246
- hsvColor = (_a = colorValue.hsv) !== null && _a !== void 0 ? _a : color.value;
248
+ hsvColor = colorValue.hsv ?? color.value;
247
249
  if (hsvColor.h !== undefined && hsvColor.v !== undefined) {
248
250
  return hsvToRgb({
249
251
  h: (0,engine_root_window_.getRangeValue)(hsvColor.h),
@@ -269,7 +271,7 @@ class HsvColorManager {
269
271
  ;// CONCATENATED MODULE: ./dist/browser/index.js
270
272
 
271
273
 
272
- function loadHsvColorPlugin() {
274
+ async function loadHsvColorPlugin() {
273
275
  (0,engine_root_window_.addColorManager)(new HsvColorManager());
274
276
  }
275
277
  })();
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see tsparticles.plugin.hsvColor.min.js.LICENSE.txt */
2
- !function(e,r){if("object"==typeof exports&&"object"==typeof module)module.exports=r(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],r);else{var t="object"==typeof exports?r(require("@tsparticles/engine")):r(e.window);for(var o in t)("object"==typeof exports?exports:e)[o]=t[o]}}(this,(e=>(()=>{"use strict";var r={533:r=>{r.exports=e}},t={};function o(e){var n=t[e];if(void 0!==n)return n.exports;var s=t[e]={exports:{}};return r[e](s,s.exports,o),s.exports}o.d=(e,r)=>{for(var t in r)o.o(r,t)&&!o.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},o.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};return(()=>{o.r(n),o.d(n,{loadHsvColorPlugin:()=>s});var e=o(533);function r(e){const r={b:0,g:0,r:0},t=e.h/60,o=e.s/100,n=e.v/100,s=n*o,a=s*(1-Math.abs(t%2-1));let i;if(t>=0&&t<=1?i={r:s,g:a,b:0}:t>1&&t<=2?i={r:a,g:s,b:0}:t>2&&t<=3?i={r:0,g:s,b:a}:t>3&&t<=4?i={r:0,g:a,b:s}:t>4&&t<=5?i={r:a,g:0,b:s}:t>5&&t<=6&&(i={r:s,g:0,b:a}),i){const e=n-s;r.r=Math.floor(255*(i.r+e)),r.g=Math.floor(255*(i.g+e)),r.b=Math.floor(255*(i.b+e))}return r}class t{constructor(){this.key="hsv",this.stringPrefix="hsv"}handleColor(e){var t;const o=null!==(t=e.value.hsv)&&void 0!==t?t:e.value;if(void 0!==o.h&&void 0!==o.v)return r(o)}handleRangeColor(t){var o;const n=null!==(o=t.value.hsv)&&void 0!==o?o:t.value;if(void 0!==n.h&&void 0!==n.v)return r({h:(0,e.getRangeValue)(n.h),s:(0,e.getRangeValue)(n.s),v:(0,e.getRangeValue)(n.v)})}parseString(t){if(!t.startsWith("hsv"))return;const o=/hsva?\(\s*(\d+)°\s*,\s*(\d+)%\s*,\s*(\d+)%\s*(,\s*([\d.%]+)\s*)?\)/i.exec(t);return o?(n={a:o.length>4?(0,e.parseAlpha)(o[5]):1,h:parseInt(o[1],10),s:parseInt(o[2],10),v:parseInt(o[3],10)},Object.assign({a:n.a},r(n))):void 0;var n}}function s(){(0,e.addColorManager)(new t)}})(),n})()));
2
+ !function(e,r){if("object"==typeof exports&&"object"==typeof module)module.exports=r(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],r);else{var t="object"==typeof exports?r(require("@tsparticles/engine")):r(e.window);for(var o in t)("object"==typeof exports?exports:e)[o]=t[o]}}(this,(e=>(()=>{"use strict";var r={533:r=>{r.exports=e}},t={};function o(e){var s=t[e];if(void 0!==s)return s.exports;var n=t[e]={exports:{}};return r[e](n,n.exports,o),n.exports}o.d=(e,r)=>{for(var t in r)o.o(r,t)&&!o.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},o.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var s={};return(()=>{o.r(s),o.d(s,{loadHsvColorPlugin:()=>n});var e=o(533);function r(e){const r={b:0,g:0,r:0},t=e.h/60,o=e.s/100,s=e.v/100,n=s*o,a=n*(1-Math.abs(t%2-1));let i;if(t>=0&&t<=1?i={r:n,g:a,b:0}:t>1&&t<=2?i={r:a,g:n,b:0}:t>2&&t<=3?i={r:0,g:n,b:a}:t>3&&t<=4?i={r:0,g:a,b:n}:t>4&&t<=5?i={r:a,g:0,b:n}:t>5&&t<=6&&(i={r:n,g:0,b:a}),i){const e=s-n;r.r=Math.floor(255*(i.r+e)),r.g=Math.floor(255*(i.g+e)),r.b=Math.floor(255*(i.b+e))}return r}class t{constructor(){this.key="hsv",this.stringPrefix="hsv"}handleColor(e){const t=e.value.hsv??e.value;if(void 0!==t.h&&void 0!==t.v)return r(t)}handleRangeColor(t){const o=t.value.hsv??t.value;if(void 0!==o.h&&void 0!==o.v)return r({h:(0,e.getRangeValue)(o.h),s:(0,e.getRangeValue)(o.s),v:(0,e.getRangeValue)(o.v)})}parseString(t){if(!t.startsWith("hsv"))return;const o=/hsva?\(\s*(\d+)°\s*,\s*(\d+)%\s*,\s*(\d+)%\s*(,\s*([\d.%]+)\s*)?\)/i.exec(t);return o?{a:(s={a:o.length>4?(0,e.parseAlpha)(o[5]):1,h:parseInt(o[1],10),s:parseInt(o[2],10),v:parseInt(o[3],10)}).a,...r(s)}:void 0;var s}}async function n(){(0,e.addColorManager)(new t)}})(),s})()));
@@ -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 HSV Color Plugin v3.0.0-beta.1 by Matteo Bruni */
@@ -1,4 +1,4 @@
1
- import type { IColor, IColorManager, IHsl, IHsla, IHsv, IHsva, IRangeColor, IRgb, IRgba } from "@tsparticles/engine";
1
+ import { type IColor, type IColorManager, type IHsl, type IHsla, type IHsv, type IHsva, type IRangeColor, type IRgb, type IRgba } from "@tsparticles/engine";
2
2
  export declare function rgbToHsv(rgb: IRgb): IHsv;
3
3
  export declare function rgbaToHsva(rgba: IRgba): IHsva;
4
4
  export declare function getStyleFromHsv(color: IHsv, opacity?: number): string;
package/types/index.d.ts CHANGED
@@ -1 +1 @@
1
- export declare function loadHsvColorPlugin(): void;
1
+ export declare function loadHsvColorPlugin(): Promise<void>;
@@ -36,7 +36,10 @@
36
36
  }
37
37
  exports.rgbToHsv = rgbToHsv;
38
38
  function rgbaToHsva(rgba) {
39
- return Object.assign({ a: rgba.a }, rgbToHsv(rgba));
39
+ return {
40
+ a: rgba.a,
41
+ ...rgbToHsv(rgba),
42
+ };
40
43
  }
41
44
  exports.rgbaToHsva = rgbaToHsva;
42
45
  function getStyleFromHsv(color, opacity) {
@@ -53,7 +56,10 @@
53
56
  }
54
57
  exports.hslToHsv = hslToHsv;
55
58
  function hslaToHsva(hsla) {
56
- return Object.assign({ a: hsla.a }, hslToHsv(hsla));
59
+ return {
60
+ a: hsla.a,
61
+ ...hslToHsv(hsla),
62
+ };
57
63
  }
58
64
  exports.hslaToHsva = hslaToHsva;
59
65
  function hsvToHsl(hsv) {
@@ -66,7 +72,10 @@
66
72
  }
67
73
  exports.hsvToHsl = hsvToHsl;
68
74
  function hsvaToHsla(hsva) {
69
- return Object.assign({ a: hsva.a }, hsvToHsl(hsva));
75
+ return {
76
+ a: hsva.a,
77
+ ...hsvToHsl(hsva),
78
+ };
70
79
  }
71
80
  exports.hsvaToHsla = hsvaToHsla;
72
81
  function hsvToRgb(hsv) {
@@ -128,7 +137,10 @@
128
137
  }
129
138
  exports.hsvToRgb = hsvToRgb;
130
139
  function hsvaToRgba(hsva) {
131
- return Object.assign({ a: hsva.a }, hsvToRgb(hsva));
140
+ return {
141
+ a: hsva.a,
142
+ ...hsvToRgb(hsva),
143
+ };
132
144
  }
133
145
  exports.hsvaToRgba = hsvaToRgba;
134
146
  class HsvColorManager {
@@ -137,15 +149,13 @@
137
149
  this.stringPrefix = "hsv";
138
150
  }
139
151
  handleColor(color) {
140
- var _a;
141
- const colorValue = color.value, hsvColor = (_a = colorValue.hsv) !== null && _a !== void 0 ? _a : color.value;
152
+ const colorValue = color.value, hsvColor = colorValue.hsv ?? color.value;
142
153
  if (hsvColor.h !== undefined && hsvColor.v !== undefined) {
143
154
  return hsvToRgb(hsvColor);
144
155
  }
145
156
  }
146
157
  handleRangeColor(color) {
147
- var _a;
148
- const colorValue = color.value, hsvColor = (_a = colorValue.hsv) !== null && _a !== void 0 ? _a : color.value;
158
+ const colorValue = color.value, hsvColor = colorValue.hsv ?? color.value;
149
159
  if (hsvColor.h !== undefined && hsvColor.v !== undefined) {
150
160
  return hsvToRgb({
151
161
  h: (0, engine_1.getRangeValue)(hsvColor.h),
package/umd/index.js CHANGED
@@ -4,16 +4,16 @@
4
4
  if (v !== undefined) module.exports = v;
5
5
  }
6
6
  else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports", "./HsvColorManager", "@tsparticles/engine"], factory);
7
+ define(["require", "exports", "./HsvColorManager.js", "@tsparticles/engine"], factory);
8
8
  }
9
9
  })(function (require, exports) {
10
10
  "use strict";
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.loadHsvColorPlugin = void 0;
13
- const HsvColorManager_1 = require("./HsvColorManager");
13
+ const HsvColorManager_js_1 = require("./HsvColorManager.js");
14
14
  const engine_1 = require("@tsparticles/engine");
15
- function loadHsvColorPlugin() {
16
- (0, engine_1.addColorManager)(new HsvColorManager_1.HsvColorManager());
15
+ async function loadHsvColorPlugin() {
16
+ (0, engine_1.addColorManager)(new HsvColorManager_js_1.HsvColorManager());
17
17
  }
18
18
  exports.loadHsvColorPlugin = loadHsvColorPlugin;
19
19
  });