@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 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,74 @@
1
+ [![banner](https://particles.js.org/images/banner3.png)](https://particles.js.org)
2
+
3
+ # tsParticles RGB Color Plugin
4
+
5
+ [![jsDelivr](https://data.jsdelivr.com/v1/package/npm/@tsparticles/plugin-rgb-color/badge)](https://www.jsdelivr.com/package/npm/@tsparticles/plugin-rgb-color)
6
+ [![npmjs](https://badge.fury.io/js/@tsparticles/plugin-rgb-color.svg)](https://www.npmjs.com/package/@tsparticles/plugin-rgb-color)
7
+ [![npmjs](https://img.shields.io/npm/dt/@tsparticles/plugin-rgb-color)](https://www.npmjs.com/package/@tsparticles/plugin-rgb-color) [![GitHub Sponsors](https://img.shields.io/github/sponsors/matteobruni)](https://github.com/sponsors/matteobruni)
8
+
9
+ [tsParticles](https://github.com/tsparticles/tsparticles) plugin for adding the RGB 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.rgbColor.min.js` file will export the function to load the plugin:
18
+
19
+ ```text
20
+ loadRgbColorPlugin
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 loadRgbColorPlugin();
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-rgb-color
46
+ ```
47
+
48
+ or
49
+
50
+ ```shell
51
+ $ yarn add @tsparticles/plugin-rgb-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 { loadRgbColorPlugin } = require("@tsparticles/plugin-rgb-color");
59
+
60
+ (async () => {
61
+ await loadRgbColorPlugin();
62
+ })();
63
+ ```
64
+
65
+ or
66
+
67
+ ```javascript
68
+ import { tsParticles } from "@tsparticles/engine";
69
+ import { loadRgbColorPlugin } from "@tsparticles/plugin-rgb-color";
70
+
71
+ (async () => {
72
+ await loadRgbColorPlugin();
73
+ })();
74
+ ```
@@ -0,0 +1,44 @@
1
+ import { getRangeValue, parseAlpha, } from "@tsparticles/engine";
2
+ var RgbIndexes;
3
+ (function (RgbIndexes) {
4
+ RgbIndexes[RgbIndexes["r"] = 1] = "r";
5
+ RgbIndexes[RgbIndexes["g"] = 2] = "g";
6
+ RgbIndexes[RgbIndexes["b"] = 3] = "b";
7
+ RgbIndexes[RgbIndexes["a"] = 5] = "a";
8
+ })(RgbIndexes || (RgbIndexes = {}));
9
+ export class RgbColorManager {
10
+ constructor() {
11
+ this.key = "rgb";
12
+ this.stringPrefix = "rgb";
13
+ }
14
+ handleColor(color) {
15
+ const colorValue = color.value, rgbColor = colorValue.rgb ?? color.value;
16
+ if (rgbColor.r !== undefined) {
17
+ return rgbColor;
18
+ }
19
+ }
20
+ handleRangeColor(color) {
21
+ const colorValue = color.value, rgbColor = colorValue.rgb ?? color.value;
22
+ if (rgbColor.r !== undefined) {
23
+ return {
24
+ r: getRangeValue(rgbColor.r),
25
+ g: getRangeValue(rgbColor.g),
26
+ b: getRangeValue(rgbColor.b),
27
+ };
28
+ }
29
+ }
30
+ parseString(input) {
31
+ if (!input.startsWith(this.stringPrefix)) {
32
+ return;
33
+ }
34
+ 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;
35
+ return result
36
+ ? {
37
+ a: result.length > minLength ? parseAlpha(result[RgbIndexes.a]) : defaultAlpha,
38
+ b: parseInt(result[RgbIndexes.b], radix),
39
+ g: parseInt(result[RgbIndexes.g], radix),
40
+ r: parseInt(result[RgbIndexes.r], radix),
41
+ }
42
+ : undefined;
43
+ }
44
+ }
@@ -0,0 +1,6 @@
1
+ import { assertValidVersion } from "@tsparticles/engine";
2
+ import { RgbColorManager } from "./RgbColorManager.js";
3
+ export async function loadRgbColorPlugin(engine, refresh = true) {
4
+ assertValidVersion(engine, "3.7.0");
5
+ await engine.addColorManager(new RgbColorManager(), refresh);
6
+ }
@@ -0,0 +1 @@
1
+ { "type": "module" }
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RgbColorManager = void 0;
4
+ const engine_1 = require("@tsparticles/engine");
5
+ var RgbIndexes;
6
+ (function (RgbIndexes) {
7
+ RgbIndexes[RgbIndexes["r"] = 1] = "r";
8
+ RgbIndexes[RgbIndexes["g"] = 2] = "g";
9
+ RgbIndexes[RgbIndexes["b"] = 3] = "b";
10
+ RgbIndexes[RgbIndexes["a"] = 5] = "a";
11
+ })(RgbIndexes || (RgbIndexes = {}));
12
+ class RgbColorManager {
13
+ constructor() {
14
+ this.key = "rgb";
15
+ this.stringPrefix = "rgb";
16
+ }
17
+ handleColor(color) {
18
+ const colorValue = color.value, rgbColor = colorValue.rgb ?? color.value;
19
+ if (rgbColor.r !== undefined) {
20
+ return rgbColor;
21
+ }
22
+ }
23
+ handleRangeColor(color) {
24
+ const colorValue = color.value, rgbColor = colorValue.rgb ?? color.value;
25
+ if (rgbColor.r !== undefined) {
26
+ return {
27
+ r: (0, engine_1.getRangeValue)(rgbColor.r),
28
+ g: (0, engine_1.getRangeValue)(rgbColor.g),
29
+ b: (0, engine_1.getRangeValue)(rgbColor.b),
30
+ };
31
+ }
32
+ }
33
+ parseString(input) {
34
+ if (!input.startsWith(this.stringPrefix)) {
35
+ return;
36
+ }
37
+ 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;
38
+ return result
39
+ ? {
40
+ a: result.length > minLength ? (0, engine_1.parseAlpha)(result[RgbIndexes.a]) : defaultAlpha,
41
+ b: parseInt(result[RgbIndexes.b], radix),
42
+ g: parseInt(result[RgbIndexes.g], radix),
43
+ r: parseInt(result[RgbIndexes.r], radix),
44
+ }
45
+ : undefined;
46
+ }
47
+ }
48
+ exports.RgbColorManager = RgbColorManager;
package/cjs/index.js ADDED
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.loadRgbColorPlugin = loadRgbColorPlugin;
4
+ const engine_1 = require("@tsparticles/engine");
5
+ const RgbColorManager_js_1 = require("./RgbColorManager.js");
6
+ async function loadRgbColorPlugin(engine, refresh = true) {
7
+ (0, engine_1.assertValidVersion)(engine, "3.7.0");
8
+ await engine.addColorManager(new RgbColorManager_js_1.RgbColorManager(), refresh);
9
+ }
@@ -0,0 +1 @@
1
+ { "type": "commonjs" }
@@ -0,0 +1,44 @@
1
+ import { getRangeValue, parseAlpha, } from "@tsparticles/engine";
2
+ var RgbIndexes;
3
+ (function (RgbIndexes) {
4
+ RgbIndexes[RgbIndexes["r"] = 1] = "r";
5
+ RgbIndexes[RgbIndexes["g"] = 2] = "g";
6
+ RgbIndexes[RgbIndexes["b"] = 3] = "b";
7
+ RgbIndexes[RgbIndexes["a"] = 5] = "a";
8
+ })(RgbIndexes || (RgbIndexes = {}));
9
+ export class RgbColorManager {
10
+ constructor() {
11
+ this.key = "rgb";
12
+ this.stringPrefix = "rgb";
13
+ }
14
+ handleColor(color) {
15
+ const colorValue = color.value, rgbColor = colorValue.rgb ?? color.value;
16
+ if (rgbColor.r !== undefined) {
17
+ return rgbColor;
18
+ }
19
+ }
20
+ handleRangeColor(color) {
21
+ const colorValue = color.value, rgbColor = colorValue.rgb ?? color.value;
22
+ if (rgbColor.r !== undefined) {
23
+ return {
24
+ r: getRangeValue(rgbColor.r),
25
+ g: getRangeValue(rgbColor.g),
26
+ b: getRangeValue(rgbColor.b),
27
+ };
28
+ }
29
+ }
30
+ parseString(input) {
31
+ if (!input.startsWith(this.stringPrefix)) {
32
+ return;
33
+ }
34
+ 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;
35
+ return result
36
+ ? {
37
+ a: result.length > minLength ? parseAlpha(result[RgbIndexes.a]) : defaultAlpha,
38
+ b: parseInt(result[RgbIndexes.b], radix),
39
+ g: parseInt(result[RgbIndexes.g], radix),
40
+ r: parseInt(result[RgbIndexes.r], radix),
41
+ }
42
+ : undefined;
43
+ }
44
+ }
package/esm/index.js ADDED
@@ -0,0 +1,6 @@
1
+ import { assertValidVersion } from "@tsparticles/engine";
2
+ import { RgbColorManager } from "./RgbColorManager.js";
3
+ export async function loadRgbColorPlugin(engine, refresh = true) {
4
+ assertValidVersion(engine, "3.7.0");
5
+ await engine.addColorManager(new RgbColorManager(), refresh);
6
+ }
@@ -0,0 +1 @@
1
+ { "type": "module" }
package/package.json ADDED
@@ -0,0 +1,108 @@
1
+ {
2
+ "name": "@tsparticles/plugin-rgb-color",
3
+ "version": "3.7.0",
4
+ "description": "tsParticles RGB color plugin",
5
+ "homepage": "https://particles.js.org",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/tsparticles/tsparticles.git",
9
+ "directory": "plugins/colors/rgbColor"
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/tsparticles/tsparticles/issues"
69
+ },
70
+ "funding": [
71
+ {
72
+ "type": "github",
73
+ "url": "https://github.com/sponsors/matteobruni"
74
+ },
75
+ {
76
+ "type": "github",
77
+ "url": "https://github.com/sponsors/tsparticles"
78
+ },
79
+ {
80
+ "type": "buymeacoffee",
81
+ "url": "https://www.buymeacoffee.com/matteobruni"
82
+ }
83
+ ],
84
+ "sideEffects": false,
85
+ "jsdelivr": "tsparticles.plugin.rgbColor.min.js",
86
+ "unpkg": "tsparticles.plugin.rgbColor.min.js",
87
+ "browser": "browser/index.js",
88
+ "main": "cjs/index.js",
89
+ "module": "esm/index.js",
90
+ "types": "types/index.d.ts",
91
+ "exports": {
92
+ ".": {
93
+ "types": "./types/index.d.ts",
94
+ "browser": "./browser/index.js",
95
+ "import": "./esm/index.js",
96
+ "require": "./cjs/index.js",
97
+ "umd": "./umd/index.js",
98
+ "default": "./cjs/index.js"
99
+ },
100
+ "./package.json": "./package.json"
101
+ },
102
+ "dependencies": {
103
+ "@tsparticles/engine": "3.7.0"
104
+ },
105
+ "publishConfig": {
106
+ "access": "public"
107
+ }
108
+ }