@tsparticles/plugin-blend 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.
Files changed (46) hide show
  1. package/647.min.js +2 -0
  2. package/647.min.js.LICENSE.txt +1 -0
  3. package/707.min.js +2 -0
  4. package/707.min.js.LICENSE.txt +1 -0
  5. package/LICENSE +21 -0
  6. package/README.md +74 -0
  7. package/browser/BlendPlugin.js +27 -0
  8. package/browser/BlendPluginInstance.js +27 -0
  9. package/browser/Options/Classes/Blend.js +18 -0
  10. package/browser/Options/Interfaces/IBlend.js +1 -0
  11. package/browser/index.js +7 -0
  12. package/browser/package.json +1 -0
  13. package/browser/types.js +1 -0
  14. package/cjs/BlendPlugin.js +27 -0
  15. package/cjs/BlendPluginInstance.js +27 -0
  16. package/cjs/Options/Classes/Blend.js +18 -0
  17. package/cjs/Options/Interfaces/IBlend.js +1 -0
  18. package/cjs/index.js +7 -0
  19. package/cjs/package.json +1 -0
  20. package/cjs/types.js +1 -0
  21. package/dist_browser_BlendPluginInstance_js.js +30 -0
  22. package/dist_browser_BlendPlugin_js.js +40 -0
  23. package/esm/BlendPlugin.js +27 -0
  24. package/esm/BlendPluginInstance.js +27 -0
  25. package/esm/Options/Classes/Blend.js +18 -0
  26. package/esm/Options/Interfaces/IBlend.js +1 -0
  27. package/esm/index.js +7 -0
  28. package/esm/package.json +1 -0
  29. package/esm/types.js +1 -0
  30. package/package.json +95 -0
  31. package/report.html +40 -0
  32. package/tsparticles.plugin.blend.js +305 -0
  33. package/tsparticles.plugin.blend.min.js +2 -0
  34. package/tsparticles.plugin.blend.min.js.LICENSE.txt +1 -0
  35. package/types/BlendPlugin.d.ts +10 -0
  36. package/types/BlendPluginInstance.d.ts +11 -0
  37. package/types/Options/Classes/Blend.d.ts +8 -0
  38. package/types/Options/Interfaces/IBlend.d.ts +4 -0
  39. package/types/index.d.ts +2 -0
  40. package/types/types.d.ts +24 -0
  41. package/umd/BlendPlugin.js +75 -0
  42. package/umd/BlendPluginInstance.js +41 -0
  43. package/umd/Options/Classes/Blend.js +32 -0
  44. package/umd/Options/Interfaces/IBlend.js +12 -0
  45. package/umd/index.js +54 -0
  46. package/umd/types.js +12 -0
package/647.min.js ADDED
@@ -0,0 +1,2 @@
1
+ /*! For license information please see 647.min.js.LICENSE.txt */
2
+ (this.webpackChunk_tsparticles_plugin_blend=this.webpackChunk_tsparticles_plugin_blend||[]).push([[647],{647(e,n,l){l.d(n,{BlendPlugin:()=>i});var t=l(303);class d{constructor(){this.mode="destination-out",this.enable=!1}load(e){(0,t.isNull)(e)||(void 0!==e.mode&&(this.mode=e.mode),void 0!==e.enable&&(this.enable=e.enable))}}class i{constructor(){this.id="blend"}async getPlugin(e){const{BlendPluginInstance:n}=await l.e(707).then(l.bind(l,707));return new n(e)}loadOptions(e,n,l){if(!this.needsPlugin(n)&&!this.needsPlugin(l))return;let t=n.blend;t?.load||(n.blend=t=new d),t.load(l?.blend)}loadParticlesOptions(e,n,l){n.blend??=new d,n.blend.load(l?.blend)}needsPlugin(e){return!!e?.blend?.enable||!!e?.particles?.blend?.enable}}}}]);
@@ -0,0 +1 @@
1
+ /*! tsParticles Blend Plugin v4.0.0-alpha.8 by Matteo Bruni */
package/707.min.js ADDED
@@ -0,0 +1,2 @@
1
+ /*! For license information please see 707.min.js.LICENSE.txt */
2
+ (this.webpackChunk_tsparticles_plugin_blend=this.webpackChunk_tsparticles_plugin_blend||[]).push([[707],{707(e,o,t){t.d(o,{BlendPluginInstance:()=>i});class i{constructor(e){this._container=e}drawParticleCleanup(e,o){e.globalCompositeOperation=o.originalBlendMode??"source-over",o.originalBlendMode=void 0}drawParticleSetup(e,o){o.options.blend?.enable&&(o.originalBlendMode=e.globalCompositeOperation,e.globalCompositeOperation=o.options.blend.mode)}drawSettingsCleanup(e){this._defaultCompositeValue&&(e.globalCompositeOperation=this._defaultCompositeValue)}drawSettingsSetup(e){const o=e.globalCompositeOperation,t=this._container.actualOptions.blend;this._defaultCompositeValue=o,e.globalCompositeOperation=t?.enable?t.mode:o}}}}]);
@@ -0,0 +1 @@
1
+ /*! tsParticles Blend Plugin v4.0.0-alpha.8 by Matteo Bruni */
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/banner2.png)](https://particles.js.org)
2
+
3
+ # tsParticles Blend Plugin
4
+
5
+ [![jsDelivr](https://data.jsdelivr.com/v1/package/npm/@tsparticles/plugin-blend/badge)](https://www.jsdelivr.com/package/npm/@tsparticles/plugin-blend)
6
+ [![npmjs](https://badge.fury.io/js/@tsparticles/plugin-blend.svg)](https://www.npmjs.com/package/@tsparticles/plugin-blend)
7
+ [![npmjs](https://img.shields.io/npm/dt/@tsparticles/plugin-blend)](https://www.npmjs.com/package/@tsparticles/plugin-blend) [![GitHub Sponsors](https://img.shields.io/github/sponsors/matteobruni)](https://github.com/sponsors/matteobruni)
8
+
9
+ [tsParticles](https://github.com/tsparticles/tsparticles) plugin for handling blend feature.
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.blend.min.js` file will export the function to load the plugin:
18
+
19
+ ```javascript
20
+ loadBlendPlugin;
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 loadBlendPlugin(tsParticles);
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-blend
46
+ ```
47
+
48
+ or
49
+
50
+ ```shell
51
+ $ yarn add @tsparticles/plugin-blend
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 { loadBlendPlugin } = require("@tsparticles/plugin-blend");
59
+
60
+ (async () => {
61
+ await loadBlendPlugin(tsParticles);
62
+ })();
63
+ ```
64
+
65
+ or
66
+
67
+ ```javascript
68
+ import { tsParticles } from "@tsparticles/engine";
69
+ import { loadBlendPlugin } from "@tsparticles/plugin-blend";
70
+
71
+ (async () => {
72
+ await loadBlendPlugin(tsParticles);
73
+ })();
74
+ ```
@@ -0,0 +1,27 @@
1
+ import { Blend } from "./Options/Classes/Blend.js";
2
+ export class BlendPlugin {
3
+ constructor() {
4
+ this.id = "blend";
5
+ }
6
+ async getPlugin(container) {
7
+ const { BlendPluginInstance } = await import("./BlendPluginInstance.js");
8
+ return new BlendPluginInstance(container);
9
+ }
10
+ loadOptions(_container, options, source) {
11
+ if (!this.needsPlugin(options) && !this.needsPlugin(source)) {
12
+ return;
13
+ }
14
+ let blendOptions = options.blend;
15
+ if (!blendOptions?.load) {
16
+ options.blend = blendOptions = new Blend();
17
+ }
18
+ blendOptions.load(source?.blend);
19
+ }
20
+ loadParticlesOptions(_container, options, source) {
21
+ options.blend ??= new Blend();
22
+ options.blend.load(source?.blend);
23
+ }
24
+ needsPlugin(options) {
25
+ return !!options?.blend?.enable || !!options?.particles?.blend?.enable;
26
+ }
27
+ }
@@ -0,0 +1,27 @@
1
+ export class BlendPluginInstance {
2
+ constructor(container) {
3
+ this._container = container;
4
+ }
5
+ drawParticleCleanup(context, particle) {
6
+ context.globalCompositeOperation = particle.originalBlendMode ?? "source-over";
7
+ particle.originalBlendMode = undefined;
8
+ }
9
+ drawParticleSetup(context, particle) {
10
+ if (!particle.options.blend?.enable) {
11
+ return;
12
+ }
13
+ particle.originalBlendMode = context.globalCompositeOperation;
14
+ context.globalCompositeOperation = particle.options.blend.mode;
15
+ }
16
+ drawSettingsCleanup(context) {
17
+ if (!this._defaultCompositeValue) {
18
+ return;
19
+ }
20
+ context.globalCompositeOperation = this._defaultCompositeValue;
21
+ }
22
+ drawSettingsSetup(context) {
23
+ const previousComposite = context.globalCompositeOperation, blend = this._container.actualOptions.blend;
24
+ this._defaultCompositeValue = previousComposite;
25
+ context.globalCompositeOperation = blend?.enable ? blend.mode : previousComposite;
26
+ }
27
+ }
@@ -0,0 +1,18 @@
1
+ import { isNull } from "@tsparticles/engine";
2
+ export class Blend {
3
+ constructor() {
4
+ this.mode = "destination-out";
5
+ this.enable = false;
6
+ }
7
+ load(data) {
8
+ if (isNull(data)) {
9
+ return;
10
+ }
11
+ if (data.mode !== undefined) {
12
+ this.mode = data.mode;
13
+ }
14
+ if (data.enable !== undefined) {
15
+ this.enable = data.enable;
16
+ }
17
+ }
18
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ export async function loadBlendPlugin(engine) {
2
+ engine.checkVersion("4.0.0-alpha.8");
3
+ await engine.register(async (e) => {
4
+ const { BlendPlugin } = await import("./BlendPlugin.js");
5
+ e.addPlugin(new BlendPlugin());
6
+ });
7
+ }
@@ -0,0 +1 @@
1
+ { "type": "module" }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,27 @@
1
+ import { Blend } from "./Options/Classes/Blend.js";
2
+ export class BlendPlugin {
3
+ constructor() {
4
+ this.id = "blend";
5
+ }
6
+ async getPlugin(container) {
7
+ const { BlendPluginInstance } = await import("./BlendPluginInstance.js");
8
+ return new BlendPluginInstance(container);
9
+ }
10
+ loadOptions(_container, options, source) {
11
+ if (!this.needsPlugin(options) && !this.needsPlugin(source)) {
12
+ return;
13
+ }
14
+ let blendOptions = options.blend;
15
+ if (!blendOptions?.load) {
16
+ options.blend = blendOptions = new Blend();
17
+ }
18
+ blendOptions.load(source?.blend);
19
+ }
20
+ loadParticlesOptions(_container, options, source) {
21
+ options.blend ??= new Blend();
22
+ options.blend.load(source?.blend);
23
+ }
24
+ needsPlugin(options) {
25
+ return !!options?.blend?.enable || !!options?.particles?.blend?.enable;
26
+ }
27
+ }
@@ -0,0 +1,27 @@
1
+ export class BlendPluginInstance {
2
+ constructor(container) {
3
+ this._container = container;
4
+ }
5
+ drawParticleCleanup(context, particle) {
6
+ context.globalCompositeOperation = particle.originalBlendMode ?? "source-over";
7
+ particle.originalBlendMode = undefined;
8
+ }
9
+ drawParticleSetup(context, particle) {
10
+ if (!particle.options.blend?.enable) {
11
+ return;
12
+ }
13
+ particle.originalBlendMode = context.globalCompositeOperation;
14
+ context.globalCompositeOperation = particle.options.blend.mode;
15
+ }
16
+ drawSettingsCleanup(context) {
17
+ if (!this._defaultCompositeValue) {
18
+ return;
19
+ }
20
+ context.globalCompositeOperation = this._defaultCompositeValue;
21
+ }
22
+ drawSettingsSetup(context) {
23
+ const previousComposite = context.globalCompositeOperation, blend = this._container.actualOptions.blend;
24
+ this._defaultCompositeValue = previousComposite;
25
+ context.globalCompositeOperation = blend?.enable ? blend.mode : previousComposite;
26
+ }
27
+ }
@@ -0,0 +1,18 @@
1
+ import { isNull } from "@tsparticles/engine";
2
+ export class Blend {
3
+ constructor() {
4
+ this.mode = "destination-out";
5
+ this.enable = false;
6
+ }
7
+ load(data) {
8
+ if (isNull(data)) {
9
+ return;
10
+ }
11
+ if (data.mode !== undefined) {
12
+ this.mode = data.mode;
13
+ }
14
+ if (data.enable !== undefined) {
15
+ this.enable = data.enable;
16
+ }
17
+ }
18
+ }
@@ -0,0 +1 @@
1
+ export {};
package/cjs/index.js ADDED
@@ -0,0 +1,7 @@
1
+ export async function loadBlendPlugin(engine) {
2
+ engine.checkVersion("4.0.0-alpha.8");
3
+ await engine.register(async (e) => {
4
+ const { BlendPlugin } = await import("./BlendPlugin.js");
5
+ e.addPlugin(new BlendPlugin());
6
+ });
7
+ }
@@ -0,0 +1 @@
1
+ { "type": "commonjs" }
package/cjs/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,30 @@
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.8
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_plugin_blend"] = this["webpackChunk_tsparticles_plugin_blend"] || []).push([["dist_browser_BlendPluginInstance_js"],{
19
+
20
+ /***/ "./dist/browser/BlendPluginInstance.js"
21
+ /*!*********************************************!*\
22
+ !*** ./dist/browser/BlendPluginInstance.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 */ BlendPluginInstance: () => (/* binding */ BlendPluginInstance)\n/* harmony export */ });\nclass BlendPluginInstance {\n constructor(container) {\n this._container = container;\n }\n drawParticleCleanup(context, particle) {\n context.globalCompositeOperation = particle.originalBlendMode ?? \"source-over\";\n particle.originalBlendMode = undefined;\n }\n drawParticleSetup(context, particle) {\n if (!particle.options.blend?.enable) {\n return;\n }\n particle.originalBlendMode = context.globalCompositeOperation;\n context.globalCompositeOperation = particle.options.blend.mode;\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 blend = this._container.actualOptions.blend;\n this._defaultCompositeValue = previousComposite;\n context.globalCompositeOperation = blend?.enable ? blend.mode : previousComposite;\n }\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-blend/./dist/browser/BlendPluginInstance.js?\n}");
27
+
28
+ /***/ }
29
+
30
+ }]);
@@ -0,0 +1,40 @@
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.8
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_plugin_blend"] = this["webpackChunk_tsparticles_plugin_blend"] || []).push([["dist_browser_BlendPlugin_js"],{
19
+
20
+ /***/ "./dist/browser/BlendPlugin.js"
21
+ /*!*************************************!*\
22
+ !*** ./dist/browser/BlendPlugin.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 */ BlendPlugin: () => (/* binding */ BlendPlugin)\n/* harmony export */ });\n/* harmony import */ var _Options_Classes_Blend_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Options/Classes/Blend.js */ \"./dist/browser/Options/Classes/Blend.js\");\n\nclass BlendPlugin {\n constructor() {\n this.id = \"blend\";\n }\n async getPlugin(container) {\n const {\n BlendPluginInstance\n } = await __webpack_require__.e(/*! import() */ \"dist_browser_BlendPluginInstance_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./BlendPluginInstance.js */ \"./dist/browser/BlendPluginInstance.js\"));\n return new BlendPluginInstance(container);\n }\n loadOptions(_container, options, source) {\n if (!this.needsPlugin(options) && !this.needsPlugin(source)) {\n return;\n }\n let blendOptions = options.blend;\n if (!blendOptions?.load) {\n options.blend = blendOptions = new _Options_Classes_Blend_js__WEBPACK_IMPORTED_MODULE_0__.Blend();\n }\n blendOptions.load(source?.blend);\n }\n loadParticlesOptions(_container, options, source) {\n options.blend ??= new _Options_Classes_Blend_js__WEBPACK_IMPORTED_MODULE_0__.Blend();\n options.blend.load(source?.blend);\n }\n needsPlugin(options) {\n return !!options?.blend?.enable || !!options?.particles?.blend?.enable;\n }\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-blend/./dist/browser/BlendPlugin.js?\n}");
27
+
28
+ /***/ },
29
+
30
+ /***/ "./dist/browser/Options/Classes/Blend.js"
31
+ /*!***********************************************!*\
32
+ !*** ./dist/browser/Options/Classes/Blend.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 */ Blend: () => (/* binding */ Blend)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nclass Blend {\n constructor() {\n this.mode = \"destination-out\";\n this.enable = false;\n }\n load(data) {\n if ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isNull)(data)) {\n return;\n }\n if (data.mode !== undefined) {\n this.mode = data.mode;\n }\n if (data.enable !== undefined) {\n this.enable = data.enable;\n }\n }\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-blend/./dist/browser/Options/Classes/Blend.js?\n}");
37
+
38
+ /***/ }
39
+
40
+ }]);
@@ -0,0 +1,27 @@
1
+ import { Blend } from "./Options/Classes/Blend.js";
2
+ export class BlendPlugin {
3
+ constructor() {
4
+ this.id = "blend";
5
+ }
6
+ async getPlugin(container) {
7
+ const { BlendPluginInstance } = await import("./BlendPluginInstance.js");
8
+ return new BlendPluginInstance(container);
9
+ }
10
+ loadOptions(_container, options, source) {
11
+ if (!this.needsPlugin(options) && !this.needsPlugin(source)) {
12
+ return;
13
+ }
14
+ let blendOptions = options.blend;
15
+ if (!blendOptions?.load) {
16
+ options.blend = blendOptions = new Blend();
17
+ }
18
+ blendOptions.load(source?.blend);
19
+ }
20
+ loadParticlesOptions(_container, options, source) {
21
+ options.blend ??= new Blend();
22
+ options.blend.load(source?.blend);
23
+ }
24
+ needsPlugin(options) {
25
+ return !!options?.blend?.enable || !!options?.particles?.blend?.enable;
26
+ }
27
+ }
@@ -0,0 +1,27 @@
1
+ export class BlendPluginInstance {
2
+ constructor(container) {
3
+ this._container = container;
4
+ }
5
+ drawParticleCleanup(context, particle) {
6
+ context.globalCompositeOperation = particle.originalBlendMode ?? "source-over";
7
+ particle.originalBlendMode = undefined;
8
+ }
9
+ drawParticleSetup(context, particle) {
10
+ if (!particle.options.blend?.enable) {
11
+ return;
12
+ }
13
+ particle.originalBlendMode = context.globalCompositeOperation;
14
+ context.globalCompositeOperation = particle.options.blend.mode;
15
+ }
16
+ drawSettingsCleanup(context) {
17
+ if (!this._defaultCompositeValue) {
18
+ return;
19
+ }
20
+ context.globalCompositeOperation = this._defaultCompositeValue;
21
+ }
22
+ drawSettingsSetup(context) {
23
+ const previousComposite = context.globalCompositeOperation, blend = this._container.actualOptions.blend;
24
+ this._defaultCompositeValue = previousComposite;
25
+ context.globalCompositeOperation = blend?.enable ? blend.mode : previousComposite;
26
+ }
27
+ }
@@ -0,0 +1,18 @@
1
+ import { isNull } from "@tsparticles/engine";
2
+ export class Blend {
3
+ constructor() {
4
+ this.mode = "destination-out";
5
+ this.enable = false;
6
+ }
7
+ load(data) {
8
+ if (isNull(data)) {
9
+ return;
10
+ }
11
+ if (data.mode !== undefined) {
12
+ this.mode = data.mode;
13
+ }
14
+ if (data.enable !== undefined) {
15
+ this.enable = data.enable;
16
+ }
17
+ }
18
+ }
@@ -0,0 +1 @@
1
+ export {};
package/esm/index.js ADDED
@@ -0,0 +1,7 @@
1
+ export async function loadBlendPlugin(engine) {
2
+ engine.checkVersion("4.0.0-alpha.8");
3
+ await engine.register(async (e) => {
4
+ const { BlendPlugin } = await import("./BlendPlugin.js");
5
+ e.addPlugin(new BlendPlugin());
6
+ });
7
+ }
@@ -0,0 +1 @@
1
+ { "type": "module" }
package/esm/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/package.json ADDED
@@ -0,0 +1,95 @@
1
+ {
2
+ "name": "@tsparticles/plugin-blend",
3
+ "version": "4.0.0-alpha.8",
4
+ "description": "tsParticles blend plugin",
5
+ "homepage": "https://particles.js.org",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/tsparticles/tsparticles.git",
9
+ "directory": "plugins/blend"
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
+ "sideEffects": false,
71
+ "jsdelivr": "tsparticles.plugin.blend.min.js",
72
+ "unpkg": "tsparticles.plugin.blend.min.js",
73
+ "browser": "browser/index.js",
74
+ "main": "cjs/index.js",
75
+ "module": "esm/index.js",
76
+ "types": "types/index.d.ts",
77
+ "exports": {
78
+ ".": {
79
+ "types": "./types/index.d.ts",
80
+ "browser": "./browser/index.js",
81
+ "import": "./esm/index.js",
82
+ "require": "./cjs/index.js",
83
+ "umd": "./umd/index.js",
84
+ "default": "./cjs/index.js"
85
+ },
86
+ "./package.json": "./package.json"
87
+ },
88
+ "dependencies": {
89
+ "@tsparticles/engine": "4.0.0-alpha.8"
90
+ },
91
+ "publishConfig": {
92
+ "access": "public"
93
+ },
94
+ "type": "module"
95
+ }