@tsparticles/plugin-emitters-shape-canvas 3.4.0 → 3.5.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.
- package/cjs/index.js +1 -2
- package/cjs/utils.js +3 -4
- package/package.json +3 -3
- package/report.html +1 -1
- package/tsparticles.plugin.emitters.shape.canvas.js +1 -1
- package/tsparticles.plugin.emitters.shape.canvas.min.js +1 -1
- package/tsparticles.plugin.emitters.shape.canvas.min.js.LICENSE.txt +1 -1
- package/umd/index.js +1 -2
- package/umd/utils.js +3 -4
package/cjs/index.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.loadEmittersShapeCanvas =
|
|
3
|
+
exports.loadEmittersShapeCanvas = loadEmittersShapeCanvas;
|
|
4
4
|
const EmittersCanvasShapeGenerator_js_1 = require("./EmittersCanvasShapeGenerator.js");
|
|
5
5
|
async function loadEmittersShapeCanvas(engine, refresh = true) {
|
|
6
6
|
const emittersEngine = engine;
|
|
7
7
|
emittersEngine.addEmitterShapeGenerator?.("canvas", new EmittersCanvasShapeGenerator_js_1.EmittersCanvasShapeGenerator());
|
|
8
8
|
await emittersEngine.refresh(refresh);
|
|
9
9
|
}
|
|
10
|
-
exports.loadEmittersShapeCanvas = loadEmittersShapeCanvas;
|
package/cjs/utils.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getCanvasImageData = getCanvasImageData;
|
|
4
|
+
exports.getImageData = getImageData;
|
|
5
|
+
exports.getTextData = getTextData;
|
|
4
6
|
const engine_1 = require("@tsparticles/engine");
|
|
5
7
|
const origin = {
|
|
6
8
|
x: 0,
|
|
@@ -39,7 +41,6 @@ function getCanvasImageData(ctx, size, offset, clear = true) {
|
|
|
39
41
|
height: pixels.length,
|
|
40
42
|
};
|
|
41
43
|
}
|
|
42
|
-
exports.getCanvasImageData = getCanvasImageData;
|
|
43
44
|
function getImageData(src, offset) {
|
|
44
45
|
const image = new Image();
|
|
45
46
|
image.crossOrigin = "Anonymous";
|
|
@@ -60,7 +61,6 @@ function getImageData(src, offset) {
|
|
|
60
61
|
image.src = src;
|
|
61
62
|
return p;
|
|
62
63
|
}
|
|
63
|
-
exports.getImageData = getImageData;
|
|
64
64
|
function getTextData(textOptions, offset, fill) {
|
|
65
65
|
const canvas = document.createElement("canvas"), context = canvas.getContext("2d"), { font, text, lines: linesOptions, color } = textOptions;
|
|
66
66
|
if (!text || !context) {
|
|
@@ -97,4 +97,3 @@ function getTextData(textOptions, offset, fill) {
|
|
|
97
97
|
}
|
|
98
98
|
return getCanvasImageData(context, canvas, offset);
|
|
99
99
|
}
|
|
100
|
-
exports.getTextData = getTextData;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsparticles/plugin-emitters-shape-canvas",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.5.0",
|
|
4
4
|
"description": "tsParticles emitters shape canvas plugin",
|
|
5
5
|
"homepage": "https://particles.js.org",
|
|
6
6
|
"repository": {
|
|
@@ -100,8 +100,8 @@
|
|
|
100
100
|
"./package.json": "./package.json"
|
|
101
101
|
},
|
|
102
102
|
"dependencies": {
|
|
103
|
-
"@tsparticles/engine": "^3.
|
|
104
|
-
"@tsparticles/plugin-emitters": "^3.
|
|
103
|
+
"@tsparticles/engine": "^3.5.0",
|
|
104
|
+
"@tsparticles/plugin-emitters": "^3.5.0"
|
|
105
105
|
},
|
|
106
106
|
"publishConfig": {
|
|
107
107
|
"access": "public"
|
package/report.html
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="UTF-8"/>
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
|
6
|
-
<title>@tsparticles/plugin-emitters-shape-canvas [
|
|
6
|
+
<title>@tsparticles/plugin-emitters-shape-canvas [1 Jul 2024 at 09:26]</title>
|
|
7
7
|
<link rel="shortcut icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAABrVBMVEUAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+O1foceMD///+J0/qK1Pr7/v8Xdr/9///W8P4UdL7L7P0Scr2r4Pyj3vwad8D5/f/2/f+55f3E6f34+/2H0/ojfMKpzOd0rNgQcb3F3O/j9f7c8v6g3Pz0/P/w+v/q+P7n9v6T1/uQ1vuE0vqLut/y+v+Z2fvt+f+15Pzv9fuc2/vR7v2V2Pvd6/bg9P7I6/285/2y4/yp3/zp8vk8i8kqgMT7/P31+fyv4vxGkcz6/P6/6P3j7vfS5PNnpNUxhcbO7f7F6v3O4vHK3/DA2u631Ouy0eqXweKJud5wqthfoNMMbLvY8f73+v2dxeR8sNtTmdDx9/zX6PSjyeaCtd1YnNGX2PuQveCGt95Nls42h8dLlM3F4vBtAAAAM3RSTlMAAyOx0/sKBvik8opWGBMOAe3l1snDm2E9LSb06eHcu5JpHbarfHZCN9CBb08zzkdNS0kYaptYAAAFV0lEQVRYw92X51/aYBDHHS2O2qqttVbrqNq9m+TJIAYIShBkWwqIiCgoWvfeq7Z2/s29hyQNyUcR7LveGwVyXy6XH8/9rqxglLfUPLxVduUor3h0rfp2TYvpivk37929TkG037hffoX0+peVtZQc1589rigVUdXS/ABSAyEmGIO/1XfvldSK8vs3OqB6u3m0nxmIrvgB0dj7rr7Y9IbuF68hnfFaiHA/sxqm0wciIG43P60qKv9WXWc1RXGh/mFESFABTSBi0sNAKzqet17eCtOb3kZIDwxEEU0oAIJGYxNBDhBND29e0rtXXbcpuPmED9IhEAAQ/AXEaF8EPmnrrKsv0LvWR3fg5sWDNAFZOgAgaKvZDogHNU9MFwnnYROkc56RD5CjAb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ZG4zanpemv+7ySU2jbA9h6uhcgpfy6G2PahirDZ6zvq6zDduMVFTKvzw8wgyEdelwY9in3XkEPs3osJuwRQ4qTkfzifndg9Gfc4pdsu82+tTnHZTBa2EAMrqr2t43pguc8tNm7JQVQ2S0ukj2d22dhXYP0/veWtwKrCkNoNimAN5+Xr/oLrxswKbVJjteWrX7eR63o4j9q0GxnaBdWgGA5VStpanIjQmEhV0/nVt5VOFUvix6awJhPcAaTEShgrG+iGyvb5a0Ndb1YGHFPEwoqAinoaykaID1o1pdPNu7XsnCKQ3R+hwWIIhGvORcJUBYXe3Xa3vq/mF/N9V13ugufMkfXn+KHsRD0B8AAAAASUVORK5CYII=" type="image/x-icon" />
|
|
8
8
|
|
|
9
9
|
<script>
|
|
@@ -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.
|
|
7
|
+
* v3.5.0
|
|
8
8
|
*/
|
|
9
9
|
/*
|
|
10
10
|
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see tsparticles.plugin.emitters.shape.canvas.min.js.LICENSE.txt */
|
|
2
|
-
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("@tsparticles/plugin-emitters"),require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/plugin-emitters","@tsparticles/engine"],e);else{var i="object"==typeof exports?e(require("@tsparticles/plugin-emitters"),require("@tsparticles/engine")):e(t.window,t.window);for(var s in i)("object"==typeof exports?exports:t)[s]=i[s]}}(this,((t,e)=>(()=>{var i={303:t=>{t.exports=e},526:e=>{e.exports=t}},s={};function o(t){var e=s[t];if(void 0!==e)return e.exports;var r=s[t]={exports:{}};return i[t](r,r.exports,o),r.exports}o.d=(t,e)=>{for(var i in e)o.o(e,i)&&!o.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},o.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),o.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var r={};
|
|
2
|
+
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("@tsparticles/plugin-emitters"),require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/plugin-emitters","@tsparticles/engine"],e);else{var i="object"==typeof exports?e(require("@tsparticles/plugin-emitters"),require("@tsparticles/engine")):e(t.window,t.window);for(var s in i)("object"==typeof exports?exports:t)[s]=i[s]}}(this,((t,e)=>(()=>{var i={303:t=>{t.exports=e},526:e=>{e.exports=t}},s={};function o(t){var e=s[t];if(void 0!==e)return e.exports;var r=s[t]={exports:{}};return i[t](r,r.exports,o),r.exports}o.d=(t,e)=>{for(var i in e)o.o(e,i)&&!o.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},o.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),o.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var r={};o.r(r),o.d(r,{loadEmittersShapeCanvas:()=>m});var n=o(526),a=o(303);const l={x:0,y:0};function c(t,e,i,s=!0){const o=t.getImageData(l.x,l.y,e.width,e.height).data;s&&t.clearRect(l.x,l.y,e.width,e.height);const r=[];for(let t=0;t<o.length;t+=i){const s=t/i,n={x:s%e.width,y:Math.floor(s/e.width)};r[n.y]||(r[n.y]=[]);const a={r:0,g:1,b:2,a:3},l=255;r[n.y][n.x]={r:o[t+a.r],g:o[t+a.g],b:o[t+a.b],a:o[t+a.a]/l}}return{pixels:r,width:Math.min(...r.map((t=>t.length))),height:r.length}}class h extends n.EmitterShapeBase{constructor(t,e,i,s){super(t,e,i,s);const o=s.filter;let r=t=>t.a>0;if(void 0!==o)if((0,a.isString)(o)){if(Object.hasOwn(window,o)){const t=window[o];(0,a.isFunction)(t)&&(r=t)}}else r=o;this.filter=r,this.scale=s.scale,this.pixelData={pixels:[],height:0,width:0}}async init(){let t;const e=this.options,i=e.selector,s=e.pixels,o=e.image,r=e.element,n=e.text,h=s.offset;if(o){const e=o.src;if(!e)return;t=await function(t,e){const i=new Image;i.crossOrigin="Anonymous";const s=new Promise(((t,s)=>{i.onerror=s,i.onload=()=>{const o=document.createElement("canvas");o.width=i.width,o.height=i.height;const r=o.getContext("2d");if(!r)return s(new Error(`${a.errorPrefix} Could not get canvas context`));r.drawImage(i,l.x,l.y,i.width,i.height,l.x,l.y,o.width,o.height),t(c(r,o,e))}}));return i.src=t,s}(e,h)}else if(n){const e=function(t,e,i){const s=document.createElement("canvas"),o=s.getContext("2d"),{font:r,text:n,lines:h,color:d}=t;if(!n||!o)return;const f=n.split(h.separator),p=(0,a.isNumber)(r.size)?`${r.size}px`:r.size,u=[];let x=0,g=0;for(const t of f){o.font=`${r.style||""} ${r.variant||""} ${r.weight||""} ${p} ${r.family}`;const e=o.measureText(t),i={measure:e,text:t,height:e.actualBoundingBoxAscent+e.actualBoundingBoxDescent,width:e.width};x=Math.max(x||0,i.width),g+=i.height+h.spacing,u.push(i)}s.width=x,s.height=g;let m=0;for(const t of u)o.font=`${r.style||""} ${r.variant||""} ${r.weight||""} ${p} ${r.family}`,i?(o.fillStyle=d,o.fillText(t.text,l.x,m+t.measure.actualBoundingBoxAscent)):(o.strokeStyle=d,o.strokeText(t.text,l.x,m+t.measure.actualBoundingBoxAscent)),m+=t.height+h.spacing;return c(o,s,e)}(n,h,this.fill);if(!e)return;t=e}else if(r??i){const e=r??(i&&document.querySelector(i));if(!e)return;const s=e.getContext("2d");if(!s)return;t=c(s,e,h)}t&&(this.pixelData=t)}randomPosition(){const{height:t,width:e}=this.pixelData,i=this.pixelData,s=this.position,o=this.scale,r=s.x-e*o*.5,n=s.y-t*o*.5;for(let s=0;s<100;s++){const s=Math.floor((0,a.getRandom)()*e*t),l={x:s%e,y:Math.floor(s/e)},c=i.pixels[l.y][l.x];if(this.filter(c))return{position:{x:l.x*o+r,y:l.y*o+n},color:{...c},opacity:c.a}}return null}resize(t,e){super.resize(t,e)}}class d{constructor(){this.offset=4}load(t){t&&void 0!==t.offset&&(this.offset=t.offset)}}class f{constructor(){this.family="Verdana",this.size=32,this.style="",this.variant="",this.weight=""}load(t){t&&(void 0!==t.family&&(this.family=t.family),void 0!==t.size&&(this.size=t.size),void 0!==t.style&&(this.style=t.style),void 0!==t.variant&&(this.variant=t.variant),void 0!==t.weight&&(this.weight=t.weight))}}class p{constructor(){this.separator="\n",this.spacing=0}load(t){t&&(void 0!==t.separator&&(this.separator=t.separator),void 0!==t.spacing&&(this.spacing=t.spacing))}}class u{constructor(){this.color="#000000",this.font=new f,this.lines=new p,this.text=""}load(t){t&&(void 0!==t.color&&(this.color=t.color),this.font.load(t.font),this.lines.load(t.lines),void 0!==t.text&&(this.text=t.text))}}class x{constructor(){this.filter=t=>t.a>0,this.pixels=new d,this.scale=1,this.selector="",this.text=new u}load(t){t&&(void 0!==t.element&&(this.element=t.element),void 0!==t.filter&&(this.filter=t.filter),this.pixels.load(t.pixels),void 0!==t.scale&&(this.scale=t.scale),void 0!==t.selector&&(this.selector=t.selector),void 0!==t.image&&(this.image=t.image),this.text.load(t.text))}}class g{generate(t,e,i,s){const o=new x;return o.load(s),new h(t,e,i,o)}}async function m(t,e=!0){const i=t;i.addEmitterShapeGenerator?.("canvas",new g),await i.refresh(e)}return r})()));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
/*! tsParticles Emitters Shape Canvas Plugin v3.
|
|
1
|
+
/*! tsParticles Emitters Shape Canvas Plugin v3.5.0 by Matteo Bruni */
|
package/umd/index.js
CHANGED
|
@@ -9,12 +9,11 @@
|
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
"use strict";
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.loadEmittersShapeCanvas =
|
|
12
|
+
exports.loadEmittersShapeCanvas = loadEmittersShapeCanvas;
|
|
13
13
|
const EmittersCanvasShapeGenerator_js_1 = require("./EmittersCanvasShapeGenerator.js");
|
|
14
14
|
async function loadEmittersShapeCanvas(engine, refresh = true) {
|
|
15
15
|
const emittersEngine = engine;
|
|
16
16
|
emittersEngine.addEmitterShapeGenerator?.("canvas", new EmittersCanvasShapeGenerator_js_1.EmittersCanvasShapeGenerator());
|
|
17
17
|
await emittersEngine.refresh(refresh);
|
|
18
18
|
}
|
|
19
|
-
exports.loadEmittersShapeCanvas = loadEmittersShapeCanvas;
|
|
20
19
|
});
|
package/umd/utils.js
CHANGED
|
@@ -9,7 +9,9 @@
|
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
"use strict";
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.getCanvasImageData = getCanvasImageData;
|
|
13
|
+
exports.getImageData = getImageData;
|
|
14
|
+
exports.getTextData = getTextData;
|
|
13
15
|
const engine_1 = require("@tsparticles/engine");
|
|
14
16
|
const origin = {
|
|
15
17
|
x: 0,
|
|
@@ -48,7 +50,6 @@
|
|
|
48
50
|
height: pixels.length,
|
|
49
51
|
};
|
|
50
52
|
}
|
|
51
|
-
exports.getCanvasImageData = getCanvasImageData;
|
|
52
53
|
function getImageData(src, offset) {
|
|
53
54
|
const image = new Image();
|
|
54
55
|
image.crossOrigin = "Anonymous";
|
|
@@ -69,7 +70,6 @@
|
|
|
69
70
|
image.src = src;
|
|
70
71
|
return p;
|
|
71
72
|
}
|
|
72
|
-
exports.getImageData = getImageData;
|
|
73
73
|
function getTextData(textOptions, offset, fill) {
|
|
74
74
|
const canvas = document.createElement("canvas"), context = canvas.getContext("2d"), { font, text, lines: linesOptions, color } = textOptions;
|
|
75
75
|
if (!text || !context) {
|
|
@@ -106,5 +106,4 @@
|
|
|
106
106
|
}
|
|
107
107
|
return getCanvasImageData(context, canvas, offset);
|
|
108
108
|
}
|
|
109
|
-
exports.getTextData = getTextData;
|
|
110
109
|
});
|