@tsparticles/plugin-trail 4.0.0-alpha.1 → 4.0.0-alpha.14
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/379.min.js +1 -0
- package/883.min.js +1 -0
- package/browser/Options/Classes/Trail.js +3 -0
- package/browser/Options/Classes/TrailFill.js +2 -0
- package/browser/TrailPlugin.js +6 -5
- package/browser/TrailPluginInstance.js +75 -0
- package/browser/index.js +3 -3
- package/cjs/Options/Classes/Trail.js +3 -0
- package/cjs/Options/Classes/TrailFill.js +2 -0
- package/cjs/TrailPlugin.js +6 -5
- package/cjs/TrailPluginInstance.js +75 -0
- package/cjs/index.js +3 -3
- package/dist_browser_TrailPluginInstance_js.js +30 -0
- package/dist_browser_TrailPlugin_js.js +4 -14
- package/esm/Options/Classes/Trail.js +3 -0
- package/esm/Options/Classes/TrailFill.js +2 -0
- package/esm/TrailPlugin.js +6 -5
- package/esm/TrailPluginInstance.js +75 -0
- package/esm/index.js +3 -3
- package/package.json +2 -2
- package/report.html +3 -3
- package/tsparticles.plugin.trail.js +2 -2
- package/tsparticles.plugin.trail.min.js +2 -2
- package/types/TrailPlugin.d.ts +4 -5
- package/types/{TrailInstance.d.ts → TrailPluginInstance.d.ts} +1 -1
- package/types/index.d.ts +1 -1
- package/umd/Options/Classes/Trail.js +3 -0
- package/umd/Options/Classes/TrailFill.js +2 -0
- package/umd/TrailPlugin.js +41 -6
- package/umd/{TrailInstance.js → TrailPluginInstance.js} +45 -42
- package/umd/index.js +3 -3
- package/877.min.js +0 -2
- package/877.min.js.LICENSE.txt +0 -1
- package/browser/TrailInstance.js +0 -72
- package/cjs/TrailInstance.js +0 -72
- package/esm/TrailInstance.js +0 -72
- package/tsparticles.plugin.trail.min.js.LICENSE.txt +0 -1
|
@@ -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.14
|
|
8
8
|
*/
|
|
9
9
|
/*
|
|
10
10
|
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
|
|
@@ -34,7 +34,7 @@ return /******/ (() => { // webpackBootstrap
|
|
|
34
34
|
\*******************************/
|
|
35
35
|
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
36
36
|
|
|
37
|
-
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadTrailPlugin: () => (/* binding */ loadTrailPlugin)\n/* harmony export */ });\
|
|
37
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadTrailPlugin: () => (/* binding */ loadTrailPlugin)\n/* harmony export */ });\nasync function loadTrailPlugin(engine) {\n engine.checkVersion(\"4.0.0-alpha.14\");\n await engine.register(async (e)=>{\n const { TrailPlugin } = await __webpack_require__.e(/*! import() */ \"dist_browser_TrailPlugin_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./TrailPlugin.js */ \"./dist/browser/TrailPlugin.js\"));\n e.addPlugin(new TrailPlugin(engine));\n });\n}\n\n\n//# sourceURL=webpack://@tsparticles/plugin-trail/./dist/browser/index.js?\n}");
|
|
38
38
|
|
|
39
39
|
/***/ },
|
|
40
40
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],t);else{var r="object"==typeof exports?t(require("@tsparticles/engine")):t(e.window);for(var o in r)("object"==typeof exports?exports:e)[o]=r[o]}}(this,e=>(()=>{"use strict";var t,r,o,i={303(t){t.exports=e}},n={};function a(e){var t=n[e];if(void 0!==t)return t.exports;var r=n[e]={exports:{}};return i[e](r,r.exports,a),r.exports}a.m=i,a.d=(e,t)=>{for(var r in t)a.o(t,r)&&!a.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},a.f={},a.e=e=>Promise.all(Object.keys(a.f).reduce((t,r)=>(a.f[r](e,t),t),[])),a.u=e=>""+e+".min.js",a.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),l={},a.l=(e,t,r,o)=>{if(l[e])return void l[e].push(t);if(void 0!==r)for(var i,n,s=document.getElementsByTagName("script"),c=0;c<s.length;c++){var p=s[c];if(p.getAttribute("src")==e||p.getAttribute("data-webpack")=="@tsparticles/plugin-trail:"+r){i=p;break}}i||(n=!0,(i=document.createElement("script")).charset="utf-8",a.nc&&i.setAttribute("nonce",a.nc),i.setAttribute("data-webpack","@tsparticles/plugin-trail:"+r),i.src=e),l[e]=[t];var u=(t,r)=>{i.onerror=i.onload=null,clearTimeout(d);var o=l[e];if(delete l[e],i.parentNode&&i.parentNode.removeChild(i),o&&o.forEach(e=>e(r)),t)return t(r)},d=setTimeout(u.bind(null,void 0,{type:"timeout",target:i}),12e4);i.onerror=u.bind(null,i.onerror),i.onload=u.bind(null,i.onload),n&&document.head.appendChild(i)},a.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.g.importScripts&&(s=a.g.location+"");var l,s,c=a.g.document;if(!s&&c&&(c.currentScript&&"SCRIPT"===c.currentScript.tagName.toUpperCase()&&(s=c.currentScript.src),!s)){var p=c.getElementsByTagName("script");if(p.length)for(var u=p.length-1;u>-1&&(!s||!/^http(s?):/.test(s));)s=p[u--].src}if(!s)throw Error("Automatic publicPath is not supported in this browser");a.p=s=s.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),t={576:0},a.f.j=(e,r)=>{var o=a.o(t,e)?t[e]:void 0;if(0!==o)if(o)r.push(o[2]);else{var i=new Promise((r,i)=>o=t[e]=[r,i]);r.push(o[2]=i);var n=a.p+a.u(e),l=Error();a.l(n,r=>{if(a.o(t,e)&&(0!==(o=t[e])&&(t[e]=void 0),o)){var i=r&&("load"===r.type?"missing":r.type),n=r&&r.target&&r.target.src;l.message="Loading chunk "+e+` failed.
|
|
2
|
+
(`+i+": "+n+")",l.name="ChunkLoadError",l.type=i,l.request=n,o[1](l)}},"chunk-"+e,e)}},r=(e,r)=>{var o,i,[n,l,s]=r,c=0;if(n.some(e=>0!==t[e])){for(o in l)a.o(l,o)&&(a.m[o]=l[o]);s&&s(a)}for(e&&e(r);c<n.length;c++)i=n[c],a.o(t,i)&&t[i]&&t[i][0](),t[i]=0},(o=this.webpackChunk_tsparticles_plugin_trail=this.webpackChunk_tsparticles_plugin_trail||[]).forEach(r.bind(null,0)),o.push=r.bind(null,o.push.bind(o));var d={};async function f(e){e.checkVersion("4.0.0-alpha.14"),await e.register(async t=>{let{TrailPlugin:r}=await a.e(379).then(a.bind(a,379));t.addPlugin(new r(e))})}return a.r(d),a.d(d,{loadTrailPlugin:()=>f}),d})());
|
package/types/TrailPlugin.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import type { Container, Engine, IPlugin, RecursivePartial } from "@tsparticles/engine";
|
|
1
|
+
import type { Container, Engine, IContainerPlugin, IPlugin, RecursivePartial } from "@tsparticles/engine";
|
|
2
2
|
import type { ITrailOptions, TrailOptions } from "./types.js";
|
|
3
|
-
import { TrailInstance } from "./TrailInstance.js";
|
|
4
3
|
export declare class TrailPlugin implements IPlugin {
|
|
5
|
-
readonly id
|
|
4
|
+
readonly id = "trail";
|
|
6
5
|
private readonly _engine;
|
|
7
6
|
constructor(engine: Engine);
|
|
8
|
-
getPlugin(container: Container): Promise<
|
|
9
|
-
loadOptions(options: TrailOptions, source?: RecursivePartial<ITrailOptions>): void;
|
|
7
|
+
getPlugin(container: Container): Promise<IContainerPlugin>;
|
|
8
|
+
loadOptions(_container: Container, options: TrailOptions, source?: RecursivePartial<ITrailOptions>): void;
|
|
10
9
|
needsPlugin(): boolean;
|
|
11
10
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Engine, type IContainerPlugin } from "@tsparticles/engine";
|
|
2
2
|
import type { TrailContainer } from "./types.js";
|
|
3
|
-
export declare class
|
|
3
|
+
export declare class TrailPluginInstance implements IContainerPlugin {
|
|
4
4
|
private readonly _container;
|
|
5
5
|
private readonly _engine;
|
|
6
6
|
private _trailFill?;
|
package/types/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { type Engine } from "@tsparticles/engine";
|
|
2
|
-
export declare function loadTrailPlugin(engine: Engine): void
|
|
2
|
+
export declare function loadTrailPlugin(engine: Engine): Promise<void>;
|
package/umd/TrailPlugin.js
CHANGED
|
@@ -1,26 +1,61 @@
|
|
|
1
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
2
|
+
if (k2 === undefined) k2 = k;
|
|
3
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
4
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
5
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
6
|
+
}
|
|
7
|
+
Object.defineProperty(o, k2, desc);
|
|
8
|
+
}) : (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
o[k2] = m[k];
|
|
11
|
+
}));
|
|
12
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
13
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
14
|
+
}) : function(o, v) {
|
|
15
|
+
o["default"] = v;
|
|
16
|
+
});
|
|
17
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
18
|
+
var ownKeys = function(o) {
|
|
19
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
20
|
+
var ar = [];
|
|
21
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
22
|
+
return ar;
|
|
23
|
+
};
|
|
24
|
+
return ownKeys(o);
|
|
25
|
+
};
|
|
26
|
+
return function (mod) {
|
|
27
|
+
if (mod && mod.__esModule) return mod;
|
|
28
|
+
var result = {};
|
|
29
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
30
|
+
__setModuleDefault(result, mod);
|
|
31
|
+
return result;
|
|
32
|
+
};
|
|
33
|
+
})();
|
|
1
34
|
(function (factory) {
|
|
2
35
|
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
36
|
var v = factory(require, exports);
|
|
4
37
|
if (v !== undefined) module.exports = v;
|
|
5
38
|
}
|
|
6
39
|
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "./Options/Classes/Trail.js"
|
|
40
|
+
define(["require", "exports", "./Options/Classes/Trail.js"], factory);
|
|
8
41
|
}
|
|
9
42
|
})(function (require, exports) {
|
|
10
43
|
"use strict";
|
|
44
|
+
var __syncRequire = typeof module === "object" && typeof module.exports === "object";
|
|
11
45
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
46
|
exports.TrailPlugin = void 0;
|
|
13
47
|
const Trail_js_1 = require("./Options/Classes/Trail.js");
|
|
14
|
-
const TrailInstance_js_1 = require("./TrailInstance.js");
|
|
15
48
|
class TrailPlugin {
|
|
49
|
+
id = "trail";
|
|
50
|
+
_engine;
|
|
16
51
|
constructor(engine) {
|
|
17
|
-
this.id = "trail";
|
|
18
52
|
this._engine = engine;
|
|
19
53
|
}
|
|
20
|
-
getPlugin(container) {
|
|
21
|
-
|
|
54
|
+
async getPlugin(container) {
|
|
55
|
+
const { TrailPluginInstance } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./TrailPluginInstance.js"))) : new Promise((resolve_1, reject_1) => { require(["./TrailPluginInstance.js"], resolve_1, reject_1); }).then(__importStar));
|
|
56
|
+
return new TrailPluginInstance(container, this._engine);
|
|
22
57
|
}
|
|
23
|
-
loadOptions(options, source) {
|
|
58
|
+
loadOptions(_container, options, source) {
|
|
24
59
|
if (!this.needsPlugin()) {
|
|
25
60
|
return;
|
|
26
61
|
}
|
|
@@ -9,50 +9,14 @@
|
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
"use strict";
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.TrailPluginInstance = void 0;
|
|
13
13
|
const engine_1 = require("@tsparticles/engine");
|
|
14
14
|
const minimumLength = 0;
|
|
15
|
-
class
|
|
15
|
+
class TrailPluginInstance {
|
|
16
|
+
_container;
|
|
17
|
+
_engine;
|
|
18
|
+
_trailFill;
|
|
16
19
|
constructor(container, engine) {
|
|
17
|
-
this._initTrail = async () => {
|
|
18
|
-
const options = this._container.actualOptions, trail = options.trail;
|
|
19
|
-
if (!trail?.enable) {
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
const trailFill = trail.fill, opacity = engine_1.inverseFactorNumerator / trail.length;
|
|
23
|
-
if (trailFill.color) {
|
|
24
|
-
const fillColor = (0, engine_1.rangeColorToRgb)(this._engine, trailFill.color);
|
|
25
|
-
if (!fillColor) {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
this._trailFill = {
|
|
29
|
-
color: {
|
|
30
|
-
...fillColor,
|
|
31
|
-
},
|
|
32
|
-
opacity,
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
await new Promise((resolve, reject) => {
|
|
37
|
-
if (!trailFill.image) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
const img = (0, engine_1.safeDocument)().createElement("img");
|
|
41
|
-
img.addEventListener("load", () => {
|
|
42
|
-
this._trailFill = {
|
|
43
|
-
image: img,
|
|
44
|
-
opacity,
|
|
45
|
-
};
|
|
46
|
-
resolve();
|
|
47
|
-
});
|
|
48
|
-
img.addEventListener("error", evt => {
|
|
49
|
-
(0, engine_1.getLogger)().error(evt);
|
|
50
|
-
reject(new Error("Error loading image"));
|
|
51
|
-
});
|
|
52
|
-
img.src = trailFill.image;
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
20
|
this._container = container;
|
|
57
21
|
this._engine = engine;
|
|
58
22
|
}
|
|
@@ -81,6 +45,45 @@
|
|
|
81
45
|
(0, engine_1.getLogger)().error(e);
|
|
82
46
|
}
|
|
83
47
|
}
|
|
48
|
+
_initTrail = async () => {
|
|
49
|
+
const options = this._container.actualOptions, trail = options.trail;
|
|
50
|
+
if (!trail?.enable) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const trailFill = trail.fill, opacity = engine_1.inverseFactorNumerator / trail.length;
|
|
54
|
+
if (trailFill.color) {
|
|
55
|
+
const fillColor = (0, engine_1.rangeColorToRgb)(this._engine, trailFill.color);
|
|
56
|
+
if (!fillColor) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
this._trailFill = {
|
|
60
|
+
color: {
|
|
61
|
+
...fillColor,
|
|
62
|
+
},
|
|
63
|
+
opacity,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
await new Promise((resolve, reject) => {
|
|
68
|
+
if (!trailFill.image) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const img = (0, engine_1.safeDocument)().createElement("img");
|
|
72
|
+
img.addEventListener("load", () => {
|
|
73
|
+
this._trailFill = {
|
|
74
|
+
image: img,
|
|
75
|
+
opacity,
|
|
76
|
+
};
|
|
77
|
+
resolve();
|
|
78
|
+
});
|
|
79
|
+
img.addEventListener("error", evt => {
|
|
80
|
+
(0, engine_1.getLogger)().error(evt);
|
|
81
|
+
reject(new Error("Error loading image"));
|
|
82
|
+
});
|
|
83
|
+
img.src = trailFill.image;
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
};
|
|
84
87
|
}
|
|
85
|
-
exports.
|
|
88
|
+
exports.TrailPluginInstance = TrailPluginInstance;
|
|
86
89
|
});
|
package/umd/index.js
CHANGED
|
@@ -44,9 +44,9 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
44
44
|
var __syncRequire = typeof module === "object" && typeof module.exports === "object";
|
|
45
45
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
46
|
exports.loadTrailPlugin = loadTrailPlugin;
|
|
47
|
-
function loadTrailPlugin(engine) {
|
|
48
|
-
engine.checkVersion("4.0.0-alpha.
|
|
49
|
-
engine.register(async (e) => {
|
|
47
|
+
async function loadTrailPlugin(engine) {
|
|
48
|
+
engine.checkVersion("4.0.0-alpha.14");
|
|
49
|
+
await engine.register(async (e) => {
|
|
50
50
|
const { TrailPlugin } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./TrailPlugin.js"))) : new Promise((resolve_1, reject_1) => { require(["./TrailPlugin.js"], resolve_1, reject_1); }).then(__importStar));
|
|
51
51
|
e.addPlugin(new TrailPlugin(engine));
|
|
52
52
|
});
|
package/877.min.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
/*! For license information please see 877.min.js.LICENSE.txt */
|
|
2
|
-
(this.webpackChunk_tsparticles_plugin_trail=this.webpackChunk_tsparticles_plugin_trail||[]).push([[877],{877(i,t,e){e.d(t,{TrailPlugin:()=>o});var r=e(303);class l{load(i){(0,r.isNull)(i)||(void 0!==i.color&&(this.color=r.OptionsColor.create(this.color,i.color)),void 0!==i.image&&(this.image=i.image))}}class a{constructor(){this.enable=!1,this.length=10,this.fill=new l}load(i){(0,r.isNull)(i)||(void 0!==i.enable&&(this.enable=i.enable),void 0!==i.fill&&this.fill.load(i.fill),void 0!==i.length&&(this.length=i.length))}}class n{constructor(i,t){this._initTrail=async()=>{const i=this._container.actualOptions.trail;if(!i?.enable)return;const t=i.fill,e=r.inverseFactorNumerator/i.length;if(t.color){const i=(0,r.rangeColorToRgb)(this._engine,t.color);if(!i)return;this._trailFill={color:{...i},opacity:e}}else await new Promise(((i,l)=>{if(!t.image)return;const a=(0,r.safeDocument)().createElement("img");a.addEventListener("load",(()=>{this._trailFill={image:a,opacity:e},i()})),a.addEventListener("error",(i=>{(0,r.getLogger)().error(i),l(new Error("Error loading image"))})),a.src=t.image}))},this._container=i,this._engine=t}canvasClear(){const i=this._container,t=i.actualOptions.trail,e=this._trailFill;if(!t?.enable||!e||t.length<=0)return!1;let l=!1;const a=i.canvas;return e.color?(a.paintBase((0,r.getStyleFromRgb)(e.color,i.hdr,e.opacity)),l=!0):e.image&&(a.paintImage(e.image,e.opacity),l=!0),l}async init(){try{await this._initTrail()}catch(i){(0,r.getLogger)().error(i)}}}class o{constructor(i){this.id="trail",this._engine=i}getPlugin(i){return Promise.resolve(new n(i,this._engine))}loadOptions(i,t){if(!this.needsPlugin())return;let e=i.trail;e?.load||(i.trail=e=new a),e.load(t?.trail)}needsPlugin(){return!0}}}}]);
|
package/877.min.js.LICENSE.txt
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/*! tsParticles Trail Plugin v4.0.0-alpha.1 by Matteo Bruni */
|
package/browser/TrailInstance.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { getLogger, getStyleFromRgb, inverseFactorNumerator, rangeColorToRgb, safeDocument, } from "@tsparticles/engine";
|
|
2
|
-
const minimumLength = 0;
|
|
3
|
-
export class TrailInstance {
|
|
4
|
-
constructor(container, engine) {
|
|
5
|
-
this._initTrail = async () => {
|
|
6
|
-
const options = this._container.actualOptions, trail = options.trail;
|
|
7
|
-
if (!trail?.enable) {
|
|
8
|
-
return;
|
|
9
|
-
}
|
|
10
|
-
const trailFill = trail.fill, opacity = inverseFactorNumerator / trail.length;
|
|
11
|
-
if (trailFill.color) {
|
|
12
|
-
const fillColor = rangeColorToRgb(this._engine, trailFill.color);
|
|
13
|
-
if (!fillColor) {
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
this._trailFill = {
|
|
17
|
-
color: {
|
|
18
|
-
...fillColor,
|
|
19
|
-
},
|
|
20
|
-
opacity,
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
await new Promise((resolve, reject) => {
|
|
25
|
-
if (!trailFill.image) {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
const img = safeDocument().createElement("img");
|
|
29
|
-
img.addEventListener("load", () => {
|
|
30
|
-
this._trailFill = {
|
|
31
|
-
image: img,
|
|
32
|
-
opacity,
|
|
33
|
-
};
|
|
34
|
-
resolve();
|
|
35
|
-
});
|
|
36
|
-
img.addEventListener("error", evt => {
|
|
37
|
-
getLogger().error(evt);
|
|
38
|
-
reject(new Error("Error loading image"));
|
|
39
|
-
});
|
|
40
|
-
img.src = trailFill.image;
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
this._container = container;
|
|
45
|
-
this._engine = engine;
|
|
46
|
-
}
|
|
47
|
-
canvasClear() {
|
|
48
|
-
const container = this._container, trail = container.actualOptions.trail, trailFill = this._trailFill;
|
|
49
|
-
if (!trail?.enable || !trailFill || trail.length <= minimumLength) {
|
|
50
|
-
return false;
|
|
51
|
-
}
|
|
52
|
-
let handled = false;
|
|
53
|
-
const canvas = container.canvas;
|
|
54
|
-
if (trailFill.color) {
|
|
55
|
-
canvas.paintBase(getStyleFromRgb(trailFill.color, container.hdr, trailFill.opacity));
|
|
56
|
-
handled = true;
|
|
57
|
-
}
|
|
58
|
-
else if (trailFill.image) {
|
|
59
|
-
canvas.paintImage(trailFill.image, trailFill.opacity);
|
|
60
|
-
handled = true;
|
|
61
|
-
}
|
|
62
|
-
return handled;
|
|
63
|
-
}
|
|
64
|
-
async init() {
|
|
65
|
-
try {
|
|
66
|
-
await this._initTrail();
|
|
67
|
-
}
|
|
68
|
-
catch (e) {
|
|
69
|
-
getLogger().error(e);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
package/cjs/TrailInstance.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { getLogger, getStyleFromRgb, inverseFactorNumerator, rangeColorToRgb, safeDocument, } from "@tsparticles/engine";
|
|
2
|
-
const minimumLength = 0;
|
|
3
|
-
export class TrailInstance {
|
|
4
|
-
constructor(container, engine) {
|
|
5
|
-
this._initTrail = async () => {
|
|
6
|
-
const options = this._container.actualOptions, trail = options.trail;
|
|
7
|
-
if (!trail?.enable) {
|
|
8
|
-
return;
|
|
9
|
-
}
|
|
10
|
-
const trailFill = trail.fill, opacity = inverseFactorNumerator / trail.length;
|
|
11
|
-
if (trailFill.color) {
|
|
12
|
-
const fillColor = rangeColorToRgb(this._engine, trailFill.color);
|
|
13
|
-
if (!fillColor) {
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
this._trailFill = {
|
|
17
|
-
color: {
|
|
18
|
-
...fillColor,
|
|
19
|
-
},
|
|
20
|
-
opacity,
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
await new Promise((resolve, reject) => {
|
|
25
|
-
if (!trailFill.image) {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
const img = safeDocument().createElement("img");
|
|
29
|
-
img.addEventListener("load", () => {
|
|
30
|
-
this._trailFill = {
|
|
31
|
-
image: img,
|
|
32
|
-
opacity,
|
|
33
|
-
};
|
|
34
|
-
resolve();
|
|
35
|
-
});
|
|
36
|
-
img.addEventListener("error", evt => {
|
|
37
|
-
getLogger().error(evt);
|
|
38
|
-
reject(new Error("Error loading image"));
|
|
39
|
-
});
|
|
40
|
-
img.src = trailFill.image;
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
this._container = container;
|
|
45
|
-
this._engine = engine;
|
|
46
|
-
}
|
|
47
|
-
canvasClear() {
|
|
48
|
-
const container = this._container, trail = container.actualOptions.trail, trailFill = this._trailFill;
|
|
49
|
-
if (!trail?.enable || !trailFill || trail.length <= minimumLength) {
|
|
50
|
-
return false;
|
|
51
|
-
}
|
|
52
|
-
let handled = false;
|
|
53
|
-
const canvas = container.canvas;
|
|
54
|
-
if (trailFill.color) {
|
|
55
|
-
canvas.paintBase(getStyleFromRgb(trailFill.color, container.hdr, trailFill.opacity));
|
|
56
|
-
handled = true;
|
|
57
|
-
}
|
|
58
|
-
else if (trailFill.image) {
|
|
59
|
-
canvas.paintImage(trailFill.image, trailFill.opacity);
|
|
60
|
-
handled = true;
|
|
61
|
-
}
|
|
62
|
-
return handled;
|
|
63
|
-
}
|
|
64
|
-
async init() {
|
|
65
|
-
try {
|
|
66
|
-
await this._initTrail();
|
|
67
|
-
}
|
|
68
|
-
catch (e) {
|
|
69
|
-
getLogger().error(e);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
package/esm/TrailInstance.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { getLogger, getStyleFromRgb, inverseFactorNumerator, rangeColorToRgb, safeDocument, } from "@tsparticles/engine";
|
|
2
|
-
const minimumLength = 0;
|
|
3
|
-
export class TrailInstance {
|
|
4
|
-
constructor(container, engine) {
|
|
5
|
-
this._initTrail = async () => {
|
|
6
|
-
const options = this._container.actualOptions, trail = options.trail;
|
|
7
|
-
if (!trail?.enable) {
|
|
8
|
-
return;
|
|
9
|
-
}
|
|
10
|
-
const trailFill = trail.fill, opacity = inverseFactorNumerator / trail.length;
|
|
11
|
-
if (trailFill.color) {
|
|
12
|
-
const fillColor = rangeColorToRgb(this._engine, trailFill.color);
|
|
13
|
-
if (!fillColor) {
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
this._trailFill = {
|
|
17
|
-
color: {
|
|
18
|
-
...fillColor,
|
|
19
|
-
},
|
|
20
|
-
opacity,
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
await new Promise((resolve, reject) => {
|
|
25
|
-
if (!trailFill.image) {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
const img = safeDocument().createElement("img");
|
|
29
|
-
img.addEventListener("load", () => {
|
|
30
|
-
this._trailFill = {
|
|
31
|
-
image: img,
|
|
32
|
-
opacity,
|
|
33
|
-
};
|
|
34
|
-
resolve();
|
|
35
|
-
});
|
|
36
|
-
img.addEventListener("error", evt => {
|
|
37
|
-
getLogger().error(evt);
|
|
38
|
-
reject(new Error("Error loading image"));
|
|
39
|
-
});
|
|
40
|
-
img.src = trailFill.image;
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
this._container = container;
|
|
45
|
-
this._engine = engine;
|
|
46
|
-
}
|
|
47
|
-
canvasClear() {
|
|
48
|
-
const container = this._container, trail = container.actualOptions.trail, trailFill = this._trailFill;
|
|
49
|
-
if (!trail?.enable || !trailFill || trail.length <= minimumLength) {
|
|
50
|
-
return false;
|
|
51
|
-
}
|
|
52
|
-
let handled = false;
|
|
53
|
-
const canvas = container.canvas;
|
|
54
|
-
if (trailFill.color) {
|
|
55
|
-
canvas.paintBase(getStyleFromRgb(trailFill.color, container.hdr, trailFill.opacity));
|
|
56
|
-
handled = true;
|
|
57
|
-
}
|
|
58
|
-
else if (trailFill.image) {
|
|
59
|
-
canvas.paintImage(trailFill.image, trailFill.opacity);
|
|
60
|
-
handled = true;
|
|
61
|
-
}
|
|
62
|
-
return handled;
|
|
63
|
-
}
|
|
64
|
-
async init() {
|
|
65
|
-
try {
|
|
66
|
-
await this._initTrail();
|
|
67
|
-
}
|
|
68
|
-
catch (e) {
|
|
69
|
-
getLogger().error(e);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/*! tsParticles Trail Plugin v4.0.0-alpha.1 by Matteo Bruni */
|