@tsparticles/plugin-background-mask 4.0.0-alpha.4 → 4.0.0-alpha.8
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/54.min.js +1 -1
- package/54.min.js.LICENSE.txt +1 -1
- package/646.min.js.LICENSE.txt +1 -1
- package/browser/BackgroundMaskPluginInstance.js +4 -5
- package/browser/index.js +3 -3
- package/cjs/BackgroundMaskPluginInstance.js +4 -5
- package/cjs/index.js +3 -3
- package/dist_browser_BackgroundMaskPluginInstance_js.js +2 -2
- package/dist_browser_BackgroundMaskPlugin_js.js +1 -1
- package/esm/BackgroundMaskPluginInstance.js +4 -5
- package/esm/index.js +3 -3
- package/package.json +2 -2
- package/report.html +3 -3
- package/tsparticles.plugin.background-mask.js +2 -2
- package/tsparticles.plugin.background-mask.min.js +1 -1
- package/tsparticles.plugin.background-mask.min.js.LICENSE.txt +1 -1
- package/types/BackgroundMaskPluginInstance.d.ts +2 -2
- package/types/index.d.ts +1 -1
- package/umd/BackgroundMaskPluginInstance.js +3 -4
- package/umd/index.js +3 -3
package/54.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see 54.min.js.LICENSE.txt */
|
|
2
|
-
(this.webpackChunk_tsparticles_plugin_background_mask=this.webpackChunk_tsparticles_plugin_background_mask||[]).push([[54],{54(a,t,e){e.d(t,{BackgroundMaskPluginInstance:()=>
|
|
2
|
+
(this.webpackChunk_tsparticles_plugin_background_mask=this.webpackChunk_tsparticles_plugin_background_mask||[]).push([[54],{54(a,t,e){e.d(t,{BackgroundMaskPluginInstance:()=>n});var i=e(303);class n{constructor(a,t){this._initCover=async()=>{const a=this._container.actualOptions,t=a.backgroundMask?.cover,e=t?.color;if(e){const a=(0,i.rangeColorToRgb)(this._engine,e);if(a){const e={...a,a:t.opacity};this._coverColorStyle=(0,i.getStyleFromRgb)(e,this._container.hdr,e.a)}}else await new Promise(((a,e)=>{if(!t?.image)return;const n=(0,i.safeDocument)().createElement("img");n.addEventListener("load",(()=>{this._coverImage={image:n,opacity:t.opacity},a()})),n.addEventListener("error",(()=>{e(new Error("Error loading image"))})),n.src=t.image}))},this._container=a,this._engine=t}canvasClear(){const a=this._container.actualOptions.backgroundMask;return!!a?.enable&&this.canvasPaint()}canvasPaint(){if(!this._container.actualOptions.backgroundMask?.enable)return!1;const a=this._container.canvas;return a.canvasClear(),this._coverImage?a.paintImage(this._coverImage.image,this._coverImage.opacity):a.paintBase(this._coverColorStyle),!0}drawSettingsCleanup(a){this._defaultCompositeValue&&(a.globalCompositeOperation=this._defaultCompositeValue)}drawSettingsSetup(a){const t=a.globalCompositeOperation,e=this._container.actualOptions.backgroundMask;this._defaultCompositeValue=t,a.globalCompositeOperation=e?.enable?e.composite:t}async init(){await this._initCover()}}}}]);
|
package/54.min.js.LICENSE.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
/*! tsParticles Background Mask Plugin v4.0.0-alpha.
|
|
1
|
+
/*! tsParticles Background Mask Plugin v4.0.0-alpha.8 by Matteo Bruni */
|
package/646.min.js.LICENSE.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
/*! tsParticles Background Mask Plugin v4.0.0-alpha.
|
|
1
|
+
/*! tsParticles Background Mask Plugin v4.0.0-alpha.8 by Matteo Bruni */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getStyleFromRgb, rangeColorToRgb, safeDocument, } from "@tsparticles/engine";
|
|
2
2
|
export class BackgroundMaskPluginInstance {
|
|
3
3
|
constructor(container, engine) {
|
|
4
4
|
this._initCover = async () => {
|
|
@@ -26,8 +26,7 @@ export class BackgroundMaskPluginInstance {
|
|
|
26
26
|
};
|
|
27
27
|
resolve();
|
|
28
28
|
});
|
|
29
|
-
img.addEventListener("error",
|
|
30
|
-
getLogger().error(evt);
|
|
29
|
+
img.addEventListener("error", () => {
|
|
31
30
|
reject(new Error("Error loading image"));
|
|
32
31
|
});
|
|
33
32
|
img.src = cover.image;
|
|
@@ -58,13 +57,13 @@ export class BackgroundMaskPluginInstance {
|
|
|
58
57
|
}
|
|
59
58
|
return true;
|
|
60
59
|
}
|
|
61
|
-
|
|
60
|
+
drawSettingsCleanup(context) {
|
|
62
61
|
if (!this._defaultCompositeValue) {
|
|
63
62
|
return;
|
|
64
63
|
}
|
|
65
64
|
context.globalCompositeOperation = this._defaultCompositeValue;
|
|
66
65
|
}
|
|
67
|
-
|
|
66
|
+
drawSettingsSetup(context) {
|
|
68
67
|
const previousComposite = context.globalCompositeOperation, backgroundMask = this._container.actualOptions.backgroundMask;
|
|
69
68
|
this._defaultCompositeValue = previousComposite;
|
|
70
69
|
context.globalCompositeOperation = backgroundMask?.enable ? backgroundMask.composite : previousComposite;
|
package/browser/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export function loadBackgroundMaskPlugin(engine) {
|
|
2
|
-
engine.checkVersion("4.0.0-alpha.
|
|
3
|
-
engine.register(async (e) => {
|
|
1
|
+
export async function loadBackgroundMaskPlugin(engine) {
|
|
2
|
+
engine.checkVersion("4.0.0-alpha.8");
|
|
3
|
+
await engine.register(async (e) => {
|
|
4
4
|
const { BackgroundMaskPlugin } = await import("./BackgroundMaskPlugin.js");
|
|
5
5
|
e.addPlugin(new BackgroundMaskPlugin(e));
|
|
6
6
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getStyleFromRgb, rangeColorToRgb, safeDocument, } from "@tsparticles/engine";
|
|
2
2
|
export class BackgroundMaskPluginInstance {
|
|
3
3
|
constructor(container, engine) {
|
|
4
4
|
this._initCover = async () => {
|
|
@@ -26,8 +26,7 @@ export class BackgroundMaskPluginInstance {
|
|
|
26
26
|
};
|
|
27
27
|
resolve();
|
|
28
28
|
});
|
|
29
|
-
img.addEventListener("error",
|
|
30
|
-
getLogger().error(evt);
|
|
29
|
+
img.addEventListener("error", () => {
|
|
31
30
|
reject(new Error("Error loading image"));
|
|
32
31
|
});
|
|
33
32
|
img.src = cover.image;
|
|
@@ -58,13 +57,13 @@ export class BackgroundMaskPluginInstance {
|
|
|
58
57
|
}
|
|
59
58
|
return true;
|
|
60
59
|
}
|
|
61
|
-
|
|
60
|
+
drawSettingsCleanup(context) {
|
|
62
61
|
if (!this._defaultCompositeValue) {
|
|
63
62
|
return;
|
|
64
63
|
}
|
|
65
64
|
context.globalCompositeOperation = this._defaultCompositeValue;
|
|
66
65
|
}
|
|
67
|
-
|
|
66
|
+
drawSettingsSetup(context) {
|
|
68
67
|
const previousComposite = context.globalCompositeOperation, backgroundMask = this._container.actualOptions.backgroundMask;
|
|
69
68
|
this._defaultCompositeValue = previousComposite;
|
|
70
69
|
context.globalCompositeOperation = backgroundMask?.enable ? backgroundMask.composite : previousComposite;
|
package/cjs/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export function loadBackgroundMaskPlugin(engine) {
|
|
2
|
-
engine.checkVersion("4.0.0-alpha.
|
|
3
|
-
engine.register(async (e) => {
|
|
1
|
+
export async function loadBackgroundMaskPlugin(engine) {
|
|
2
|
+
engine.checkVersion("4.0.0-alpha.8");
|
|
3
|
+
await engine.register(async (e) => {
|
|
4
4
|
const { BackgroundMaskPlugin } = await import("./BackgroundMaskPlugin.js");
|
|
5
5
|
e.addPlugin(new BackgroundMaskPlugin(e));
|
|
6
6
|
});
|
|
@@ -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
|
-
* v4.0.0-alpha.
|
|
7
|
+
* v4.0.0-alpha.8
|
|
8
8
|
*/
|
|
9
9
|
"use strict";
|
|
10
10
|
/*
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
\******************************************************/
|
|
24
24
|
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
25
25
|
|
|
26
|
-
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ BackgroundMaskPluginInstance: () => (/* binding */ BackgroundMaskPluginInstance)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nclass BackgroundMaskPluginInstance {\n constructor(container, engine) {\n this._initCover = async () => {\n const options = this._container.actualOptions,\n cover = options.backgroundMask?.cover,\n color = cover?.color;\n if (color) {\n const coverRgb = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.rangeColorToRgb)(this._engine, color);\n if (coverRgb) {\n const coverColor = {\n ...coverRgb,\n a: cover.opacity\n };\n this._coverColorStyle = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getStyleFromRgb)(coverColor, this._container.hdr, coverColor.a);\n }\n } else {\n await new Promise((resolve, reject) => {\n if (!cover?.image) {\n return;\n }\n const img = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.safeDocument)().createElement(\"img\");\n img.addEventListener(\"load\", () => {\n this._coverImage = {\n image: img,\n opacity: cover.opacity\n };\n resolve();\n });\n img.addEventListener(\"error\",
|
|
26
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ BackgroundMaskPluginInstance: () => (/* binding */ BackgroundMaskPluginInstance)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nclass BackgroundMaskPluginInstance {\n constructor(container, engine) {\n this._initCover = async () => {\n const options = this._container.actualOptions,\n cover = options.backgroundMask?.cover,\n color = cover?.color;\n if (color) {\n const coverRgb = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.rangeColorToRgb)(this._engine, color);\n if (coverRgb) {\n const coverColor = {\n ...coverRgb,\n a: cover.opacity\n };\n this._coverColorStyle = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getStyleFromRgb)(coverColor, this._container.hdr, coverColor.a);\n }\n } else {\n await new Promise((resolve, reject) => {\n if (!cover?.image) {\n return;\n }\n const img = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.safeDocument)().createElement(\"img\");\n img.addEventListener(\"load\", () => {\n this._coverImage = {\n image: img,\n opacity: cover.opacity\n };\n resolve();\n });\n img.addEventListener(\"error\", () => {\n reject(new Error(\"Error loading image\"));\n });\n img.src = cover.image;\n });\n }\n };\n this._container = container;\n this._engine = engine;\n }\n canvasClear() {\n const backgroundMask = this._container.actualOptions.backgroundMask;\n if (!backgroundMask?.enable) {\n return false;\n }\n return this.canvasPaint();\n }\n canvasPaint() {\n if (!this._container.actualOptions.backgroundMask?.enable) {\n return false;\n }\n const canvas = this._container.canvas;\n canvas.canvasClear();\n if (this._coverImage) {\n canvas.paintImage(this._coverImage.image, this._coverImage.opacity);\n } else {\n canvas.paintBase(this._coverColorStyle);\n }\n return true;\n }\n drawSettingsCleanup(context) {\n if (!this._defaultCompositeValue) {\n return;\n }\n context.globalCompositeOperation = this._defaultCompositeValue;\n }\n drawSettingsSetup(context) {\n const previousComposite = context.globalCompositeOperation,\n backgroundMask = this._container.actualOptions.backgroundMask;\n this._defaultCompositeValue = previousComposite;\n context.globalCompositeOperation = backgroundMask?.enable ? backgroundMask.composite : previousComposite;\n }\n async init() {\n await this._initCover();\n }\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-background-mask/./dist/browser/BackgroundMaskPluginInstance.js?\n}");
|
|
27
27
|
|
|
28
28
|
/***/ }
|
|
29
29
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getStyleFromRgb, rangeColorToRgb, safeDocument, } from "@tsparticles/engine";
|
|
2
2
|
export class BackgroundMaskPluginInstance {
|
|
3
3
|
constructor(container, engine) {
|
|
4
4
|
this._initCover = async () => {
|
|
@@ -26,8 +26,7 @@ export class BackgroundMaskPluginInstance {
|
|
|
26
26
|
};
|
|
27
27
|
resolve();
|
|
28
28
|
});
|
|
29
|
-
img.addEventListener("error",
|
|
30
|
-
getLogger().error(evt);
|
|
29
|
+
img.addEventListener("error", () => {
|
|
31
30
|
reject(new Error("Error loading image"));
|
|
32
31
|
});
|
|
33
32
|
img.src = cover.image;
|
|
@@ -58,13 +57,13 @@ export class BackgroundMaskPluginInstance {
|
|
|
58
57
|
}
|
|
59
58
|
return true;
|
|
60
59
|
}
|
|
61
|
-
|
|
60
|
+
drawSettingsCleanup(context) {
|
|
62
61
|
if (!this._defaultCompositeValue) {
|
|
63
62
|
return;
|
|
64
63
|
}
|
|
65
64
|
context.globalCompositeOperation = this._defaultCompositeValue;
|
|
66
65
|
}
|
|
67
|
-
|
|
66
|
+
drawSettingsSetup(context) {
|
|
68
67
|
const previousComposite = context.globalCompositeOperation, backgroundMask = this._container.actualOptions.backgroundMask;
|
|
69
68
|
this._defaultCompositeValue = previousComposite;
|
|
70
69
|
context.globalCompositeOperation = backgroundMask?.enable ? backgroundMask.composite : previousComposite;
|
package/esm/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export function loadBackgroundMaskPlugin(engine) {
|
|
2
|
-
engine.checkVersion("4.0.0-alpha.
|
|
3
|
-
engine.register(async (e) => {
|
|
1
|
+
export async function loadBackgroundMaskPlugin(engine) {
|
|
2
|
+
engine.checkVersion("4.0.0-alpha.8");
|
|
3
|
+
await engine.register(async (e) => {
|
|
4
4
|
const { BackgroundMaskPlugin } = await import("./BackgroundMaskPlugin.js");
|
|
5
5
|
e.addPlugin(new BackgroundMaskPlugin(e));
|
|
6
6
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsparticles/plugin-background-mask",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.8",
|
|
4
4
|
"description": "tsParticles background mask plugin",
|
|
5
5
|
"homepage": "https://particles.js.org",
|
|
6
6
|
"repository": {
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
"./package.json": "./package.json"
|
|
87
87
|
},
|
|
88
88
|
"dependencies": {
|
|
89
|
-
"@tsparticles/engine": "4.0.0-alpha.
|
|
89
|
+
"@tsparticles/engine": "4.0.0-alpha.8"
|
|
90
90
|
},
|
|
91
91
|
"publishConfig": {
|
|
92
92
|
"access": "public"
|