@tsparticles/effect-trail 4.0.4 → 4.1.0

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.
@@ -1,5 +1,5 @@
1
- import { defaultAlpha, double, getRangeValue, half, originPoint, } from "@tsparticles/engine";
2
- const minTrailLength = 3, trailLengthOffset = 1, minWidth = -1, firstIndex = 0, defaultLength = 10, loopTrailLengthOffset = 2, loopTrailLengthMinIndex = 0;
1
+ import { OutMode, OutModeDirection, defaultAlpha, double, getRangeValue, half, originPoint, } from "@tsparticles/engine";
2
+ const minTrailLength = 3, trailLengthOffset = 1, minWidth = -1, firstIndex = 0, defaultLength = 10, loopTrailLengthOffset = 2, loopTrailLengthMinIndex = 0, defaultWidth = 0, minBound = 0;
3
3
  const defaultTransform = {
4
4
  a: 1,
5
5
  b: 0,
@@ -7,12 +7,12 @@ const defaultTransform = {
7
7
  d: 1,
8
8
  };
9
9
  export class TrailDrawer {
10
- _container;
10
+ #container;
11
11
  constructor(container) {
12
- this._container = container;
12
+ this.#container = container;
13
13
  }
14
14
  drawAfter(data) {
15
- const { context, drawPosition, drawRadius, drawScale, particle, transformData } = data, container = this._container, diameter = drawRadius * double, pxRatio = container.retina.pixelRatio, trail = particle.trail;
15
+ const { context, drawPosition, drawRadius, drawScale, particle, transformData } = data, container = this.#container, diameter = drawRadius * double, pxRatio = container.retina.pixelRatio, trail = particle.trail;
16
16
  if (!trail || !particle.trailLength) {
17
17
  return;
18
18
  }
@@ -60,6 +60,39 @@ export class TrailDrawer {
60
60
  }
61
61
  context.restore();
62
62
  }
63
+ isInsideCanvas(data) {
64
+ const { canvasSize, direction, outMode, particle, radius } = data, position = particle.position, trail = particle.trail;
65
+ let minX = position.x - radius, maxX = position.x + radius, minY = position.y - radius, maxY = position.y + radius;
66
+ if (trail?.length) {
67
+ const widthPadding = Math.max(radius, particle.trailMaxWidth ?? defaultWidth, particle.trailMinWidth ?? defaultWidth);
68
+ for (const step of trail) {
69
+ minX = Math.min(minX, step.position.x - widthPadding);
70
+ maxX = Math.max(maxX, step.position.x + widthPadding);
71
+ minY = Math.min(minY, step.position.y - widthPadding);
72
+ maxY = Math.max(maxY, step.position.y + widthPadding);
73
+ }
74
+ }
75
+ const strictBounds = outMode === OutMode.destroy;
76
+ if (direction === OutModeDirection.bottom) {
77
+ return minY <= canvasSize.height;
78
+ }
79
+ if (direction === OutModeDirection.left) {
80
+ return maxX >= minBound;
81
+ }
82
+ if (direction === OutModeDirection.right) {
83
+ return minX <= canvasSize.width;
84
+ }
85
+ if (direction === OutModeDirection.top) {
86
+ return maxY >= minBound;
87
+ }
88
+ if (!strictBounds) {
89
+ return (position.x + radius >= minBound &&
90
+ position.y + radius >= minBound &&
91
+ position.x - radius <= canvasSize.width &&
92
+ position.y - radius <= canvasSize.height);
93
+ }
94
+ return maxX >= minBound && maxY >= minBound && minX <= canvasSize.width && minY <= canvasSize.height;
95
+ }
63
96
  particleInit(container, particle) {
64
97
  particle.trail = [];
65
98
  const effectData = particle.effectData;
package/browser/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { TrailDrawer } from "./TrailDrawer.js";
2
2
  export async function loadTrailEffect(engine) {
3
- engine.checkVersion("4.0.4");
3
+ engine.checkVersion("4.1.0");
4
4
  await engine.pluginManager.register(e => {
5
5
  e.pluginManager.addEffect("trail", container => {
6
6
  return Promise.resolve(new TrailDrawer(container));
@@ -1,5 +1,5 @@
1
1
  export async function loadTrailEffect(engine) {
2
- engine.checkVersion("4.0.4");
2
+ engine.checkVersion("4.1.0");
3
3
  await engine.pluginManager.register(e => {
4
4
  e.pluginManager.addEffect("trail", async (container) => {
5
5
  const { TrailDrawer } = await import("./TrailDrawer.js");
@@ -1,5 +1,5 @@
1
- import { defaultAlpha, double, getRangeValue, half, originPoint, } from "@tsparticles/engine";
2
- const minTrailLength = 3, trailLengthOffset = 1, minWidth = -1, firstIndex = 0, defaultLength = 10, loopTrailLengthOffset = 2, loopTrailLengthMinIndex = 0;
1
+ import { OutMode, OutModeDirection, defaultAlpha, double, getRangeValue, half, originPoint, } from "@tsparticles/engine";
2
+ const minTrailLength = 3, trailLengthOffset = 1, minWidth = -1, firstIndex = 0, defaultLength = 10, loopTrailLengthOffset = 2, loopTrailLengthMinIndex = 0, defaultWidth = 0, minBound = 0;
3
3
  const defaultTransform = {
4
4
  a: 1,
5
5
  b: 0,
@@ -7,12 +7,12 @@ const defaultTransform = {
7
7
  d: 1,
8
8
  };
9
9
  export class TrailDrawer {
10
- _container;
10
+ #container;
11
11
  constructor(container) {
12
- this._container = container;
12
+ this.#container = container;
13
13
  }
14
14
  drawAfter(data) {
15
- const { context, drawPosition, drawRadius, drawScale, particle, transformData } = data, container = this._container, diameter = drawRadius * double, pxRatio = container.retina.pixelRatio, trail = particle.trail;
15
+ const { context, drawPosition, drawRadius, drawScale, particle, transformData } = data, container = this.#container, diameter = drawRadius * double, pxRatio = container.retina.pixelRatio, trail = particle.trail;
16
16
  if (!trail || !particle.trailLength) {
17
17
  return;
18
18
  }
@@ -60,6 +60,39 @@ export class TrailDrawer {
60
60
  }
61
61
  context.restore();
62
62
  }
63
+ isInsideCanvas(data) {
64
+ const { canvasSize, direction, outMode, particle, radius } = data, position = particle.position, trail = particle.trail;
65
+ let minX = position.x - radius, maxX = position.x + radius, minY = position.y - radius, maxY = position.y + radius;
66
+ if (trail?.length) {
67
+ const widthPadding = Math.max(radius, particle.trailMaxWidth ?? defaultWidth, particle.trailMinWidth ?? defaultWidth);
68
+ for (const step of trail) {
69
+ minX = Math.min(minX, step.position.x - widthPadding);
70
+ maxX = Math.max(maxX, step.position.x + widthPadding);
71
+ minY = Math.min(minY, step.position.y - widthPadding);
72
+ maxY = Math.max(maxY, step.position.y + widthPadding);
73
+ }
74
+ }
75
+ const strictBounds = outMode === OutMode.destroy;
76
+ if (direction === OutModeDirection.bottom) {
77
+ return minY <= canvasSize.height;
78
+ }
79
+ if (direction === OutModeDirection.left) {
80
+ return maxX >= minBound;
81
+ }
82
+ if (direction === OutModeDirection.right) {
83
+ return minX <= canvasSize.width;
84
+ }
85
+ if (direction === OutModeDirection.top) {
86
+ return maxY >= minBound;
87
+ }
88
+ if (!strictBounds) {
89
+ return (position.x + radius >= minBound &&
90
+ position.y + radius >= minBound &&
91
+ position.x - radius <= canvasSize.width &&
92
+ position.y - radius <= canvasSize.height);
93
+ }
94
+ return maxX >= minBound && maxY >= minBound && minX <= canvasSize.width && minY <= canvasSize.height;
95
+ }
63
96
  particleInit(container, particle) {
64
97
  particle.trail = [];
65
98
  const effectData = particle.effectData;
package/cjs/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { TrailDrawer } from "./TrailDrawer.js";
2
2
  export async function loadTrailEffect(engine) {
3
- engine.checkVersion("4.0.4");
3
+ engine.checkVersion("4.1.0");
4
4
  await engine.pluginManager.register(e => {
5
5
  e.pluginManager.addEffect("trail", container => {
6
6
  return Promise.resolve(new TrailDrawer(container));
package/cjs/index.lazy.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export async function loadTrailEffect(engine) {
2
- engine.checkVersion("4.0.4");
2
+ engine.checkVersion("4.1.0");
3
3
  await engine.pluginManager.register(e => {
4
4
  e.pluginManager.addEffect("trail", async (container) => {
5
5
  const { TrailDrawer } = await import("./TrailDrawer.js");
@@ -1,5 +1,5 @@
1
- import { defaultAlpha, double, getRangeValue, half, originPoint, } from "@tsparticles/engine";
2
- const minTrailLength = 3, trailLengthOffset = 1, minWidth = -1, firstIndex = 0, defaultLength = 10, loopTrailLengthOffset = 2, loopTrailLengthMinIndex = 0;
1
+ import { OutMode, OutModeDirection, defaultAlpha, double, getRangeValue, half, originPoint, } from "@tsparticles/engine";
2
+ const minTrailLength = 3, trailLengthOffset = 1, minWidth = -1, firstIndex = 0, defaultLength = 10, loopTrailLengthOffset = 2, loopTrailLengthMinIndex = 0, defaultWidth = 0, minBound = 0;
3
3
  const defaultTransform = {
4
4
  a: 1,
5
5
  b: 0,
@@ -7,12 +7,12 @@ const defaultTransform = {
7
7
  d: 1,
8
8
  };
9
9
  export class TrailDrawer {
10
- _container;
10
+ #container;
11
11
  constructor(container) {
12
- this._container = container;
12
+ this.#container = container;
13
13
  }
14
14
  drawAfter(data) {
15
- const { context, drawPosition, drawRadius, drawScale, particle, transformData } = data, container = this._container, diameter = drawRadius * double, pxRatio = container.retina.pixelRatio, trail = particle.trail;
15
+ const { context, drawPosition, drawRadius, drawScale, particle, transformData } = data, container = this.#container, diameter = drawRadius * double, pxRatio = container.retina.pixelRatio, trail = particle.trail;
16
16
  if (!trail || !particle.trailLength) {
17
17
  return;
18
18
  }
@@ -60,6 +60,39 @@ export class TrailDrawer {
60
60
  }
61
61
  context.restore();
62
62
  }
63
+ isInsideCanvas(data) {
64
+ const { canvasSize, direction, outMode, particle, radius } = data, position = particle.position, trail = particle.trail;
65
+ let minX = position.x - radius, maxX = position.x + radius, minY = position.y - radius, maxY = position.y + radius;
66
+ if (trail?.length) {
67
+ const widthPadding = Math.max(radius, particle.trailMaxWidth ?? defaultWidth, particle.trailMinWidth ?? defaultWidth);
68
+ for (const step of trail) {
69
+ minX = Math.min(minX, step.position.x - widthPadding);
70
+ maxX = Math.max(maxX, step.position.x + widthPadding);
71
+ minY = Math.min(minY, step.position.y - widthPadding);
72
+ maxY = Math.max(maxY, step.position.y + widthPadding);
73
+ }
74
+ }
75
+ const strictBounds = outMode === OutMode.destroy;
76
+ if (direction === OutModeDirection.bottom) {
77
+ return minY <= canvasSize.height;
78
+ }
79
+ if (direction === OutModeDirection.left) {
80
+ return maxX >= minBound;
81
+ }
82
+ if (direction === OutModeDirection.right) {
83
+ return minX <= canvasSize.width;
84
+ }
85
+ if (direction === OutModeDirection.top) {
86
+ return maxY >= minBound;
87
+ }
88
+ if (!strictBounds) {
89
+ return (position.x + radius >= minBound &&
90
+ position.y + radius >= minBound &&
91
+ position.x - radius <= canvasSize.width &&
92
+ position.y - radius <= canvasSize.height);
93
+ }
94
+ return maxX >= minBound && maxY >= minBound && minX <= canvasSize.width && minY <= canvasSize.height;
95
+ }
63
96
  particleInit(container, particle) {
64
97
  particle.trail = [];
65
98
  const effectData = particle.effectData;
package/esm/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { TrailDrawer } from "./TrailDrawer.js";
2
2
  export async function loadTrailEffect(engine) {
3
- engine.checkVersion("4.0.4");
3
+ engine.checkVersion("4.1.0");
4
4
  await engine.pluginManager.register(e => {
5
5
  e.pluginManager.addEffect("trail", container => {
6
6
  return Promise.resolve(new TrailDrawer(container));
package/esm/index.lazy.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export async function loadTrailEffect(engine) {
2
- engine.checkVersion("4.0.4");
2
+ engine.checkVersion("4.1.0");
3
3
  await engine.pluginManager.register(e => {
4
4
  e.pluginManager.addEffect("trail", async (container) => {
5
5
  const { TrailDrawer } = await import("./TrailDrawer.js");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsparticles/effect-trail",
3
- "version": "4.0.4",
3
+ "version": "4.1.0",
4
4
  "description": "tsParticles trail effect",
5
5
  "homepage": "https://particles.js.org",
6
6
  "repository": {
@@ -106,7 +106,7 @@
106
106
  "./package.json": "./package.json"
107
107
  },
108
108
  "peerDependencies": {
109
- "@tsparticles/engine": "4.0.4"
109
+ "@tsparticles/engine": "4.1.0"
110
110
  },
111
111
  "publishConfig": {
112
112
  "access": "public"
package/report.html CHANGED
@@ -4930,7 +4930,7 @@ var drawChart = (function (exports) {
4930
4930
  </script>
4931
4931
  <script>
4932
4932
  /*<!--*/
4933
- const data = {"version":2,"tree":{"name":"root","children":[{"name":"tsparticles.effect.trail.js","children":[{"name":"dist/browser","children":[{"uid":"bebe7175-1","name":"TrailDrawer.js"},{"uid":"bebe7175-3","name":"index.js"},{"uid":"bebe7175-5","name":"browser.js"}]}]}],"isRoot":true},"nodeParts":{"bebe7175-1":{"renderedLength":4219,"gzipLength":0,"brotliLength":0,"metaUid":"bebe7175-0"},"bebe7175-3":{"renderedLength":297,"gzipLength":0,"brotliLength":0,"metaUid":"bebe7175-2"},"bebe7175-5":{"renderedLength":173,"gzipLength":0,"brotliLength":0,"metaUid":"bebe7175-4"}},"nodeMetas":{"bebe7175-0":{"id":"/dist/browser/TrailDrawer.js","moduleParts":{"tsparticles.effect.trail.js":"bebe7175-1"},"imported":[{"uid":"bebe7175-6"}],"importedBy":[{"uid":"bebe7175-2"}]},"bebe7175-2":{"id":"/dist/browser/index.js","moduleParts":{"tsparticles.effect.trail.js":"bebe7175-3"},"imported":[{"uid":"bebe7175-0"}],"importedBy":[{"uid":"bebe7175-4"}]},"bebe7175-4":{"id":"/dist/browser/browser.js","moduleParts":{"tsparticles.effect.trail.js":"bebe7175-5"},"imported":[{"uid":"bebe7175-2"}],"importedBy":[],"isEntry":true},"bebe7175-6":{"id":"@tsparticles/engine","moduleParts":{},"imported":[],"importedBy":[{"uid":"bebe7175-0"}],"isExternal":true}},"env":{"rollup":"4.60.4"},"options":{"gzip":false,"brotli":false,"sourcemap":false}};
4933
+ const data = {"version":2,"tree":{"name":"root","children":[{"name":"tsparticles.effect.trail.js","children":[{"name":"dist/browser","children":[{"uid":"97c4234a-1","name":"TrailDrawer.js"},{"uid":"97c4234a-3","name":"index.js"},{"uid":"97c4234a-5","name":"browser.js"}]}]}],"isRoot":true},"nodeParts":{"97c4234a-1":{"renderedLength":6054,"gzipLength":0,"brotliLength":0,"metaUid":"97c4234a-0"},"97c4234a-3":{"renderedLength":297,"gzipLength":0,"brotliLength":0,"metaUid":"97c4234a-2"},"97c4234a-5":{"renderedLength":173,"gzipLength":0,"brotliLength":0,"metaUid":"97c4234a-4"}},"nodeMetas":{"97c4234a-0":{"id":"/dist/browser/TrailDrawer.js","moduleParts":{"tsparticles.effect.trail.js":"97c4234a-1"},"imported":[{"uid":"97c4234a-6"}],"importedBy":[{"uid":"97c4234a-2"}]},"97c4234a-2":{"id":"/dist/browser/index.js","moduleParts":{"tsparticles.effect.trail.js":"97c4234a-3"},"imported":[{"uid":"97c4234a-0"}],"importedBy":[{"uid":"97c4234a-4"}]},"97c4234a-4":{"id":"/dist/browser/browser.js","moduleParts":{"tsparticles.effect.trail.js":"97c4234a-5"},"imported":[{"uid":"97c4234a-2"}],"importedBy":[],"isEntry":true},"97c4234a-6":{"id":"@tsparticles/engine","moduleParts":{},"imported":[],"importedBy":[{"uid":"97c4234a-0"}],"isExternal":true}},"env":{"rollup":"4.60.4"},"options":{"gzip":false,"brotli":false,"sourcemap":false}};
4934
4934
 
4935
4935
  const run = () => {
4936
4936
  const width = window.innerWidth;
@@ -1,12 +1,12 @@
1
1
  (function(g){g.__tsParticlesInternals=g.__tsParticlesInternals||{};g.__tsParticlesInternals.bundles=g.__tsParticlesInternals.bundles||{};g.__tsParticlesInternals.effects=g.__tsParticlesInternals.effects||{};g.__tsParticlesInternals.engine=g.__tsParticlesInternals.engine||{};g.__tsParticlesInternals.interactions=g.__tsParticlesInternals.interactions||{};g.__tsParticlesInternals.palettes=g.__tsParticlesInternals.palettes||{};g.__tsParticlesInternals.paths=g.__tsParticlesInternals.paths||{};g.__tsParticlesInternals.plugins=g.__tsParticlesInternals.plugins||{};g.__tsParticlesInternals.plugins=g.__tsParticlesInternals.plugins||{};g.__tsParticlesInternals.plugins.emittersShapes=g.__tsParticlesInternals.plugins.emittersShapes||{};g.__tsParticlesInternals.presets=g.__tsParticlesInternals.presets||{};g.__tsParticlesInternals.shapes=g.__tsParticlesInternals.shapes||{};g.__tsParticlesInternals.updaters=g.__tsParticlesInternals.updaters||{};g.__tsParticlesInternals.utils=g.__tsParticlesInternals.utils||{};g.__tsParticlesInternals.canvas=g.__tsParticlesInternals.canvas||{};g.__tsParticlesInternals.canvas=g.__tsParticlesInternals.canvas||{};g.__tsParticlesInternals.canvas.utils=g.__tsParticlesInternals.canvas.utils||{};g.__tsParticlesInternals.path=g.__tsParticlesInternals.path||{};g.__tsParticlesInternals.path=g.__tsParticlesInternals.path||{};g.__tsParticlesInternals.path.utils=g.__tsParticlesInternals.path.utils||{};var __tsProxyFactory=typeof Proxy!=="undefined"?function(obj){return new Proxy(obj,{get:function(target,key){if(!(key in target)){target[key]={};}return target[key];}});}:function(obj){return obj;};g.__tsParticlesInternals.bundles=__tsProxyFactory(g.__tsParticlesInternals.bundles);g.__tsParticlesInternals.effects=__tsProxyFactory(g.__tsParticlesInternals.effects);g.__tsParticlesInternals.interactions=__tsProxyFactory(g.__tsParticlesInternals.interactions);g.__tsParticlesInternals.palettes=__tsProxyFactory(g.__tsParticlesInternals.palettes);g.__tsParticlesInternals.paths=__tsProxyFactory(g.__tsParticlesInternals.paths);g.__tsParticlesInternals.plugins=__tsProxyFactory(g.__tsParticlesInternals.plugins);g.__tsParticlesInternals.plugins.emittersShapes=__tsProxyFactory(g.__tsParticlesInternals.plugins.emittersShapes);g.__tsParticlesInternals.presets=__tsProxyFactory(g.__tsParticlesInternals.presets);g.__tsParticlesInternals.shapes=__tsProxyFactory(g.__tsParticlesInternals.shapes);g.__tsParticlesInternals.updaters=__tsProxyFactory(g.__tsParticlesInternals.updaters);g.__tsParticlesInternals.utils=__tsProxyFactory(g.__tsParticlesInternals.utils);g.__tsParticlesInternals.canvas=__tsProxyFactory(g.__tsParticlesInternals.canvas);g.__tsParticlesInternals.path=__tsProxyFactory(g.__tsParticlesInternals.path);g.tsparticlesInternalExports=g.tsparticlesInternalExports||{};})(typeof globalThis!=="undefined"?globalThis:typeof window!=="undefined"?window:this);
2
- /* Effect v4.0.4 */
2
+ /* Effect v4.1.0 */
3
3
  (function (global, factory) {
4
4
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tsparticles/engine')) :
5
5
  typeof define === 'function' && define.amd ? define(['exports', '@tsparticles/engine'], factory) :
6
6
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.__tsParticlesInternals = global.__tsParticlesInternals || {}, global.__tsParticlesInternals.effects = global.__tsParticlesInternals.effects || {}, global.__tsParticlesInternals.effects.trail = global.__tsParticlesInternals.effects.trail || {}), global.__tsParticlesInternals.engine));
7
7
  })(this, (function (exports, engine) { 'use strict';
8
8
 
9
- const minTrailLength = 3, trailLengthOffset = 1, minWidth = -1, firstIndex = 0, defaultLength = 10, loopTrailLengthOffset = 2, loopTrailLengthMinIndex = 0;
9
+ const minTrailLength = 3, trailLengthOffset = 1, minWidth = -1, firstIndex = 0, defaultLength = 10, loopTrailLengthOffset = 2, loopTrailLengthMinIndex = 0, defaultWidth = 0, minBound = 0;
10
10
  const defaultTransform = {
11
11
  a: 1,
12
12
  b: 0,
@@ -14,12 +14,12 @@
14
14
  d: 1,
15
15
  };
16
16
  class TrailDrawer {
17
- _container;
17
+ #container;
18
18
  constructor(container) {
19
- this._container = container;
19
+ this.#container = container;
20
20
  }
21
21
  drawAfter(data) {
22
- const { context, drawPosition, drawRadius, drawScale, particle, transformData } = data, container = this._container, diameter = drawRadius * engine.double, pxRatio = container.retina.pixelRatio, trail = particle.trail;
22
+ const { context, drawPosition, drawRadius, drawScale, particle, transformData } = data, container = this.#container, diameter = drawRadius * engine.double, pxRatio = container.retina.pixelRatio, trail = particle.trail;
23
23
  if (!trail || !particle.trailLength) {
24
24
  return;
25
25
  }
@@ -67,6 +67,39 @@
67
67
  }
68
68
  context.restore();
69
69
  }
70
+ isInsideCanvas(data) {
71
+ const { canvasSize, direction, outMode, particle, radius } = data, position = particle.position, trail = particle.trail;
72
+ let minX = position.x - radius, maxX = position.x + radius, minY = position.y - radius, maxY = position.y + radius;
73
+ if (trail?.length) {
74
+ const widthPadding = Math.max(radius, particle.trailMaxWidth ?? defaultWidth, particle.trailMinWidth ?? defaultWidth);
75
+ for (const step of trail) {
76
+ minX = Math.min(minX, step.position.x - widthPadding);
77
+ maxX = Math.max(maxX, step.position.x + widthPadding);
78
+ minY = Math.min(minY, step.position.y - widthPadding);
79
+ maxY = Math.max(maxY, step.position.y + widthPadding);
80
+ }
81
+ }
82
+ const strictBounds = outMode === engine.OutMode.destroy;
83
+ if (direction === engine.OutModeDirection.bottom) {
84
+ return minY <= canvasSize.height;
85
+ }
86
+ if (direction === engine.OutModeDirection.left) {
87
+ return maxX >= minBound;
88
+ }
89
+ if (direction === engine.OutModeDirection.right) {
90
+ return minX <= canvasSize.width;
91
+ }
92
+ if (direction === engine.OutModeDirection.top) {
93
+ return maxY >= minBound;
94
+ }
95
+ if (!strictBounds) {
96
+ return (position.x + radius >= minBound &&
97
+ position.y + radius >= minBound &&
98
+ position.x - radius <= canvasSize.width &&
99
+ position.y - radius <= canvasSize.height);
100
+ }
101
+ return maxX >= minBound && maxY >= minBound && minX <= canvasSize.width && minY <= canvasSize.height;
102
+ }
70
103
  particleInit(container, particle) {
71
104
  particle.trail = [];
72
105
  const effectData = particle.effectData;
@@ -83,7 +116,7 @@
83
116
  }
84
117
 
85
118
  async function loadTrailEffect(engine) {
86
- engine.checkVersion("4.0.4");
119
+ engine.checkVersion("4.1.0");
87
120
  await engine.pluginManager.register(e => {
88
121
  e.pluginManager.addEffect("trail", container => {
89
122
  return Promise.resolve(new TrailDrawer(container));
@@ -1 +1 @@
1
- !function(t){t.__tsParticlesInternals=t.__tsParticlesInternals||{},t.__tsParticlesInternals.bundles=t.__tsParticlesInternals.bundles||{},t.__tsParticlesInternals.effects=t.__tsParticlesInternals.effects||{},t.__tsParticlesInternals.engine=t.__tsParticlesInternals.engine||{},t.__tsParticlesInternals.interactions=t.__tsParticlesInternals.interactions||{},t.__tsParticlesInternals.palettes=t.__tsParticlesInternals.palettes||{},t.__tsParticlesInternals.paths=t.__tsParticlesInternals.paths||{},t.__tsParticlesInternals.plugins=t.__tsParticlesInternals.plugins||{},t.__tsParticlesInternals.plugins=t.__tsParticlesInternals.plugins||{},t.__tsParticlesInternals.plugins.emittersShapes=t.__tsParticlesInternals.plugins.emittersShapes||{},t.__tsParticlesInternals.presets=t.__tsParticlesInternals.presets||{},t.__tsParticlesInternals.shapes=t.__tsParticlesInternals.shapes||{},t.__tsParticlesInternals.updaters=t.__tsParticlesInternals.updaters||{},t.__tsParticlesInternals.utils=t.__tsParticlesInternals.utils||{},t.__tsParticlesInternals.canvas=t.__tsParticlesInternals.canvas||{},t.__tsParticlesInternals.canvas=t.__tsParticlesInternals.canvas||{},t.__tsParticlesInternals.canvas.utils=t.__tsParticlesInternals.canvas.utils||{},t.__tsParticlesInternals.path=t.__tsParticlesInternals.path||{},t.__tsParticlesInternals.path=t.__tsParticlesInternals.path||{},t.__tsParticlesInternals.path.utils=t.__tsParticlesInternals.path.utils||{};var s="undefined"!=typeof Proxy?function(t){return new Proxy(t,{get:function(t,s){return s in t||(t[s]={}),t[s]}})}:function(t){return t};t.__tsParticlesInternals.bundles=s(t.__tsParticlesInternals.bundles),t.__tsParticlesInternals.effects=s(t.__tsParticlesInternals.effects),t.__tsParticlesInternals.interactions=s(t.__tsParticlesInternals.interactions),t.__tsParticlesInternals.palettes=s(t.__tsParticlesInternals.palettes),t.__tsParticlesInternals.paths=s(t.__tsParticlesInternals.paths),t.__tsParticlesInternals.plugins=s(t.__tsParticlesInternals.plugins),t.__tsParticlesInternals.plugins.emittersShapes=s(t.__tsParticlesInternals.plugins.emittersShapes),t.__tsParticlesInternals.presets=s(t.__tsParticlesInternals.presets),t.__tsParticlesInternals.shapes=s(t.__tsParticlesInternals.shapes),t.__tsParticlesInternals.updaters=s(t.__tsParticlesInternals.updaters),t.__tsParticlesInternals.utils=s(t.__tsParticlesInternals.utils),t.__tsParticlesInternals.canvas=s(t.__tsParticlesInternals.canvas),t.__tsParticlesInternals.path=s(t.__tsParticlesInternals.path),t.tsparticlesInternalExports=t.tsparticlesInternalExports||{}}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:this),function(t,s){"object"==typeof exports&&"undefined"!=typeof module?s(exports,require("@tsparticles/engine")):"function"==typeof define&&define.amd?define(["exports","@tsparticles/engine"],s):s(((t="undefined"!=typeof globalThis?globalThis:t||self).__tsParticlesInternals=t.__tsParticlesInternals||{},t.__tsParticlesInternals.effects=t.__tsParticlesInternals.effects||{},t.__tsParticlesInternals.effects.trail=t.__tsParticlesInternals.effects.trail||{}),t.__tsParticlesInternals.engine)}(this,function(t,s){"use strict";const e={a:1,b:0,c:0,d:1};class a{_container;constructor(t){this._container=t}drawAfter(t){const{context:a,drawPosition:n,drawRadius:l,drawScale:r,particle:i,transformData:_}=t,c=this._container,o=l*s.double,P=c.retina.pixelRatio,p=i.trail;if(!p||!i.trailLength)return;const I=n,f=i.trailLength*r+l;if(p.push({break:i.justWarped,color:a.fillStyle||a.strokeStyle,position:{x:I.x,y:I.y},transformData:_}),p.length<3)return;const h=Math.floor(f);p.length>h&&p.splice(0,p.length-h);const u=Math.min(p.length,f);a.save(),a.lineCap="butt",a.lineJoin="round";for(let t=u-2;t>0;t--){const n=p[t+1],l=p[t],_=p[t-1];if(!n||!l||!_)continue;const c=n.position,I=l.position,f=_.position,h=i.trailTransform?l.transformData??e:e;if(l.break||n.break||_.break)continue;a.setTransform(h.a,h.b,h.c,h.d,I.x,I.y);const d=(c.x+I.x)*s.half-I.x,g=(c.y+I.y)*s.half-I.y,x=(I.x+f.x)*s.half-I.x,b=(I.y+f.y)*s.half-I.y;a.beginPath(),a.moveTo(d,g),a.quadraticCurveTo(s.originPoint.x,s.originPoint.y,x,b);const y=Math.max(t/u*o,P,(i.trailMinWidth??-1)*r),m=a.globalAlpha;a.globalAlpha=i.trailFade?t/u:s.defaultAlpha,a.lineWidth=i.trailMaxWidth?Math.min(y,i.trailMaxWidth*r):y,a.strokeStyle=l.color,a.stroke(),a.globalAlpha=m}a.restore()}particleInit(t,e){e.trail=[];const a=e.effectData;e.trailFade=a?.fade??!0,e.trailLength=s.getRangeValue(a?.length??10)*t.retina.pixelRatio,e.trailMaxWidth=a?.maxWidth?s.getRangeValue(a.maxWidth)*t.retina.pixelRatio:void 0,e.trailMinWidth=a?.minWidth?s.getRangeValue(a.minWidth)*t.retina.pixelRatio:void 0,e.trailTransform=a?.transform??!1}}async function n(t){t.checkVersion("4.0.4"),await t.pluginManager.register(t=>{t.pluginManager.addEffect("trail",t=>Promise.resolve(new a(t)))})}const l=globalThis;l.__tsParticlesInternals=l.__tsParticlesInternals??{},l.loadTrailEffect=n,t.loadTrailEffect=n}),Object.assign(globalThis.window||globalThis,{loadTrailEffect:(globalThis.__tsParticlesInternals.effects.trail||{}).loadTrailEffect}),delete(globalThis.window||globalThis).tsparticlesInternalExports;
1
+ !function(t){t.__tsParticlesInternals=t.__tsParticlesInternals||{},t.__tsParticlesInternals.bundles=t.__tsParticlesInternals.bundles||{},t.__tsParticlesInternals.effects=t.__tsParticlesInternals.effects||{},t.__tsParticlesInternals.engine=t.__tsParticlesInternals.engine||{},t.__tsParticlesInternals.interactions=t.__tsParticlesInternals.interactions||{},t.__tsParticlesInternals.palettes=t.__tsParticlesInternals.palettes||{},t.__tsParticlesInternals.paths=t.__tsParticlesInternals.paths||{},t.__tsParticlesInternals.plugins=t.__tsParticlesInternals.plugins||{},t.__tsParticlesInternals.plugins=t.__tsParticlesInternals.plugins||{},t.__tsParticlesInternals.plugins.emittersShapes=t.__tsParticlesInternals.plugins.emittersShapes||{},t.__tsParticlesInternals.presets=t.__tsParticlesInternals.presets||{},t.__tsParticlesInternals.shapes=t.__tsParticlesInternals.shapes||{},t.__tsParticlesInternals.updaters=t.__tsParticlesInternals.updaters||{},t.__tsParticlesInternals.utils=t.__tsParticlesInternals.utils||{},t.__tsParticlesInternals.canvas=t.__tsParticlesInternals.canvas||{},t.__tsParticlesInternals.canvas=t.__tsParticlesInternals.canvas||{},t.__tsParticlesInternals.canvas.utils=t.__tsParticlesInternals.canvas.utils||{},t.__tsParticlesInternals.path=t.__tsParticlesInternals.path||{},t.__tsParticlesInternals.path=t.__tsParticlesInternals.path||{},t.__tsParticlesInternals.path.utils=t.__tsParticlesInternals.path.utils||{};var s="undefined"!=typeof Proxy?function(t){return new Proxy(t,{get:function(t,s){return s in t||(t[s]={}),t[s]}})}:function(t){return t};t.__tsParticlesInternals.bundles=s(t.__tsParticlesInternals.bundles),t.__tsParticlesInternals.effects=s(t.__tsParticlesInternals.effects),t.__tsParticlesInternals.interactions=s(t.__tsParticlesInternals.interactions),t.__tsParticlesInternals.palettes=s(t.__tsParticlesInternals.palettes),t.__tsParticlesInternals.paths=s(t.__tsParticlesInternals.paths),t.__tsParticlesInternals.plugins=s(t.__tsParticlesInternals.plugins),t.__tsParticlesInternals.plugins.emittersShapes=s(t.__tsParticlesInternals.plugins.emittersShapes),t.__tsParticlesInternals.presets=s(t.__tsParticlesInternals.presets),t.__tsParticlesInternals.shapes=s(t.__tsParticlesInternals.shapes),t.__tsParticlesInternals.updaters=s(t.__tsParticlesInternals.updaters),t.__tsParticlesInternals.utils=s(t.__tsParticlesInternals.utils),t.__tsParticlesInternals.canvas=s(t.__tsParticlesInternals.canvas),t.__tsParticlesInternals.path=s(t.__tsParticlesInternals.path),t.tsparticlesInternalExports=t.tsparticlesInternalExports||{}}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:this),function(t,s){"object"==typeof exports&&"undefined"!=typeof module?s(exports,require("@tsparticles/engine")):"function"==typeof define&&define.amd?define(["exports","@tsparticles/engine"],s):s(((t="undefined"!=typeof globalThis?globalThis:t||self).__tsParticlesInternals=t.__tsParticlesInternals||{},t.__tsParticlesInternals.effects=t.__tsParticlesInternals.effects||{},t.__tsParticlesInternals.effects.trail=t.__tsParticlesInternals.effects.trail||{}),t.__tsParticlesInternals.engine)}(this,function(t,s){"use strict";const e={a:1,b:0,c:0,d:1};class a{#t;constructor(t){this.#t=t}drawAfter(t){const{context:a,drawPosition:n,drawRadius:r,drawScale:i,particle:l,transformData:c}=t,_=this.#t,o=r*s.double,p=_.retina.pixelRatio,h=l.trail;if(!h||!l.trailLength)return;const P=n,I=l.trailLength*i+r;if(h.push({break:l.justWarped,color:a.fillStyle||a.strokeStyle,position:{x:P.x,y:P.y},transformData:c}),h.length<3)return;const f=Math.floor(I);h.length>f&&h.splice(0,h.length-f);const d=Math.min(h.length,I);a.save(),a.lineCap="butt",a.lineJoin="round";for(let t=d-2;t>0;t--){const n=h[t+1],r=h[t],c=h[t-1];if(!n||!r||!c)continue;const _=n.position,P=r.position,I=c.position,f=l.trailTransform?r.transformData??e:e;if(r.break||n.break||c.break)continue;a.setTransform(f.a,f.b,f.c,f.d,P.x,P.y);const u=(_.x+P.x)*s.half-P.x,g=(_.y+P.y)*s.half-P.y,x=(P.x+I.x)*s.half-P.x,y=(P.y+I.y)*s.half-P.y;a.beginPath(),a.moveTo(u,g),a.quadraticCurveTo(s.originPoint.x,s.originPoint.y,x,y);const b=Math.max(t/d*o,p,(l.trailMinWidth??-1)*i),m=a.globalAlpha;a.globalAlpha=l.trailFade?t/d:s.defaultAlpha,a.lineWidth=l.trailMaxWidth?Math.min(b,l.trailMaxWidth*i):b,a.strokeStyle=r.color,a.stroke(),a.globalAlpha=m}a.restore()}isInsideCanvas(t){const{canvasSize:e,direction:a,outMode:n,particle:r,radius:i}=t,l=r.position,c=r.trail;let _=l.x-i,o=l.x+i,p=l.y-i,h=l.y+i;if(c?.length){const t=Math.max(i,r.trailMaxWidth??0,r.trailMinWidth??0);for(const s of c)_=Math.min(_,s.position.x-t),o=Math.max(o,s.position.x+t),p=Math.min(p,s.position.y-t),h=Math.max(h,s.position.y+t)}const P=n===s.OutMode.destroy;return a===s.OutModeDirection.bottom?p<=e.height:a===s.OutModeDirection.left?o>=0:a===s.OutModeDirection.right?_<=e.width:a===s.OutModeDirection.top?h>=0:P?o>=0&&h>=0&&_<=e.width&&p<=e.height:l.x+i>=0&&l.y+i>=0&&l.x-i<=e.width&&l.y-i<=e.height}particleInit(t,e){e.trail=[];const a=e.effectData;e.trailFade=a?.fade??!0,e.trailLength=s.getRangeValue(a?.length??10)*t.retina.pixelRatio,e.trailMaxWidth=a?.maxWidth?s.getRangeValue(a.maxWidth)*t.retina.pixelRatio:void 0,e.trailMinWidth=a?.minWidth?s.getRangeValue(a.minWidth)*t.retina.pixelRatio:void 0,e.trailTransform=a?.transform??!1}}async function n(t){t.checkVersion("4.1.0"),await t.pluginManager.register(t=>{t.pluginManager.addEffect("trail",t=>Promise.resolve(new a(t)))})}const r=globalThis;r.__tsParticlesInternals=r.__tsParticlesInternals??{},r.loadTrailEffect=n,t.loadTrailEffect=n}),Object.assign(globalThis.window||globalThis,{loadTrailEffect:(globalThis.__tsParticlesInternals.effects.trail||{}).loadTrailEffect}),delete(globalThis.window||globalThis).tsparticlesInternalExports;
@@ -1,4 +1,4 @@
1
- import { type Container, type ICoordinates, type IEffectDrawer, type IShapeDrawData, type IShapeValues, type Particle, type RangeValue } from "@tsparticles/engine";
1
+ import { type Container, type ICoordinates, type IEffectDrawer, type IParticleCanvasBoundsData, type IShapeDrawData, type IShapeValues, type Particle, type RangeValue } from "@tsparticles/engine";
2
2
  export interface TrailStep {
3
3
  break: boolean;
4
4
  color: string | CanvasGradient | CanvasPattern;
@@ -27,8 +27,9 @@ export type TrailParticle = Particle & {
27
27
  trailTransform?: boolean;
28
28
  };
29
29
  export declare class TrailDrawer implements IEffectDrawer<TrailParticle> {
30
- private readonly _container;
30
+ #private;
31
31
  constructor(container: Container);
32
32
  drawAfter(data: IShapeDrawData<TrailParticle>): void;
33
+ isInsideCanvas(data: IParticleCanvasBoundsData<TrailParticle>): boolean;
33
34
  particleInit(container: Container, particle: TrailParticle): void;
34
35
  }