@tsparticles/plugin-canvas-mask 3.0.0-beta.3 → 3.0.0-beta.5
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 +8 -8
- package/cjs/utils.js +9 -11
- package/esm/utils.js +8 -8
- package/package.json +3 -3
- package/report.html +4 -22
- package/tsparticles.plugin.canvas-mask.js +8 -8
- package/tsparticles.plugin.canvas-mask.min.js.LICENSE.txt +1 -1
- package/types/utils.d.ts +0 -2
- package/umd/utils.js +9 -11
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
|
-
|
|
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.
|
|
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(
|
|
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
|
-
|
|
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.
|
|
3
|
+
"version": "3.0.0-beta.5",
|
|
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
|
-
"
|
|
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.
|
|
89
|
+
"@tsparticles/engine": "^3.0.0-beta.5"
|
|
90
90
|
},
|
|
91
91
|
"publishConfig": {
|
|
92
92
|
"access": "public"
|