@tsparticles/plugin-rgb-color 3.7.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 +21 -0
- package/README.md +74 -0
- package/browser/RgbColorManager.js +44 -0
- package/browser/index.js +6 -0
- package/browser/package.json +1 -0
- package/cjs/RgbColorManager.js +48 -0
- package/cjs/index.js +9 -0
- package/cjs/package.json +1 -0
- package/esm/RgbColorManager.js +44 -0
- package/esm/index.js +6 -0
- package/esm/package.json +1 -0
- package/package.json +108 -0
- package/report.html +39 -0
- package/tsparticles.plugin.rgbColor.js +138 -0
- package/tsparticles.plugin.rgbColor.min.js +2 -0
- package/tsparticles.plugin.rgbColor.min.js.LICENSE.txt +1 -0
- package/types/RgbColorManager.d.ts +9 -0
- package/types/index.d.ts +2 -0
- package/umd/RgbColorManager.js +58 -0
- package/umd/index.js +19 -0
|
@@ -0,0 +1,138 @@
|
|
|
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.7.0
|
|
8
|
+
*/
|
|
9
|
+
/*
|
|
10
|
+
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
|
|
11
|
+
* This devtool is neither made for production nor for readable output files.
|
|
12
|
+
* It uses "eval()" calls to create a separate source file in the browser devtools.
|
|
13
|
+
* If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
|
|
14
|
+
* or disable the default devtool with "devtool: false".
|
|
15
|
+
* If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
|
|
16
|
+
*/
|
|
17
|
+
(function webpackUniversalModuleDefinition(root, factory) {
|
|
18
|
+
if(typeof exports === 'object' && typeof module === 'object')
|
|
19
|
+
module.exports = factory(require("@tsparticles/engine"));
|
|
20
|
+
else if(typeof define === 'function' && define.amd)
|
|
21
|
+
define(["@tsparticles/engine"], factory);
|
|
22
|
+
else {
|
|
23
|
+
var a = typeof exports === 'object' ? factory(require("@tsparticles/engine")) : factory(root["window"]);
|
|
24
|
+
for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
|
|
25
|
+
}
|
|
26
|
+
})(this, (__WEBPACK_EXTERNAL_MODULE__tsparticles_engine__) => {
|
|
27
|
+
return /******/ (() => { // webpackBootstrap
|
|
28
|
+
/******/ "use strict";
|
|
29
|
+
/******/ var __webpack_modules__ = ({
|
|
30
|
+
|
|
31
|
+
/***/ "./dist/browser/RgbColorManager.js":
|
|
32
|
+
/*!*****************************************!*\
|
|
33
|
+
!*** ./dist/browser/RgbColorManager.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 */ RgbColorManager: () => (/* binding */ RgbColorManager)\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\nvar RgbIndexes;\n(function (RgbIndexes) {\n RgbIndexes[RgbIndexes[\"r\"] = 1] = \"r\";\n RgbIndexes[RgbIndexes[\"g\"] = 2] = \"g\";\n RgbIndexes[RgbIndexes[\"b\"] = 3] = \"b\";\n RgbIndexes[RgbIndexes[\"a\"] = 5] = \"a\";\n})(RgbIndexes || (RgbIndexes = {}));\nclass RgbColorManager {\n constructor() {\n this.key = \"rgb\";\n this.stringPrefix = \"rgb\";\n }\n handleColor(color) {\n const colorValue = color.value,\n rgbColor = colorValue.rgb ?? color.value;\n if (rgbColor.r !== undefined) {\n return rgbColor;\n }\n }\n handleRangeColor(color) {\n const colorValue = color.value,\n rgbColor = colorValue.rgb ?? color.value;\n if (rgbColor.r !== undefined) {\n return {\n r: (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(rgbColor.r),\n g: (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(rgbColor.g),\n b: (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(rgbColor.b)\n };\n }\n }\n parseString(input) {\n if (!input.startsWith(this.stringPrefix)) {\n return;\n }\n const regex = /rgba?\\(\\s*(\\d{1,3})\\s*[\\s,]\\s*(\\d{1,3})\\s*[\\s,]\\s*(\\d{1,3})\\s*([\\s,]\\s*(0|1|0?\\.\\d+|(\\d{1,3})%)\\s*)?\\)/i,\n result = regex.exec(input),\n radix = 10,\n minLength = 4,\n defaultAlpha = 1;\n return result ? {\n a: result.length > minLength ? (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.parseAlpha)(result[RgbIndexes.a]) : defaultAlpha,\n b: parseInt(result[RgbIndexes.b], radix),\n g: parseInt(result[RgbIndexes.g], radix),\n r: parseInt(result[RgbIndexes.r], radix)\n } : undefined;\n }\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-rgb-color/./dist/browser/RgbColorManager.js?");
|
|
38
|
+
|
|
39
|
+
/***/ }),
|
|
40
|
+
|
|
41
|
+
/***/ "./dist/browser/index.js":
|
|
42
|
+
/*!*******************************!*\
|
|
43
|
+
!*** ./dist/browser/index.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 */ loadRgbColorPlugin: () => (/* binding */ loadRgbColorPlugin)\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 _RgbColorManager_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./RgbColorManager.js */ \"./dist/browser/RgbColorManager.js\");\n\n\nasync function loadRgbColorPlugin(engine, refresh = true) {\n (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.assertValidVersion)(engine, \"3.7.0\");\n await engine.addColorManager(new _RgbColorManager_js__WEBPACK_IMPORTED_MODULE_1__.RgbColorManager(), refresh);\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-rgb-color/./dist/browser/index.js?");
|
|
48
|
+
|
|
49
|
+
/***/ }),
|
|
50
|
+
|
|
51
|
+
/***/ "@tsparticles/engine":
|
|
52
|
+
/*!*********************************************************************************************************************************!*\
|
|
53
|
+
!*** external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"} ***!
|
|
54
|
+
\*********************************************************************************************************************************/
|
|
55
|
+
/***/ ((module) => {
|
|
56
|
+
|
|
57
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__;
|
|
58
|
+
|
|
59
|
+
/***/ })
|
|
60
|
+
|
|
61
|
+
/******/ });
|
|
62
|
+
/************************************************************************/
|
|
63
|
+
/******/ // The module cache
|
|
64
|
+
/******/ var __webpack_module_cache__ = {};
|
|
65
|
+
/******/
|
|
66
|
+
/******/ // The require function
|
|
67
|
+
/******/ function __webpack_require__(moduleId) {
|
|
68
|
+
/******/ // Check if module is in cache
|
|
69
|
+
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
70
|
+
/******/ if (cachedModule !== undefined) {
|
|
71
|
+
/******/ return cachedModule.exports;
|
|
72
|
+
/******/ }
|
|
73
|
+
/******/ // Create a new module (and put it into the cache)
|
|
74
|
+
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
75
|
+
/******/ // no module.id needed
|
|
76
|
+
/******/ // no module.loaded needed
|
|
77
|
+
/******/ exports: {}
|
|
78
|
+
/******/ };
|
|
79
|
+
/******/
|
|
80
|
+
/******/ // Execute the module function
|
|
81
|
+
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
82
|
+
/******/
|
|
83
|
+
/******/ // Return the exports of the module
|
|
84
|
+
/******/ return module.exports;
|
|
85
|
+
/******/ }
|
|
86
|
+
/******/
|
|
87
|
+
/************************************************************************/
|
|
88
|
+
/******/ /* webpack/runtime/compat get default export */
|
|
89
|
+
/******/ (() => {
|
|
90
|
+
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
91
|
+
/******/ __webpack_require__.n = (module) => {
|
|
92
|
+
/******/ var getter = module && module.__esModule ?
|
|
93
|
+
/******/ () => (module['default']) :
|
|
94
|
+
/******/ () => (module);
|
|
95
|
+
/******/ __webpack_require__.d(getter, { a: getter });
|
|
96
|
+
/******/ return getter;
|
|
97
|
+
/******/ };
|
|
98
|
+
/******/ })();
|
|
99
|
+
/******/
|
|
100
|
+
/******/ /* webpack/runtime/define property getters */
|
|
101
|
+
/******/ (() => {
|
|
102
|
+
/******/ // define getter functions for harmony exports
|
|
103
|
+
/******/ __webpack_require__.d = (exports, definition) => {
|
|
104
|
+
/******/ for(var key in definition) {
|
|
105
|
+
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
106
|
+
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
107
|
+
/******/ }
|
|
108
|
+
/******/ }
|
|
109
|
+
/******/ };
|
|
110
|
+
/******/ })();
|
|
111
|
+
/******/
|
|
112
|
+
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
113
|
+
/******/ (() => {
|
|
114
|
+
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
115
|
+
/******/ })();
|
|
116
|
+
/******/
|
|
117
|
+
/******/ /* webpack/runtime/make namespace object */
|
|
118
|
+
/******/ (() => {
|
|
119
|
+
/******/ // define __esModule on exports
|
|
120
|
+
/******/ __webpack_require__.r = (exports) => {
|
|
121
|
+
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
122
|
+
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
123
|
+
/******/ }
|
|
124
|
+
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
125
|
+
/******/ };
|
|
126
|
+
/******/ })();
|
|
127
|
+
/******/
|
|
128
|
+
/************************************************************************/
|
|
129
|
+
/******/
|
|
130
|
+
/******/ // startup
|
|
131
|
+
/******/ // Load entry module and return exports
|
|
132
|
+
/******/ // This entry module can't be inlined because the eval devtool is used.
|
|
133
|
+
/******/ var __webpack_exports__ = __webpack_require__("./dist/browser/index.js");
|
|
134
|
+
/******/
|
|
135
|
+
/******/ return __webpack_exports__;
|
|
136
|
+
/******/ })()
|
|
137
|
+
;
|
|
138
|
+
});
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! For license information please see tsparticles.plugin.rgbColor.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=>(()=>{var r={303:r=>{r.exports=e}},t={};function o(e){var n=t[e];if(void 0!==n)return n.exports;var a=t[e]={exports:{}};return r[e](a,a.exports,o),a.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={};o.r(n),o.d(n,{loadRgbColorPlugin:()=>l});var a,s=o(303);!function(e){e[e.r=1]="r",e[e.g=2]="g",e[e.b=3]="b",e[e.a=5]="a"}(a||(a={}));class i{constructor(){this.key="rgb",this.stringPrefix="rgb"}handleColor(e){const r=e.value.rgb??e.value;if(void 0!==r.r)return r}handleRangeColor(e){const r=e.value.rgb??e.value;if(void 0!==r.r)return{r:(0,s.getRangeValue)(r.r),g:(0,s.getRangeValue)(r.g),b:(0,s.getRangeValue)(r.b)}}parseString(e){if(!e.startsWith(this.stringPrefix))return;const r=/rgba?\(\s*(\d{1,3})\s*[\s,]\s*(\d{1,3})\s*[\s,]\s*(\d{1,3})\s*([\s,]\s*(0|1|0?\.\d+|(\d{1,3})%)\s*)?\)/i.exec(e);return r?{a:r.length>4?(0,s.parseAlpha)(r[a.a]):1,b:parseInt(r[a.b],10),g:parseInt(r[a.g],10),r:parseInt(r[a.r],10)}:void 0}}async function l(e,r=!0){(0,s.assertValidVersion)(e,"3.7.0"),await e.addColorManager(new i,r)}return n})()));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/*! tsParticles RGB Color Plugin v3.7.0 by Matteo Bruni */
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type IColor, type IColorManager, type IRangeColor, type IRgb, type IRgba } from "@tsparticles/engine";
|
|
2
|
+
export declare class RgbColorManager implements IColorManager {
|
|
3
|
+
readonly key: string;
|
|
4
|
+
readonly stringPrefix: string;
|
|
5
|
+
constructor();
|
|
6
|
+
handleColor(color: IColor): IRgb | undefined;
|
|
7
|
+
handleRangeColor(color: IRangeColor): IRgb | undefined;
|
|
8
|
+
parseString(input: string): IRgba | undefined;
|
|
9
|
+
}
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
5
|
+
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports", "@tsparticles/engine"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.RgbColorManager = void 0;
|
|
13
|
+
const engine_1 = require("@tsparticles/engine");
|
|
14
|
+
var RgbIndexes;
|
|
15
|
+
(function (RgbIndexes) {
|
|
16
|
+
RgbIndexes[RgbIndexes["r"] = 1] = "r";
|
|
17
|
+
RgbIndexes[RgbIndexes["g"] = 2] = "g";
|
|
18
|
+
RgbIndexes[RgbIndexes["b"] = 3] = "b";
|
|
19
|
+
RgbIndexes[RgbIndexes["a"] = 5] = "a";
|
|
20
|
+
})(RgbIndexes || (RgbIndexes = {}));
|
|
21
|
+
class RgbColorManager {
|
|
22
|
+
constructor() {
|
|
23
|
+
this.key = "rgb";
|
|
24
|
+
this.stringPrefix = "rgb";
|
|
25
|
+
}
|
|
26
|
+
handleColor(color) {
|
|
27
|
+
const colorValue = color.value, rgbColor = colorValue.rgb ?? color.value;
|
|
28
|
+
if (rgbColor.r !== undefined) {
|
|
29
|
+
return rgbColor;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
handleRangeColor(color) {
|
|
33
|
+
const colorValue = color.value, rgbColor = colorValue.rgb ?? color.value;
|
|
34
|
+
if (rgbColor.r !== undefined) {
|
|
35
|
+
return {
|
|
36
|
+
r: (0, engine_1.getRangeValue)(rgbColor.r),
|
|
37
|
+
g: (0, engine_1.getRangeValue)(rgbColor.g),
|
|
38
|
+
b: (0, engine_1.getRangeValue)(rgbColor.b),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
parseString(input) {
|
|
43
|
+
if (!input.startsWith(this.stringPrefix)) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const regex = /rgba?\(\s*(\d{1,3})\s*[\s,]\s*(\d{1,3})\s*[\s,]\s*(\d{1,3})\s*([\s,]\s*(0|1|0?\.\d+|(\d{1,3})%)\s*)?\)/i, result = regex.exec(input), radix = 10, minLength = 4, defaultAlpha = 1;
|
|
47
|
+
return result
|
|
48
|
+
? {
|
|
49
|
+
a: result.length > minLength ? (0, engine_1.parseAlpha)(result[RgbIndexes.a]) : defaultAlpha,
|
|
50
|
+
b: parseInt(result[RgbIndexes.b], radix),
|
|
51
|
+
g: parseInt(result[RgbIndexes.g], radix),
|
|
52
|
+
r: parseInt(result[RgbIndexes.r], radix),
|
|
53
|
+
}
|
|
54
|
+
: undefined;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.RgbColorManager = RgbColorManager;
|
|
58
|
+
});
|
package/umd/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
5
|
+
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports", "@tsparticles/engine", "./RgbColorManager.js"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.loadRgbColorPlugin = loadRgbColorPlugin;
|
|
13
|
+
const engine_1 = require("@tsparticles/engine");
|
|
14
|
+
const RgbColorManager_js_1 = require("./RgbColorManager.js");
|
|
15
|
+
async function loadRgbColorPlugin(engine, refresh = true) {
|
|
16
|
+
(0, engine_1.assertValidVersion)(engine, "3.7.0");
|
|
17
|
+
await engine.addColorManager(new RgbColorManager_js_1.RgbColorManager(), refresh);
|
|
18
|
+
}
|
|
19
|
+
});
|