@tsparticles/plugin-oklch-color 3.9.1 → 4.0.0-alpha.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.9.1
7
+ * v4.0.0-alpha.1
8
8
  */
9
9
  /*
10
10
  * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
@@ -28,55 +28,25 @@ return /******/ (() => { // webpackBootstrap
28
28
  /******/ "use strict";
29
29
  /******/ var __webpack_modules__ = ({
30
30
 
31
- /***/ "./dist/browser/LchColorManager.js":
32
- /*!*****************************************!*\
33
- !*** ./dist/browser/LchColorManager.js ***!
34
- \*****************************************/
35
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
36
-
37
- 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 _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils.js */ \"./dist/browser/utils.js\");\n\n\nclass LchColorManager {\n constructor() {\n this.key = \"lch\";\n this.stringPrefix = \"lch\";\n }\n handleColor(color) {\n const colorValue = color.value,\n lchColor = colorValue.lch ?? color.value;\n if (lchColor.l !== undefined && lchColor.c !== undefined && lchColor.h !== undefined) {\n return (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.lchToRgb)(lchColor);\n }\n }\n handleRangeColor(color) {\n const colorValue = color.value,\n lchColor = colorValue.lch ?? color.value;\n if (lchColor.l !== undefined && lchColor.c !== undefined && lchColor.h !== undefined) {\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 }\n parseString(input) {\n const isLch = input.startsWith(\"lch\");\n if (!isLch) {\n return;\n }\n const regex = /lch\\(\\s*(\\d+(\\.\\d+)?)%\\s+(\\d+(\\.\\d+)?)\\s+(\\d+(\\.\\d+)?)(?:\\s*\\/\\s*(0|1|0?\\.\\d+|\\d{1,3}%))?\\s*\\)/i,\n result = regex.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]),\n h: parseFloat(result[indexes.h]),\n l: parseFloat(result[indexes.l])\n }) : undefined;\n }\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-oklch-color/./dist/browser/LchColorManager.js?\n}");
38
-
39
- /***/ }),
40
-
41
- /***/ "./dist/browser/OklchColorManager.js":
42
- /*!*******************************************!*\
43
- !*** ./dist/browser/OklchColorManager.js ***!
44
- \*******************************************/
45
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
46
-
47
- eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ OklchColorManager: () => (/* binding */ OklchColorManager)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils.js */ \"./dist/browser/utils.js\");\n\n\nclass OklchColorManager {\n constructor() {\n this.key = \"oklch\";\n this.stringPrefix = \"oklch\";\n }\n handleColor(color) {\n const colorValue = color.value,\n oklchColor = colorValue.oklch ?? color.value;\n if (oklchColor.l !== undefined && oklchColor.c !== undefined && oklchColor.h !== undefined) {\n return (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.oklchToRgb)(oklchColor);\n }\n }\n handleRangeColor(color) {\n const colorValue = color.value,\n oklchColor = colorValue.oklch ?? color.value;\n if (oklchColor.l !== undefined && oklchColor.c !== undefined && oklchColor.h !== undefined) {\n return (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.oklchToRgb)({\n l: (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(oklchColor.l),\n c: (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(oklchColor.c),\n h: (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(oklchColor.h)\n });\n }\n }\n parseString(input) {\n const isOklch = input.startsWith(\"oklch\");\n if (!isOklch) {\n return;\n }\n const regex = /oklch\\(\\s*(\\d+(\\.\\d+)?)%\\s+(\\d+(\\.\\d+)?)\\s+(\\d+(\\.\\d+)?)(°)?(?:\\s*\\/\\s*(0|1|0?\\.\\d+|\\d{1,3}%))?\\s*\\)/i,\n result = regex.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__.oklchaToRgba)({\n a: result[indexes.a] ? (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.parseAlpha)(result[indexes.a]) : defaultAlpha,\n c: parseFloat(result[indexes.c]),\n h: parseFloat(result[indexes.h]),\n l: parseFloat(result[indexes.l])\n }) : undefined;\n }\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-oklch-color/./dist/browser/OklchColorManager.js?\n}");
48
-
49
- /***/ }),
50
-
51
- /***/ "./dist/browser/index.js":
31
+ /***/ "./dist/browser/index.js"
52
32
  /*!*******************************!*\
53
33
  !*** ./dist/browser/index.js ***!
54
34
  \*******************************/
55
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
56
-
57
- eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadOklchColorPlugin: () => (/* binding */ loadOklchColorPlugin)\n/* harmony export */ });\n/* harmony import */ var _LchColorManager_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./LchColorManager.js */ \"./dist/browser/LchColorManager.js\");\n/* harmony import */ var _OklchColorManager_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./OklchColorManager.js */ \"./dist/browser/OklchColorManager.js\");\n\n\nasync function loadOklchColorPlugin(engine, refresh = true) {\n engine.checkVersion(\"3.9.1\");\n await engine.addColorManager(new _OklchColorManager_js__WEBPACK_IMPORTED_MODULE_1__.OklchColorManager(), refresh);\n await engine.addColorManager(new _LchColorManager_js__WEBPACK_IMPORTED_MODULE_0__.LchColorManager(), refresh);\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-oklch-color/./dist/browser/index.js?\n}");
58
-
59
- /***/ }),
60
-
61
- /***/ "./dist/browser/utils.js":
62
- /*!*******************************!*\
63
- !*** ./dist/browser/utils.js ***!
64
- \*******************************/
65
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
35
+ (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
66
36
 
67
- eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ getStyleFromOklch: () => (/* binding */ getStyleFromOklch),\n/* harmony export */ lchToRgb: () => (/* binding */ lchToRgb),\n/* harmony export */ lchaToRgba: () => (/* binding */ lchaToRgba),\n/* harmony export */ oklchToRgb: () => (/* binding */ oklchToRgb),\n/* harmony export */ oklchaToRgba: () => (/* binding */ oklchaToRgba)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__);\n\nconst rgbFactor = 255,\n fullDegree = 360;\nfunction lchToRgb(lch) {\n const l = lch.l / _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.percentDenominator,\n c = lch.c,\n h = lch.h / fullDegree,\n result = {\n r: 0,\n g: 0,\n b: 0\n };\n result.r = Math.floor(l * rgbFactor);\n result.g = Math.floor(c * rgbFactor);\n result.b = Math.floor(h * rgbFactor);\n return result;\n}\nfunction lchaToRgba(lcha) {\n return {\n a: lcha.a,\n ...lchToRgb(lcha)\n };\n}\nfunction oklchToRgb(oklch) {\n const l = oklch.l / _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.percentDenominator,\n c = oklch.c / _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.percentDenominator,\n h = oklch.h / fullDegree,\n result = {\n r: 0,\n g: 0,\n b: 0\n };\n result.r = Math.floor(l * rgbFactor);\n result.g = Math.floor(c * rgbFactor);\n result.b = Math.floor(h * rgbFactor);\n return result;\n}\nfunction oklchaToRgba(oklcha) {\n return {\n a: oklcha.a,\n ...oklchToRgb(oklcha)\n };\n}\nfunction getStyleFromOklch(color, opacity) {\n const {\n l,\n c,\n h\n } = color,\n alpha = opacity !== undefined ? `, ${opacity}` : \"\";\n return `oklch(${l}%, ${c}%, ${h}°${alpha})`;\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-oklch-color/./dist/browser/utils.js?\n}");
37
+ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadOklchColorPlugin: () => (/* binding */ loadOklchColorPlugin)\n/* harmony export */ });\nfunction loadOklchColorPlugin(engine) {\n engine.checkVersion(\"4.0.0-alpha.1\");\n engine.register(async e => {\n const {\n OklchColorManager\n } = await __webpack_require__.e(/*! import() */ \"dist_browser_OklchColorManager_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./OklchColorManager.js */ \"./dist/browser/OklchColorManager.js\"));\n e.addColorManager(new OklchColorManager());\n });\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-oklch-color/./dist/browser/index.js?\n}");
68
38
 
69
- /***/ }),
39
+ /***/ },
70
40
 
71
- /***/ "@tsparticles/engine":
41
+ /***/ "@tsparticles/engine"
72
42
  /*!*********************************************************************************************************************************!*\
73
43
  !*** external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"} ***!
74
44
  \*********************************************************************************************************************************/
75
- /***/ ((module) => {
45
+ (module) {
76
46
 
77
47
  module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__;
78
48
 
79
- /***/ })
49
+ /***/ }
80
50
 
81
51
  /******/ });
82
52
  /************************************************************************/
@@ -90,6 +60,12 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__;
90
60
  /******/ if (cachedModule !== undefined) {
91
61
  /******/ return cachedModule.exports;
92
62
  /******/ }
63
+ /******/ // Check if module exists (development only)
64
+ /******/ if (__webpack_modules__[moduleId] === undefined) {
65
+ /******/ var e = new Error("Cannot find module '" + moduleId + "'");
66
+ /******/ e.code = 'MODULE_NOT_FOUND';
67
+ /******/ throw e;
68
+ /******/ }
93
69
  /******/ // Create a new module (and put it into the cache)
94
70
  /******/ var module = __webpack_module_cache__[moduleId] = {
95
71
  /******/ // no module.id needed
@@ -104,19 +80,10 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__;
104
80
  /******/ return module.exports;
105
81
  /******/ }
106
82
  /******/
107
- /************************************************************************/
108
- /******/ /* webpack/runtime/compat get default export */
109
- /******/ (() => {
110
- /******/ // getDefaultExport function for compatibility with non-harmony modules
111
- /******/ __webpack_require__.n = (module) => {
112
- /******/ var getter = module && module.__esModule ?
113
- /******/ () => (module['default']) :
114
- /******/ () => (module);
115
- /******/ __webpack_require__.d(getter, { a: getter });
116
- /******/ return getter;
117
- /******/ };
118
- /******/ })();
83
+ /******/ // expose the modules object (__webpack_modules__)
84
+ /******/ __webpack_require__.m = __webpack_modules__;
119
85
  /******/
86
+ /************************************************************************/
120
87
  /******/ /* webpack/runtime/define property getters */
121
88
  /******/ (() => {
122
89
  /******/ // define getter functions for harmony exports
@@ -129,11 +96,90 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__;
129
96
  /******/ };
130
97
  /******/ })();
131
98
  /******/
99
+ /******/ /* webpack/runtime/ensure chunk */
100
+ /******/ (() => {
101
+ /******/ __webpack_require__.f = {};
102
+ /******/ // This file contains only the entry chunk.
103
+ /******/ // The chunk loading function for additional chunks
104
+ /******/ __webpack_require__.e = (chunkId) => {
105
+ /******/ return Promise.all(Object.keys(__webpack_require__.f).reduce((promises, key) => {
106
+ /******/ __webpack_require__.f[key](chunkId, promises);
107
+ /******/ return promises;
108
+ /******/ }, []));
109
+ /******/ };
110
+ /******/ })();
111
+ /******/
112
+ /******/ /* webpack/runtime/get javascript chunk filename */
113
+ /******/ (() => {
114
+ /******/ // This function allow to reference async chunks
115
+ /******/ __webpack_require__.u = (chunkId) => {
116
+ /******/ // return url for filenames based on template
117
+ /******/ return "" + chunkId + ".js";
118
+ /******/ };
119
+ /******/ })();
120
+ /******/
121
+ /******/ /* webpack/runtime/global */
122
+ /******/ (() => {
123
+ /******/ __webpack_require__.g = (function() {
124
+ /******/ if (typeof globalThis === 'object') return globalThis;
125
+ /******/ try {
126
+ /******/ return this || new Function('return this')();
127
+ /******/ } catch (e) {
128
+ /******/ if (typeof window === 'object') return window;
129
+ /******/ }
130
+ /******/ })();
131
+ /******/ })();
132
+ /******/
132
133
  /******/ /* webpack/runtime/hasOwnProperty shorthand */
133
134
  /******/ (() => {
134
135
  /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
135
136
  /******/ })();
136
137
  /******/
138
+ /******/ /* webpack/runtime/load script */
139
+ /******/ (() => {
140
+ /******/ var inProgress = {};
141
+ /******/ var dataWebpackPrefix = "@tsparticles/plugin-oklch-color:";
142
+ /******/ // loadScript function to load a script via script tag
143
+ /******/ __webpack_require__.l = (url, done, key, chunkId) => {
144
+ /******/ if(inProgress[url]) { inProgress[url].push(done); return; }
145
+ /******/ var script, needAttach;
146
+ /******/ if(key !== undefined) {
147
+ /******/ var scripts = document.getElementsByTagName("script");
148
+ /******/ for(var i = 0; i < scripts.length; i++) {
149
+ /******/ var s = scripts[i];
150
+ /******/ if(s.getAttribute("src") == url || s.getAttribute("data-webpack") == dataWebpackPrefix + key) { script = s; break; }
151
+ /******/ }
152
+ /******/ }
153
+ /******/ if(!script) {
154
+ /******/ needAttach = true;
155
+ /******/ script = document.createElement('script');
156
+ /******/
157
+ /******/ script.charset = 'utf-8';
158
+ /******/ if (__webpack_require__.nc) {
159
+ /******/ script.setAttribute("nonce", __webpack_require__.nc);
160
+ /******/ }
161
+ /******/ script.setAttribute("data-webpack", dataWebpackPrefix + key);
162
+ /******/
163
+ /******/ script.src = url;
164
+ /******/ }
165
+ /******/ inProgress[url] = [done];
166
+ /******/ var onScriptComplete = (prev, event) => {
167
+ /******/ // avoid mem leaks in IE.
168
+ /******/ script.onerror = script.onload = null;
169
+ /******/ clearTimeout(timeout);
170
+ /******/ var doneFns = inProgress[url];
171
+ /******/ delete inProgress[url];
172
+ /******/ script.parentNode && script.parentNode.removeChild(script);
173
+ /******/ doneFns && doneFns.forEach((fn) => (fn(event)));
174
+ /******/ if(prev) return prev(event);
175
+ /******/ }
176
+ /******/ var timeout = setTimeout(onScriptComplete.bind(null, undefined, { type: 'timeout', target: script }), 120000);
177
+ /******/ script.onerror = onScriptComplete.bind(null, script.onerror);
178
+ /******/ script.onload = onScriptComplete.bind(null, script.onload);
179
+ /******/ needAttach && document.head.appendChild(script);
180
+ /******/ };
181
+ /******/ })();
182
+ /******/
137
183
  /******/ /* webpack/runtime/make namespace object */
138
184
  /******/ (() => {
139
185
  /******/ // define __esModule on exports
@@ -145,6 +191,119 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__;
145
191
  /******/ };
146
192
  /******/ })();
147
193
  /******/
194
+ /******/ /* webpack/runtime/publicPath */
195
+ /******/ (() => {
196
+ /******/ var scriptUrl;
197
+ /******/ if (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + "";
198
+ /******/ var document = __webpack_require__.g.document;
199
+ /******/ if (!scriptUrl && document) {
200
+ /******/ if (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT')
201
+ /******/ scriptUrl = document.currentScript.src;
202
+ /******/ if (!scriptUrl) {
203
+ /******/ var scripts = document.getElementsByTagName("script");
204
+ /******/ if(scripts.length) {
205
+ /******/ var i = scripts.length - 1;
206
+ /******/ while (i > -1 && (!scriptUrl || !/^http(s?):/.test(scriptUrl))) scriptUrl = scripts[i--].src;
207
+ /******/ }
208
+ /******/ }
209
+ /******/ }
210
+ /******/ // When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration
211
+ /******/ // or pass an empty string ("") and set the __webpack_public_path__ variable from your code to use your own logic.
212
+ /******/ if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser");
213
+ /******/ scriptUrl = scriptUrl.replace(/^blob:/, "").replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/");
214
+ /******/ __webpack_require__.p = scriptUrl;
215
+ /******/ })();
216
+ /******/
217
+ /******/ /* webpack/runtime/jsonp chunk loading */
218
+ /******/ (() => {
219
+ /******/ // no baseURI
220
+ /******/
221
+ /******/ // object to store loaded and loading chunks
222
+ /******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched
223
+ /******/ // [resolve, reject, Promise] = chunk loading, 0 = chunk loaded
224
+ /******/ var installedChunks = {
225
+ /******/ "tsparticles.plugin.oklchColor": 0
226
+ /******/ };
227
+ /******/
228
+ /******/ __webpack_require__.f.j = (chunkId, promises) => {
229
+ /******/ // JSONP chunk loading for javascript
230
+ /******/ var installedChunkData = __webpack_require__.o(installedChunks, chunkId) ? installedChunks[chunkId] : undefined;
231
+ /******/ if(installedChunkData !== 0) { // 0 means "already installed".
232
+ /******/
233
+ /******/ // a Promise means "currently loading".
234
+ /******/ if(installedChunkData) {
235
+ /******/ promises.push(installedChunkData[2]);
236
+ /******/ } else {
237
+ /******/ if(true) { // all chunks have JS
238
+ /******/ // setup Promise in chunk cache
239
+ /******/ var promise = new Promise((resolve, reject) => (installedChunkData = installedChunks[chunkId] = [resolve, reject]));
240
+ /******/ promises.push(installedChunkData[2] = promise);
241
+ /******/
242
+ /******/ // start chunk loading
243
+ /******/ var url = __webpack_require__.p + __webpack_require__.u(chunkId);
244
+ /******/ // create error before stack unwound to get useful stacktrace later
245
+ /******/ var error = new Error();
246
+ /******/ var loadingEnded = (event) => {
247
+ /******/ if(__webpack_require__.o(installedChunks, chunkId)) {
248
+ /******/ installedChunkData = installedChunks[chunkId];
249
+ /******/ if(installedChunkData !== 0) installedChunks[chunkId] = undefined;
250
+ /******/ if(installedChunkData) {
251
+ /******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type);
252
+ /******/ var realSrc = event && event.target && event.target.src;
253
+ /******/ error.message = 'Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')';
254
+ /******/ error.name = 'ChunkLoadError';
255
+ /******/ error.type = errorType;
256
+ /******/ error.request = realSrc;
257
+ /******/ installedChunkData[1](error);
258
+ /******/ }
259
+ /******/ }
260
+ /******/ };
261
+ /******/ __webpack_require__.l(url, loadingEnded, "chunk-" + chunkId, chunkId);
262
+ /******/ }
263
+ /******/ }
264
+ /******/ }
265
+ /******/ };
266
+ /******/
267
+ /******/ // no prefetching
268
+ /******/
269
+ /******/ // no preloaded
270
+ /******/
271
+ /******/ // no HMR
272
+ /******/
273
+ /******/ // no HMR manifest
274
+ /******/
275
+ /******/ // no on chunks loaded
276
+ /******/
277
+ /******/ // install a JSONP callback for chunk loading
278
+ /******/ var webpackJsonpCallback = (parentChunkLoadingFunction, data) => {
279
+ /******/ var [chunkIds, moreModules, runtime] = data;
280
+ /******/ // add "moreModules" to the modules object,
281
+ /******/ // then flag all "chunkIds" as loaded and fire callback
282
+ /******/ var moduleId, chunkId, i = 0;
283
+ /******/ if(chunkIds.some((id) => (installedChunks[id] !== 0))) {
284
+ /******/ for(moduleId in moreModules) {
285
+ /******/ if(__webpack_require__.o(moreModules, moduleId)) {
286
+ /******/ __webpack_require__.m[moduleId] = moreModules[moduleId];
287
+ /******/ }
288
+ /******/ }
289
+ /******/ if(runtime) var result = runtime(__webpack_require__);
290
+ /******/ }
291
+ /******/ if(parentChunkLoadingFunction) parentChunkLoadingFunction(data);
292
+ /******/ for(;i < chunkIds.length; i++) {
293
+ /******/ chunkId = chunkIds[i];
294
+ /******/ if(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) {
295
+ /******/ installedChunks[chunkId][0]();
296
+ /******/ }
297
+ /******/ installedChunks[chunkId] = 0;
298
+ /******/ }
299
+ /******/
300
+ /******/ }
301
+ /******/
302
+ /******/ var chunkLoadingGlobal = this["webpackChunk_tsparticles_plugin_oklch_color"] = this["webpackChunk_tsparticles_plugin_oklch_color"] || [];
303
+ /******/ chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));
304
+ /******/ chunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));
305
+ /******/ })();
306
+ /******/
148
307
  /************************************************************************/
149
308
  /******/
150
309
  /******/ // startup
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see tsparticles.plugin.oklchColor.min.js.LICENSE.txt */
2
- !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 r="object"==typeof exports?o(require("@tsparticles/engine")):o(e.window);for(var t in r)("object"==typeof exports?exports:e)[t]=r[t]}}(this,(e=>(()=>{var o={303:o=>{o.exports=e}},r={};function t(e){var a=r[e];if(void 0!==a)return a.exports;var n=r[e]={exports:{}};return o[e](n,n.exports,t),n.exports}t.d=(e,o)=>{for(var r in o)t.o(o,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:o[r]})},t.o=(e,o)=>Object.prototype.hasOwnProperty.call(e,o),t.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var a={};t.r(a),t.d(a,{loadOklchColorPlugin:()=>h});var n=t(303);const l=255;function i(e){const o=e.l/n.percentDenominator,r=e.c,t=e.h/360,a={r:0,g:0,b:0};return a.r=Math.floor(o*l),a.g=Math.floor(r*l),a.b=Math.floor(t*l),a}function s(e){const o=e.l/n.percentDenominator,r=e.c/n.percentDenominator,t=e.h/360,a={r:0,g:0,b:0};return a.r=Math.floor(o*l),a.g=Math.floor(r*l),a.b=Math.floor(t*l),a}class c{constructor(){this.key="lch",this.stringPrefix="lch"}handleColor(e){const o=e.value.lch??e.value;if(void 0!==o.l&&void 0!==o.c&&void 0!==o.h)return i(o)}handleRangeColor(e){const o=e.value.lch??e.value;if(void 0!==o.l&&void 0!==o.c&&void 0!==o.h)return i({l:(0,n.getRangeValue)(o.l),c:(0,n.getRangeValue)(o.c),h:(0,n.getRangeValue)(o.h)})}parseString(e){if(!e.startsWith("lch"))return;const o=/lch\(\s*(\d+(\.\d+)?)%\s+(\d+(\.\d+)?)\s+(\d+(\.\d+)?)(?:\s*\/\s*(0|1|0?\.\d+|\d{1,3}%))?\s*\)/i.exec(e),r=1,t=3,a=5,l=7;return o?{a:(s={a:o[l]?(0,n.parseAlpha)(o[l]):1,c:parseFloat(o[t]),h:parseFloat(o[a]),l:parseFloat(o[r])}).a,...i(s)}:void 0;var s}}class d{constructor(){this.key="oklch",this.stringPrefix="oklch"}handleColor(e){const o=e.value.oklch??e.value;if(void 0!==o.l&&void 0!==o.c&&void 0!==o.h)return s(o)}handleRangeColor(e){const o=e.value.oklch??e.value;if(void 0!==o.l&&void 0!==o.c&&void 0!==o.h)return s({l:(0,n.getRangeValue)(o.l),c:(0,n.getRangeValue)(o.c),h:(0,n.getRangeValue)(o.h)})}parseString(e){if(!e.startsWith("oklch"))return;const o=/oklch\(\s*(\d+(\.\d+)?)%\s+(\d+(\.\d+)?)\s+(\d+(\.\d+)?)(°)?(?:\s*\/\s*(0|1|0?\.\d+|\d{1,3}%))?\s*\)/i.exec(e),r=1,t=3,a=5,l=7;return o?{a:(i={a:o[l]?(0,n.parseAlpha)(o[l]):1,c:parseFloat(o[t]),h:parseFloat(o[a]),l:parseFloat(o[r])}).a,...s(i)}:void 0;var i}}async function h(e,o=!0){e.checkVersion("3.9.1"),await e.addColorManager(new d,o),await e.addColorManager(new c,o)}return a})()));
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=>(()=>{var r,t,o={303(r){r.exports=e}},n={};function i(e){var r=n[e];if(void 0!==r)return r.exports;var t=n[e]={exports:{}};return o[e](t,t.exports,i),t.exports}i.m=o,i.d=(e,r)=>{for(var t in r)i.o(r,t)&&!i.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},i.f={},i.e=e=>Promise.all(Object.keys(i.f).reduce(((r,t)=>(i.f[t](e,r),r)),[])),i.u=e=>e+".min.js",i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),i.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),r={},t="@tsparticles/plugin-oklch-color:",i.l=(e,o,n,a)=>{if(r[e])r[e].push(o);else{var l,c;if(void 0!==n)for(var s=document.getElementsByTagName("script"),p=0;p<s.length;p++){var u=s[p];if(u.getAttribute("src")==e||u.getAttribute("data-webpack")==t+n){l=u;break}}l||(c=!0,(l=document.createElement("script")).charset="utf-8",i.nc&&l.setAttribute("nonce",i.nc),l.setAttribute("data-webpack",t+n),l.src=e),r[e]=[o];var d=(t,o)=>{l.onerror=l.onload=null,clearTimeout(f);var n=r[e];if(delete r[e],l.parentNode&&l.parentNode.removeChild(l),n&&n.forEach((e=>e(o))),t)return t(o)},f=setTimeout(d.bind(null,void 0,{type:"timeout",target:l}),12e4);l.onerror=d.bind(null,l.onerror),l.onload=d.bind(null,l.onload),c&&document.head.appendChild(l)}},i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e;i.g.importScripts&&(e=i.g.location+"");var r=i.g.document;if(!e&&r&&(r.currentScript&&"SCRIPT"===r.currentScript.tagName.toUpperCase()&&(e=r.currentScript.src),!e)){var t=r.getElementsByTagName("script");if(t.length)for(var o=t.length-1;o>-1&&(!e||!/^http(s?):/.test(e));)e=t[o--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),i.p=e})(),(()=>{var e={60:0};i.f.j=(r,t)=>{var o=i.o(e,r)?e[r]:void 0;if(0!==o)if(o)t.push(o[2]);else{var n=new Promise(((t,n)=>o=e[r]=[t,n]));t.push(o[2]=n);var a=i.p+i.u(r),l=new Error;i.l(a,(t=>{if(i.o(e,r)&&(0!==(o=e[r])&&(e[r]=void 0),o)){var n=t&&("load"===t.type?"missing":t.type),a=t&&t.target&&t.target.src;l.message="Loading chunk "+r+" failed.\n("+n+": "+a+")",l.name="ChunkLoadError",l.type=n,l.request=a,o[1](l)}}),"chunk-"+r,r)}};var r=(r,t)=>{var o,n,[a,l,c]=t,s=0;if(a.some((r=>0!==e[r]))){for(o in l)i.o(l,o)&&(i.m[o]=l[o]);if(c)c(i)}for(r&&r(t);s<a.length;s++)n=a[s],i.o(e,n)&&e[n]&&e[n][0](),e[n]=0},t=this.webpackChunk_tsparticles_plugin_oklch_color=this.webpackChunk_tsparticles_plugin_oklch_color||[];t.forEach(r.bind(null,0)),t.push=r.bind(null,t.push.bind(t))})();var a={};function l(e){e.checkVersion("4.0.0-alpha.1"),e.register((async e=>{const{OklchColorManager:r}=await i.e(599).then(i.bind(i,599));e.addColorManager(new r)}))}return i.r(a),i.d(a,{loadOklchColorPlugin:()=>l}),a})()));
@@ -1 +1 @@
1
- /*! tsParticles OKLCH Color Plugin v3.9.1 by Matteo Bruni */
1
+ /*! tsParticles OKLCH Color Plugin v4.0.0-alpha.1 by Matteo Bruni */
@@ -1,8 +1,8 @@
1
1
  import { type IColor, type IColorManager, type IRangeColor, type IRgb, type IRgba } from "@tsparticles/engine";
2
2
  export declare class OklchColorManager implements IColorManager {
3
3
  readonly key: string;
4
- readonly stringPrefix: string;
5
4
  constructor();
5
+ accepts(input: string): boolean;
6
6
  handleColor(color: IColor): IRgb | undefined;
7
7
  handleRangeColor(color: IRangeColor): IRgb | undefined;
8
8
  parseString(input: string): IRgba | undefined;
package/types/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  import { type Engine } from "@tsparticles/engine";
2
- export declare function loadOklchColorPlugin(engine: Engine, refresh?: boolean): Promise<void>;
2
+ export declare function loadOklchColorPlugin(engine: Engine): void;
package/types/utils.d.ts CHANGED
@@ -1,6 +1,4 @@
1
- import { type ILch, type ILcha, type IOklch, type IOklcha, type IRgb, type IRgba } from "@tsparticles/engine";
2
- export declare function lchToRgb(lch: ILch): IRgb;
3
- export declare function lchaToRgba(lcha: ILcha): IRgba;
1
+ import { type IOklch, type IOklcha, type IRgb, type IRgba } from "@tsparticles/engine";
4
2
  export declare function oklchToRgb(oklch: IOklch): IRgb;
5
3
  export declare function oklchaToRgba(oklcha: IOklcha): IRgba;
6
4
  export declare function getStyleFromOklch(color: IOklch, opacity?: number): string;
@@ -12,33 +12,37 @@
12
12
  exports.OklchColorManager = void 0;
13
13
  const engine_1 = require("@tsparticles/engine");
14
14
  const utils_js_1 = require("./utils.js");
15
+ const oklchRegex = /oklch\(\s*(\d+(\.\d+)?)%\s+(\d+(\.\d+)?)\s+(\d+(\.\d+)?)(°)?(?:\s*\/\s*(0|1|0?\.\d+|\d{1,3}%))?\s*\)/i;
15
16
  class OklchColorManager {
16
17
  constructor() {
17
18
  this.key = "oklch";
18
- this.stringPrefix = "oklch";
19
+ }
20
+ accepts(input) {
21
+ return input.startsWith("oklch");
19
22
  }
20
23
  handleColor(color) {
21
24
  const colorValue = color.value, oklchColor = colorValue.oklch ?? color.value;
22
- if (oklchColor.l !== undefined && oklchColor.c !== undefined && oklchColor.h !== undefined) {
23
- return (0, utils_js_1.oklchToRgb)(oklchColor);
25
+ if (!Object.hasOwn(oklchColor, "l") && !Object.hasOwn(oklchColor, "c") && !Object.hasOwn(oklchColor, "h")) {
26
+ return;
24
27
  }
28
+ return (0, utils_js_1.oklchToRgb)(oklchColor);
25
29
  }
26
30
  handleRangeColor(color) {
27
31
  const colorValue = color.value, oklchColor = colorValue.oklch ?? color.value;
28
- if (oklchColor.l !== undefined && oklchColor.c !== undefined && oklchColor.h !== undefined) {
29
- return (0, utils_js_1.oklchToRgb)({
30
- l: (0, engine_1.getRangeValue)(oklchColor.l),
31
- c: (0, engine_1.getRangeValue)(oklchColor.c),
32
- h: (0, engine_1.getRangeValue)(oklchColor.h),
33
- });
32
+ if (!Object.hasOwn(oklchColor, "l") && !Object.hasOwn(oklchColor, "c") && !Object.hasOwn(oklchColor, "h")) {
33
+ return;
34
34
  }
35
+ return (0, utils_js_1.oklchToRgb)({
36
+ l: (0, engine_1.getRangeValue)(oklchColor.l),
37
+ c: (0, engine_1.getRangeValue)(oklchColor.c),
38
+ h: (0, engine_1.getRangeValue)(oklchColor.h),
39
+ });
35
40
  }
36
41
  parseString(input) {
37
- const isOklch = input.startsWith("oklch");
38
- if (!isOklch) {
42
+ if (!this.accepts(input)) {
39
43
  return;
40
44
  }
41
- const regex = /oklch\(\s*(\d+(\.\d+)?)%\s+(\d+(\.\d+)?)\s+(\d+(\.\d+)?)(°)?(?:\s*\/\s*(0|1|0?\.\d+|\d{1,3}%))?\s*\)/i, result = regex.exec(input), indexes = {
45
+ const result = oklchRegex.exec(input), indexes = {
42
46
  l: 1,
43
47
  c: 3,
44
48
  h: 5,
@@ -47,9 +51,9 @@
47
51
  return result
48
52
  ? (0, utils_js_1.oklchaToRgba)({
49
53
  a: result[indexes.a] ? (0, engine_1.parseAlpha)(result[indexes.a]) : defaultAlpha,
50
- c: parseFloat(result[indexes.c]),
51
- h: parseFloat(result[indexes.h]),
52
- l: parseFloat(result[indexes.l]),
54
+ c: parseFloat(result[indexes.c] ?? "0"),
55
+ h: parseFloat(result[indexes.h] ?? "0"),
56
+ l: parseFloat(result[indexes.l] ?? "0"),
53
57
  })
54
58
  : undefined;
55
59
  }
package/umd/index.js CHANGED
@@ -1,20 +1,54 @@
1
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
2
+ if (k2 === undefined) k2 = k;
3
+ var desc = Object.getOwnPropertyDescriptor(m, k);
4
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
5
+ desc = { enumerable: true, get: function() { return m[k]; } };
6
+ }
7
+ Object.defineProperty(o, k2, desc);
8
+ }) : (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ o[k2] = m[k];
11
+ }));
12
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
13
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
14
+ }) : function(o, v) {
15
+ o["default"] = v;
16
+ });
17
+ var __importStar = (this && this.__importStar) || (function () {
18
+ var ownKeys = function(o) {
19
+ ownKeys = Object.getOwnPropertyNames || function (o) {
20
+ var ar = [];
21
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
22
+ return ar;
23
+ };
24
+ return ownKeys(o);
25
+ };
26
+ return function (mod) {
27
+ if (mod && mod.__esModule) return mod;
28
+ var result = {};
29
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
30
+ __setModuleDefault(result, mod);
31
+ return result;
32
+ };
33
+ })();
1
34
  (function (factory) {
2
35
  if (typeof module === "object" && typeof module.exports === "object") {
3
36
  var v = factory(require, exports);
4
37
  if (v !== undefined) module.exports = v;
5
38
  }
6
39
  else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports", "./LchColorManager.js", "./OklchColorManager.js"], factory);
40
+ define(["require", "exports"], factory);
8
41
  }
9
42
  })(function (require, exports) {
10
43
  "use strict";
44
+ var __syncRequire = typeof module === "object" && typeof module.exports === "object";
11
45
  Object.defineProperty(exports, "__esModule", { value: true });
12
46
  exports.loadOklchColorPlugin = loadOklchColorPlugin;
13
- const LchColorManager_js_1 = require("./LchColorManager.js");
14
- const OklchColorManager_js_1 = require("./OklchColorManager.js");
15
- async function loadOklchColorPlugin(engine, refresh = true) {
16
- engine.checkVersion("3.9.1");
17
- await engine.addColorManager(new OklchColorManager_js_1.OklchColorManager(), refresh);
18
- await engine.addColorManager(new LchColorManager_js_1.LchColorManager(), refresh);
47
+ function loadOklchColorPlugin(engine) {
48
+ engine.checkVersion("4.0.0-alpha.1");
49
+ engine.register(async (e) => {
50
+ const { OklchColorManager } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./OklchColorManager.js"))) : new Promise((resolve_1, reject_1) => { require(["./OklchColorManager.js"], resolve_1, reject_1); }).then(__importStar));
51
+ e.addColorManager(new OklchColorManager());
52
+ });
19
53
  }
20
54
  });
package/umd/utils.js CHANGED
@@ -9,33 +9,35 @@
9
9
  })(function (require, exports) {
10
10
  "use strict";
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.lchToRgb = lchToRgb;
13
- exports.lchaToRgba = lchaToRgba;
14
12
  exports.oklchToRgb = oklchToRgb;
15
13
  exports.oklchaToRgba = oklchaToRgba;
16
14
  exports.getStyleFromOklch = getStyleFromOklch;
17
15
  const engine_1 = require("@tsparticles/engine");
18
- const rgbFactor = 255, fullDegree = 360;
19
- function lchToRgb(lch) {
20
- const l = lch.l / engine_1.percentDenominator, c = lch.c, h = lch.h / fullDegree, result = { r: 0, g: 0, b: 0 };
21
- result.r = Math.floor(l * rgbFactor);
22
- result.g = Math.floor(c * rgbFactor);
23
- result.b = Math.floor(h * rgbFactor);
24
- return result;
25
- }
26
- function lchaToRgba(lcha) {
16
+ const OKLAB_LMS = {
17
+ l: { L: 1, a: 0.3963377774, b: 0.2158037573 },
18
+ m: { L: 1, a: -0.1055613458, b: -0.0638541728 },
19
+ s: { L: 1, a: -0.0894841775, b: -1.291485548 },
20
+ }, LMS_TO_LINEAR_RGB = {
21
+ r: { l: 4.0767416621, m: -3.3077115913, s: 0.2309699292 },
22
+ g: { l: -1.2684380046, m: 2.6097574011, s: -0.3413193965 },
23
+ b: { l: -0.0041960863, m: -0.7034186147, s: 1.707614701 },
24
+ }, SRGB = {
25
+ GAMMA: 2.4,
26
+ LINEAR_THRESHOLD: 0.0031308,
27
+ LINEAR_SCALE: 12.92,
28
+ SCALE: 1.055,
29
+ OFFSET: 0.055,
30
+ }, minSrgbValue = 0, maxSrgbValue = 1;
31
+ function oklchToRgb(oklch) {
32
+ const L = oklch.l / engine_1.percentDenominator, C = oklch.c / engine_1.percentDenominator, hRad = (0, engine_1.degToRad)(oklch.h), a = C * Math.cos(hRad), b = C * Math.sin(hRad), l_ = OKLAB_LMS.l.L * L + OKLAB_LMS.l.a * a + OKLAB_LMS.l.b * b, m_ = OKLAB_LMS.m.L * L + OKLAB_LMS.m.a * a + OKLAB_LMS.m.b * b, s_ = OKLAB_LMS.s.L * L + OKLAB_LMS.s.a * a + OKLAB_LMS.s.b * b, cubic = 3, l = l_ ** cubic, m = m_ ** cubic, s = s_ ** cubic, rLinear = LMS_TO_LINEAR_RGB.r.l * l + LMS_TO_LINEAR_RGB.r.m * m + LMS_TO_LINEAR_RGB.r.s * s, gLinear = LMS_TO_LINEAR_RGB.g.l * l + LMS_TO_LINEAR_RGB.g.m * m + LMS_TO_LINEAR_RGB.g.s * s, bLinear = LMS_TO_LINEAR_RGB.b.l * l + LMS_TO_LINEAR_RGB.b.m * m + LMS_TO_LINEAR_RGB.b.s * s, toSrgb = (x) => x <= SRGB.LINEAR_THRESHOLD
33
+ ? SRGB.LINEAR_SCALE * x
34
+ : SRGB.SCALE * Math.pow(x, engine_1.inverseFactorNumerator / SRGB.GAMMA) - SRGB.OFFSET, toSrgbFixed = num => Math.round((0, engine_1.clamp)(toSrgb(num), minSrgbValue, maxSrgbValue) * engine_1.rgbMax);
27
35
  return {
28
- a: lcha.a,
29
- ...lchToRgb(lcha),
36
+ r: toSrgbFixed(rLinear),
37
+ g: toSrgbFixed(gLinear),
38
+ b: toSrgbFixed(bLinear),
30
39
  };
31
40
  }
32
- function oklchToRgb(oklch) {
33
- const l = oklch.l / engine_1.percentDenominator, c = oklch.c / engine_1.percentDenominator, h = oklch.h / fullDegree, result = { r: 0, g: 0, b: 0 };
34
- result.r = Math.floor(l * rgbFactor);
35
- result.g = Math.floor(c * rgbFactor);
36
- result.b = Math.floor(h * rgbFactor);
37
- return result;
38
- }
39
41
  function oklchaToRgba(oklcha) {
40
42
  return {
41
43
  a: oklcha.a,
@@ -43,7 +45,7 @@
43
45
  };
44
46
  }
45
47
  function getStyleFromOklch(color, opacity) {
46
- const { l, c, h } = color, alpha = opacity !== undefined ? `, ${opacity}` : "";
47
- return `oklch(${l}%, ${c}%, ${h}°${alpha})`;
48
+ const { l, c, h } = color, alpha = opacity !== undefined ? ` / ${opacity.toString()}` : "";
49
+ return `oklch(${l.toString()}% ${c.toString()}% ${h.toString()}°${alpha})`;
48
50
  }
49
51
  });
@@ -1,44 +0,0 @@
1
- import { getRangeValue, parseAlpha, } from "@tsparticles/engine";
2
- import { lchToRgb, lchaToRgba } from "./utils.js";
3
- export class LchColorManager {
4
- constructor() {
5
- this.key = "lch";
6
- this.stringPrefix = "lch";
7
- }
8
- handleColor(color) {
9
- const colorValue = color.value, lchColor = colorValue.lch ?? color.value;
10
- if (lchColor.l !== undefined && lchColor.c !== undefined && lchColor.h !== undefined) {
11
- return lchToRgb(lchColor);
12
- }
13
- }
14
- handleRangeColor(color) {
15
- const colorValue = color.value, lchColor = colorValue.lch ?? color.value;
16
- if (lchColor.l !== undefined && lchColor.c !== undefined && lchColor.h !== undefined) {
17
- return lchToRgb({
18
- l: getRangeValue(lchColor.l),
19
- c: getRangeValue(lchColor.c),
20
- h: getRangeValue(lchColor.h),
21
- });
22
- }
23
- }
24
- parseString(input) {
25
- const isLch = input.startsWith("lch");
26
- if (!isLch) {
27
- return;
28
- }
29
- const regex = /lch\(\s*(\d+(\.\d+)?)%\s+(\d+(\.\d+)?)\s+(\d+(\.\d+)?)(?:\s*\/\s*(0|1|0?\.\d+|\d{1,3}%))?\s*\)/i, result = regex.exec(input), indexes = {
30
- l: 1,
31
- c: 3,
32
- h: 5,
33
- a: 7,
34
- }, defaultAlpha = 1;
35
- return result
36
- ? lchaToRgba({
37
- a: result[indexes.a] ? parseAlpha(result[indexes.a]) : defaultAlpha,
38
- c: parseFloat(result[indexes.c]),
39
- h: parseFloat(result[indexes.h]),
40
- l: parseFloat(result[indexes.l]),
41
- })
42
- : undefined;
43
- }
44
- }