@tsparticles/updater-twinkle 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.
- package/1.min.js +2 -0
- package/1.min.js.LICENSE.txt +1 -0
- package/browser/TwinkleUpdater.js +11 -10
- package/browser/index.js +8 -6
- package/cjs/Options/Classes/Twinkle.js +6 -10
- package/cjs/Options/Classes/TwinkleValues.js +5 -9
- package/cjs/Options/Interfaces/ITwinkle.js +1 -2
- package/cjs/Options/Interfaces/ITwinkleValues.js +1 -2
- package/cjs/TwinkleUpdater.js +14 -17
- package/cjs/Types.js +1 -2
- package/cjs/index.js +8 -9
- package/dist_browser_TwinkleUpdater_js.js +50 -0
- package/esm/TwinkleUpdater.js +11 -10
- package/esm/index.js +8 -6
- package/package.json +4 -3
- package/report.html +5 -4
- package/tsparticles.updater.twinkle.js +209 -50
- package/tsparticles.updater.twinkle.min.js +1 -1
- package/tsparticles.updater.twinkle.min.js.LICENSE.txt +1 -1
- package/types/TwinkleUpdater.d.ts +3 -3
- package/types/index.d.ts +1 -1
- package/umd/TwinkleUpdater.js +11 -10
- package/umd/index.js +43 -7
package/1.min.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! For license information please see 1.min.js.LICENSE.txt */
|
|
2
|
+
(this.webpackChunk_tsparticles_updater_twinkle=this.webpackChunk_tsparticles_updater_twinkle||[]).push([[1],[,(e,t,i)=>{i.d(t,{TwinkleUpdater:()=>l});var o=i(303);class n{constructor(){this.enable=!1,this.frequency=.05,this.opacity=1}load(e){(0,o.isNull)(e)||(void 0!==e.color&&(this.color=o.OptionsColor.create(this.color,e.color)),void 0!==e.enable&&(this.enable=e.enable),void 0!==e.frequency&&(this.frequency=e.frequency),void 0!==e.opacity&&(this.opacity=(0,o.setRangeValue)(e.opacity)))}}class s{constructor(){this.lines=new n,this.particles=new n}load(e){(0,o.isNull)(e)||(this.lines.load(e.lines),this.particles.load(e.particles))}}class l{constructor(e){this._engine=e}getColorStyles(e,t,i,n){const s=e.options,{container:l}=e,a=s.twinkle;if(!a)return{};const r=a.particles,c=r.enable&&(0,o.getRandom)()<r.frequency,p=e.options.zIndex,d=(1-e.zIndexFactor)**p.opacityRate,u=c?(0,o.getRangeValue)(r.opacity)*d:n,h=(0,o.rangeColorToHsl)(this._engine,r.color),k=(()=>{if(h)return(0,o.getStyleFromHsl)(h,l.hdr,u)})(),w={},y=c&&k;return w.fill=y?k:void 0,w.stroke=y?k:void 0,w}init(){}isEnabled(e){const t=e.options.twinkle;return!!t&&t.particles.enable}loadOptions(e,...t){e.twinkle??=new s;for(const i of t)e.twinkle.load(i?.twinkle)}update(){}}}]]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/*! tsParticles Twinkle Updater v4.0.0-alpha.1 by Matteo Bruni */
|
|
@@ -4,18 +4,22 @@ export class TwinkleUpdater {
|
|
|
4
4
|
constructor(engine) {
|
|
5
5
|
this._engine = engine;
|
|
6
6
|
}
|
|
7
|
-
getColorStyles(particle,
|
|
8
|
-
const pOptions = particle.options, twinkleOptions = pOptions
|
|
7
|
+
getColorStyles(particle, _context, _radius, opacity) {
|
|
8
|
+
const pOptions = particle.options, { container } = particle, twinkleOptions = pOptions["twinkle"];
|
|
9
9
|
if (!twinkleOptions) {
|
|
10
10
|
return {};
|
|
11
11
|
}
|
|
12
|
-
const twinkle = twinkleOptions.particles, twinkling = twinkle.enable && getRandom() < twinkle.frequency, zIndexOptions = particle.options.zIndex, zOffset = 1, zOpacityFactor = (zOffset - particle.zIndexFactor) ** zIndexOptions.opacityRate, twinklingOpacity = twinkling ? getRangeValue(twinkle.opacity) * zOpacityFactor : opacity, twinkleRgb = rangeColorToHsl(this._engine, twinkle.color),
|
|
12
|
+
const twinkle = twinkleOptions.particles, twinkling = twinkle.enable && getRandom() < twinkle.frequency, zIndexOptions = particle.options.zIndex, zOffset = 1, zOpacityFactor = (zOffset - particle.zIndexFactor) ** zIndexOptions.opacityRate, twinklingOpacity = twinkling ? getRangeValue(twinkle.opacity) * zOpacityFactor : opacity, twinkleRgb = rangeColorToHsl(this._engine, twinkle.color), getTwinkleStyle = () => {
|
|
13
|
+
if (!twinkleRgb) {
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
return getStyleFromHsl(twinkleRgb, container.hdr, twinklingOpacity);
|
|
17
|
+
}, twinkleStyle = getTwinkleStyle(), res = {}, needsTwinkle = twinkling && twinkleStyle;
|
|
13
18
|
res.fill = needsTwinkle ? twinkleStyle : undefined;
|
|
14
19
|
res.stroke = needsTwinkle ? twinkleStyle : undefined;
|
|
15
20
|
return res;
|
|
16
21
|
}
|
|
17
|
-
|
|
18
|
-
await Promise.resolve();
|
|
22
|
+
init() {
|
|
19
23
|
}
|
|
20
24
|
isEnabled(particle) {
|
|
21
25
|
const pOptions = particle.options, twinkleOptions = pOptions.twinkle;
|
|
@@ -25,14 +29,11 @@ export class TwinkleUpdater {
|
|
|
25
29
|
return twinkleOptions.particles.enable;
|
|
26
30
|
}
|
|
27
31
|
loadOptions(options, ...sources) {
|
|
28
|
-
|
|
29
|
-
options.twinkle = new Twinkle();
|
|
30
|
-
}
|
|
32
|
+
options.twinkle ??= new Twinkle();
|
|
31
33
|
for (const source of sources) {
|
|
32
34
|
options.twinkle.load(source?.twinkle);
|
|
33
35
|
}
|
|
34
36
|
}
|
|
35
|
-
|
|
36
|
-
await Promise.resolve();
|
|
37
|
+
update() {
|
|
37
38
|
}
|
|
38
39
|
}
|
package/browser/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
engine.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
export function loadTwinkleUpdater(engine) {
|
|
2
|
+
engine.checkVersion("4.0.0-alpha.1");
|
|
3
|
+
engine.register(e => {
|
|
4
|
+
e.addParticleUpdater("twinkle", async () => {
|
|
5
|
+
const { TwinkleUpdater } = await import("./TwinkleUpdater.js");
|
|
6
|
+
return new TwinkleUpdater(e);
|
|
7
|
+
});
|
|
8
|
+
});
|
|
7
9
|
}
|
|
@@ -1,19 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const engine_1 = require("@tsparticles/engine");
|
|
5
|
-
const TwinkleValues_js_1 = require("./TwinkleValues.js");
|
|
6
|
-
class Twinkle {
|
|
1
|
+
import { isNull } from "@tsparticles/engine";
|
|
2
|
+
import { TwinkleValues } from "./TwinkleValues.js";
|
|
3
|
+
export class Twinkle {
|
|
7
4
|
constructor() {
|
|
8
|
-
this.lines = new
|
|
9
|
-
this.particles = new
|
|
5
|
+
this.lines = new TwinkleValues();
|
|
6
|
+
this.particles = new TwinkleValues();
|
|
10
7
|
}
|
|
11
8
|
load(data) {
|
|
12
|
-
if (
|
|
9
|
+
if (isNull(data)) {
|
|
13
10
|
return;
|
|
14
11
|
}
|
|
15
12
|
this.lines.load(data.lines);
|
|
16
13
|
this.particles.load(data.particles);
|
|
17
14
|
}
|
|
18
15
|
}
|
|
19
|
-
exports.Twinkle = Twinkle;
|
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.TwinkleValues = void 0;
|
|
4
|
-
const engine_1 = require("@tsparticles/engine");
|
|
5
|
-
class TwinkleValues {
|
|
1
|
+
import { OptionsColor, isNull, setRangeValue, } from "@tsparticles/engine";
|
|
2
|
+
export class TwinkleValues {
|
|
6
3
|
constructor() {
|
|
7
4
|
this.enable = false;
|
|
8
5
|
this.frequency = 0.05;
|
|
9
6
|
this.opacity = 1;
|
|
10
7
|
}
|
|
11
8
|
load(data) {
|
|
12
|
-
if (
|
|
9
|
+
if (isNull(data)) {
|
|
13
10
|
return;
|
|
14
11
|
}
|
|
15
12
|
if (data.color !== undefined) {
|
|
16
|
-
this.color =
|
|
13
|
+
this.color = OptionsColor.create(this.color, data.color);
|
|
17
14
|
}
|
|
18
15
|
if (data.enable !== undefined) {
|
|
19
16
|
this.enable = data.enable;
|
|
@@ -22,8 +19,7 @@ class TwinkleValues {
|
|
|
22
19
|
this.frequency = data.frequency;
|
|
23
20
|
}
|
|
24
21
|
if (data.opacity !== undefined) {
|
|
25
|
-
this.opacity =
|
|
22
|
+
this.opacity = setRangeValue(data.opacity);
|
|
26
23
|
}
|
|
27
24
|
}
|
|
28
25
|
}
|
|
29
|
-
exports.TwinkleValues = TwinkleValues;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/cjs/TwinkleUpdater.js
CHANGED
|
@@ -1,24 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const engine_1 = require("@tsparticles/engine");
|
|
5
|
-
const Twinkle_js_1 = require("./Options/Classes/Twinkle.js");
|
|
6
|
-
class TwinkleUpdater {
|
|
1
|
+
import { getRandom, getRangeValue, getStyleFromHsl, rangeColorToHsl, } from "@tsparticles/engine";
|
|
2
|
+
import { Twinkle } from "./Options/Classes/Twinkle.js";
|
|
3
|
+
export class TwinkleUpdater {
|
|
7
4
|
constructor(engine) {
|
|
8
5
|
this._engine = engine;
|
|
9
6
|
}
|
|
10
|
-
getColorStyles(particle,
|
|
11
|
-
const pOptions = particle.options, twinkleOptions = pOptions
|
|
7
|
+
getColorStyles(particle, _context, _radius, opacity) {
|
|
8
|
+
const pOptions = particle.options, { container } = particle, twinkleOptions = pOptions["twinkle"];
|
|
12
9
|
if (!twinkleOptions) {
|
|
13
10
|
return {};
|
|
14
11
|
}
|
|
15
|
-
const twinkle = twinkleOptions.particles, twinkling = twinkle.enable &&
|
|
12
|
+
const twinkle = twinkleOptions.particles, twinkling = twinkle.enable && getRandom() < twinkle.frequency, zIndexOptions = particle.options.zIndex, zOffset = 1, zOpacityFactor = (zOffset - particle.zIndexFactor) ** zIndexOptions.opacityRate, twinklingOpacity = twinkling ? getRangeValue(twinkle.opacity) * zOpacityFactor : opacity, twinkleRgb = rangeColorToHsl(this._engine, twinkle.color), getTwinkleStyle = () => {
|
|
13
|
+
if (!twinkleRgb) {
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
return getStyleFromHsl(twinkleRgb, container.hdr, twinklingOpacity);
|
|
17
|
+
}, twinkleStyle = getTwinkleStyle(), res = {}, needsTwinkle = twinkling && twinkleStyle;
|
|
16
18
|
res.fill = needsTwinkle ? twinkleStyle : undefined;
|
|
17
19
|
res.stroke = needsTwinkle ? twinkleStyle : undefined;
|
|
18
20
|
return res;
|
|
19
21
|
}
|
|
20
|
-
|
|
21
|
-
await Promise.resolve();
|
|
22
|
+
init() {
|
|
22
23
|
}
|
|
23
24
|
isEnabled(particle) {
|
|
24
25
|
const pOptions = particle.options, twinkleOptions = pOptions.twinkle;
|
|
@@ -28,15 +29,11 @@ class TwinkleUpdater {
|
|
|
28
29
|
return twinkleOptions.particles.enable;
|
|
29
30
|
}
|
|
30
31
|
loadOptions(options, ...sources) {
|
|
31
|
-
|
|
32
|
-
options.twinkle = new Twinkle_js_1.Twinkle();
|
|
33
|
-
}
|
|
32
|
+
options.twinkle ??= new Twinkle();
|
|
34
33
|
for (const source of sources) {
|
|
35
34
|
options.twinkle.load(source?.twinkle);
|
|
36
35
|
}
|
|
37
36
|
}
|
|
38
|
-
|
|
39
|
-
await Promise.resolve();
|
|
37
|
+
update() {
|
|
40
38
|
}
|
|
41
39
|
}
|
|
42
|
-
exports.TwinkleUpdater = TwinkleUpdater;
|
package/cjs/Types.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/cjs/index.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}, refresh);
|
|
1
|
+
export function loadTwinkleUpdater(engine) {
|
|
2
|
+
engine.checkVersion("4.0.0-alpha.1");
|
|
3
|
+
engine.register(e => {
|
|
4
|
+
e.addParticleUpdater("twinkle", async () => {
|
|
5
|
+
const { TwinkleUpdater } = await import("./TwinkleUpdater.js");
|
|
6
|
+
return new TwinkleUpdater(e);
|
|
7
|
+
});
|
|
8
|
+
});
|
|
10
9
|
}
|
|
@@ -0,0 +1,50 @@
|
|
|
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
|
+
* v4.0.0-alpha.1
|
|
8
|
+
*/
|
|
9
|
+
"use strict";
|
|
10
|
+
/*
|
|
11
|
+
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
|
|
12
|
+
* This devtool is neither made for production nor for readable output files.
|
|
13
|
+
* It uses "eval()" calls to create a separate source file in the browser devtools.
|
|
14
|
+
* If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
|
|
15
|
+
* or disable the default devtool with "devtool: false".
|
|
16
|
+
* If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
|
|
17
|
+
*/
|
|
18
|
+
(this["webpackChunk_tsparticles_updater_twinkle"] = this["webpackChunk_tsparticles_updater_twinkle"] || []).push([["dist_browser_TwinkleUpdater_js"],{
|
|
19
|
+
|
|
20
|
+
/***/ "./dist/browser/Options/Classes/Twinkle.js"
|
|
21
|
+
/*!*************************************************!*\
|
|
22
|
+
!*** ./dist/browser/Options/Classes/Twinkle.js ***!
|
|
23
|
+
\*************************************************/
|
|
24
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
25
|
+
|
|
26
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Twinkle: () => (/* binding */ Twinkle)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _TwinkleValues_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./TwinkleValues.js */ \"./dist/browser/Options/Classes/TwinkleValues.js\");\n\n\nclass Twinkle {\n constructor() {\n this.lines = new _TwinkleValues_js__WEBPACK_IMPORTED_MODULE_1__.TwinkleValues();\n this.particles = new _TwinkleValues_js__WEBPACK_IMPORTED_MODULE_1__.TwinkleValues();\n }\n load(data) {\n if ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isNull)(data)) {\n return;\n }\n this.lines.load(data.lines);\n this.particles.load(data.particles);\n }\n}\n\n//# sourceURL=webpack://@tsparticles/updater-twinkle/./dist/browser/Options/Classes/Twinkle.js?\n}");
|
|
27
|
+
|
|
28
|
+
/***/ },
|
|
29
|
+
|
|
30
|
+
/***/ "./dist/browser/Options/Classes/TwinkleValues.js"
|
|
31
|
+
/*!*******************************************************!*\
|
|
32
|
+
!*** ./dist/browser/Options/Classes/TwinkleValues.js ***!
|
|
33
|
+
\*******************************************************/
|
|
34
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
35
|
+
|
|
36
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ TwinkleValues: () => (/* binding */ TwinkleValues)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nclass TwinkleValues {\n constructor() {\n this.enable = false;\n this.frequency = 0.05;\n this.opacity = 1;\n }\n load(data) {\n if ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isNull)(data)) {\n return;\n }\n if (data.color !== undefined) {\n this.color = _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.OptionsColor.create(this.color, data.color);\n }\n if (data.enable !== undefined) {\n this.enable = data.enable;\n }\n if (data.frequency !== undefined) {\n this.frequency = data.frequency;\n }\n if (data.opacity !== undefined) {\n this.opacity = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.setRangeValue)(data.opacity);\n }\n }\n}\n\n//# sourceURL=webpack://@tsparticles/updater-twinkle/./dist/browser/Options/Classes/TwinkleValues.js?\n}");
|
|
37
|
+
|
|
38
|
+
/***/ },
|
|
39
|
+
|
|
40
|
+
/***/ "./dist/browser/TwinkleUpdater.js"
|
|
41
|
+
/*!****************************************!*\
|
|
42
|
+
!*** ./dist/browser/TwinkleUpdater.js ***!
|
|
43
|
+
\****************************************/
|
|
44
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
45
|
+
|
|
46
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ TwinkleUpdater: () => (/* binding */ TwinkleUpdater)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _Options_Classes_Twinkle_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Options/Classes/Twinkle.js */ \"./dist/browser/Options/Classes/Twinkle.js\");\n\n\nclass TwinkleUpdater {\n constructor(engine) {\n this._engine = engine;\n }\n getColorStyles(particle, _context, _radius, opacity) {\n const pOptions = particle.options,\n {\n container\n } = particle,\n twinkleOptions = pOptions[\"twinkle\"];\n if (!twinkleOptions) {\n return {};\n }\n const twinkle = twinkleOptions.particles,\n twinkling = twinkle.enable && (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)() < twinkle.frequency,\n zIndexOptions = particle.options.zIndex,\n zOffset = 1,\n zOpacityFactor = (zOffset - particle.zIndexFactor) ** zIndexOptions.opacityRate,\n twinklingOpacity = twinkling ? (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(twinkle.opacity) * zOpacityFactor : opacity,\n twinkleRgb = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.rangeColorToHsl)(this._engine, twinkle.color),\n getTwinkleStyle = () => {\n if (!twinkleRgb) {\n return undefined;\n }\n return (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getStyleFromHsl)(twinkleRgb, container.hdr, twinklingOpacity);\n },\n twinkleStyle = getTwinkleStyle(),\n res = {},\n needsTwinkle = twinkling && twinkleStyle;\n res.fill = needsTwinkle ? twinkleStyle : undefined;\n res.stroke = needsTwinkle ? twinkleStyle : undefined;\n return res;\n }\n init() {}\n isEnabled(particle) {\n const pOptions = particle.options,\n twinkleOptions = pOptions.twinkle;\n if (!twinkleOptions) {\n return false;\n }\n return twinkleOptions.particles.enable;\n }\n loadOptions(options, ...sources) {\n options.twinkle ??= new _Options_Classes_Twinkle_js__WEBPACK_IMPORTED_MODULE_1__.Twinkle();\n for (const source of sources) {\n options.twinkle.load(source?.twinkle);\n }\n }\n update() {}\n}\n\n//# sourceURL=webpack://@tsparticles/updater-twinkle/./dist/browser/TwinkleUpdater.js?\n}");
|
|
47
|
+
|
|
48
|
+
/***/ }
|
|
49
|
+
|
|
50
|
+
}]);
|
package/esm/TwinkleUpdater.js
CHANGED
|
@@ -4,18 +4,22 @@ export class TwinkleUpdater {
|
|
|
4
4
|
constructor(engine) {
|
|
5
5
|
this._engine = engine;
|
|
6
6
|
}
|
|
7
|
-
getColorStyles(particle,
|
|
8
|
-
const pOptions = particle.options, twinkleOptions = pOptions
|
|
7
|
+
getColorStyles(particle, _context, _radius, opacity) {
|
|
8
|
+
const pOptions = particle.options, { container } = particle, twinkleOptions = pOptions["twinkle"];
|
|
9
9
|
if (!twinkleOptions) {
|
|
10
10
|
return {};
|
|
11
11
|
}
|
|
12
|
-
const twinkle = twinkleOptions.particles, twinkling = twinkle.enable && getRandom() < twinkle.frequency, zIndexOptions = particle.options.zIndex, zOffset = 1, zOpacityFactor = (zOffset - particle.zIndexFactor) ** zIndexOptions.opacityRate, twinklingOpacity = twinkling ? getRangeValue(twinkle.opacity) * zOpacityFactor : opacity, twinkleRgb = rangeColorToHsl(this._engine, twinkle.color),
|
|
12
|
+
const twinkle = twinkleOptions.particles, twinkling = twinkle.enable && getRandom() < twinkle.frequency, zIndexOptions = particle.options.zIndex, zOffset = 1, zOpacityFactor = (zOffset - particle.zIndexFactor) ** zIndexOptions.opacityRate, twinklingOpacity = twinkling ? getRangeValue(twinkle.opacity) * zOpacityFactor : opacity, twinkleRgb = rangeColorToHsl(this._engine, twinkle.color), getTwinkleStyle = () => {
|
|
13
|
+
if (!twinkleRgb) {
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
return getStyleFromHsl(twinkleRgb, container.hdr, twinklingOpacity);
|
|
17
|
+
}, twinkleStyle = getTwinkleStyle(), res = {}, needsTwinkle = twinkling && twinkleStyle;
|
|
13
18
|
res.fill = needsTwinkle ? twinkleStyle : undefined;
|
|
14
19
|
res.stroke = needsTwinkle ? twinkleStyle : undefined;
|
|
15
20
|
return res;
|
|
16
21
|
}
|
|
17
|
-
|
|
18
|
-
await Promise.resolve();
|
|
22
|
+
init() {
|
|
19
23
|
}
|
|
20
24
|
isEnabled(particle) {
|
|
21
25
|
const pOptions = particle.options, twinkleOptions = pOptions.twinkle;
|
|
@@ -25,14 +29,11 @@ export class TwinkleUpdater {
|
|
|
25
29
|
return twinkleOptions.particles.enable;
|
|
26
30
|
}
|
|
27
31
|
loadOptions(options, ...sources) {
|
|
28
|
-
|
|
29
|
-
options.twinkle = new Twinkle();
|
|
30
|
-
}
|
|
32
|
+
options.twinkle ??= new Twinkle();
|
|
31
33
|
for (const source of sources) {
|
|
32
34
|
options.twinkle.load(source?.twinkle);
|
|
33
35
|
}
|
|
34
36
|
}
|
|
35
|
-
|
|
36
|
-
await Promise.resolve();
|
|
37
|
+
update() {
|
|
37
38
|
}
|
|
38
39
|
}
|
package/esm/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
engine.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
export function loadTwinkleUpdater(engine) {
|
|
2
|
+
engine.checkVersion("4.0.0-alpha.1");
|
|
3
|
+
engine.register(e => {
|
|
4
|
+
e.addParticleUpdater("twinkle", async () => {
|
|
5
|
+
const { TwinkleUpdater } = await import("./TwinkleUpdater.js");
|
|
6
|
+
return new TwinkleUpdater(e);
|
|
7
|
+
});
|
|
8
|
+
});
|
|
7
9
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsparticles/updater-twinkle",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-alpha.1",
|
|
4
4
|
"description": "tsParticles particles twinkle updater",
|
|
5
5
|
"homepage": "https://particles.js.org",
|
|
6
6
|
"repository": {
|
|
@@ -87,9 +87,10 @@
|
|
|
87
87
|
"./package.json": "./package.json"
|
|
88
88
|
},
|
|
89
89
|
"dependencies": {
|
|
90
|
-
"@tsparticles/engine": "
|
|
90
|
+
"@tsparticles/engine": "4.0.0-alpha.1"
|
|
91
91
|
},
|
|
92
92
|
"publishConfig": {
|
|
93
93
|
"access": "public"
|
|
94
|
-
}
|
|
94
|
+
},
|
|
95
|
+
"type": "module"
|
|
95
96
|
}
|