@tsparticles/plugin-canvas-mask 3.0.0-beta.3 → 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 +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
|
@@ -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
|
-
* v3.0.0-beta.
|
|
7
|
+
* v3.0.0-beta.4
|
|
8
8
|
*/
|
|
9
9
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
10
10
|
if(typeof exports === 'object' && typeof module === 'object')
|
|
@@ -281,13 +281,6 @@ class CanvasMask {
|
|
|
281
281
|
}
|
|
282
282
|
;// CONCATENATED MODULE: ./dist/browser/utils.js
|
|
283
283
|
|
|
284
|
-
function shuffle(array) {
|
|
285
|
-
for (let currentIndex = array.length - 1; currentIndex >= 0; currentIndex--) {
|
|
286
|
-
const randomIndex = Math.floor((0,engine_root_window_.getRandom)() * currentIndex);
|
|
287
|
-
[array[currentIndex], array[randomIndex]] = [array[randomIndex], array[currentIndex]];
|
|
288
|
-
}
|
|
289
|
-
return array;
|
|
290
|
-
}
|
|
291
284
|
function addParticlesFromCanvasPixels(container, data, position, scale, override, filter) {
|
|
292
285
|
const {
|
|
293
286
|
height,
|
|
@@ -421,6 +414,13 @@ function getTextData(textOptions, offset) {
|
|
|
421
414
|
}
|
|
422
415
|
return getCanvasImageData(context, canvas, offset);
|
|
423
416
|
}
|
|
417
|
+
function shuffle(array) {
|
|
418
|
+
for (let currentIndex = array.length - 1; currentIndex >= 0; currentIndex--) {
|
|
419
|
+
const randomIndex = Math.floor((0,engine_root_window_.getRandom)() * currentIndex);
|
|
420
|
+
[array[currentIndex], array[randomIndex]] = [array[randomIndex], array[currentIndex]];
|
|
421
|
+
}
|
|
422
|
+
return array;
|
|
423
|
+
}
|
|
424
424
|
const range = n => [...Array(n).keys()];
|
|
425
425
|
;// CONCATENATED MODULE: ./dist/browser/CanvasMaskInstance.js
|
|
426
426
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
/*! tsParticles Canvas Mask Plugin v3.0.0-beta.
|
|
1
|
+
/*! tsParticles Canvas Mask Plugin v3.0.0-beta.4 by Matteo Bruni */
|
package/types/utils.d.ts
CHANGED
|
@@ -6,9 +6,7 @@ export type CanvasPixelData = {
|
|
|
6
6
|
pixels: IRgba[][];
|
|
7
7
|
width: number;
|
|
8
8
|
};
|
|
9
|
-
export declare function shuffle<T>(array: T[]): T[];
|
|
10
9
|
export declare function addParticlesFromCanvasPixels(container: Container, data: CanvasPixelData, position: ICoordinates, scale: number, override: ICanvasMaskOverride, filter: (pixel: IRgba) => boolean): void;
|
|
11
10
|
export declare function getCanvasImageData(ctx: CanvasRenderingContext2D, size: IDimension, offset: number, clear?: boolean): CanvasPixelData;
|
|
12
11
|
export declare function getImageData(src: string, offset: number): Promise<CanvasPixelData>;
|
|
13
12
|
export declare function getTextData(textOptions: TextMask, offset: number): CanvasPixelData | undefined;
|
|
14
|
-
export declare const range: (n: number) => Array<number>;
|
package/umd/utils.js
CHANGED
|
@@ -9,18 +9,10 @@
|
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
"use strict";
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.getTextData = exports.getImageData = exports.getCanvasImageData = exports.addParticlesFromCanvasPixels = void 0;
|
|
13
13
|
const engine_1 = require("@tsparticles/engine");
|
|
14
|
-
function shuffle(array) {
|
|
15
|
-
for (let currentIndex = array.length - 1; currentIndex >= 0; currentIndex--) {
|
|
16
|
-
const randomIndex = Math.floor((0, engine_1.getRandom)() * currentIndex);
|
|
17
|
-
[array[currentIndex], array[randomIndex]] = [array[randomIndex], array[currentIndex]];
|
|
18
|
-
}
|
|
19
|
-
return array;
|
|
20
|
-
}
|
|
21
|
-
exports.shuffle = shuffle;
|
|
22
14
|
function addParticlesFromCanvasPixels(container, data, position, scale, override, filter) {
|
|
23
|
-
const { height, width } = data, numPixels = height * width, indexArray = shuffle(
|
|
15
|
+
const { height, width } = data, numPixels = height * width, indexArray = shuffle(range(numPixels)), maxParticles = Math.min(numPixels, container.actualOptions.particles.number.value), canvasSize = container.canvas.size;
|
|
24
16
|
let selectedPixels = 0;
|
|
25
17
|
const positionOffset = {
|
|
26
18
|
x: (canvasSize.width * position.x) / 100 - (width * scale) / 2,
|
|
@@ -133,6 +125,12 @@
|
|
|
133
125
|
return getCanvasImageData(context, canvas, offset);
|
|
134
126
|
}
|
|
135
127
|
exports.getTextData = getTextData;
|
|
128
|
+
function shuffle(array) {
|
|
129
|
+
for (let currentIndex = array.length - 1; currentIndex >= 0; currentIndex--) {
|
|
130
|
+
const randomIndex = Math.floor((0, engine_1.getRandom)() * currentIndex);
|
|
131
|
+
[array[currentIndex], array[randomIndex]] = [array[randomIndex], array[currentIndex]];
|
|
132
|
+
}
|
|
133
|
+
return array;
|
|
134
|
+
}
|
|
136
135
|
const range = (n) => [...Array(n).keys()];
|
|
137
|
-
exports.range = range;
|
|
138
136
|
});
|