@tsparticles/plugin-lch-color 4.0.0-alpha.2 → 4.0.0-alpha.20

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/912.min.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";(this.webpackChunk_tsparticles_plugin_lch_color=this.webpackChunk_tsparticles_plugin_lch_color||[]).push([[912],{912(e,a,t){t.d(a,{LchColorManager:()=>p});var l=t(303);let c={EPSILON:216/24389,KAPPA:24389/27,L_OFFSET:16,L_SCALE:116,A_SCALE:500,B_SCALE:200},r=3.2404542,s=-1.5371385,h=-.4985314,n=-.969266,u=1.8760108,o=.041556,A=.0556434,L=-.2040259,O=1.0572252;function _(e){let a=e.l,t=e.c,_=(0,l.degToRad)(e.h),i=t*Math.cos(_),p=t*Math.sin(_),S=(a+c.L_OFFSET)/c.L_SCALE,E=S+i/c.A_SCALE,d=S-p/c.B_SCALE,P=E**3,g=d**3,C=P>c.EPSILON?P:(c.L_SCALE*E-c.L_OFFSET)/c.KAPPA,F=a>c.KAPPA*c.EPSILON?S**3:a/c.KAPPA,b=g>c.EPSILON?g:(c.L_SCALE*d-c.L_OFFSET)/c.KAPPA,w=.95047*C,v=+F,j=1.08883*b,K=e=>Math.round(255*(0,l.clamp)(e<=.0031308?12.92*e:1.055*Math.pow(e,l.inverseFactorNumerator/2.4)-.055,0,1));return{r:K(r*w+s*v+h*j),g:K(n*w+u*v+o*j),b:K(A*w+L*v+O*j)}}let i=/lch\(\s*(\d+(\.\d+)?)%\s+(\d+(\.\d+)?)\s+(\d+(\.\d+)?)(?:\s*\/\s*(0|1|0?\.\d+|\d{1,3}%))?\s*\)/i;class p{accepts(e){return e.startsWith("lch")}handleColor(e){let a=e.value.lch??e.value;if(Object.hasOwn(a,"l")&&Object.hasOwn(a,"c")&&Object.hasOwn(a,"h"))return _(a)}handleRangeColor(e){let a=e.value.lch??e.value;if(Object.hasOwn(a,"l")&&Object.hasOwn(a,"c")&&Object.hasOwn(a,"h"))return _({l:(0,l.getRangeValue)(a.l),c:(0,l.getRangeValue)(a.c),h:(0,l.getRangeValue)(a.h)})}parseString(e){var a;if(!this.accepts(e))return;let t=i.exec(e);return t?{a:(a={a:t[7]?(0,l.parseAlpha)(t[7]):1,c:parseFloat(t[3]??"0"),h:parseFloat(t[5]??"0"),l:parseFloat(t[1]??"0")}).a,..._(a)}:void 0}}}}]);
@@ -2,22 +2,19 @@ import { getRangeValue, parseAlpha, } from "@tsparticles/engine";
2
2
  import { lchToRgb, lchaToRgba } from "./utils.js";
3
3
  const lchRegex = /lch\(\s*(\d+(\.\d+)?)%\s+(\d+(\.\d+)?)\s+(\d+(\.\d+)?)(?:\s*\/\s*(0|1|0?\.\d+|\d{1,3}%))?\s*\)/i;
4
4
  export class LchColorManager {
5
- constructor() {
6
- this.key = "lch";
7
- }
8
5
  accepts(input) {
9
6
  return input.startsWith("lch");
10
7
  }
11
8
  handleColor(color) {
12
9
  const colorValue = color.value, lchColor = colorValue.lch ?? color.value;
13
- if (!Object.hasOwn(lchColor, "l") && !Object.hasOwn(lchColor, "c") && !Object.hasOwn(lchColor, "h")) {
10
+ if (!Object.hasOwn(lchColor, "l") || !Object.hasOwn(lchColor, "c") || !Object.hasOwn(lchColor, "h")) {
14
11
  return;
15
12
  }
16
13
  return lchToRgb(lchColor);
17
14
  }
18
15
  handleRangeColor(color) {
19
16
  const colorValue = color.value, lchColor = colorValue.lch ?? color.value;
20
- if (!Object.hasOwn(lchColor, "l") && !Object.hasOwn(lchColor, "c") && !Object.hasOwn(lchColor, "h")) {
17
+ if (!Object.hasOwn(lchColor, "l") || !Object.hasOwn(lchColor, "c") || !Object.hasOwn(lchColor, "h")) {
21
18
  return;
22
19
  }
23
20
  return lchToRgb({
package/browser/index.js CHANGED
@@ -1,7 +1,7 @@
1
- export function loadLchColorPlugin(engine) {
2
- engine.checkVersion("4.0.0-alpha.2");
3
- engine.register(async (e) => {
1
+ export async function loadLchColorPlugin(engine) {
2
+ engine.checkVersion("4.0.0-alpha.20");
3
+ await engine.register(async (e) => {
4
4
  const { LchColorManager } = await import("./LchColorManager.js");
5
- e.addColorManager(new LchColorManager());
5
+ e.addColorManager("lch", new LchColorManager());
6
6
  });
7
7
  }
@@ -2,22 +2,19 @@ import { getRangeValue, parseAlpha, } from "@tsparticles/engine";
2
2
  import { lchToRgb, lchaToRgba } from "./utils.js";
3
3
  const lchRegex = /lch\(\s*(\d+(\.\d+)?)%\s+(\d+(\.\d+)?)\s+(\d+(\.\d+)?)(?:\s*\/\s*(0|1|0?\.\d+|\d{1,3}%))?\s*\)/i;
4
4
  export class LchColorManager {
5
- constructor() {
6
- this.key = "lch";
7
- }
8
5
  accepts(input) {
9
6
  return input.startsWith("lch");
10
7
  }
11
8
  handleColor(color) {
12
9
  const colorValue = color.value, lchColor = colorValue.lch ?? color.value;
13
- if (!Object.hasOwn(lchColor, "l") && !Object.hasOwn(lchColor, "c") && !Object.hasOwn(lchColor, "h")) {
10
+ if (!Object.hasOwn(lchColor, "l") || !Object.hasOwn(lchColor, "c") || !Object.hasOwn(lchColor, "h")) {
14
11
  return;
15
12
  }
16
13
  return lchToRgb(lchColor);
17
14
  }
18
15
  handleRangeColor(color) {
19
16
  const colorValue = color.value, lchColor = colorValue.lch ?? color.value;
20
- if (!Object.hasOwn(lchColor, "l") && !Object.hasOwn(lchColor, "c") && !Object.hasOwn(lchColor, "h")) {
17
+ if (!Object.hasOwn(lchColor, "l") || !Object.hasOwn(lchColor, "c") || !Object.hasOwn(lchColor, "h")) {
21
18
  return;
22
19
  }
23
20
  return lchToRgb({
package/cjs/index.js CHANGED
@@ -1,7 +1,7 @@
1
- export function loadLchColorPlugin(engine) {
2
- engine.checkVersion("4.0.0-alpha.2");
3
- engine.register(async (e) => {
1
+ export async function loadLchColorPlugin(engine) {
2
+ engine.checkVersion("4.0.0-alpha.20");
3
+ await engine.register(async (e) => {
4
4
  const { LchColorManager } = await import("./LchColorManager.js");
5
- e.addColorManager(new LchColorManager());
5
+ e.addColorManager("lch", new LchColorManager());
6
6
  });
7
7
  }
@@ -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
- * v4.0.0-alpha.2
7
+ * v4.0.0-alpha.20
8
8
  */
9
9
  "use strict";
10
10
  /*
@@ -23,7 +23,7 @@
23
23
  \*****************************************/
24
24
  (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
25
25
 
26
- eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ LchColorManager: () => (/* binding */ LchColorManager)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils.js */ \"./dist/browser/utils.js\");\n\n\nconst lchRegex = /lch\\(\\s*(\\d+(\\.\\d+)?)%\\s+(\\d+(\\.\\d+)?)\\s+(\\d+(\\.\\d+)?)(?:\\s*\\/\\s*(0|1|0?\\.\\d+|\\d{1,3}%))?\\s*\\)/i;\nclass LchColorManager {\n constructor() {\n this.key = \"lch\";\n }\n accepts(input) {\n return input.startsWith(\"lch\");\n }\n handleColor(color) {\n const colorValue = color.value,\n lchColor = colorValue.lch ?? color.value;\n if (!Object.hasOwn(lchColor, \"l\") && !Object.hasOwn(lchColor, \"c\") && !Object.hasOwn(lchColor, \"h\")) {\n return;\n }\n return (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.lchToRgb)(lchColor);\n }\n handleRangeColor(color) {\n const colorValue = color.value,\n lchColor = colorValue.lch ?? color.value;\n if (!Object.hasOwn(lchColor, \"l\") && !Object.hasOwn(lchColor, \"c\") && !Object.hasOwn(lchColor, \"h\")) {\n return;\n }\n return (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.lchToRgb)({\n l: (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(lchColor.l),\n c: (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(lchColor.c),\n h: (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(lchColor.h)\n });\n }\n parseString(input) {\n if (!this.accepts(input)) {\n return;\n }\n const result = lchRegex.exec(input),\n indexes = {\n l: 1,\n c: 3,\n h: 5,\n a: 7\n },\n defaultAlpha = 1;\n return result ? (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.lchaToRgba)({\n a: result[indexes.a] ? (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.parseAlpha)(result[indexes.a]) : defaultAlpha,\n c: parseFloat(result[indexes.c] ?? \"0\"),\n h: parseFloat(result[indexes.h] ?? \"0\"),\n l: parseFloat(result[indexes.l] ?? \"0\")\n }) : undefined;\n }\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-lch-color/./dist/browser/LchColorManager.js?\n}");
26
+ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ LchColorManager: () => (/* binding */ LchColorManager)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils.js */ \"./dist/browser/utils.js\");\n\n\nconst lchRegex = /lch\\(\\s*(\\d+(\\.\\d+)?)%\\s+(\\d+(\\.\\d+)?)\\s+(\\d+(\\.\\d+)?)(?:\\s*\\/\\s*(0|1|0?\\.\\d+|\\d{1,3}%))?\\s*\\)/i;\nclass LchColorManager {\n accepts(input) {\n return input.startsWith(\"lch\");\n }\n handleColor(color) {\n const colorValue = color.value, lchColor = colorValue.lch ?? color.value;\n if (!Object.hasOwn(lchColor, \"l\") || !Object.hasOwn(lchColor, \"c\") || !Object.hasOwn(lchColor, \"h\")) {\n return;\n }\n return (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.lchToRgb)(lchColor);\n }\n handleRangeColor(color) {\n const colorValue = color.value, lchColor = colorValue.lch ?? color.value;\n if (!Object.hasOwn(lchColor, \"l\") || !Object.hasOwn(lchColor, \"c\") || !Object.hasOwn(lchColor, \"h\")) {\n return;\n }\n return (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.lchToRgb)({\n l: (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(lchColor.l),\n c: (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(lchColor.c),\n h: (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(lchColor.h)\n });\n }\n parseString(input) {\n if (!this.accepts(input)) {\n return;\n }\n const result = lchRegex.exec(input), indexes = {\n l: 1,\n c: 3,\n h: 5,\n a: 7\n }, defaultAlpha = 1;\n return result ? (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.lchaToRgba)({\n a: result[indexes.a] ? (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.parseAlpha)(result[indexes.a]) : defaultAlpha,\n c: parseFloat(result[indexes.c] ?? \"0\"),\n h: parseFloat(result[indexes.h] ?? \"0\"),\n l: parseFloat(result[indexes.l] ?? \"0\")\n }) : undefined;\n }\n}\n\n\n//# sourceURL=webpack://@tsparticles/plugin-lch-color/./dist/browser/LchColorManager.js?\n}");
27
27
 
28
28
  /***/ },
29
29
 
@@ -33,7 +33,7 @@ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpa
33
33
  \*******************************/
34
34
  (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
35
35
 
36
- eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ getStyleFromLch: () => (/* binding */ getStyleFromLch),\n/* harmony export */ lchToRgb: () => (/* binding */ lchToRgb),\n/* harmony export */ lchaToRgba: () => (/* binding */ lchaToRgba)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nconst RGB = {\n MAX: 255\n },\n WHITE_POINT_D65 = {\n X: 0.95047,\n Y: 1.0,\n Z: 1.08883\n },\n CIE = {\n LAB_EPSILON_NUMERATOR: 216,\n LAB_EPSILON_DENOMINATOR: 24389,\n LAB_KAPPA_NUMERATOR: 24389,\n LAB_KAPPA_DENOMINATOR: 27,\n LAB_L_OFFSET: 16,\n LAB_L_SCALE: 116,\n LAB_A_SCALE: 500,\n LAB_B_SCALE: 200\n },\n LAB = {\n EPSILON: CIE.LAB_EPSILON_NUMERATOR / CIE.LAB_EPSILON_DENOMINATOR,\n KAPPA: CIE.LAB_KAPPA_NUMERATOR / CIE.LAB_KAPPA_DENOMINATOR,\n L_OFFSET: CIE.LAB_L_OFFSET,\n L_SCALE: CIE.LAB_L_SCALE,\n A_SCALE: CIE.LAB_A_SCALE,\n B_SCALE: CIE.LAB_B_SCALE\n },\n XYZ_TO_LINEAR_RGB = {\n r: {\n x: 3.2404542,\n y: -1.5371385,\n z: -0.4985314\n },\n g: {\n x: -0.969266,\n y: 1.8760108,\n z: 0.041556\n },\n b: {\n x: 0.0556434,\n y: -0.2040259,\n z: 1.0572252\n }\n },\n SRGB = {\n GAMMA: 2.4,\n LINEAR_THRESHOLD: 0.0031308,\n LINEAR_SCALE: 12.92,\n SCALE: 1.055,\n OFFSET: 0.055\n },\n minSrgbValue = 0,\n maxSrgbValue = 1;\nfunction lchToRgb(lch) {\n const L = lch.l,\n C = lch.c,\n hRad = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.degToRad)(lch.h),\n a = C * Math.cos(hRad),\n b = C * Math.sin(hRad),\n fy = (L + LAB.L_OFFSET) / LAB.L_SCALE,\n fx = fy + a / LAB.A_SCALE,\n fz = fy - b / LAB.B_SCALE,\n cubic = 3,\n fx3 = fx ** cubic,\n fz3 = fz ** cubic,\n xr = fx3 > LAB.EPSILON ? fx3 : (LAB.L_SCALE * fx - LAB.L_OFFSET) / LAB.KAPPA,\n yr = L > LAB.KAPPA * LAB.EPSILON ? fy ** cubic : L / LAB.KAPPA,\n zr = fz3 > LAB.EPSILON ? fz3 : (LAB.L_SCALE * fz - LAB.L_OFFSET) / LAB.KAPPA,\n X = xr * WHITE_POINT_D65.X,\n Y = yr * WHITE_POINT_D65.Y,\n Z = zr * WHITE_POINT_D65.Z,\n rLinear = XYZ_TO_LINEAR_RGB.r.x * X + XYZ_TO_LINEAR_RGB.r.y * Y + XYZ_TO_LINEAR_RGB.r.z * Z,\n gLinear = XYZ_TO_LINEAR_RGB.g.x * X + XYZ_TO_LINEAR_RGB.g.y * Y + XYZ_TO_LINEAR_RGB.g.z * Z,\n bLinear = XYZ_TO_LINEAR_RGB.b.x * X + XYZ_TO_LINEAR_RGB.b.y * Y + XYZ_TO_LINEAR_RGB.b.z * Z,\n toSrgb = x => x <= SRGB.LINEAR_THRESHOLD ? SRGB.LINEAR_SCALE * x : SRGB.SCALE * Math.pow(x, _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.inverseFactorNumerator / SRGB.GAMMA) - SRGB.OFFSET,\n toSrgbFixed = num => Math.round((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.clamp)(toSrgb(num), minSrgbValue, maxSrgbValue) * RGB.MAX);\n return {\n r: toSrgbFixed(rLinear),\n g: toSrgbFixed(gLinear),\n b: toSrgbFixed(bLinear)\n };\n}\nfunction lchaToRgba(lcha) {\n return {\n a: lcha.a,\n ...lchToRgb(lcha)\n };\n}\nfunction getStyleFromLch(color, opacity) {\n const {\n l,\n c,\n h\n } = color,\n alpha = opacity !== undefined ? `/ ${opacity.toString()}` : \"\";\n return `lch(${l.toString()}%, ${c.toString()}%, ${h.toString()}°${alpha})`;\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-lch-color/./dist/browser/utils.js?\n}");
36
+ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ getStyleFromLch: () => (/* binding */ getStyleFromLch),\n/* harmony export */ lchToRgb: () => (/* binding */ lchToRgb),\n/* harmony export */ lchaToRgba: () => (/* binding */ lchaToRgba)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nconst RGB = {\n MAX: 255\n}, WHITE_POINT_D65 = {\n X: 0.95047,\n Y: 1.0,\n Z: 1.08883\n}, CIE = {\n LAB_EPSILON_NUMERATOR: 216,\n LAB_EPSILON_DENOMINATOR: 24389,\n LAB_KAPPA_NUMERATOR: 24389,\n LAB_KAPPA_DENOMINATOR: 27,\n LAB_L_OFFSET: 16,\n LAB_L_SCALE: 116,\n LAB_A_SCALE: 500,\n LAB_B_SCALE: 200\n}, LAB = {\n EPSILON: CIE.LAB_EPSILON_NUMERATOR / CIE.LAB_EPSILON_DENOMINATOR,\n KAPPA: CIE.LAB_KAPPA_NUMERATOR / CIE.LAB_KAPPA_DENOMINATOR,\n L_OFFSET: CIE.LAB_L_OFFSET,\n L_SCALE: CIE.LAB_L_SCALE,\n A_SCALE: CIE.LAB_A_SCALE,\n B_SCALE: CIE.LAB_B_SCALE\n}, XYZ_TO_LINEAR_RGB = {\n r: {\n x: 3.2404542,\n y: -1.5371385,\n z: -0.4985314\n },\n g: {\n x: -0.969266,\n y: 1.8760108,\n z: 0.041556\n },\n b: {\n x: 0.0556434,\n y: -0.2040259,\n z: 1.0572252\n }\n}, SRGB = {\n GAMMA: 2.4,\n LINEAR_THRESHOLD: 0.0031308,\n LINEAR_SCALE: 12.92,\n SCALE: 1.055,\n OFFSET: 0.055\n}, minSrgbValue = 0, maxSrgbValue = 1;\nfunction lchToRgb(lch) {\n const L = lch.l, C = lch.c, hRad = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.degToRad)(lch.h), a = C * Math.cos(hRad), b = C * Math.sin(hRad), fy = (L + LAB.L_OFFSET) / LAB.L_SCALE, fx = fy + a / LAB.A_SCALE, fz = fy - b / LAB.B_SCALE, cubic = 3, fx3 = fx ** cubic, fz3 = fz ** cubic, xr = fx3 > LAB.EPSILON ? fx3 : (LAB.L_SCALE * fx - LAB.L_OFFSET) / LAB.KAPPA, yr = L > LAB.KAPPA * LAB.EPSILON ? fy ** cubic : L / LAB.KAPPA, zr = fz3 > LAB.EPSILON ? fz3 : (LAB.L_SCALE * fz - LAB.L_OFFSET) / LAB.KAPPA, X = xr * WHITE_POINT_D65.X, Y = yr * WHITE_POINT_D65.Y, Z = zr * WHITE_POINT_D65.Z, rLinear = XYZ_TO_LINEAR_RGB.r.x * X + XYZ_TO_LINEAR_RGB.r.y * Y + XYZ_TO_LINEAR_RGB.r.z * Z, gLinear = XYZ_TO_LINEAR_RGB.g.x * X + XYZ_TO_LINEAR_RGB.g.y * Y + XYZ_TO_LINEAR_RGB.g.z * Z, bLinear = XYZ_TO_LINEAR_RGB.b.x * X + XYZ_TO_LINEAR_RGB.b.y * Y + XYZ_TO_LINEAR_RGB.b.z * Z, toSrgb = (x)=>x <= SRGB.LINEAR_THRESHOLD ? SRGB.LINEAR_SCALE * x : SRGB.SCALE * Math.pow(x, _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.inverseFactorNumerator / SRGB.GAMMA) - SRGB.OFFSET, toSrgbFixed = (num)=>Math.round((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.clamp)(toSrgb(num), minSrgbValue, maxSrgbValue) * RGB.MAX);\n return {\n r: toSrgbFixed(rLinear),\n g: toSrgbFixed(gLinear),\n b: toSrgbFixed(bLinear)\n };\n}\nfunction lchaToRgba(lcha) {\n return {\n a: lcha.a,\n ...lchToRgb(lcha)\n };\n}\nfunction getStyleFromLch(color, opacity) {\n const { l, c, h } = color, alpha = opacity !== undefined ? `/ ${opacity.toString()}` : \"\";\n return `lch(${l.toString()}%, ${c.toString()}%, ${h.toString()}°${alpha})`;\n}\n\n\n//# sourceURL=webpack://@tsparticles/plugin-lch-color/./dist/browser/utils.js?\n}");
37
37
 
38
38
  /***/ }
39
39
 
@@ -2,22 +2,19 @@ import { getRangeValue, parseAlpha, } from "@tsparticles/engine";
2
2
  import { lchToRgb, lchaToRgba } from "./utils.js";
3
3
  const lchRegex = /lch\(\s*(\d+(\.\d+)?)%\s+(\d+(\.\d+)?)\s+(\d+(\.\d+)?)(?:\s*\/\s*(0|1|0?\.\d+|\d{1,3}%))?\s*\)/i;
4
4
  export class LchColorManager {
5
- constructor() {
6
- this.key = "lch";
7
- }
8
5
  accepts(input) {
9
6
  return input.startsWith("lch");
10
7
  }
11
8
  handleColor(color) {
12
9
  const colorValue = color.value, lchColor = colorValue.lch ?? color.value;
13
- if (!Object.hasOwn(lchColor, "l") && !Object.hasOwn(lchColor, "c") && !Object.hasOwn(lchColor, "h")) {
10
+ if (!Object.hasOwn(lchColor, "l") || !Object.hasOwn(lchColor, "c") || !Object.hasOwn(lchColor, "h")) {
14
11
  return;
15
12
  }
16
13
  return lchToRgb(lchColor);
17
14
  }
18
15
  handleRangeColor(color) {
19
16
  const colorValue = color.value, lchColor = colorValue.lch ?? color.value;
20
- if (!Object.hasOwn(lchColor, "l") && !Object.hasOwn(lchColor, "c") && !Object.hasOwn(lchColor, "h")) {
17
+ if (!Object.hasOwn(lchColor, "l") || !Object.hasOwn(lchColor, "c") || !Object.hasOwn(lchColor, "h")) {
21
18
  return;
22
19
  }
23
20
  return lchToRgb({
package/esm/index.js CHANGED
@@ -1,7 +1,7 @@
1
- export function loadLchColorPlugin(engine) {
2
- engine.checkVersion("4.0.0-alpha.2");
3
- engine.register(async (e) => {
1
+ export async function loadLchColorPlugin(engine) {
2
+ engine.checkVersion("4.0.0-alpha.20");
3
+ await engine.register(async (e) => {
4
4
  const { LchColorManager } = await import("./LchColorManager.js");
5
- e.addColorManager(new LchColorManager());
5
+ e.addColorManager("lch", new LchColorManager());
6
6
  });
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsparticles/plugin-lch-color",
3
- "version": "4.0.0-alpha.2",
3
+ "version": "4.0.0-alpha.20",
4
4
  "description": "tsParticles LCH color plugin",
5
5
  "homepage": "https://particles.js.org",
6
6
  "repository": {
@@ -100,7 +100,7 @@
100
100
  "./package.json": "./package.json"
101
101
  },
102
102
  "dependencies": {
103
- "@tsparticles/engine": "4.0.0-alpha.2"
103
+ "@tsparticles/engine": "4.0.0-alpha.20"
104
104
  },
105
105
  "publishConfig": {
106
106
  "access": "public"