@tsparticles/effect-trail 4.0.0-beta.0 → 4.0.0-beta.10
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/410.min.js +1 -0
- package/README.md +23 -0
- package/browser/TrailDrawer.js +7 -3
- package/browser/index.js +4 -4
- package/cjs/TrailDrawer.js +7 -3
- package/cjs/index.js +4 -4
- package/dist_browser_TrailDrawer_js.js +2 -2
- package/esm/TrailDrawer.js +7 -3
- package/esm/index.js +4 -4
- package/package.json +4 -5
- package/report.html +84 -29
- package/tsparticles.effect.trail.js +2 -2
- package/tsparticles.effect.trail.min.js +1 -1
- package/types/TrailDrawer.d.ts +2 -0
- package/543.min.js +0 -1
- package/umd/TrailDrawer.js +0 -94
- package/umd/index.js +0 -56
|
@@ -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-beta.
|
|
7
|
+
* v4.0.0-beta.10
|
|
8
8
|
*/
|
|
9
9
|
/*
|
|
10
10
|
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
|
|
@@ -44,7 +44,7 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__;
|
|
|
44
44
|
\*******************************/
|
|
45
45
|
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
46
46
|
|
|
47
|
-
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadTrailEffect: () => (/* binding */ loadTrailEffect)\n/* harmony export */ });\nasync function loadTrailEffect(engine) {\n engine.checkVersion(\"4.0.0-beta.
|
|
47
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadTrailEffect: () => (/* binding */ loadTrailEffect)\n/* harmony export */ });\nasync function loadTrailEffect(engine) {\n engine.checkVersion(\"4.0.0-beta.10\");\n await engine.pluginManager.register((e)=>{\n e.pluginManager.addEffect(\"trail\", async (container)=>{\n const { TrailDrawer } = await __webpack_require__.e(/*! import() */ \"dist_browser_TrailDrawer_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./TrailDrawer.js */ \"./dist/browser/TrailDrawer.js\"));\n return new TrailDrawer(container);\n });\n });\n}\n\n\n//# sourceURL=webpack://@tsparticles/effect-trail/./dist/browser/index.js?\n}");
|
|
48
48
|
|
|
49
49
|
/***/ }
|
|
50
50
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
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),c={},a.l=(e,t,r,o)=>{if(c[e])return void c[e].push(t);if(void 0!==r)for(var i,n,s=document.getElementsByTagName("script"),l=0;l<s.length;l++){var p=s[l];if(p.getAttribute("src")==e||p.getAttribute("data-webpack")=="@tsparticles/effect-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/effect-trail:"+r),i.src=e),c[e]=[t];var u=(t,r)=>{i.onerror=i.onload=null,clearTimeout(f);var o=c[e];if(delete c[e],i.parentNode&&i.parentNode.removeChild(i),o&&o.forEach(e=>e(r)),t)return t(r)},f=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 c,s,l=a.g.document;if(!s&&l&&(l.currentScript&&"SCRIPT"===l.currentScript.tagName.toUpperCase()&&(s=l.currentScript.src),!s)){var p=l.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={826: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),c=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;c.message="Loading chunk "+e+` failed.
|
|
2
|
-
(`+i+": "+n+")",c.name="ChunkLoadError",c.type=i,c.request=n,o[1](c)}},"chunk-"+e,e)}},r=(e,r)=>{var o,i,[n,c,s]=r,l=0;if(n.some(e=>0!==t[e])){for(o in c)a.o(c,o)&&(a.m[o]=c[o]);s&&s(a)}for(e&&e(r);l<n.length;l++)i=n[l],a.o(t,i)&&t[i]&&t[i][0](),t[i]=0},(o=this.webpackChunk_tsparticles_effect_trail=this.webpackChunk_tsparticles_effect_trail||[]).forEach(r.bind(null,0)),o.push=r.bind(null,o.push.bind(o));var f={};async function d(e){e.checkVersion("4.0.0-beta.
|
|
2
|
+
(`+i+": "+n+")",c.name="ChunkLoadError",c.type=i,c.request=n,o[1](c)}},"chunk-"+e,e)}},r=(e,r)=>{var o,i,[n,c,s]=r,l=0;if(n.some(e=>0!==t[e])){for(o in c)a.o(c,o)&&(a.m[o]=c[o]);s&&s(a)}for(e&&e(r);l<n.length;l++)i=n[l],a.o(t,i)&&t[i]&&t[i][0](),t[i]=0},(o=this.webpackChunk_tsparticles_effect_trail=this.webpackChunk_tsparticles_effect_trail||[]).forEach(r.bind(null,0)),o.push=r.bind(null,o.push.bind(o));var f={};async function d(e){e.checkVersion("4.0.0-beta.10"),await e.pluginManager.register(e=>{e.pluginManager.addEffect("trail",async e=>{let{TrailDrawer:t}=await a.e(410).then(a.bind(a,410));return new t(e)})})}return a.r(f),a.d(f,{loadTrailEffect:()=>d}),f})());
|
package/types/TrailDrawer.d.ts
CHANGED
|
@@ -18,6 +18,8 @@ type TrailParticle = Particle & {
|
|
|
18
18
|
trailTransform?: boolean;
|
|
19
19
|
};
|
|
20
20
|
export declare class TrailDrawer implements IEffectDrawer<TrailParticle> {
|
|
21
|
+
private readonly _container;
|
|
22
|
+
constructor(container: Container);
|
|
21
23
|
drawAfter(data: IShapeDrawData<TrailParticle>): void;
|
|
22
24
|
particleInit(container: Container, particle: TrailParticle): void;
|
|
23
25
|
}
|
package/543.min.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";(this.webpackChunk_tsparticles_effect_trail=this.webpackChunk_tsparticles_effect_trail||[]).push([[543],{543(t,a,i){i.d(a,{TrailDrawer:()=>n});var e=i(303);let l={a:1,b:0,c:0,d:1};class n{drawAfter(t){let{context:a,drawPosition:i,drawRadius:n,drawScale:r,particle:h,transformData:o}=t,s=n*e.double,d=h.container.retina.pixelRatio,f=h.trail;if(!f||!h.trailLength)return;let c=h.trailLength*r+n;if(f.push({color:a.fillStyle||a.strokeStyle,position:{x:i.x,y:i.y},transformData:o}),f.length<3)return;let g=Math.floor(c);f.length>g&&f.splice(0,f.length-g);let x=Math.min(f.length,c),p={width:h.container.canvas.size.width*r+s,height:h.container.canvas.size.height*r+s};a.save(),a.lineCap="butt",a.lineJoin="round";for(let t=x-2;t>0;t--){let i=f[t+1],n=f[t],o=f[t-1];if(!i||!n||!o)continue;let g=i.position,u=n.position,y=o.position,b=h.trailTransform?n.transformData??l:l,{distance:m}=(0,e.getDistances)(g,u),{distance:M}=(0,e.getDistances)(u,y);if(m>c*e.double||M>c*e.double||Math.abs(g.x-u.x)>p.width*e.half||Math.abs(g.y-u.y)>p.height*e.half||Math.abs(u.x-y.x)>p.width*e.half||Math.abs(u.y-y.y)>p.height*e.half)continue;a.setTransform(b.a,b.b,b.c,b.d,u.x,u.y);let W=(g.x+u.x)*e.half-u.x,v=(g.y+u.y)*e.half-u.y,w=(u.x+y.x)*e.half-u.x,k=(u.y+y.y)*e.half-u.y;a.beginPath(),a.moveTo(W,v),a.quadraticCurveTo(e.originPoint.x,e.originPoint.y,w,k);let R=Math.max(t/x*s,d,(h.trailMinWidth??-1)*r),T=a.globalAlpha;a.globalAlpha=h.trailFade?t/x:e.defaultAlpha,a.lineWidth=h.trailMaxWidth?Math.min(R,h.trailMaxWidth*r):R,a.strokeStyle=n.color,a.stroke(),a.globalAlpha=T}a.restore()}particleInit(t,a){a.trail=[];let i=a.effectData;a.trailFade=i?.fade??!0,a.trailLength=(0,e.getRangeValue)(i?.length??10)*t.retina.pixelRatio,a.trailMaxWidth=i?.maxWidth?(0,e.getRangeValue)(i.maxWidth)*t.retina.pixelRatio:void 0,a.trailMinWidth=i?.minWidth?(0,e.getRangeValue)(i.minWidth)*t.retina.pixelRatio:void 0,a.trailTransform=i?.transform??!1}}}}]);
|
package/umd/TrailDrawer.js
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
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", "@tsparticles/engine"], factory);
|
|
8
|
-
}
|
|
9
|
-
})(function (require, exports) {
|
|
10
|
-
"use strict";
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.TrailDrawer = void 0;
|
|
13
|
-
const engine_1 = require("@tsparticles/engine");
|
|
14
|
-
const minTrailLength = 3, trailLengthOffset = 1, minWidth = -1, firstIndex = 0, defaultLength = 10, loopTrailLengthOffset = 2, loopTrailLengthMinIndex = 0;
|
|
15
|
-
const defaultTransform = {
|
|
16
|
-
a: 1,
|
|
17
|
-
b: 0,
|
|
18
|
-
c: 0,
|
|
19
|
-
d: 1,
|
|
20
|
-
};
|
|
21
|
-
class TrailDrawer {
|
|
22
|
-
drawAfter(data) {
|
|
23
|
-
const { context, drawPosition, drawRadius, drawScale, particle, transformData } = data, diameter = drawRadius * engine_1.double, pxRatio = particle.container.retina.pixelRatio, trail = particle.trail;
|
|
24
|
-
if (!trail || !particle.trailLength) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
const currentPos = drawPosition, pathLength = particle.trailLength * drawScale + drawRadius;
|
|
28
|
-
trail.push({
|
|
29
|
-
color: context.fillStyle || context.strokeStyle,
|
|
30
|
-
position: {
|
|
31
|
-
x: currentPos.x,
|
|
32
|
-
y: currentPos.y,
|
|
33
|
-
},
|
|
34
|
-
transformData,
|
|
35
|
-
});
|
|
36
|
-
if (trail.length < minTrailLength) {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
const pathLengthFloor = Math.floor(pathLength);
|
|
40
|
-
if (trail.length > pathLengthFloor) {
|
|
41
|
-
trail.splice(firstIndex, trail.length - pathLengthFloor);
|
|
42
|
-
}
|
|
43
|
-
const trailLength = Math.min(trail.length, pathLength), canvasSize = {
|
|
44
|
-
width: particle.container.canvas.size.width * drawScale + diameter,
|
|
45
|
-
height: particle.container.canvas.size.height * drawScale + diameter,
|
|
46
|
-
};
|
|
47
|
-
context.save();
|
|
48
|
-
context.lineCap = "butt";
|
|
49
|
-
context.lineJoin = "round";
|
|
50
|
-
for (let i = trailLength - loopTrailLengthOffset; i > loopTrailLengthMinIndex; i--) {
|
|
51
|
-
const previousStep = trail[i + trailLengthOffset], step = trail[i], nextStep = trail[i - trailLengthOffset];
|
|
52
|
-
if (!previousStep || !step || !nextStep) {
|
|
53
|
-
continue;
|
|
54
|
-
}
|
|
55
|
-
const previousPosition = previousStep.position, position = step.position, nextPosition = nextStep.position, stepTransformData = particle.trailTransform ? (step.transformData ?? defaultTransform) : defaultTransform, { distance: previousDistance } = (0, engine_1.getDistances)(previousPosition, position), { distance: nextDistance } = (0, engine_1.getDistances)(position, nextPosition);
|
|
56
|
-
if (previousDistance > pathLength * engine_1.double || nextDistance > pathLength * engine_1.double) {
|
|
57
|
-
continue;
|
|
58
|
-
}
|
|
59
|
-
if (Math.abs(previousPosition.x - position.x) > canvasSize.width * engine_1.half ||
|
|
60
|
-
Math.abs(previousPosition.y - position.y) > canvasSize.height * engine_1.half ||
|
|
61
|
-
Math.abs(position.x - nextPosition.x) > canvasSize.width * engine_1.half ||
|
|
62
|
-
Math.abs(position.y - nextPosition.y) > canvasSize.height * engine_1.half) {
|
|
63
|
-
continue;
|
|
64
|
-
}
|
|
65
|
-
context.setTransform(stepTransformData.a, stepTransformData.b, stepTransformData.c, stepTransformData.d, position.x, position.y);
|
|
66
|
-
const startX = (previousPosition.x + position.x) * engine_1.half - position.x, startY = (previousPosition.y + position.y) * engine_1.half - position.y, endX = (position.x + nextPosition.x) * engine_1.half - position.x, endY = (position.y + nextPosition.y) * engine_1.half - position.y;
|
|
67
|
-
context.beginPath();
|
|
68
|
-
context.moveTo(startX, startY);
|
|
69
|
-
context.quadraticCurveTo(engine_1.originPoint.x, engine_1.originPoint.y, endX, endY);
|
|
70
|
-
const width = Math.max((i / trailLength) * diameter, pxRatio, (particle.trailMinWidth ?? minWidth) * drawScale), oldAlpha = context.globalAlpha;
|
|
71
|
-
context.globalAlpha = particle.trailFade ? i / trailLength : engine_1.defaultAlpha;
|
|
72
|
-
context.lineWidth = particle.trailMaxWidth ? Math.min(width, particle.trailMaxWidth * drawScale) : width;
|
|
73
|
-
context.strokeStyle = step.color;
|
|
74
|
-
context.stroke();
|
|
75
|
-
context.globalAlpha = oldAlpha;
|
|
76
|
-
}
|
|
77
|
-
context.restore();
|
|
78
|
-
}
|
|
79
|
-
particleInit(container, particle) {
|
|
80
|
-
particle.trail = [];
|
|
81
|
-
const effectData = particle.effectData;
|
|
82
|
-
particle.trailFade = effectData?.fade ?? true;
|
|
83
|
-
particle.trailLength = (0, engine_1.getRangeValue)(effectData?.length ?? defaultLength) * container.retina.pixelRatio;
|
|
84
|
-
particle.trailMaxWidth = effectData?.maxWidth
|
|
85
|
-
? (0, engine_1.getRangeValue)(effectData.maxWidth) * container.retina.pixelRatio
|
|
86
|
-
: undefined;
|
|
87
|
-
particle.trailMinWidth = effectData?.minWidth
|
|
88
|
-
? (0, engine_1.getRangeValue)(effectData.minWidth) * container.retina.pixelRatio
|
|
89
|
-
: undefined;
|
|
90
|
-
particle.trailTransform = effectData?.transform ?? false;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
exports.TrailDrawer = TrailDrawer;
|
|
94
|
-
});
|
package/umd/index.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
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
|
-
})();
|
|
34
|
-
(function (factory) {
|
|
35
|
-
if (typeof module === "object" && typeof module.exports === "object") {
|
|
36
|
-
var v = factory(require, exports);
|
|
37
|
-
if (v !== undefined) module.exports = v;
|
|
38
|
-
}
|
|
39
|
-
else if (typeof define === "function" && define.amd) {
|
|
40
|
-
define(["require", "exports"], factory);
|
|
41
|
-
}
|
|
42
|
-
})(function (require, exports) {
|
|
43
|
-
"use strict";
|
|
44
|
-
var __syncRequire = typeof module === "object" && typeof module.exports === "object";
|
|
45
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
-
exports.loadTrailEffect = loadTrailEffect;
|
|
47
|
-
async function loadTrailEffect(engine) {
|
|
48
|
-
engine.checkVersion("4.0.0-beta.0");
|
|
49
|
-
await engine.register(e => {
|
|
50
|
-
e.addEffect("trail", async () => {
|
|
51
|
-
const { TrailDrawer } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./TrailDrawer.js"))) : new Promise((resolve_1, reject_1) => { require(["./TrailDrawer.js"], resolve_1, reject_1); }).then(__importStar));
|
|
52
|
-
return new TrailDrawer();
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
});
|