@tsparticles/engine 3.6.0 → 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/README.md +6 -1
- package/browser/Core/Canvas.js +32 -21
- package/browser/Core/Container.js +1 -1
- package/browser/Core/Engine.js +17 -1
- package/browser/Core/Particle.js +1 -1
- package/browser/Types/EasingFunction.js +1 -0
- package/browser/Utils/ColorUtils.js +25 -45
- package/browser/Utils/NumberUtils.js +1 -10
- package/browser/Utils/Utils.js +6 -0
- package/browser/exports.js +0 -2
- package/browser/init.js +0 -6
- package/cjs/Core/Canvas.js +32 -21
- package/cjs/Core/Container.js +1 -1
- package/cjs/Core/Engine.js +17 -1
- package/cjs/Core/Particle.js +1 -1
- package/cjs/Types/EasingFunction.js +2 -0
- package/cjs/Utils/ColorUtils.js +25 -46
- package/cjs/Utils/NumberUtils.js +1 -12
- package/cjs/Utils/Utils.js +7 -0
- package/cjs/exports.js +0 -2
- package/cjs/init.js +0 -6
- package/esm/Core/Canvas.js +32 -21
- package/esm/Core/Container.js +1 -1
- package/esm/Core/Engine.js +17 -1
- package/esm/Core/Particle.js +1 -1
- package/esm/Types/EasingFunction.js +1 -0
- package/esm/Utils/ColorUtils.js +25 -45
- package/esm/Utils/NumberUtils.js +1 -10
- package/esm/Utils/Utils.js +6 -0
- package/esm/exports.js +0 -2
- package/esm/init.js +0 -6
- package/package.json +1 -1
- package/report.html +1 -1
- package/tsparticles.engine.js +11 -31
- package/tsparticles.engine.min.js +1 -1
- package/tsparticles.engine.min.js.LICENSE.txt +1 -1
- package/types/Core/Canvas.d.ts +4 -1
- package/types/Core/Engine.d.ts +9 -1
- package/types/Types/EasingFunction.d.ts +1 -0
- package/types/Utils/ColorUtils.d.ts +8 -9
- package/types/Utils/NumberUtils.d.ts +0 -5
- package/types/Utils/Utils.d.ts +2 -0
- package/types/exports.d.ts +0 -2
- package/umd/Core/Canvas.js +32 -21
- package/umd/Core/Container.js +1 -1
- package/umd/Core/Engine.js +17 -1
- package/umd/Core/Particle.js +1 -1
- package/umd/Types/EasingFunction.js +12 -0
- package/umd/Utils/ColorUtils.js +25 -46
- package/umd/Utils/NumberUtils.js +1 -12
- package/umd/Utils/Utils.js +7 -0
- package/umd/exports.js +1 -3
- package/umd/init.js +1 -7
- package/browser/Utils/HslColorManager.js +0 -45
- package/browser/Utils/RgbColorManager.js +0 -44
- package/cjs/Utils/HslColorManager.js +0 -49
- package/cjs/Utils/RgbColorManager.js +0 -48
- package/esm/Utils/HslColorManager.js +0 -45
- package/esm/Utils/RgbColorManager.js +0 -44
- package/types/Utils/HslColorManager.d.ts +0 -10
- package/types/Utils/RgbColorManager.d.ts +0 -10
- package/umd/Utils/HslColorManager.js +0 -59
- package/umd/Utils/RgbColorManager.js +0 -58
package/umd/Core/Canvas.js
CHANGED
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
class Canvas {
|
|
41
|
-
constructor(container) {
|
|
41
|
+
constructor(container, engine) {
|
|
42
42
|
this.container = container;
|
|
43
43
|
this._applyPostDrawUpdaters = particle => {
|
|
44
44
|
for (const updater of this._postDrawUpdaters) {
|
|
@@ -74,10 +74,10 @@
|
|
|
74
74
|
let fColor, sColor;
|
|
75
75
|
for (const plugin of this._colorPlugins) {
|
|
76
76
|
if (!fColor && plugin.particleFillColor) {
|
|
77
|
-
fColor = (0, ColorUtils_js_1.rangeColorToHsl)(plugin.particleFillColor(particle));
|
|
77
|
+
fColor = (0, ColorUtils_js_1.rangeColorToHsl)(this._engine, plugin.particleFillColor(particle));
|
|
78
78
|
}
|
|
79
79
|
if (!sColor && plugin.particleStrokeColor) {
|
|
80
|
-
sColor = (0, ColorUtils_js_1.rangeColorToHsl)(plugin.particleStrokeColor(particle));
|
|
80
|
+
sColor = (0, ColorUtils_js_1.rangeColorToHsl)(this._engine, plugin.particleStrokeColor(particle));
|
|
81
81
|
}
|
|
82
82
|
if (fColor && sColor) {
|
|
83
83
|
break;
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
this._initCover = async () => {
|
|
89
89
|
const options = this.container.actualOptions, cover = options.backgroundMask.cover, color = cover.color;
|
|
90
90
|
if (color) {
|
|
91
|
-
const coverRgb = (0, ColorUtils_js_1.rangeColorToRgb)(color);
|
|
91
|
+
const coverRgb = (0, ColorUtils_js_1.rangeColorToRgb)(this._engine, color);
|
|
92
92
|
if (coverRgb) {
|
|
93
93
|
const coverColor = {
|
|
94
94
|
...coverRgb,
|
|
@@ -147,7 +147,7 @@
|
|
|
147
147
|
}
|
|
148
148
|
const factorNumerator = 1, opacity = factorNumerator / trail.length;
|
|
149
149
|
if (trailFill.color) {
|
|
150
|
-
const fillColor = (0, ColorUtils_js_1.rangeColorToRgb)(trailFill.color);
|
|
150
|
+
const fillColor = (0, ColorUtils_js_1.rangeColorToRgb)(this._engine, trailFill.color);
|
|
151
151
|
if (!fillColor) {
|
|
152
152
|
return;
|
|
153
153
|
}
|
|
@@ -228,10 +228,16 @@
|
|
|
228
228
|
height: "100%",
|
|
229
229
|
}, true);
|
|
230
230
|
};
|
|
231
|
-
this.
|
|
231
|
+
this._engine = engine;
|
|
232
|
+
this._standardSize = {
|
|
232
233
|
height: 0,
|
|
233
234
|
width: 0,
|
|
234
235
|
};
|
|
236
|
+
const pxRatio = container.retina.pixelRatio, stdSize = this._standardSize;
|
|
237
|
+
this.size = {
|
|
238
|
+
height: stdSize.height * pxRatio,
|
|
239
|
+
width: stdSize.width * pxRatio,
|
|
240
|
+
};
|
|
235
241
|
this._context = null;
|
|
236
242
|
this._generated = false;
|
|
237
243
|
this._preDrawUpdaters = [];
|
|
@@ -375,7 +381,7 @@
|
|
|
375
381
|
return;
|
|
376
382
|
}
|
|
377
383
|
if (background.color) {
|
|
378
|
-
const color = (0, ColorUtils_js_1.rangeColorToRgb)(background.color);
|
|
384
|
+
const color = (0, ColorUtils_js_1.rangeColorToRgb)(this._engine, background.color);
|
|
379
385
|
elementStyle.backgroundColor = color ? (0, ColorUtils_js_1.getStyleFromRgb)(color, background.opacity) : "";
|
|
380
386
|
}
|
|
381
387
|
else {
|
|
@@ -420,8 +426,13 @@
|
|
|
420
426
|
this.element = canvas;
|
|
421
427
|
this.element.ariaHidden = "true";
|
|
422
428
|
this._originalStyle = (0, Utils_js_1.deepExtend)({}, this.element.style);
|
|
423
|
-
|
|
424
|
-
|
|
429
|
+
const standardSize = this._standardSize;
|
|
430
|
+
standardSize.height = canvas.offsetHeight;
|
|
431
|
+
standardSize.width = canvas.offsetWidth;
|
|
432
|
+
const pxRatio = this.container.retina.pixelRatio;
|
|
433
|
+
const retinaSize = this.size;
|
|
434
|
+
retinaSize.height = standardSize.height * pxRatio;
|
|
435
|
+
retinaSize.width = standardSize.width * pxRatio;
|
|
425
436
|
this._context = this.element.getContext("2d");
|
|
426
437
|
this._safeMutationObserver(obs => {
|
|
427
438
|
if (!this.element || !(this.element instanceof Node)) {
|
|
@@ -456,23 +467,23 @@
|
|
|
456
467
|
if (!this.element) {
|
|
457
468
|
return false;
|
|
458
469
|
}
|
|
459
|
-
const container = this.container,
|
|
460
|
-
width: this.element.offsetWidth
|
|
461
|
-
height: this.element.offsetHeight
|
|
470
|
+
const container = this.container, currentSize = container.canvas._standardSize, newSize = {
|
|
471
|
+
width: this.element.offsetWidth,
|
|
472
|
+
height: this.element.offsetHeight,
|
|
462
473
|
};
|
|
463
|
-
if (newSize.height ===
|
|
464
|
-
newSize.width === size.width &&
|
|
465
|
-
newSize.height === this.element.height &&
|
|
466
|
-
newSize.width === this.element.width) {
|
|
474
|
+
if (newSize.height === currentSize.height && newSize.width === currentSize.width) {
|
|
467
475
|
return false;
|
|
468
476
|
}
|
|
469
|
-
const oldSize = { ...
|
|
470
|
-
|
|
471
|
-
|
|
477
|
+
const oldSize = { ...currentSize }, pxRatio = container.retina.pixelRatio;
|
|
478
|
+
currentSize.height = newSize.height;
|
|
479
|
+
currentSize.width = newSize.width;
|
|
480
|
+
const retinaSize = this.size;
|
|
481
|
+
this.element.width = retinaSize.width = currentSize.width * pxRatio;
|
|
482
|
+
this.element.height = retinaSize.height = currentSize.height * pxRatio;
|
|
472
483
|
if (this.container.started) {
|
|
473
484
|
container.particles.setResizeFactor({
|
|
474
|
-
width:
|
|
475
|
-
height:
|
|
485
|
+
width: currentSize.width / oldSize.width,
|
|
486
|
+
height: currentSize.height / oldSize.height,
|
|
476
487
|
});
|
|
477
488
|
}
|
|
478
489
|
return true;
|
package/umd/Core/Container.js
CHANGED
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
this._sourceOptions = sourceOptions;
|
|
101
101
|
this._initialSourceOptions = sourceOptions;
|
|
102
102
|
this.retina = new Retina_js_1.Retina(this);
|
|
103
|
-
this.canvas = new Canvas_js_1.Canvas(this);
|
|
103
|
+
this.canvas = new Canvas_js_1.Canvas(this, this._engine);
|
|
104
104
|
this.particles = new Particles_js_1.Particles(this._engine, this);
|
|
105
105
|
this.pathGenerators = new Map();
|
|
106
106
|
this.interactivity = {
|
package/umd/Core/Engine.js
CHANGED
|
@@ -83,6 +83,8 @@
|
|
|
83
83
|
this._eventDispatcher = new EventDispatcher_js_1.EventDispatcher();
|
|
84
84
|
this._initialized = false;
|
|
85
85
|
this.plugins = [];
|
|
86
|
+
this.colorManagers = new Map();
|
|
87
|
+
this.easingFunctions = new Map();
|
|
86
88
|
this._initializers = {
|
|
87
89
|
interactors: new Map(),
|
|
88
90
|
movers: new Map(),
|
|
@@ -107,13 +109,24 @@
|
|
|
107
109
|
return this._domArray;
|
|
108
110
|
}
|
|
109
111
|
get version() {
|
|
110
|
-
return "3.
|
|
112
|
+
return "3.7.0";
|
|
113
|
+
}
|
|
114
|
+
async addColorManager(manager, refresh = true) {
|
|
115
|
+
this.colorManagers.set(manager.key, manager);
|
|
116
|
+
await this.refresh(refresh);
|
|
111
117
|
}
|
|
112
118
|
addConfig(config) {
|
|
113
119
|
const key = config.key ?? config.name ?? "default";
|
|
114
120
|
this._configs.set(key, config);
|
|
115
121
|
this._eventDispatcher.dispatchEvent(EventType_js_1.EventType.configAdded, { data: { name: key, config } });
|
|
116
122
|
}
|
|
123
|
+
async addEasing(name, easing, refresh = true) {
|
|
124
|
+
if (this.getEasing(name)) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
this.easingFunctions.set(name, easing);
|
|
128
|
+
await this.refresh(refresh);
|
|
129
|
+
}
|
|
117
130
|
async addEffect(effect, drawer, refresh = true) {
|
|
118
131
|
(0, Utils_js_1.executeOnSingleOrMultiple)(effect, type => {
|
|
119
132
|
if (!this.getEffectDrawer(type)) {
|
|
@@ -187,6 +200,9 @@
|
|
|
187
200
|
}
|
|
188
201
|
return res;
|
|
189
202
|
}
|
|
203
|
+
getEasing(name) {
|
|
204
|
+
return this.easingFunctions.get(name) ?? ((value) => value);
|
|
205
|
+
}
|
|
190
206
|
getEffectDrawer(type) {
|
|
191
207
|
return this.effectDrawers.get(type);
|
|
192
208
|
}
|
package/umd/Core/Particle.js
CHANGED
|
@@ -337,7 +337,7 @@
|
|
|
337
337
|
this.sides = sideCountFunc(this);
|
|
338
338
|
}
|
|
339
339
|
this.spawning = false;
|
|
340
|
-
this.shadowColor = (0, ColorUtils_js_1.rangeColorToRgb)(this.options.shadow.color);
|
|
340
|
+
this.shadowColor = (0, ColorUtils_js_1.rangeColorToRgb)(this._engine, this.options.shadow.color);
|
|
341
341
|
for (const updater of particles.updaters) {
|
|
342
342
|
updater.init(this);
|
|
343
343
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
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"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
});
|
package/umd/Utils/ColorUtils.js
CHANGED
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
"use strict";
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.addColorManager = addColorManager;
|
|
13
12
|
exports.rangeColorToRgb = rangeColorToRgb;
|
|
14
13
|
exports.colorToRgb = colorToRgb;
|
|
15
14
|
exports.colorToHsl = colorToHsl;
|
|
@@ -34,83 +33,63 @@
|
|
|
34
33
|
const Constants_js_1 = require("../Core/Utils/Constants.js");
|
|
35
34
|
const AnimationStatus_js_1 = require("../Enums/AnimationStatus.js");
|
|
36
35
|
const Utils_js_1 = require("./Utils.js");
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
})(RgbIndexes || (RgbIndexes = {}));
|
|
44
|
-
const randomColorValue = "random", midColorValue = "mid", colorManagers = new Map();
|
|
45
|
-
function addColorManager(manager) {
|
|
46
|
-
colorManagers.set(manager.key, manager);
|
|
47
|
-
}
|
|
48
|
-
function stringToRgba(input) {
|
|
49
|
-
for (const manager of colorManagers.values()) {
|
|
36
|
+
const randomColorValue = "random", midColorValue = "mid";
|
|
37
|
+
function stringToRgba(engine, input) {
|
|
38
|
+
if (!input) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
for (const manager of engine.colorManagers.values()) {
|
|
50
42
|
if (input.startsWith(manager.stringPrefix)) {
|
|
51
43
|
return manager.parseString(input);
|
|
52
44
|
}
|
|
53
45
|
}
|
|
54
|
-
const shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])([a-f\d])?$/i, hexFixed = input.replace(shorthandRegex, (_, r, g, b, a) => {
|
|
55
|
-
return r + r + g + g + b + b + (a !== undefined ? a + a : "");
|
|
56
|
-
}), regex = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})?$/i, result = regex.exec(hexFixed), radix = 16, defaultAlpha = 1, alphaFactor = 0xff;
|
|
57
|
-
return result
|
|
58
|
-
? {
|
|
59
|
-
a: result[RgbIndexes.a] !== undefined
|
|
60
|
-
? parseInt(result[RgbIndexes.a], radix) / alphaFactor
|
|
61
|
-
: defaultAlpha,
|
|
62
|
-
b: parseInt(result[RgbIndexes.b], radix),
|
|
63
|
-
g: parseInt(result[RgbIndexes.g], radix),
|
|
64
|
-
r: parseInt(result[RgbIndexes.r], radix),
|
|
65
|
-
}
|
|
66
|
-
: undefined;
|
|
67
46
|
}
|
|
68
|
-
function rangeColorToRgb(input, index, useIndex = true) {
|
|
47
|
+
function rangeColorToRgb(engine, input, index, useIndex = true) {
|
|
69
48
|
if (!input) {
|
|
70
49
|
return;
|
|
71
50
|
}
|
|
72
51
|
const color = (0, TypeUtils_js_1.isString)(input) ? { value: input } : input;
|
|
73
52
|
if ((0, TypeUtils_js_1.isString)(color.value)) {
|
|
74
|
-
return colorToRgb(color.value, index, useIndex);
|
|
53
|
+
return colorToRgb(engine, color.value, index, useIndex);
|
|
75
54
|
}
|
|
76
55
|
if ((0, TypeUtils_js_1.isArray)(color.value)) {
|
|
77
|
-
return rangeColorToRgb({
|
|
56
|
+
return rangeColorToRgb(engine, {
|
|
78
57
|
value: (0, Utils_js_1.itemFromArray)(color.value, index, useIndex),
|
|
79
58
|
});
|
|
80
59
|
}
|
|
81
|
-
for (const manager of colorManagers.values()) {
|
|
60
|
+
for (const manager of engine.colorManagers.values()) {
|
|
82
61
|
const res = manager.handleRangeColor(color);
|
|
83
62
|
if (res) {
|
|
84
63
|
return res;
|
|
85
64
|
}
|
|
86
65
|
}
|
|
87
66
|
}
|
|
88
|
-
function colorToRgb(input, index, useIndex = true) {
|
|
67
|
+
function colorToRgb(engine, input, index, useIndex = true) {
|
|
89
68
|
if (!input) {
|
|
90
69
|
return;
|
|
91
70
|
}
|
|
92
71
|
const color = (0, TypeUtils_js_1.isString)(input) ? { value: input } : input;
|
|
93
72
|
if ((0, TypeUtils_js_1.isString)(color.value)) {
|
|
94
|
-
return color.value === randomColorValue ? getRandomRgbColor() : stringToRgb(color.value);
|
|
73
|
+
return color.value === randomColorValue ? getRandomRgbColor() : stringToRgb(engine, color.value);
|
|
95
74
|
}
|
|
96
75
|
if ((0, TypeUtils_js_1.isArray)(color.value)) {
|
|
97
|
-
return colorToRgb({
|
|
76
|
+
return colorToRgb(engine, {
|
|
98
77
|
value: (0, Utils_js_1.itemFromArray)(color.value, index, useIndex),
|
|
99
78
|
});
|
|
100
79
|
}
|
|
101
|
-
for (const manager of colorManagers.values()) {
|
|
80
|
+
for (const manager of engine.colorManagers.values()) {
|
|
102
81
|
const res = manager.handleColor(color);
|
|
103
82
|
if (res) {
|
|
104
83
|
return res;
|
|
105
84
|
}
|
|
106
85
|
}
|
|
107
86
|
}
|
|
108
|
-
function colorToHsl(color, index, useIndex = true) {
|
|
109
|
-
const rgb = colorToRgb(color, index, useIndex);
|
|
87
|
+
function colorToHsl(engine, color, index, useIndex = true) {
|
|
88
|
+
const rgb = colorToRgb(engine, color, index, useIndex);
|
|
110
89
|
return rgb ? rgbToHsl(rgb) : undefined;
|
|
111
90
|
}
|
|
112
|
-
function rangeColorToHsl(color, index, useIndex = true) {
|
|
113
|
-
const rgb = rangeColorToRgb(color, index, useIndex);
|
|
91
|
+
function rangeColorToHsl(engine, color, index, useIndex = true) {
|
|
92
|
+
const rgb = rangeColorToRgb(engine, color, index, useIndex);
|
|
114
93
|
return rgb ? rgbToHsl(rgb) : undefined;
|
|
115
94
|
}
|
|
116
95
|
function rgbToHsl(color) {
|
|
@@ -137,11 +116,11 @@
|
|
|
137
116
|
}
|
|
138
117
|
return res;
|
|
139
118
|
}
|
|
140
|
-
function stringToAlpha(input) {
|
|
141
|
-
return stringToRgba(input)?.a;
|
|
119
|
+
function stringToAlpha(engine, input) {
|
|
120
|
+
return stringToRgba(engine, input)?.a;
|
|
142
121
|
}
|
|
143
|
-
function stringToRgb(input) {
|
|
144
|
-
return stringToRgba(input);
|
|
122
|
+
function stringToRgb(engine, input) {
|
|
123
|
+
return stringToRgba(engine, input);
|
|
145
124
|
}
|
|
146
125
|
function hslToRgb(hsl) {
|
|
147
126
|
const hMax = 360, sMax = 100, lMax = 100, sMin = 0, lMin = 0, h = ((hsl.h % hMax) + hMax) % hMax, s = Math.max(sMin, Math.min(sMax, hsl.s)), l = Math.max(lMin, Math.min(lMax, hsl.l)), hNormalized = h / hMax, sNormalized = s / sMax, lNormalized = l / lMax, rgbFactor = 255, triple = 3;
|
|
@@ -232,11 +211,11 @@
|
|
|
232
211
|
return linkColor;
|
|
233
212
|
}
|
|
234
213
|
}
|
|
235
|
-
function getLinkRandomColor(optColor, blink, consent) {
|
|
214
|
+
function getLinkRandomColor(engine, optColor, blink, consent) {
|
|
236
215
|
const color = (0, TypeUtils_js_1.isString)(optColor) ? optColor : optColor.value;
|
|
237
216
|
if (color === randomColorValue) {
|
|
238
217
|
if (consent) {
|
|
239
|
-
return rangeColorToRgb({
|
|
218
|
+
return rangeColorToRgb(engine, {
|
|
240
219
|
value: color,
|
|
241
220
|
});
|
|
242
221
|
}
|
|
@@ -249,7 +228,7 @@
|
|
|
249
228
|
return midColorValue;
|
|
250
229
|
}
|
|
251
230
|
else {
|
|
252
|
-
return rangeColorToRgb({
|
|
231
|
+
return rangeColorToRgb(engine, {
|
|
253
232
|
value: color,
|
|
254
233
|
});
|
|
255
234
|
}
|
package/umd/Utils/NumberUtils.js
CHANGED
|
@@ -9,8 +9,6 @@
|
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
"use strict";
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.addEasing = addEasing;
|
|
13
|
-
exports.getEasing = getEasing;
|
|
14
12
|
exports.setRandom = setRandom;
|
|
15
13
|
exports.getRandom = getRandom;
|
|
16
14
|
exports.setAnimationFunctions = setAnimationFunctions;
|
|
@@ -43,16 +41,7 @@
|
|
|
43
41
|
const _animationLoop = {
|
|
44
42
|
nextFrame: (cb) => requestAnimationFrame(cb),
|
|
45
43
|
cancel: (idx) => cancelAnimationFrame(idx),
|
|
46
|
-
},
|
|
47
|
-
function addEasing(name, easing) {
|
|
48
|
-
if (easingFunctions.get(name)) {
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
easingFunctions.set(name, easing);
|
|
52
|
-
}
|
|
53
|
-
function getEasing(name) {
|
|
54
|
-
return easingFunctions.get(name) ?? ((value) => value);
|
|
55
|
-
}
|
|
44
|
+
}, double = 2, doublePI = Math.PI * double;
|
|
56
45
|
function setRandom(rnd = Math.random) {
|
|
57
46
|
_random = rnd;
|
|
58
47
|
}
|
package/umd/Utils/Utils.js
CHANGED
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
exports.getPosition = getPosition;
|
|
39
39
|
exports.getSize = getSize;
|
|
40
40
|
exports.updateAnimation = updateAnimation;
|
|
41
|
+
exports.assertValidVersion = assertValidVersion;
|
|
41
42
|
const NumberUtils_js_1 = require("./NumberUtils.js");
|
|
42
43
|
const Constants_js_1 = require("../Core/Utils/Constants.js");
|
|
43
44
|
const TypeUtils_js_1 = require("./TypeUtils.js");
|
|
@@ -454,4 +455,10 @@
|
|
|
454
455
|
data.value = (0, NumberUtils_js_1.clamp)(data.value, minValue, maxValue);
|
|
455
456
|
}
|
|
456
457
|
}
|
|
458
|
+
function assertValidVersion(engine, pluginVersion) {
|
|
459
|
+
if (engine.version === pluginVersion) {
|
|
460
|
+
return;
|
|
461
|
+
}
|
|
462
|
+
throw new Error(`The tsParticles version is different from the loaded plugins version. Engine version: ${engine.version}. Plugins version: ${pluginVersion}`);
|
|
463
|
+
}
|
|
457
464
|
});
|
package/umd/exports.js
CHANGED
|
@@ -18,7 +18,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
18
18
|
if (v !== undefined) module.exports = v;
|
|
19
19
|
}
|
|
20
20
|
else if (typeof define === "function" && define.amd) {
|
|
21
|
-
define(["require", "exports", "./Core/Utils/Constants.js", "./Core/Utils/ExternalInteractorBase.js", "./Core/Utils/ParticlesInteractorBase.js", "./Core/Utils/Point.js", "./Core/Utils/Ranges.js", "./Core/Utils/Vectors.js", "./Enums/Directions/MoveDirection.js", "./Enums/Directions/RotateDirection.js", "./Enums/Directions/OutModeDirection.js", "./Enums/Modes/AnimationMode.js", "./Enums/Modes/CollisionMode.js", "./Enums/Modes/LimitMode.js", "./Enums/Modes/OutMode.js", "./Enums/Modes/PixelMode.js", "./Enums/Modes/ThemeMode.js", "./Enums/Modes/ResponsiveMode.js", "./Enums/Types/AlterType.js", "./Enums/Types/DestroyType.js", "./Enums/Types/GradientType.js", "./Enums/Types/InteractorType.js", "./Enums/Types/ParticleOutType.js", "./Enums/Types/StartValueType.js", "./Enums/Types/DivType.js", "./Enums/Types/EasingType.js", "./Enums/Types/EventType.js", "./Enums/AnimationStatus.js", "./Enums/InteractivityDetect.js", "./Options/Classes/AnimatableColor.js", "./Options/Classes/AnimationOptions.js", "./Options/Classes/Background/Background.js", "./Options/Classes/BackgroundMask/BackgroundMask.js", "./Options/Classes/BackgroundMask/BackgroundMaskCover.js", "./Options/Classes/ColorAnimation.js", "./Options/Classes/FullScreen/FullScreen.js", "./Options/Classes/HslAnimation.js", "./Options/Classes/Interactivity/Events/ClickEvent.js", "./Options/Classes/Interactivity/Events/DivEvent.js", "./Options/Classes/Interactivity/Events/ClickEvent.js", "./Options/Classes/Interactivity/Events/DivEvent.js", "./Options/Classes/Interactivity/Events/Events.js", "./Options/Classes/Interactivity/Events/HoverEvent.js", "./Options/Classes/Interactivity/Events/Parallax.js", "./Options/Classes/Interactivity/Events/ResizeEvent.js", "./Options/Classes/Interactivity/Interactivity.js", "./Options/Classes/Interactivity/Modes/Modes.js", "./Options/Classes/ManualParticle.js", "./Options/Classes/Options.js", "./Options/Classes/OptionsColor.js", "./Options/Classes/Particles/Bounce/ParticlesBounce.js", "./Options/Classes/Particles/Bounce/ParticlesBounceFactor.js", "./Options/Classes/Particles/Collisions/Collisions.js", "./Options/Classes/Particles/Collisions/CollisionsAbsorb.js", "./Options/Classes/Particles/Collisions/CollisionsOverlap.js", "./Options/Classes/Particles/ParticlesOptions.js", "./Options/Classes/Particles/Shadow.js", "./Options/Classes/Particles/Stroke.js", "./Options/Classes/Particles/Move/MoveAttract.js", "./Options/Classes/Particles/Move/Move.js", "./Options/Classes/Particles/Move/MoveAngle.js", "./Options/Classes/Particles/Move/MoveCenter.js", "./Options/Classes/Particles/Move/MoveGravity.js", "./Options/Classes/Particles/Move/OutModes.js", "./Options/Classes/Particles/Move/Path/MovePath.js", "./Options/Classes/Particles/Move/Spin.js", "./Options/Classes/Particles/Move/MoveTrail.js", "./Options/Classes/Particles/Number/ParticlesNumber.js", "./Options/Classes/Particles/Number/ParticlesNumberLimit.js", "./Options/Classes/Particles/Number/ParticlesDensity.js", "./Options/Classes/Particles/Opacity/Opacity.js", "./Options/Classes/Particles/Opacity/OpacityAnimation.js", "./Options/Classes/Particles/Shape/Shape.js", "./Options/Classes/Particles/Size/Size.js", "./Options/Classes/Particles/Size/SizeAnimation.js", "./Options/Classes/Particles/ZIndex/ZIndex.js", "./Options/Classes/Responsive.js", "./Options/Classes/Theme/Theme.js", "./Options/Classes/Theme/ThemeDefault.js", "./Options/Classes/ValueWithRandom.js", "./Utils/CanvasUtils.js", "./Utils/ColorUtils.js", "./Utils/
|
|
21
|
+
define(["require", "exports", "./Core/Utils/Constants.js", "./Core/Utils/ExternalInteractorBase.js", "./Core/Utils/ParticlesInteractorBase.js", "./Core/Utils/Point.js", "./Core/Utils/Ranges.js", "./Core/Utils/Vectors.js", "./Enums/Directions/MoveDirection.js", "./Enums/Directions/RotateDirection.js", "./Enums/Directions/OutModeDirection.js", "./Enums/Modes/AnimationMode.js", "./Enums/Modes/CollisionMode.js", "./Enums/Modes/LimitMode.js", "./Enums/Modes/OutMode.js", "./Enums/Modes/PixelMode.js", "./Enums/Modes/ThemeMode.js", "./Enums/Modes/ResponsiveMode.js", "./Enums/Types/AlterType.js", "./Enums/Types/DestroyType.js", "./Enums/Types/GradientType.js", "./Enums/Types/InteractorType.js", "./Enums/Types/ParticleOutType.js", "./Enums/Types/StartValueType.js", "./Enums/Types/DivType.js", "./Enums/Types/EasingType.js", "./Enums/Types/EventType.js", "./Enums/AnimationStatus.js", "./Enums/InteractivityDetect.js", "./Options/Classes/AnimatableColor.js", "./Options/Classes/AnimationOptions.js", "./Options/Classes/Background/Background.js", "./Options/Classes/BackgroundMask/BackgroundMask.js", "./Options/Classes/BackgroundMask/BackgroundMaskCover.js", "./Options/Classes/ColorAnimation.js", "./Options/Classes/FullScreen/FullScreen.js", "./Options/Classes/HslAnimation.js", "./Options/Classes/Interactivity/Events/ClickEvent.js", "./Options/Classes/Interactivity/Events/DivEvent.js", "./Options/Classes/Interactivity/Events/ClickEvent.js", "./Options/Classes/Interactivity/Events/DivEvent.js", "./Options/Classes/Interactivity/Events/Events.js", "./Options/Classes/Interactivity/Events/HoverEvent.js", "./Options/Classes/Interactivity/Events/Parallax.js", "./Options/Classes/Interactivity/Events/ResizeEvent.js", "./Options/Classes/Interactivity/Interactivity.js", "./Options/Classes/Interactivity/Modes/Modes.js", "./Options/Classes/ManualParticle.js", "./Options/Classes/Options.js", "./Options/Classes/OptionsColor.js", "./Options/Classes/Particles/Bounce/ParticlesBounce.js", "./Options/Classes/Particles/Bounce/ParticlesBounceFactor.js", "./Options/Classes/Particles/Collisions/Collisions.js", "./Options/Classes/Particles/Collisions/CollisionsAbsorb.js", "./Options/Classes/Particles/Collisions/CollisionsOverlap.js", "./Options/Classes/Particles/ParticlesOptions.js", "./Options/Classes/Particles/Shadow.js", "./Options/Classes/Particles/Stroke.js", "./Options/Classes/Particles/Move/MoveAttract.js", "./Options/Classes/Particles/Move/Move.js", "./Options/Classes/Particles/Move/MoveAngle.js", "./Options/Classes/Particles/Move/MoveCenter.js", "./Options/Classes/Particles/Move/MoveGravity.js", "./Options/Classes/Particles/Move/OutModes.js", "./Options/Classes/Particles/Move/Path/MovePath.js", "./Options/Classes/Particles/Move/Spin.js", "./Options/Classes/Particles/Move/MoveTrail.js", "./Options/Classes/Particles/Number/ParticlesNumber.js", "./Options/Classes/Particles/Number/ParticlesNumberLimit.js", "./Options/Classes/Particles/Number/ParticlesDensity.js", "./Options/Classes/Particles/Opacity/Opacity.js", "./Options/Classes/Particles/Opacity/OpacityAnimation.js", "./Options/Classes/Particles/Shape/Shape.js", "./Options/Classes/Particles/Size/Size.js", "./Options/Classes/Particles/Size/SizeAnimation.js", "./Options/Classes/Particles/ZIndex/ZIndex.js", "./Options/Classes/Responsive.js", "./Options/Classes/Theme/Theme.js", "./Options/Classes/Theme/ThemeDefault.js", "./Options/Classes/ValueWithRandom.js", "./Utils/CanvasUtils.js", "./Utils/ColorUtils.js", "./Utils/NumberUtils.js", "./Utils/OptionsUtils.js", "./Utils/Utils.js", "./Utils/TypeUtils.js"], factory);
|
|
22
22
|
}
|
|
23
23
|
})(function (require, exports) {
|
|
24
24
|
"use strict";
|
|
@@ -103,10 +103,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
103
103
|
__exportStar(require("./Options/Classes/ValueWithRandom.js"), exports);
|
|
104
104
|
__exportStar(require("./Utils/CanvasUtils.js"), exports);
|
|
105
105
|
__exportStar(require("./Utils/ColorUtils.js"), exports);
|
|
106
|
-
__exportStar(require("./Utils/HslColorManager.js"), exports);
|
|
107
106
|
__exportStar(require("./Utils/NumberUtils.js"), exports);
|
|
108
107
|
__exportStar(require("./Utils/OptionsUtils.js"), exports);
|
|
109
|
-
__exportStar(require("./Utils/RgbColorManager.js"), exports);
|
|
110
108
|
__exportStar(require("./Utils/Utils.js"), exports);
|
|
111
109
|
__exportStar(require("./Utils/TypeUtils.js"), exports);
|
|
112
110
|
});
|
package/umd/init.js
CHANGED
|
@@ -4,20 +4,14 @@
|
|
|
4
4
|
if (v !== undefined) module.exports = v;
|
|
5
5
|
}
|
|
6
6
|
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "./Core/Engine.js"
|
|
7
|
+
define(["require", "exports", "./Core/Engine.js"], factory);
|
|
8
8
|
}
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
"use strict";
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.init = init;
|
|
13
13
|
const Engine_js_1 = require("./Core/Engine.js");
|
|
14
|
-
const HslColorManager_js_1 = require("./Utils/HslColorManager.js");
|
|
15
|
-
const RgbColorManager_js_1 = require("./Utils/RgbColorManager.js");
|
|
16
|
-
const ColorUtils_js_1 = require("./Utils/ColorUtils.js");
|
|
17
14
|
function init() {
|
|
18
|
-
const rgbColorManager = new RgbColorManager_js_1.RgbColorManager(), hslColorManager = new HslColorManager_js_1.HslColorManager();
|
|
19
|
-
(0, ColorUtils_js_1.addColorManager)(rgbColorManager);
|
|
20
|
-
(0, ColorUtils_js_1.addColorManager)(hslColorManager);
|
|
21
15
|
const engine = new Engine_js_1.Engine();
|
|
22
16
|
engine.init();
|
|
23
17
|
return engine;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { getRangeValue, parseAlpha } from "./NumberUtils.js";
|
|
2
|
-
import { hslToRgb, hslaToRgba } from "./ColorUtils.js";
|
|
3
|
-
var HslIndexes;
|
|
4
|
-
(function (HslIndexes) {
|
|
5
|
-
HslIndexes[HslIndexes["h"] = 1] = "h";
|
|
6
|
-
HslIndexes[HslIndexes["s"] = 2] = "s";
|
|
7
|
-
HslIndexes[HslIndexes["l"] = 3] = "l";
|
|
8
|
-
HslIndexes[HslIndexes["a"] = 5] = "a";
|
|
9
|
-
})(HslIndexes || (HslIndexes = {}));
|
|
10
|
-
export class HslColorManager {
|
|
11
|
-
constructor() {
|
|
12
|
-
this.key = "hsl";
|
|
13
|
-
this.stringPrefix = "hsl";
|
|
14
|
-
}
|
|
15
|
-
handleColor(color) {
|
|
16
|
-
const colorValue = color.value, hslColor = colorValue.hsl ?? color.value;
|
|
17
|
-
if (hslColor.h !== undefined && hslColor.s !== undefined && hslColor.l !== undefined) {
|
|
18
|
-
return hslToRgb(hslColor);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
handleRangeColor(color) {
|
|
22
|
-
const colorValue = color.value, hslColor = colorValue.hsl ?? color.value;
|
|
23
|
-
if (hslColor.h !== undefined && hslColor.l !== undefined) {
|
|
24
|
-
return hslToRgb({
|
|
25
|
-
h: getRangeValue(hslColor.h),
|
|
26
|
-
l: getRangeValue(hslColor.l),
|
|
27
|
-
s: getRangeValue(hslColor.s),
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
parseString(input) {
|
|
32
|
-
if (!input.startsWith("hsl")) {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
const regex = /hsla?\(\s*(\d+)\s*[\s,]\s*(\d+)%\s*[\s,]\s*(\d+)%\s*([\s,]\s*(0|1|0?\.\d+|(\d{1,3})%)\s*)?\)/i, result = regex.exec(input), minLength = 4, defaultAlpha = 1, radix = 10;
|
|
36
|
-
return result
|
|
37
|
-
? hslaToRgba({
|
|
38
|
-
a: result.length > minLength ? parseAlpha(result[HslIndexes.a]) : defaultAlpha,
|
|
39
|
-
h: parseInt(result[HslIndexes.h], radix),
|
|
40
|
-
l: parseInt(result[HslIndexes.l], radix),
|
|
41
|
-
s: parseInt(result[HslIndexes.s], radix),
|
|
42
|
-
})
|
|
43
|
-
: undefined;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { getRangeValue, parseAlpha } from "./NumberUtils.js";
|
|
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
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HslColorManager = void 0;
|
|
4
|
-
const NumberUtils_js_1 = require("./NumberUtils.js");
|
|
5
|
-
const ColorUtils_js_1 = require("./ColorUtils.js");
|
|
6
|
-
var HslIndexes;
|
|
7
|
-
(function (HslIndexes) {
|
|
8
|
-
HslIndexes[HslIndexes["h"] = 1] = "h";
|
|
9
|
-
HslIndexes[HslIndexes["s"] = 2] = "s";
|
|
10
|
-
HslIndexes[HslIndexes["l"] = 3] = "l";
|
|
11
|
-
HslIndexes[HslIndexes["a"] = 5] = "a";
|
|
12
|
-
})(HslIndexes || (HslIndexes = {}));
|
|
13
|
-
class HslColorManager {
|
|
14
|
-
constructor() {
|
|
15
|
-
this.key = "hsl";
|
|
16
|
-
this.stringPrefix = "hsl";
|
|
17
|
-
}
|
|
18
|
-
handleColor(color) {
|
|
19
|
-
const colorValue = color.value, hslColor = colorValue.hsl ?? color.value;
|
|
20
|
-
if (hslColor.h !== undefined && hslColor.s !== undefined && hslColor.l !== undefined) {
|
|
21
|
-
return (0, ColorUtils_js_1.hslToRgb)(hslColor);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
handleRangeColor(color) {
|
|
25
|
-
const colorValue = color.value, hslColor = colorValue.hsl ?? color.value;
|
|
26
|
-
if (hslColor.h !== undefined && hslColor.l !== undefined) {
|
|
27
|
-
return (0, ColorUtils_js_1.hslToRgb)({
|
|
28
|
-
h: (0, NumberUtils_js_1.getRangeValue)(hslColor.h),
|
|
29
|
-
l: (0, NumberUtils_js_1.getRangeValue)(hslColor.l),
|
|
30
|
-
s: (0, NumberUtils_js_1.getRangeValue)(hslColor.s),
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
parseString(input) {
|
|
35
|
-
if (!input.startsWith("hsl")) {
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
const regex = /hsla?\(\s*(\d+)\s*[\s,]\s*(\d+)%\s*[\s,]\s*(\d+)%\s*([\s,]\s*(0|1|0?\.\d+|(\d{1,3})%)\s*)?\)/i, result = regex.exec(input), minLength = 4, defaultAlpha = 1, radix = 10;
|
|
39
|
-
return result
|
|
40
|
-
? (0, ColorUtils_js_1.hslaToRgba)({
|
|
41
|
-
a: result.length > minLength ? (0, NumberUtils_js_1.parseAlpha)(result[HslIndexes.a]) : defaultAlpha,
|
|
42
|
-
h: parseInt(result[HslIndexes.h], radix),
|
|
43
|
-
l: parseInt(result[HslIndexes.l], radix),
|
|
44
|
-
s: parseInt(result[HslIndexes.s], radix),
|
|
45
|
-
})
|
|
46
|
-
: undefined;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
exports.HslColorManager = HslColorManager;
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RgbColorManager = void 0;
|
|
4
|
-
const NumberUtils_js_1 = require("./NumberUtils.js");
|
|
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, NumberUtils_js_1.getRangeValue)(rgbColor.r),
|
|
28
|
-
g: (0, NumberUtils_js_1.getRangeValue)(rgbColor.g),
|
|
29
|
-
b: (0, NumberUtils_js_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, NumberUtils_js_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;
|