@tsparticles/plugin-canvas-mask 3.0.0-beta.2 → 3.0.0-beta.4

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/browser/utils.js CHANGED
@@ -1,11 +1,4 @@
1
1
  import { errorPrefix, getRandom, isNumber, } from "@tsparticles/engine";
2
- export function shuffle(array) {
3
- for (let currentIndex = array.length - 1; currentIndex >= 0; currentIndex--) {
4
- const randomIndex = Math.floor(getRandom() * currentIndex);
5
- [array[currentIndex], array[randomIndex]] = [array[randomIndex], array[currentIndex]];
6
- }
7
- return array;
8
- }
9
2
  export function addParticlesFromCanvasPixels(container, data, position, scale, override, filter) {
10
3
  const { height, width } = data, numPixels = height * width, indexArray = shuffle(range(numPixels)), maxParticles = Math.min(numPixels, container.actualOptions.particles.number.value), canvasSize = container.canvas.size;
11
4
  let selectedPixels = 0;
@@ -116,4 +109,11 @@ export function getTextData(textOptions, offset) {
116
109
  }
117
110
  return getCanvasImageData(context, canvas, offset);
118
111
  }
119
- export const range = (n) => [...Array(n).keys()];
112
+ function shuffle(array) {
113
+ for (let currentIndex = array.length - 1; currentIndex >= 0; currentIndex--) {
114
+ const randomIndex = Math.floor(getRandom() * currentIndex);
115
+ [array[currentIndex], array[randomIndex]] = [array[randomIndex], array[currentIndex]];
116
+ }
117
+ return array;
118
+ }
119
+ const range = (n) => [...Array(n).keys()];
package/cjs/utils.js CHANGED
@@ -1,17 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.range = exports.getTextData = exports.getImageData = exports.getCanvasImageData = exports.addParticlesFromCanvasPixels = exports.shuffle = void 0;
3
+ exports.getTextData = exports.getImageData = exports.getCanvasImageData = exports.addParticlesFromCanvasPixels = void 0;
4
4
  const engine_1 = require("@tsparticles/engine");
5
- function shuffle(array) {
6
- for (let currentIndex = array.length - 1; currentIndex >= 0; currentIndex--) {
7
- const randomIndex = Math.floor((0, engine_1.getRandom)() * currentIndex);
8
- [array[currentIndex], array[randomIndex]] = [array[randomIndex], array[currentIndex]];
9
- }
10
- return array;
11
- }
12
- exports.shuffle = shuffle;
13
5
  function addParticlesFromCanvasPixels(container, data, position, scale, override, filter) {
14
- const { height, width } = data, numPixels = height * width, indexArray = shuffle((0, exports.range)(numPixels)), maxParticles = Math.min(numPixels, container.actualOptions.particles.number.value), canvasSize = container.canvas.size;
6
+ const { height, width } = data, numPixels = height * width, indexArray = shuffle(range(numPixels)), maxParticles = Math.min(numPixels, container.actualOptions.particles.number.value), canvasSize = container.canvas.size;
15
7
  let selectedPixels = 0;
16
8
  const positionOffset = {
17
9
  x: (canvasSize.width * position.x) / 100 - (width * scale) / 2,
@@ -124,5 +116,11 @@ function getTextData(textOptions, offset) {
124
116
  return getCanvasImageData(context, canvas, offset);
125
117
  }
126
118
  exports.getTextData = getTextData;
119
+ function shuffle(array) {
120
+ for (let currentIndex = array.length - 1; currentIndex >= 0; currentIndex--) {
121
+ const randomIndex = Math.floor((0, engine_1.getRandom)() * currentIndex);
122
+ [array[currentIndex], array[randomIndex]] = [array[randomIndex], array[currentIndex]];
123
+ }
124
+ return array;
125
+ }
127
126
  const range = (n) => [...Array(n).keys()];
128
- exports.range = range;
package/esm/utils.js CHANGED
@@ -1,11 +1,4 @@
1
1
  import { errorPrefix, getRandom, isNumber, } from "@tsparticles/engine";
2
- export function shuffle(array) {
3
- for (let currentIndex = array.length - 1; currentIndex >= 0; currentIndex--) {
4
- const randomIndex = Math.floor(getRandom() * currentIndex);
5
- [array[currentIndex], array[randomIndex]] = [array[randomIndex], array[currentIndex]];
6
- }
7
- return array;
8
- }
9
2
  export function addParticlesFromCanvasPixels(container, data, position, scale, override, filter) {
10
3
  const { height, width } = data, numPixels = height * width, indexArray = shuffle(range(numPixels)), maxParticles = Math.min(numPixels, container.actualOptions.particles.number.value), canvasSize = container.canvas.size;
11
4
  let selectedPixels = 0;
@@ -116,4 +109,11 @@ export function getTextData(textOptions, offset) {
116
109
  }
117
110
  return getCanvasImageData(context, canvas, offset);
118
111
  }
119
- export const range = (n) => [...Array(n).keys()];
112
+ function shuffle(array) {
113
+ for (let currentIndex = array.length - 1; currentIndex >= 0; currentIndex--) {
114
+ const randomIndex = Math.floor(getRandom() * currentIndex);
115
+ [array[currentIndex], array[randomIndex]] = [array[randomIndex], array[currentIndex]];
116
+ }
117
+ return array;
118
+ }
119
+ const range = (n) => [...Array(n).keys()];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsparticles/plugin-canvas-mask",
3
- "version": "3.0.0-beta.2",
3
+ "version": "3.0.0-beta.4",
4
4
  "description": "tsParticles canvas mask plugin",
5
5
  "homepage": "https://particles.js.org",
6
6
  "repository": {
@@ -60,7 +60,7 @@
60
60
  "confettijs",
61
61
  "fireworksjs",
62
62
  "canvas-confetti",
63
- "@tsparticles/plugin"
63
+ "tsparticles-plugin"
64
64
  ],
65
65
  "author": "Matteo Bruni <matteo.bruni@me.com>",
66
66
  "license": "MIT",
@@ -86,7 +86,7 @@
86
86
  "./package.json": "./package.json"
87
87
  },
88
88
  "dependencies": {
89
- "@tsparticles/engine": "^3.0.0-beta.2"
89
+ "@tsparticles/engine": "^3.0.0-beta.4"
90
90
  },
91
91
  "publishConfig": {
92
92
  "access": "public"