@tsparticles/shape-image 3.2.2 → 3.3.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/329.min.js +2 -0
- package/329.min.js.LICENSE.txt +1 -0
- package/33.min.js +2 -0
- package/33.min.js.LICENSE.txt +1 -0
- package/{623.min.js → 715.min.js} +2 -2
- package/715.min.js.LICENSE.txt +1 -0
- package/browser/ImageDrawer.js +41 -38
- package/cjs/GifUtils/Utils.js +1 -24
- package/cjs/ImageDrawer.js +42 -62
- package/cjs/index.js +2 -25
- package/dist_browser_GifUtils_Utils_js.js +1 -1
- package/dist_browser_ImageDrawer_js.js +2 -2
- package/dist_browser_ImagePreloader_js.js +1 -1
- package/esm/ImageDrawer.js +41 -38
- package/package.json +2 -2
- package/report.html +1 -1
- package/tsparticles.shape.image.js +3 -3
- package/tsparticles.shape.image.min.js +1 -1
- package/tsparticles.shape.image.min.js.LICENSE.txt +1 -1
- package/types/ImageDrawer.d.ts +4 -4
- package/umd/ImageDrawer.js +43 -64
- package/21.min.js +0 -2
- package/21.min.js.LICENSE.txt +0 -1
- package/618.min.js +0 -2
- package/618.min.js.LICENSE.txt +0 -1
- package/623.min.js.LICENSE.txt +0 -1
package/329.min.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! For license information please see 329.min.js.LICENSE.txt */
|
|
2
|
+
(this.webpackChunk_tsparticles_shape_image=this.webpackChunk_tsparticles_shape_image||[]).push([[329],{329:(t,e,a)=>{a.d(e,{zS:()=>p,loadGifImage:()=>w});const o=[0,4,2,1],i=[8,8,4,2];class s{constructor(t){this.pos=0,this.data=new Uint8ClampedArray(t)}getString(t){const e=this.data.slice(this.pos,this.pos+t);return this.pos+=e.length,e.reduce(((t,e)=>t+String.fromCharCode(e)),"")}nextByte(){return this.data[this.pos++]}nextTwoBytes(){return this.pos+=2,this.data[this.pos-2]+(this.data[this.pos-1]<<8)}readSubBlocks(){let t="",e=0;do{e=this.data[this.pos++];for(let a=e;--a>=0;t+=String.fromCharCode(this.data[this.pos++]));}while(0!==e);return t}readSubBlocksBin(){let t=this.data[this.pos],e=0;for(let a=0;0!==t;a+=t+1,t=this.data[this.pos+a])e+=t;const a=new Uint8Array(e);t=this.data[this.pos++];for(let e=0;0!==t;t=this.data[this.pos++])for(let o=t;--o>=0;a[e++]=this.data[this.pos++]);return a}skipSubBlocks(){for(const t=1,e=0;this.data[this.pos]!==e;this.pos+=this.data[this.pos]+t);this.pos++}}const r={x:0,y:0},n=0,l=.5,h=0,c=0,g=0;function f(t,e){const a=[];for(let o=0;o<e;o++)a.push({r:t.data[t.pos],g:t.data[t.pos+1],b:t.data[t.pos+2]}),t.pos+=3;return a}async function d(t,e,a,s,r,n){switch(t.nextByte()){case 59:return!0;case 44:await async function(t,e,a,s,r,n){const l=e.frames[s(!0)];l.left=t.nextTwoBytes(),l.top=t.nextTwoBytes(),l.width=t.nextTwoBytes(),l.height=t.nextTwoBytes();const h=t.nextByte(),c=128==(128&h),g=64==(64&h);l.sortFlag=32==(32&h),l.reserved=(24&h)>>>3;const d=1<<1+(7&h);c&&(l.localColorTable=f(t,d));const p=t=>{const{r:o,g:i,b:s}=(c?l.localColorTable:e.globalColorTable)[t];return t!==r(null)?{r:o,g:i,b:s,a:255}:{r:o,g:i,b:s,a:a?~~((o+i+s)/3):0}},w=(()=>{try{return new ImageData(l.width,l.height,{colorSpace:"srgb"})}catch(t){if(t instanceof DOMException&&"IndexSizeError"===t.name)return null;throw t}})();if(null==w)throw new EvalError("GIF frame size is to large");const u=t.nextByte(),m=t.readSubBlocksBin(),y=1<<u,b=(t,e)=>{const a=t>>>3,o=7&t;return(m[a]+(m[a+1]<<8)+(m[a+2]<<16)&(1<<e)-1<<o)>>>o};if(g){for(let a=0,r=u+1,h=0,c=[[0]],g=0;g<4;g++){if(o[g]<l.height){let t=0,e=0,s=!1;for(;!s;){const n=a;if(a=b(h,r),h+=r+1,a===y){r=u+1,c.length=y+2;for(let t=0;t<c.length;t++)c[t]=t<y?[t]:[]}else{a>=c.length?c.push(c[n].concat(c[n][0])):n!==y&&c.push(c[n].concat(c[a][0]));for(const s of c[a]){const{r:a,g:r,b:n,a:h}=p(s);w.data.set([a,r,n,h],o[g]*l.width+i[g]*e+t%(4*l.width)),t+=4}c.length===1<<r&&r<12&&r++}t===4*l.width*(e+1)&&(e++,o[g]+i[g]*e>=l.height&&(s=!0))}}n?.(t.pos/(t.data.length-1),s(!1)+1,w,{x:l.left,y:l.top},{width:e.width,height:e.height})}l.image=w,l.bitmap=await createImageBitmap(w)}else{let a=0,o=u+1,i=0,r=-4,h=!1;const c=[[0]];for(;!h;){const t=a;if(a=b(i,o),i+=o,a===y){o=u+1,c.length=y+2;for(let t=0;t<c.length;t++)c[t]=t<y?[t]:[]}else{if(a===y+1){h=!0;break}a>=c.length?c.push(c[t].concat(c[t][0])):t!==y&&c.push(c[t].concat(c[a][0]));for(const t of c[a]){const{r:e,g:a,b:o,a:i}=p(t);w.data.set([e,a,o,i],r+=4)}c.length>=1<<o&&o<12&&o++}}l.image=w,l.bitmap=await createImageBitmap(w),n?.((t.pos+1)/t.data.length,s(!1)+1,l.image,{x:l.left,y:l.top},{width:e.width,height:e.height})}}(t,e,a,s,r,n);break;case 33:!function(t,e,a,o){switch(t.nextByte()){case 249:{const i=e.frames[a(!1)];t.pos++;const s=t.nextByte();i.GCreserved=(224&s)>>>5,i.disposalMethod=(28&s)>>>2,i.userInputDelayFlag=2==(2&s);const r=1==(1&s);i.delayTime=10*t.nextTwoBytes();const n=t.nextByte();r&&o(n),t.pos++;break}case 255:{t.pos++;const a={identifier:t.getString(8),authenticationCode:t.getString(3),data:t.readSubBlocksBin()};e.applicationExtensions.push(a);break}case 254:e.comments.push([a(!1),t.readSubBlocks()]);break;case 1:if(0===e.globalColorTable.length)throw new EvalError("plain text extension without global color table");t.pos++,e.frames[a(!1)].plainTextData={left:t.nextTwoBytes(),top:t.nextTwoBytes(),width:t.nextTwoBytes(),height:t.nextTwoBytes(),charSize:{width:t.nextTwoBytes(),height:t.nextTwoBytes()},foregroundColor:t.nextByte(),backgroundColor:t.nextByte(),text:t.readSubBlocks()};break;default:t.skipSubBlocks()}}(t,e,s,r);break;default:throw new EvalError("undefined block found")}return!1}function p(t){const{context:e,radius:a,particle:o,delta:i}=t,s=o.image;if(!s?.gifData||!s.gif)return;const f=new OffscreenCanvas(s.gifData.width,s.gifData.height),d=f.getContext("2d");if(!d)throw new Error("could not create offscreen canvas context");d.imageSmoothingQuality="low",d.imageSmoothingEnabled=!1,d.clearRect(r.x,r.y,f.width,f.height),void 0===o.gifLoopCount&&(o.gifLoopCount=s.gifLoopCount??g);let p=o.gifFrame??n;const w={x:-s.gifData.width*l,y:-s.gifData.height*l},u=s.gifData.frames[p];if(void 0===o.gifTime&&(o.gifTime=h),u.bitmap){switch(e.scale(a/s.gifData.width,a/s.gifData.height),u.disposalMethod){case 4:case 5:case 6:case 7:case 0:d.drawImage(u.bitmap,u.left,u.top),e.drawImage(f,w.x,w.y),d.clearRect(r.x,r.y,f.width,f.height);break;case 1:d.drawImage(u.bitmap,u.left,u.top),e.drawImage(f,w.x,w.y);break;case 2:d.drawImage(u.bitmap,u.left,u.top),e.drawImage(f,w.x,w.y),d.clearRect(r.x,r.y,f.width,f.height),s.gifData.globalColorTable.length?d.putImageData(s.gifData.backgroundImage,w.x,w.y):d.putImageData(s.gifData.frames[c].image,w.x+u.left,w.y+u.top);break;case 3:{const t=d.getImageData(r.x,r.y,f.width,f.height);d.drawImage(u.bitmap,u.left,u.top),e.drawImage(f,w.x,w.y),d.clearRect(r.x,r.y,f.width,f.height),d.putImageData(t,r.x,r.y)}}if(o.gifTime+=i.value,o.gifTime>u.delayTime){if(o.gifTime-=u.delayTime,++p>=s.gifData.frames.length){if(--o.gifLoopCount<=g)return;p=c,d.clearRect(r.x,r.y,f.width,f.height)}o.gifFrame=p}e.scale(s.gifData.width/a,s.gifData.height/a)}}async function w(t){if("gif"===t.type){t.loading=!0;try{t.gifData=await async function(t,e,a){a||(a=!1);const o=await fetch(t);if(!o.ok&&404===o.status)throw new EvalError("file not found");const i=await o.arrayBuffer(),r={width:0,height:0,totalTime:0,colorRes:0,pixelAspectRatio:0,frames:[],sortFlag:!1,globalColorTable:[],backgroundImage:new ImageData(1,1,{colorSpace:"srgb"}),comments:[],applicationExtensions:[]},n=new s(new Uint8ClampedArray(i));if("GIF89a"!==n.getString(6))throw new Error("not a supported GIF file");r.width=n.nextTwoBytes(),r.height=n.nextTwoBytes();const l=n.nextByte(),h=128==(128&l);r.colorRes=(112&l)>>>4,r.sortFlag=8==(8&l);const c=1<<1+(7&l),g=n.nextByte();r.pixelAspectRatio=n.nextByte(),0!==r.pixelAspectRatio&&(r.pixelAspectRatio=(r.pixelAspectRatio+15)/64),h&&(r.globalColorTable=f(n,c));const p=(()=>{try{return new ImageData(r.width,r.height,{colorSpace:"srgb"})}catch(t){if(t instanceof DOMException&&"IndexSizeError"===t.name)return null;throw t}})();if(null==p)throw new Error("GIF frame size is to large");const{r:w,g:u,b:m}=r.globalColorTable[g];p.data.set(h?[w,u,m,255]:[0,0,0,0]);for(let t=4;t<p.data.length;t*=2)p.data.copyWithin(t,0,t);r.backgroundImage=p;let y=-1,b=!0,x=-1;const B=t=>(t&&(b=!0),y),T=t=>(null!=t&&(x=t),x);try{do{b&&(r.frames.push({left:0,top:0,width:0,height:0,disposalMethod:0,image:new ImageData(1,1,{colorSpace:"srgb"}),plainTextData:null,userInputDelayFlag:!1,delayTime:0,sortFlag:!1,localColorTable:[],reserved:0,GCreserved:0}),y++,x=-1,b=!1)}while(!await d(n,r,a,B,T,e));r.frames.length--;for(const t of r.frames){if(t.userInputDelayFlag&&0===t.delayTime){r.totalTime=1/0;break}r.totalTime+=t.delayTime}return r}catch(t){if(t instanceof EvalError)throw new Error(`error while parsing frame ${y} "${t.message}"`);throw t}}(t.source),t.gifLoopCount=function(t){for(const e of t.applicationExtensions)if(e.identifier+e.authenticationCode==="NETSCAPE2.0")return e.data[1]+(e.data[2]<<8);return NaN}(t.gifData)??g,t.gifLoopCount||(t.gifLoopCount=1/0)}catch{t.error=!0}t.loading=!1}else{const{loadImage:e}=await Promise.resolve().then(a.bind(a,764));await e(t)}}}}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/*! tsParticles Image Shape v3.3.0 by Matteo Bruni */
|
package/33.min.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! For license information please see 33.min.js.LICENSE.txt */
|
|
2
|
+
(this.webpackChunk_tsparticles_shape_image=this.webpackChunk_tsparticles_shape_image||[]).push([[33,329],{329:(t,e,a)=>{a.d(e,{zS:()=>p,loadGifImage:()=>m});const i=[0,4,2,1],o=[8,8,4,2];class s{constructor(t){this.pos=0,this.data=new Uint8ClampedArray(t)}getString(t){const e=this.data.slice(this.pos,this.pos+t);return this.pos+=e.length,e.reduce(((t,e)=>t+String.fromCharCode(e)),"")}nextByte(){return this.data[this.pos++]}nextTwoBytes(){return this.pos+=2,this.data[this.pos-2]+(this.data[this.pos-1]<<8)}readSubBlocks(){let t="",e=0;do{e=this.data[this.pos++];for(let a=e;--a>=0;t+=String.fromCharCode(this.data[this.pos++]));}while(0!==e);return t}readSubBlocksBin(){let t=this.data[this.pos],e=0;for(let a=0;0!==t;a+=t+1,t=this.data[this.pos+a])e+=t;const a=new Uint8Array(e);t=this.data[this.pos++];for(let e=0;0!==t;t=this.data[this.pos++])for(let i=t;--i>=0;a[e++]=this.data[this.pos++]);return a}skipSubBlocks(){for(const t=1,e=0;this.data[this.pos]!==e;this.pos+=this.data[this.pos]+t);this.pos++}}const n={x:0,y:0},r=0,l=.5,h=0,g=0,c=0;function f(t,e){const a=[];for(let i=0;i<e;i++)a.push({r:t.data[t.pos],g:t.data[t.pos+1],b:t.data[t.pos+2]}),t.pos+=3;return a}async function d(t,e,a,s,n,r){switch(t.nextByte()){case 59:return!0;case 44:await async function(t,e,a,s,n,r){const l=e.frames[s(!0)];l.left=t.nextTwoBytes(),l.top=t.nextTwoBytes(),l.width=t.nextTwoBytes(),l.height=t.nextTwoBytes();const h=t.nextByte(),g=128==(128&h),c=64==(64&h);l.sortFlag=32==(32&h),l.reserved=(24&h)>>>3;const d=1<<1+(7&h);g&&(l.localColorTable=f(t,d));const p=t=>{const{r:i,g:o,b:s}=(g?l.localColorTable:e.globalColorTable)[t];return t!==n(null)?{r:i,g:o,b:s,a:255}:{r:i,g:o,b:s,a:a?~~((i+o+s)/3):0}},m=(()=>{try{return new ImageData(l.width,l.height,{colorSpace:"srgb"})}catch(t){if(t instanceof DOMException&&"IndexSizeError"===t.name)return null;throw t}})();if(null==m)throw new EvalError("GIF frame size is to large");const u=t.nextByte(),w=t.readSubBlocksBin(),y=1<<u,x=(t,e)=>{const a=t>>>3,i=7&t;return(w[a]+(w[a+1]<<8)+(w[a+2]<<16)&(1<<e)-1<<i)>>>i};if(c){for(let a=0,n=u+1,h=0,g=[[0]],c=0;c<4;c++){if(i[c]<l.height){let t=0,e=0,s=!1;for(;!s;){const r=a;if(a=x(h,n),h+=n+1,a===y){n=u+1,g.length=y+2;for(let t=0;t<g.length;t++)g[t]=t<y?[t]:[]}else{a>=g.length?g.push(g[r].concat(g[r][0])):r!==y&&g.push(g[r].concat(g[a][0]));for(const s of g[a]){const{r:a,g:n,b:r,a:h}=p(s);m.data.set([a,n,r,h],i[c]*l.width+o[c]*e+t%(4*l.width)),t+=4}g.length===1<<n&&n<12&&n++}t===4*l.width*(e+1)&&(e++,i[c]+o[c]*e>=l.height&&(s=!0))}}r?.(t.pos/(t.data.length-1),s(!1)+1,m,{x:l.left,y:l.top},{width:e.width,height:e.height})}l.image=m,l.bitmap=await createImageBitmap(m)}else{let a=0,i=u+1,o=0,n=-4,h=!1;const g=[[0]];for(;!h;){const t=a;if(a=x(o,i),o+=i,a===y){i=u+1,g.length=y+2;for(let t=0;t<g.length;t++)g[t]=t<y?[t]:[]}else{if(a===y+1){h=!0;break}a>=g.length?g.push(g[t].concat(g[t][0])):t!==y&&g.push(g[t].concat(g[a][0]));for(const t of g[a]){const{r:e,g:a,b:i,a:o}=p(t);m.data.set([e,a,i,o],n+=4)}g.length>=1<<i&&i<12&&i++}}l.image=m,l.bitmap=await createImageBitmap(m),r?.((t.pos+1)/t.data.length,s(!1)+1,l.image,{x:l.left,y:l.top},{width:e.width,height:e.height})}}(t,e,a,s,n,r);break;case 33:!function(t,e,a,i){switch(t.nextByte()){case 249:{const o=e.frames[a(!1)];t.pos++;const s=t.nextByte();o.GCreserved=(224&s)>>>5,o.disposalMethod=(28&s)>>>2,o.userInputDelayFlag=2==(2&s);const n=1==(1&s);o.delayTime=10*t.nextTwoBytes();const r=t.nextByte();n&&i(r),t.pos++;break}case 255:{t.pos++;const a={identifier:t.getString(8),authenticationCode:t.getString(3),data:t.readSubBlocksBin()};e.applicationExtensions.push(a);break}case 254:e.comments.push([a(!1),t.readSubBlocks()]);break;case 1:if(0===e.globalColorTable.length)throw new EvalError("plain text extension without global color table");t.pos++,e.frames[a(!1)].plainTextData={left:t.nextTwoBytes(),top:t.nextTwoBytes(),width:t.nextTwoBytes(),height:t.nextTwoBytes(),charSize:{width:t.nextTwoBytes(),height:t.nextTwoBytes()},foregroundColor:t.nextByte(),backgroundColor:t.nextByte(),text:t.readSubBlocks()};break;default:t.skipSubBlocks()}}(t,e,s,n);break;default:throw new EvalError("undefined block found")}return!1}function p(t){const{context:e,radius:a,particle:i,delta:o}=t,s=i.image;if(!s?.gifData||!s.gif)return;const f=new OffscreenCanvas(s.gifData.width,s.gifData.height),d=f.getContext("2d");if(!d)throw new Error("could not create offscreen canvas context");d.imageSmoothingQuality="low",d.imageSmoothingEnabled=!1,d.clearRect(n.x,n.y,f.width,f.height),void 0===i.gifLoopCount&&(i.gifLoopCount=s.gifLoopCount??c);let p=i.gifFrame??r;const m={x:-s.gifData.width*l,y:-s.gifData.height*l},u=s.gifData.frames[p];if(void 0===i.gifTime&&(i.gifTime=h),u.bitmap){switch(e.scale(a/s.gifData.width,a/s.gifData.height),u.disposalMethod){case 4:case 5:case 6:case 7:case 0:d.drawImage(u.bitmap,u.left,u.top),e.drawImage(f,m.x,m.y),d.clearRect(n.x,n.y,f.width,f.height);break;case 1:d.drawImage(u.bitmap,u.left,u.top),e.drawImage(f,m.x,m.y);break;case 2:d.drawImage(u.bitmap,u.left,u.top),e.drawImage(f,m.x,m.y),d.clearRect(n.x,n.y,f.width,f.height),s.gifData.globalColorTable.length?d.putImageData(s.gifData.backgroundImage,m.x,m.y):d.putImageData(s.gifData.frames[g].image,m.x+u.left,m.y+u.top);break;case 3:{const t=d.getImageData(n.x,n.y,f.width,f.height);d.drawImage(u.bitmap,u.left,u.top),e.drawImage(f,m.x,m.y),d.clearRect(n.x,n.y,f.width,f.height),d.putImageData(t,n.x,n.y)}}if(i.gifTime+=o.value,i.gifTime>u.delayTime){if(i.gifTime-=u.delayTime,++p>=s.gifData.frames.length){if(--i.gifLoopCount<=c)return;p=g,d.clearRect(n.x,n.y,f.width,f.height)}i.gifFrame=p}e.scale(s.gifData.width/a,s.gifData.height/a)}}async function m(t){if("gif"===t.type){t.loading=!0;try{t.gifData=await async function(t,e,a){a||(a=!1);const i=await fetch(t);if(!i.ok&&404===i.status)throw new EvalError("file not found");const o=await i.arrayBuffer(),n={width:0,height:0,totalTime:0,colorRes:0,pixelAspectRatio:0,frames:[],sortFlag:!1,globalColorTable:[],backgroundImage:new ImageData(1,1,{colorSpace:"srgb"}),comments:[],applicationExtensions:[]},r=new s(new Uint8ClampedArray(o));if("GIF89a"!==r.getString(6))throw new Error("not a supported GIF file");n.width=r.nextTwoBytes(),n.height=r.nextTwoBytes();const l=r.nextByte(),h=128==(128&l);n.colorRes=(112&l)>>>4,n.sortFlag=8==(8&l);const g=1<<1+(7&l),c=r.nextByte();n.pixelAspectRatio=r.nextByte(),0!==n.pixelAspectRatio&&(n.pixelAspectRatio=(n.pixelAspectRatio+15)/64),h&&(n.globalColorTable=f(r,g));const p=(()=>{try{return new ImageData(n.width,n.height,{colorSpace:"srgb"})}catch(t){if(t instanceof DOMException&&"IndexSizeError"===t.name)return null;throw t}})();if(null==p)throw new Error("GIF frame size is to large");const{r:m,g:u,b:w}=n.globalColorTable[c];p.data.set(h?[m,u,w,255]:[0,0,0,0]);for(let t=4;t<p.data.length;t*=2)p.data.copyWithin(t,0,t);n.backgroundImage=p;let y=-1,x=!0,b=-1;const C=t=>(t&&(x=!0),y),I=t=>(null!=t&&(b=t),b);try{do{x&&(n.frames.push({left:0,top:0,width:0,height:0,disposalMethod:0,image:new ImageData(1,1,{colorSpace:"srgb"}),plainTextData:null,userInputDelayFlag:!1,delayTime:0,sortFlag:!1,localColorTable:[],reserved:0,GCreserved:0}),y++,b=-1,x=!1)}while(!await d(r,n,a,C,I,e));n.frames.length--;for(const t of n.frames){if(t.userInputDelayFlag&&0===t.delayTime){n.totalTime=1/0;break}n.totalTime+=t.delayTime}return n}catch(t){if(t instanceof EvalError)throw new Error(`error while parsing frame ${y} "${t.message}"`);throw t}}(t.source),t.gifLoopCount=function(t){for(const e of t.applicationExtensions)if(e.identifier+e.authenticationCode==="NETSCAPE2.0")return e.data[1]+(e.data[2]<<8);return NaN}(t.gifData)??c,t.gifLoopCount||(t.gifLoopCount=1/0)}catch{t.error=!0}t.loading=!1}else{const{loadImage:e}=await Promise.resolve().then(a.bind(a,764));await e(t)}}},33:(t,e,a)=>{a.d(e,{ImageDrawer:()=>n});var i=a(303),o=a(764),s=a(329);class n{constructor(t){this.loadImageShape=async t=>{if(!this._engine.loadImage)throw new Error(`${i.errorPrefix} image shape not initialized`);await this._engine.loadImage({gif:t.gif,name:t.name,replaceColor:t.replaceColor??!1,src:t.src})},this._engine=t}addImage(t){this._engine.images||(this._engine.images=[]),this._engine.images.push(t)}draw(t){const{context:e,radius:a,particle:i,opacity:o}=t,n=i.image,r=n?.element;if(n){if(e.globalAlpha=o,n.gif&&n.gifData)(0,s.zS)(t);else if(r){const t=n.ratio,i={x:-a,y:-a},o=2*a;e.drawImage(r,i.x,i.y,o,o/t)}e.globalAlpha=1}}getSidesCount(){return 12}async init(t){const e=t.actualOptions;if(e.preload&&this._engine.loadImage)for(const t of e.preload)await this._engine.loadImage(t)}loadShape(t){if("image"!==t.shape&&"images"!==t.shape)return;this._engine.images||(this._engine.images=[]);const e=t.shapeData;if(!e)return;this._engine.images.find((t=>t.name===e.name||t.source===e.src))||this.loadImageShape(e).then((()=>{this.loadShape(t)}))}particleInit(t,e){if("image"!==e.shape&&"images"!==e.shape)return;this._engine.images||(this._engine.images=[]);const a=this._engine.images,i=e.shapeData;if(!i)return;const s=e.getFillColor(),n=a.find((t=>t.name===i.name||t.source===i.src));if(!n)return;const r=i.replaceColor??n.replaceColor;n.loading?setTimeout((()=>{this.particleInit(t,e)})):(async()=>{let t;t=n.svgData&&s?await(0,o.d)(n,i,s,e):{color:s,data:n,element:n.element,gif:n.gif,gifData:n.gifData,gifLoopCount:n.gifLoopCount,loaded:!0,ratio:i.width&&i.height?i.width/i.height:n.ratio??1,replaceColor:r,source:i.src},t.ratio||(t.ratio=1);const a={image:t,fill:i.fill??e.shapeFill,close:i.close??e.shapeClose};e.image=a.image,e.shapeFill=a.fill,e.shapeClose=a.close})()}}}}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/*! tsParticles Image Shape v3.3.0 by Matteo Bruni */
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! For license information please see
|
|
2
|
-
(this.webpackChunk_tsparticles_shape_image=this.webpackChunk_tsparticles_shape_image||[]).push([[
|
|
1
|
+
/*! For license information please see 715.min.js.LICENSE.txt */
|
|
2
|
+
(this.webpackChunk_tsparticles_shape_image=this.webpackChunk_tsparticles_shape_image||[]).push([[715],{715:(e,i,s)=>{s.d(i,{ImagePreloaderPlugin:()=>r});class o{constructor(){this.src="",this.gif=!1}load(e){e&&(void 0!==e.gif&&(this.gif=e.gif),void 0!==e.height&&(this.height=e.height),void 0!==e.name&&(this.name=e.name),void 0!==e.replaceColor&&(this.replaceColor=e.replaceColor),void 0!==e.src&&(this.src=e.src),void 0!==e.width&&(this.width=e.width))}}class r{constructor(e){this.id="imagePreloader",this._engine=e}async getPlugin(){return await Promise.resolve(),{}}loadOptions(e,i){if(!i?.preload)return;e.preload||(e.preload=[]);const s=e.preload;for(const e of i.preload){const i=s.find((i=>i.name===e.name||i.src===e.src));if(i)i.load(e);else{const i=new o;i.load(e),s.push(i)}}}needsPlugin(){return!0}}}}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/*! tsParticles Image Shape v3.3.0 by Matteo Bruni */
|
package/browser/ImageDrawer.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { errorPrefix } from "@tsparticles/engine";
|
|
2
|
+
import { replaceImageColor } from "./Utils.js";
|
|
3
|
+
import { drawGif } from "./GifUtils/Utils.js";
|
|
2
4
|
const double = 2, defaultAlpha = 1, sides = 12, defaultRatio = 1;
|
|
3
5
|
export class ImageDrawer {
|
|
4
6
|
constructor(engine) {
|
|
@@ -21,14 +23,13 @@ export class ImageDrawer {
|
|
|
21
23
|
}
|
|
22
24
|
this._engine.images.push(image);
|
|
23
25
|
}
|
|
24
|
-
|
|
26
|
+
draw(data) {
|
|
25
27
|
const { context, radius, particle, opacity } = data, image = particle.image, element = image?.element;
|
|
26
28
|
if (!image) {
|
|
27
29
|
return;
|
|
28
30
|
}
|
|
29
31
|
context.globalAlpha = opacity;
|
|
30
32
|
if (image.gif && image.gifData) {
|
|
31
|
-
const { drawGif } = await import("./GifUtils/Utils.js");
|
|
32
33
|
drawGif(data);
|
|
33
34
|
}
|
|
34
35
|
else if (element) {
|
|
@@ -52,7 +53,7 @@ export class ImageDrawer {
|
|
|
52
53
|
await this._engine.loadImage(imageData);
|
|
53
54
|
}
|
|
54
55
|
}
|
|
55
|
-
|
|
56
|
+
loadShape(particle) {
|
|
56
57
|
if (particle.shape !== "image" && particle.shape !== "images") {
|
|
57
58
|
return;
|
|
58
59
|
}
|
|
@@ -65,11 +66,12 @@ export class ImageDrawer {
|
|
|
65
66
|
}
|
|
66
67
|
const image = this._engine.images.find((t) => t.name === imageData.name || t.source === imageData.src);
|
|
67
68
|
if (!image) {
|
|
68
|
-
|
|
69
|
-
|
|
69
|
+
void this.loadImageShape(imageData).then(() => {
|
|
70
|
+
this.loadShape(particle);
|
|
71
|
+
});
|
|
70
72
|
}
|
|
71
73
|
}
|
|
72
|
-
|
|
74
|
+
particleInit(container, particle) {
|
|
73
75
|
if (particle.shape !== "image" && particle.shape !== "images") {
|
|
74
76
|
return;
|
|
75
77
|
}
|
|
@@ -87,41 +89,42 @@ export class ImageDrawer {
|
|
|
87
89
|
const replaceColor = imageData.replaceColor ?? image.replaceColor;
|
|
88
90
|
if (image.loading) {
|
|
89
91
|
setTimeout(() => {
|
|
90
|
-
|
|
92
|
+
this.particleInit(container, particle);
|
|
91
93
|
});
|
|
92
94
|
return;
|
|
93
95
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
96
|
+
void (async () => {
|
|
97
|
+
let imageRes;
|
|
98
|
+
if (image.svgData && color) {
|
|
99
|
+
imageRes = await replaceImageColor(image, imageData, color, particle);
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
imageRes = {
|
|
103
|
+
color,
|
|
104
|
+
data: image,
|
|
105
|
+
element: image.element,
|
|
106
|
+
gif: image.gif,
|
|
107
|
+
gifData: image.gifData,
|
|
108
|
+
gifLoopCount: image.gifLoopCount,
|
|
109
|
+
loaded: true,
|
|
110
|
+
ratio: imageData.width && imageData.height
|
|
111
|
+
? imageData.width / imageData.height
|
|
112
|
+
: image.ratio ?? defaultRatio,
|
|
113
|
+
replaceColor: replaceColor,
|
|
114
|
+
source: imageData.src,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
if (!imageRes.ratio) {
|
|
118
|
+
imageRes.ratio = 1;
|
|
119
|
+
}
|
|
120
|
+
const fill = imageData.fill ?? particle.shapeFill, close = imageData.close ?? particle.shapeClose, imageShape = {
|
|
121
|
+
image: imageRes,
|
|
122
|
+
fill,
|
|
123
|
+
close,
|
|
113
124
|
};
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}
|
|
118
|
-
const fill = imageData.fill ?? particle.shapeFill, close = imageData.close ?? particle.shapeClose, imageShape = {
|
|
119
|
-
image: imageRes,
|
|
120
|
-
fill,
|
|
121
|
-
close,
|
|
122
|
-
};
|
|
123
|
-
particle.image = imageShape.image;
|
|
124
|
-
particle.shapeFill = imageShape.fill;
|
|
125
|
-
particle.shapeClose = imageShape.close;
|
|
125
|
+
particle.image = imageShape.image;
|
|
126
|
+
particle.shapeFill = imageShape.fill;
|
|
127
|
+
particle.shapeClose = imageShape.close;
|
|
128
|
+
})();
|
|
126
129
|
}
|
|
127
130
|
}
|
package/cjs/GifUtils/Utils.js
CHANGED
|
@@ -1,27 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
3
|
exports.loadGifImage = exports.drawGif = exports.decodeGIF = exports.getGIFLoopAmount = void 0;
|
|
27
4
|
const Constants_js_1 = require("./Constants.js");
|
|
@@ -437,7 +414,7 @@ function drawGif(data) {
|
|
|
437
414
|
exports.drawGif = drawGif;
|
|
438
415
|
async function loadGifImage(image) {
|
|
439
416
|
if (image.type !== "gif") {
|
|
440
|
-
const { loadImage } = await
|
|
417
|
+
const { loadImage } = await import("../Utils.js");
|
|
441
418
|
await loadImage(image);
|
|
442
419
|
return;
|
|
443
420
|
}
|
package/cjs/ImageDrawer.js
CHANGED
|
@@ -1,30 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
3
|
exports.ImageDrawer = void 0;
|
|
27
4
|
const engine_1 = require("@tsparticles/engine");
|
|
5
|
+
const Utils_js_1 = require("./Utils.js");
|
|
6
|
+
const Utils_js_2 = require("./GifUtils/Utils.js");
|
|
28
7
|
const double = 2, defaultAlpha = 1, sides = 12, defaultRatio = 1;
|
|
29
8
|
class ImageDrawer {
|
|
30
9
|
constructor(engine) {
|
|
@@ -47,15 +26,14 @@ class ImageDrawer {
|
|
|
47
26
|
}
|
|
48
27
|
this._engine.images.push(image);
|
|
49
28
|
}
|
|
50
|
-
|
|
29
|
+
draw(data) {
|
|
51
30
|
const { context, radius, particle, opacity } = data, image = particle.image, element = image?.element;
|
|
52
31
|
if (!image) {
|
|
53
32
|
return;
|
|
54
33
|
}
|
|
55
34
|
context.globalAlpha = opacity;
|
|
56
35
|
if (image.gif && image.gifData) {
|
|
57
|
-
|
|
58
|
-
drawGif(data);
|
|
36
|
+
(0, Utils_js_2.drawGif)(data);
|
|
59
37
|
}
|
|
60
38
|
else if (element) {
|
|
61
39
|
const ratio = image.ratio, pos = {
|
|
@@ -78,7 +56,7 @@ class ImageDrawer {
|
|
|
78
56
|
await this._engine.loadImage(imageData);
|
|
79
57
|
}
|
|
80
58
|
}
|
|
81
|
-
|
|
59
|
+
loadShape(particle) {
|
|
82
60
|
if (particle.shape !== "image" && particle.shape !== "images") {
|
|
83
61
|
return;
|
|
84
62
|
}
|
|
@@ -91,11 +69,12 @@ class ImageDrawer {
|
|
|
91
69
|
}
|
|
92
70
|
const image = this._engine.images.find((t) => t.name === imageData.name || t.source === imageData.src);
|
|
93
71
|
if (!image) {
|
|
94
|
-
|
|
95
|
-
|
|
72
|
+
void this.loadImageShape(imageData).then(() => {
|
|
73
|
+
this.loadShape(particle);
|
|
74
|
+
});
|
|
96
75
|
}
|
|
97
76
|
}
|
|
98
|
-
|
|
77
|
+
particleInit(container, particle) {
|
|
99
78
|
if (particle.shape !== "image" && particle.shape !== "images") {
|
|
100
79
|
return;
|
|
101
80
|
}
|
|
@@ -113,42 +92,43 @@ class ImageDrawer {
|
|
|
113
92
|
const replaceColor = imageData.replaceColor ?? image.replaceColor;
|
|
114
93
|
if (image.loading) {
|
|
115
94
|
setTimeout(() => {
|
|
116
|
-
|
|
95
|
+
this.particleInit(container, particle);
|
|
117
96
|
});
|
|
118
97
|
return;
|
|
119
98
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
99
|
+
void (async () => {
|
|
100
|
+
let imageRes;
|
|
101
|
+
if (image.svgData && color) {
|
|
102
|
+
imageRes = await (0, Utils_js_1.replaceImageColor)(image, imageData, color, particle);
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
imageRes = {
|
|
106
|
+
color,
|
|
107
|
+
data: image,
|
|
108
|
+
element: image.element,
|
|
109
|
+
gif: image.gif,
|
|
110
|
+
gifData: image.gifData,
|
|
111
|
+
gifLoopCount: image.gifLoopCount,
|
|
112
|
+
loaded: true,
|
|
113
|
+
ratio: imageData.width && imageData.height
|
|
114
|
+
? imageData.width / imageData.height
|
|
115
|
+
: image.ratio ?? defaultRatio,
|
|
116
|
+
replaceColor: replaceColor,
|
|
117
|
+
source: imageData.src,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
if (!imageRes.ratio) {
|
|
121
|
+
imageRes.ratio = 1;
|
|
122
|
+
}
|
|
123
|
+
const fill = imageData.fill ?? particle.shapeFill, close = imageData.close ?? particle.shapeClose, imageShape = {
|
|
124
|
+
image: imageRes,
|
|
125
|
+
fill,
|
|
126
|
+
close,
|
|
139
127
|
};
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
}
|
|
144
|
-
const fill = imageData.fill ?? particle.shapeFill, close = imageData.close ?? particle.shapeClose, imageShape = {
|
|
145
|
-
image: imageRes,
|
|
146
|
-
fill,
|
|
147
|
-
close,
|
|
148
|
-
};
|
|
149
|
-
particle.image = imageShape.image;
|
|
150
|
-
particle.shapeFill = imageShape.fill;
|
|
151
|
-
particle.shapeClose = imageShape.close;
|
|
128
|
+
particle.image = imageShape.image;
|
|
129
|
+
particle.shapeFill = imageShape.fill;
|
|
130
|
+
particle.shapeClose = imageShape.close;
|
|
131
|
+
})();
|
|
152
132
|
}
|
|
153
133
|
}
|
|
154
134
|
exports.ImageDrawer = ImageDrawer;
|
package/cjs/index.js
CHANGED
|
@@ -1,27 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
3
|
exports.loadImageShape = void 0;
|
|
27
4
|
const Utils_js_1 = require("./Utils.js");
|
|
@@ -55,7 +32,7 @@ function addLoadImageToEngine(engine) {
|
|
|
55
32
|
engine.images.push(image);
|
|
56
33
|
let imageFunc;
|
|
57
34
|
if (data.gif) {
|
|
58
|
-
const { loadGifImage } = await
|
|
35
|
+
const { loadGifImage } = await import("./GifUtils/Utils.js");
|
|
59
36
|
imageFunc = loadGifImage;
|
|
60
37
|
}
|
|
61
38
|
else {
|
|
@@ -70,7 +47,7 @@ function addLoadImageToEngine(engine) {
|
|
|
70
47
|
}
|
|
71
48
|
async function loadImageShape(engine, refresh = true) {
|
|
72
49
|
addLoadImageToEngine(engine);
|
|
73
|
-
const { ImagePreloaderPlugin } = await
|
|
50
|
+
const { ImagePreloaderPlugin } = await import("./ImagePreloader.js"), { ImageDrawer } = await import("./ImageDrawer.js");
|
|
74
51
|
const preloader = new ImagePreloaderPlugin(engine);
|
|
75
52
|
await engine.addPlugin(preloader, refresh);
|
|
76
53
|
await engine.addShape(["image", "images"], new ImageDrawer(engine), refresh);
|
|
@@ -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.3.0
|
|
8
8
|
*/
|
|
9
9
|
"use strict";
|
|
10
10
|
/*
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
\*************************************/
|
|
24
24
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
25
25
|
|
|
26
|
-
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ImageDrawer: () => (/* binding */ ImageDrawer)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__);\n\nconst double = 2,\n defaultAlpha = 1,\n sides = 12,\n defaultRatio = 1;\nclass ImageDrawer {\n constructor(engine) {\n this.loadImageShape = async imageShape => {\n if (!this._engine.loadImage) {\n throw new Error(`${_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.errorPrefix} image shape not initialized`);\n }\n await this._engine.loadImage({\n gif: imageShape.gif,\n name: imageShape.name,\n replaceColor: imageShape.replaceColor ?? false,\n src: imageShape.src\n });\n };\n this._engine = engine;\n }\n addImage(image) {\n if (!this._engine.images) {\n this._engine.images = [];\n }\n this._engine.images.push(image);\n }\n
|
|
26
|
+
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ImageDrawer: () => (/* binding */ ImageDrawer)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _Utils_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Utils.js */ \"./dist/browser/Utils.js\");\n/* harmony import */ var _GifUtils_Utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./GifUtils/Utils.js */ \"./dist/browser/GifUtils/Utils.js\");\n\n\n\nconst double = 2,\n defaultAlpha = 1,\n sides = 12,\n defaultRatio = 1;\nclass ImageDrawer {\n constructor(engine) {\n this.loadImageShape = async imageShape => {\n if (!this._engine.loadImage) {\n throw new Error(`${_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.errorPrefix} image shape not initialized`);\n }\n await this._engine.loadImage({\n gif: imageShape.gif,\n name: imageShape.name,\n replaceColor: imageShape.replaceColor ?? false,\n src: imageShape.src\n });\n };\n this._engine = engine;\n }\n addImage(image) {\n if (!this._engine.images) {\n this._engine.images = [];\n }\n this._engine.images.push(image);\n }\n draw(data) {\n const {\n context,\n radius,\n particle,\n opacity\n } = data,\n image = particle.image,\n element = image?.element;\n if (!image) {\n return;\n }\n context.globalAlpha = opacity;\n if (image.gif && image.gifData) {\n (0,_GifUtils_Utils_js__WEBPACK_IMPORTED_MODULE_1__.drawGif)(data);\n } else if (element) {\n const ratio = image.ratio,\n pos = {\n x: -radius,\n y: -radius\n },\n diameter = radius * double;\n context.drawImage(element, pos.x, pos.y, diameter, diameter / ratio);\n }\n context.globalAlpha = defaultAlpha;\n }\n getSidesCount() {\n return sides;\n }\n async init(container) {\n const options = container.actualOptions;\n if (!options.preload || !this._engine.loadImage) {\n return;\n }\n for (const imageData of options.preload) {\n await this._engine.loadImage(imageData);\n }\n }\n loadShape(particle) {\n if (particle.shape !== \"image\" && particle.shape !== \"images\") {\n return;\n }\n if (!this._engine.images) {\n this._engine.images = [];\n }\n const imageData = particle.shapeData;\n if (!imageData) {\n return;\n }\n const image = this._engine.images.find(t => t.name === imageData.name || t.source === imageData.src);\n if (!image) {\n void this.loadImageShape(imageData).then(() => {\n this.loadShape(particle);\n });\n }\n }\n particleInit(container, particle) {\n if (particle.shape !== \"image\" && particle.shape !== \"images\") {\n return;\n }\n if (!this._engine.images) {\n this._engine.images = [];\n }\n const images = this._engine.images,\n imageData = particle.shapeData;\n if (!imageData) {\n return;\n }\n const color = particle.getFillColor(),\n image = images.find(t => t.name === imageData.name || t.source === imageData.src);\n if (!image) {\n return;\n }\n const replaceColor = imageData.replaceColor ?? image.replaceColor;\n if (image.loading) {\n setTimeout(() => {\n this.particleInit(container, particle);\n });\n return;\n }\n void (async () => {\n let imageRes;\n if (image.svgData && color) {\n imageRes = await (0,_Utils_js__WEBPACK_IMPORTED_MODULE_2__.replaceImageColor)(image, imageData, color, particle);\n } else {\n imageRes = {\n color,\n data: image,\n element: image.element,\n gif: image.gif,\n gifData: image.gifData,\n gifLoopCount: image.gifLoopCount,\n loaded: true,\n ratio: imageData.width && imageData.height ? imageData.width / imageData.height : image.ratio ?? defaultRatio,\n replaceColor: replaceColor,\n source: imageData.src\n };\n }\n if (!imageRes.ratio) {\n imageRes.ratio = 1;\n }\n const fill = imageData.fill ?? particle.shapeFill,\n close = imageData.close ?? particle.shapeClose,\n imageShape = {\n image: imageRes,\n fill,\n close\n };\n particle.image = imageShape.image;\n particle.shapeFill = imageShape.fill;\n particle.shapeClose = imageShape.close;\n })();\n }\n}\n\n//# sourceURL=webpack://@tsparticles/shape-image/./dist/browser/ImageDrawer.js?");
|
|
27
27
|
|
|
28
28
|
/***/ })
|
|
29
29
|
|
package/esm/ImageDrawer.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { errorPrefix } from "@tsparticles/engine";
|
|
2
|
+
import { replaceImageColor } from "./Utils.js";
|
|
3
|
+
import { drawGif } from "./GifUtils/Utils.js";
|
|
2
4
|
const double = 2, defaultAlpha = 1, sides = 12, defaultRatio = 1;
|
|
3
5
|
export class ImageDrawer {
|
|
4
6
|
constructor(engine) {
|
|
@@ -21,14 +23,13 @@ export class ImageDrawer {
|
|
|
21
23
|
}
|
|
22
24
|
this._engine.images.push(image);
|
|
23
25
|
}
|
|
24
|
-
|
|
26
|
+
draw(data) {
|
|
25
27
|
const { context, radius, particle, opacity } = data, image = particle.image, element = image?.element;
|
|
26
28
|
if (!image) {
|
|
27
29
|
return;
|
|
28
30
|
}
|
|
29
31
|
context.globalAlpha = opacity;
|
|
30
32
|
if (image.gif && image.gifData) {
|
|
31
|
-
const { drawGif } = await import("./GifUtils/Utils.js");
|
|
32
33
|
drawGif(data);
|
|
33
34
|
}
|
|
34
35
|
else if (element) {
|
|
@@ -52,7 +53,7 @@ export class ImageDrawer {
|
|
|
52
53
|
await this._engine.loadImage(imageData);
|
|
53
54
|
}
|
|
54
55
|
}
|
|
55
|
-
|
|
56
|
+
loadShape(particle) {
|
|
56
57
|
if (particle.shape !== "image" && particle.shape !== "images") {
|
|
57
58
|
return;
|
|
58
59
|
}
|
|
@@ -65,11 +66,12 @@ export class ImageDrawer {
|
|
|
65
66
|
}
|
|
66
67
|
const image = this._engine.images.find((t) => t.name === imageData.name || t.source === imageData.src);
|
|
67
68
|
if (!image) {
|
|
68
|
-
|
|
69
|
-
|
|
69
|
+
void this.loadImageShape(imageData).then(() => {
|
|
70
|
+
this.loadShape(particle);
|
|
71
|
+
});
|
|
70
72
|
}
|
|
71
73
|
}
|
|
72
|
-
|
|
74
|
+
particleInit(container, particle) {
|
|
73
75
|
if (particle.shape !== "image" && particle.shape !== "images") {
|
|
74
76
|
return;
|
|
75
77
|
}
|
|
@@ -87,41 +89,42 @@ export class ImageDrawer {
|
|
|
87
89
|
const replaceColor = imageData.replaceColor ?? image.replaceColor;
|
|
88
90
|
if (image.loading) {
|
|
89
91
|
setTimeout(() => {
|
|
90
|
-
|
|
92
|
+
this.particleInit(container, particle);
|
|
91
93
|
});
|
|
92
94
|
return;
|
|
93
95
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
96
|
+
void (async () => {
|
|
97
|
+
let imageRes;
|
|
98
|
+
if (image.svgData && color) {
|
|
99
|
+
imageRes = await replaceImageColor(image, imageData, color, particle);
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
imageRes = {
|
|
103
|
+
color,
|
|
104
|
+
data: image,
|
|
105
|
+
element: image.element,
|
|
106
|
+
gif: image.gif,
|
|
107
|
+
gifData: image.gifData,
|
|
108
|
+
gifLoopCount: image.gifLoopCount,
|
|
109
|
+
loaded: true,
|
|
110
|
+
ratio: imageData.width && imageData.height
|
|
111
|
+
? imageData.width / imageData.height
|
|
112
|
+
: image.ratio ?? defaultRatio,
|
|
113
|
+
replaceColor: replaceColor,
|
|
114
|
+
source: imageData.src,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
if (!imageRes.ratio) {
|
|
118
|
+
imageRes.ratio = 1;
|
|
119
|
+
}
|
|
120
|
+
const fill = imageData.fill ?? particle.shapeFill, close = imageData.close ?? particle.shapeClose, imageShape = {
|
|
121
|
+
image: imageRes,
|
|
122
|
+
fill,
|
|
123
|
+
close,
|
|
113
124
|
};
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}
|
|
118
|
-
const fill = imageData.fill ?? particle.shapeFill, close = imageData.close ?? particle.shapeClose, imageShape = {
|
|
119
|
-
image: imageRes,
|
|
120
|
-
fill,
|
|
121
|
-
close,
|
|
122
|
-
};
|
|
123
|
-
particle.image = imageShape.image;
|
|
124
|
-
particle.shapeFill = imageShape.fill;
|
|
125
|
-
particle.shapeClose = imageShape.close;
|
|
125
|
+
particle.image = imageShape.image;
|
|
126
|
+
particle.shapeFill = imageShape.fill;
|
|
127
|
+
particle.shapeClose = imageShape.close;
|
|
128
|
+
})();
|
|
126
129
|
}
|
|
127
130
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsparticles/shape-image",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"description": "tsParticles image shape",
|
|
5
5
|
"homepage": "https://particles.js.org",
|
|
6
6
|
"repository": {
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"./package.json": "./package.json"
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@tsparticles/engine": "^3.
|
|
62
|
+
"@tsparticles/engine": "^3.3.0"
|
|
63
63
|
},
|
|
64
64
|
"publishConfig": {
|
|
65
65
|
"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/shape-image [
|
|
6
|
+
<title>@tsparticles/shape-image [27 Feb 2024 at 12:20]</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/AXEaF8EPmnrrKsv0LvWR3fg5sWDNAFZOgAgaKvZDogHNU9MFwnnYROkc56RD5CjAbQX9Ow4g7upCsvYu55aSI/Nj0H1akgKQEUM94dwK65hYRmFU9MIcH/fqJYOZYcnuJSU/waKDgTOEVaVKhwrTRP5XzgSpAITYzom7UvkhFX5VutmxeNnWDjjswTKTyfgluNDGbUpWissXhF3s7mlSml+czWkg3D0l1nNjGNjz3myOQOa1KM/jOS6ebdbAVTCi4gljHSFrviza7tOgRWcS0MOUX9zdNgag5w7rRqA44Lzw0hr1WqES36dFliSJFlh2rXIae3FFcDDgKdxrUIDePr8jGcSClV1u7A9xeN0ModY/pHMxmR1EzRh8TJiwqsHmKW0l4FCEZI+jHio+JdPPE9qwQtTRxku2D8sIeRL2LnxWSllANCQGOIiqVHAz2ye2JR0DcH+HoxDkaADLjgxjKQ+AwCX/g0+DNgdG0ukYCONAe+dbc2IAc6fwt1ARoDSezNHxV2Cmzwv3O6lDMV55edBGwGK9n1+x2F8EDfAGCxug8MhpsMEcTEAWf3rx2vZhe/LAmtIn/6apE6PN0ULKgywD9mmdxbmFl3OvD5AS5fW5zLbv/YHmcsBTjf/afDz3MaZTVCfAP9z6/Bw6ycv8EUBWJIn9zYcoAWWlW9+OzO3vkTy8H+RANLmdrpOuYWdZYEXpo+TlCJrW5EARb7fF+bWdqf3hhyZI1nWJQHgznErZhbjoEsWqi8dQNoE294aldzFurwSABL2XXMf9+H1VQGke9exw5P/AnA5Pv5ngMul7LOvO922iwACu8WkCwLCafvM4CeWPxfA8lNHcWZSoi8EwMAIciKX2Z4SWCMAa3snCZ/G4EA8D6CMLNFsGQhkkz/gQNEBbPCbWsxGUpYVu3z8IyNAknwJkfPMEhLyrdi5RTyUVACkw4GSFRNWJNEW+fgPGwHD8/JxnRuLabN4CGNRkAE23na2+VmEAUmrYymSGjMAYqH84YUIyzgzs3XC7gNgH36Vcc4zKY9o9fgPBXUAiHHwVboBHGLiX6Zcjp1f2wu4tvzZKo0ecPnDtQYDQvJXaBeNzce45Fp28ZQLrEZVuFqgBwOalArKXnW1UzlnSusQKJqKYNuz4tOnI6sZG4zanpemv+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.3.0
|
|
8
8
|
*/
|
|
9
9
|
/*
|
|
10
10
|
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
|
|
@@ -44,7 +44,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
|
|
|
44
44
|
\*******************************/
|
|
45
45
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
46
46
|
|
|
47
|
-
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadImageShape: () => (/* binding */ loadImageShape)\n/* harmony export */ });\n/* harmony import */ var _Utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Utils.js */ \"./dist/browser/Utils.js\");\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__);\n\n\nconst extLength = 3;\nfunction addLoadImageToEngine(engine) {\n if (engine.loadImage) {\n return;\n }\n engine.loadImage = async data => {\n if (!data.name && !data.src) {\n throw new Error(`${_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.errorPrefix} no image source provided`);\n }\n if (!engine.images) {\n engine.images = [];\n }\n if (engine.images.find(t => t.name === data.name || t.source === data.src)) {\n return;\n }\n try {\n const image = {\n gif: data.gif ?? false,\n name: data.name ?? data.src,\n source: data.src,\n type: data.src.substring(data.src.length - extLength),\n error: false,\n loading: true,\n replaceColor: data.replaceColor,\n ratio: data.width && data.height ? data.width / data.height : undefined\n };\n engine.images.push(image);\n let imageFunc;\n if (data.gif) {\n const {\n loadGifImage\n } = await __webpack_require__.e(/*! import() */ \"dist_browser_GifUtils_Utils_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./GifUtils/Utils.js */ \"./dist/browser/GifUtils/Utils.js\"));\n imageFunc = loadGifImage;\n } else {\n imageFunc = data.replaceColor ? _Utils_js__WEBPACK_IMPORTED_MODULE_1__.downloadSvgImage : _Utils_js__WEBPACK_IMPORTED_MODULE_1__.loadImage;\n }\n await imageFunc(image);\n } catch {\n throw new Error(`${_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.errorPrefix} ${data.name ?? data.src} not found`);\n }\n };\n}\nasync function loadImageShape(engine, refresh = true) {\n addLoadImageToEngine(engine);\n const {\n ImagePreloaderPlugin\n } = await __webpack_require__.e(/*! import() */ \"dist_browser_ImagePreloader_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./ImagePreloader.js */ \"./dist/browser/ImagePreloader.js\")),\n {\n ImageDrawer\n } = await
|
|
47
|
+
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadImageShape: () => (/* binding */ loadImageShape)\n/* harmony export */ });\n/* harmony import */ var _Utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Utils.js */ \"./dist/browser/Utils.js\");\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__);\n\n\nconst extLength = 3;\nfunction addLoadImageToEngine(engine) {\n if (engine.loadImage) {\n return;\n }\n engine.loadImage = async data => {\n if (!data.name && !data.src) {\n throw new Error(`${_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.errorPrefix} no image source provided`);\n }\n if (!engine.images) {\n engine.images = [];\n }\n if (engine.images.find(t => t.name === data.name || t.source === data.src)) {\n return;\n }\n try {\n const image = {\n gif: data.gif ?? false,\n name: data.name ?? data.src,\n source: data.src,\n type: data.src.substring(data.src.length - extLength),\n error: false,\n loading: true,\n replaceColor: data.replaceColor,\n ratio: data.width && data.height ? data.width / data.height : undefined\n };\n engine.images.push(image);\n let imageFunc;\n if (data.gif) {\n const {\n loadGifImage\n } = await __webpack_require__.e(/*! import() */ \"dist_browser_GifUtils_Utils_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./GifUtils/Utils.js */ \"./dist/browser/GifUtils/Utils.js\"));\n imageFunc = loadGifImage;\n } else {\n imageFunc = data.replaceColor ? _Utils_js__WEBPACK_IMPORTED_MODULE_1__.downloadSvgImage : _Utils_js__WEBPACK_IMPORTED_MODULE_1__.loadImage;\n }\n await imageFunc(image);\n } catch {\n throw new Error(`${_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.errorPrefix} ${data.name ?? data.src} not found`);\n }\n };\n}\nasync function loadImageShape(engine, refresh = true) {\n addLoadImageToEngine(engine);\n const {\n ImagePreloaderPlugin\n } = await __webpack_require__.e(/*! import() */ \"dist_browser_ImagePreloader_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./ImagePreloader.js */ \"./dist/browser/ImagePreloader.js\")),\n {\n ImageDrawer\n } = await Promise.all(/*! import() */[__webpack_require__.e(\"dist_browser_GifUtils_Utils_js\"), __webpack_require__.e(\"dist_browser_ImageDrawer_js\")]).then(__webpack_require__.bind(__webpack_require__, /*! ./ImageDrawer.js */ \"./dist/browser/ImageDrawer.js\"));\n const preloader = new ImagePreloaderPlugin(engine);\n await engine.addPlugin(preloader, refresh);\n await engine.addShape([\"image\", \"images\"], new ImageDrawer(engine), refresh);\n}\n\n//# sourceURL=webpack://@tsparticles/shape-image/./dist/browser/index.js?");
|
|
48
48
|
|
|
49
49
|
/***/ }),
|
|
50
50
|
|
|
@@ -220,7 +220,7 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__;
|
|
|
220
220
|
/******/ var scripts = document.getElementsByTagName("script");
|
|
221
221
|
/******/ if(scripts.length) {
|
|
222
222
|
/******/ var i = scripts.length - 1;
|
|
223
|
-
/******/ while (i > -1 && !scriptUrl) scriptUrl = scripts[i--].src;
|
|
223
|
+
/******/ while (i > -1 && (!scriptUrl || !/^http(s?):/.test(scriptUrl))) scriptUrl = scripts[i--].src;
|
|
224
224
|
/******/ }
|
|
225
225
|
/******/ }
|
|
226
226
|
/******/ }
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see tsparticles.shape.image.min.js.LICENSE.txt */
|
|
2
|
-
!function(e,r){if("object"==typeof exports&&"object"==typeof module)module.exports=r(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],r);else{var t="object"==typeof exports?r(require("@tsparticles/engine")):r(e.window);for(var o in t)("object"==typeof exports?exports:e)[o]=t[o]}}(this,(e=>(()=>{var r,t,o={
|
|
2
|
+
!function(e,r){if("object"==typeof exports&&"object"==typeof module)module.exports=r(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],r);else{var t="object"==typeof exports?r(require("@tsparticles/engine")):r(e.window);for(var o in t)("object"==typeof exports?exports:e)[o]=t[o]}}(this,(e=>(()=>{var r,t,o={764:(e,r,t)=>{t.d(r,{a:()=>c,d:()=>l,loadImage:()=>s});var o=t(303);const a=0,n=1,i=/(#(?:[0-9a-f]{2}){2,4}|(#[0-9a-f]{3})|(rgb|hsl)a?\((-?\d+%?[,\s]+){2,3}\s*[\d.]+%?\))|currentcolor/gi;async function s(e){return new Promise((r=>{e.loading=!0;const t=new Image;e.element=t,t.addEventListener("load",(()=>{e.loading=!1,r()})),t.addEventListener("error",(()=>{e.element=void 0,e.error=!0,e.loading=!1,(0,o.getLogger)().error(`${o.errorPrefix} loading image: ${e.source}`),r()})),t.src=e.source}))}async function c(e){if("svg"!==e.type)return void await s(e);e.loading=!0;const r=await fetch(e.source);r.ok?e.svgData=await r.text():((0,o.getLogger)().error(`${o.errorPrefix} Image not found`),e.error=!0),e.loading=!1}function l(e,r,t,c){const l=function(e,r,t){const{svgData:n}=e;if(!n)return"";const s=(0,o.getStyleFromHsl)(r,t);if(n.includes("fill"))return n.replace(i,(()=>s));const c=n.indexOf(">");return`${n.substring(a,c)} fill="${s}"${n.substring(c)}`}(e,t,c.opacity?.value??n),d={color:t,gif:r.gif,data:{...e,svgData:l},loaded:!1,ratio:r.width/r.height,replaceColor:r.replaceColor,source:r.src};return new Promise((r=>{const t=new Blob([l],{type:"image/svg+xml"}),o=URL||window.URL||window.webkitURL||window,a=o.createObjectURL(t),n=new Image;n.addEventListener("load",(()=>{d.loaded=!0,d.element=n,r(d),o.revokeObjectURL(a)}));n.addEventListener("error",(()=>{(async()=>{o.revokeObjectURL(a);const t={...e,error:!1,loading:!0};await s(t),d.loaded=!0,d.element=t.element,r(d)})()})),n.src=a}))}},303:r=>{r.exports=e}},a={};function n(e){var r=a[e];if(void 0!==r)return r.exports;var t=a[e]={exports:{}};return o[e](t,t.exports,n),t.exports}n.m=o,n.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return n.d(r,{a:r}),r},n.d=(e,r)=>{for(var t in r)n.o(r,t)&&!n.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},n.f={},n.e=e=>Promise.all(Object.keys(n.f).reduce(((r,t)=>(n.f[t](e,r),r)),[])),n.u=e=>e+".min.js",n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),r={},t="@tsparticles/shape-image:",n.l=(e,o,a,i)=>{if(r[e])r[e].push(o);else{var s,c;if(void 0!==a)for(var l=document.getElementsByTagName("script"),d=0;d<l.length;d++){var u=l[d];if(u.getAttribute("src")==e||u.getAttribute("data-webpack")==t+a){s=u;break}}s||(c=!0,(s=document.createElement("script")).charset="utf-8",s.timeout=120,n.nc&&s.setAttribute("nonce",n.nc),s.setAttribute("data-webpack",t+a),s.src=e),r[e]=[o];var g=(t,o)=>{s.onerror=s.onload=null,clearTimeout(f);var a=r[e];if(delete r[e],s.parentNode&&s.parentNode.removeChild(s),a&&a.forEach((e=>e(o))),t)return t(o)},f=setTimeout(g.bind(null,void 0,{type:"timeout",target:s}),12e4);s.onerror=g.bind(null,s.onerror),s.onload=g.bind(null,s.onload),c&&document.head.appendChild(s)}},n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e;n.g.importScripts&&(e=n.g.location+"");var r=n.g.document;if(!e&&r&&(r.currentScript&&(e=r.currentScript.src),!e)){var t=r.getElementsByTagName("script");if(t.length)for(var o=t.length-1;o>-1&&(!e||!/^http(s?):/.test(e));)e=t[o--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),n.p=e})(),(()=>{var e={999:0};n.f.j=(r,t)=>{var o=n.o(e,r)?e[r]:void 0;if(0!==o)if(o)t.push(o[2]);else{var a=new Promise(((t,a)=>o=e[r]=[t,a]));t.push(o[2]=a);var i=n.p+n.u(r),s=new Error;n.l(i,(t=>{if(n.o(e,r)&&(0!==(o=e[r])&&(e[r]=void 0),o)){var a=t&&("load"===t.type?"missing":t.type),i=t&&t.target&&t.target.src;s.message="Loading chunk "+r+" failed.\n("+a+": "+i+")",s.name="ChunkLoadError",s.type=a,s.request=i,o[1](s)}}),"chunk-"+r,r)}};var r=(r,t)=>{var o,a,i=t[0],s=t[1],c=t[2],l=0;if(i.some((r=>0!==e[r]))){for(o in s)n.o(s,o)&&(n.m[o]=s[o]);if(c)c(n)}for(r&&r(t);l<i.length;l++)a=i[l],n.o(e,a)&&e[a]&&e[a][0](),e[a]=0},t=this.webpackChunk_tsparticles_shape_image=this.webpackChunk_tsparticles_shape_image||[];t.forEach(r.bind(null,0)),t.push=r.bind(null,t.push.bind(t))})();var i={};return(()=>{n.r(i),n.d(i,{loadImageShape:()=>o});var e=n(764),r=n(303);const t=3;async function o(o,a=!0){!function(o){o.loadImage||(o.loadImage=async a=>{if(!a.name&&!a.src)throw new Error(`${r.errorPrefix} no image source provided`);if(o.images||(o.images=[]),!o.images.find((e=>e.name===a.name||e.source===a.src)))try{const r={gif:a.gif??!1,name:a.name??a.src,source:a.src,type:a.src.substring(a.src.length-t),error:!1,loading:!0,replaceColor:a.replaceColor,ratio:a.width&&a.height?a.width/a.height:void 0};let i;if(o.images.push(r),a.gif){const{loadGifImage:e}=await n.e(329).then(n.bind(n,329));i=e}else i=a.replaceColor?e.a:e.loadImage;await i(r)}catch{throw new Error(`${r.errorPrefix} ${a.name??a.src} not found`)}})}(o);const{ImagePreloaderPlugin:i}=await n.e(715).then(n.bind(n,715)),{ImageDrawer:s}=await n.e(33).then(n.bind(n,33)),c=new i(o);await o.addPlugin(c,a),await o.addShape(["image","images"],new s(o),a)}})(),i})()));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
/*! tsParticles Image Shape v3.
|
|
1
|
+
/*! tsParticles Image Shape v3.3.0 by Matteo Bruni */
|
package/types/ImageDrawer.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { type Container, type IShapeDrawData, type IShapeDrawer } from "@tsparticles/engine";
|
|
2
|
-
import type
|
|
2
|
+
import { type IImage, type ImageParticle } from "./Utils.js";
|
|
3
3
|
import type { ImageContainer, ImageEngine } from "./types.js";
|
|
4
4
|
export declare class ImageDrawer implements IShapeDrawer<ImageParticle> {
|
|
5
5
|
private readonly _engine;
|
|
6
6
|
constructor(engine: ImageEngine);
|
|
7
7
|
addImage(image: IImage): void;
|
|
8
|
-
draw(data: IShapeDrawData<ImageParticle>):
|
|
8
|
+
draw(data: IShapeDrawData<ImageParticle>): void;
|
|
9
9
|
getSidesCount(): number;
|
|
10
10
|
init(container: ImageContainer): Promise<void>;
|
|
11
|
-
loadShape(particle: ImageParticle):
|
|
12
|
-
particleInit(container: Container, particle: ImageParticle):
|
|
11
|
+
loadShape(particle: ImageParticle): void;
|
|
12
|
+
particleInit(container: Container, particle: ImageParticle): void;
|
|
13
13
|
private readonly loadImageShape;
|
|
14
14
|
}
|
package/umd/ImageDrawer.js
CHANGED
|
@@ -1,40 +1,18 @@
|
|
|
1
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
2
|
-
if (k2 === undefined) k2 = k;
|
|
3
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
4
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
5
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
6
|
-
}
|
|
7
|
-
Object.defineProperty(o, k2, desc);
|
|
8
|
-
}) : (function(o, m, k, k2) {
|
|
9
|
-
if (k2 === undefined) k2 = k;
|
|
10
|
-
o[k2] = m[k];
|
|
11
|
-
}));
|
|
12
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
13
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
14
|
-
}) : function(o, v) {
|
|
15
|
-
o["default"] = v;
|
|
16
|
-
});
|
|
17
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
18
|
-
if (mod && mod.__esModule) return mod;
|
|
19
|
-
var result = {};
|
|
20
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
21
|
-
__setModuleDefault(result, mod);
|
|
22
|
-
return result;
|
|
23
|
-
};
|
|
24
1
|
(function (factory) {
|
|
25
2
|
if (typeof module === "object" && typeof module.exports === "object") {
|
|
26
3
|
var v = factory(require, exports);
|
|
27
4
|
if (v !== undefined) module.exports = v;
|
|
28
5
|
}
|
|
29
6
|
else if (typeof define === "function" && define.amd) {
|
|
30
|
-
define(["require", "exports", "@tsparticles/engine"], factory);
|
|
7
|
+
define(["require", "exports", "@tsparticles/engine", "./Utils.js", "./GifUtils/Utils.js"], factory);
|
|
31
8
|
}
|
|
32
9
|
})(function (require, exports) {
|
|
33
10
|
"use strict";
|
|
34
|
-
var __syncRequire = typeof module === "object" && typeof module.exports === "object";
|
|
35
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
12
|
exports.ImageDrawer = void 0;
|
|
37
13
|
const engine_1 = require("@tsparticles/engine");
|
|
14
|
+
const Utils_js_1 = require("./Utils.js");
|
|
15
|
+
const Utils_js_2 = require("./GifUtils/Utils.js");
|
|
38
16
|
const double = 2, defaultAlpha = 1, sides = 12, defaultRatio = 1;
|
|
39
17
|
class ImageDrawer {
|
|
40
18
|
constructor(engine) {
|
|
@@ -57,15 +35,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
57
35
|
}
|
|
58
36
|
this._engine.images.push(image);
|
|
59
37
|
}
|
|
60
|
-
|
|
38
|
+
draw(data) {
|
|
61
39
|
const { context, radius, particle, opacity } = data, image = particle.image, element = image?.element;
|
|
62
40
|
if (!image) {
|
|
63
41
|
return;
|
|
64
42
|
}
|
|
65
43
|
context.globalAlpha = opacity;
|
|
66
44
|
if (image.gif && image.gifData) {
|
|
67
|
-
|
|
68
|
-
drawGif(data);
|
|
45
|
+
(0, Utils_js_2.drawGif)(data);
|
|
69
46
|
}
|
|
70
47
|
else if (element) {
|
|
71
48
|
const ratio = image.ratio, pos = {
|
|
@@ -88,7 +65,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
88
65
|
await this._engine.loadImage(imageData);
|
|
89
66
|
}
|
|
90
67
|
}
|
|
91
|
-
|
|
68
|
+
loadShape(particle) {
|
|
92
69
|
if (particle.shape !== "image" && particle.shape !== "images") {
|
|
93
70
|
return;
|
|
94
71
|
}
|
|
@@ -101,11 +78,12 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
101
78
|
}
|
|
102
79
|
const image = this._engine.images.find((t) => t.name === imageData.name || t.source === imageData.src);
|
|
103
80
|
if (!image) {
|
|
104
|
-
|
|
105
|
-
|
|
81
|
+
void this.loadImageShape(imageData).then(() => {
|
|
82
|
+
this.loadShape(particle);
|
|
83
|
+
});
|
|
106
84
|
}
|
|
107
85
|
}
|
|
108
|
-
|
|
86
|
+
particleInit(container, particle) {
|
|
109
87
|
if (particle.shape !== "image" && particle.shape !== "images") {
|
|
110
88
|
return;
|
|
111
89
|
}
|
|
@@ -123,42 +101,43 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
123
101
|
const replaceColor = imageData.replaceColor ?? image.replaceColor;
|
|
124
102
|
if (image.loading) {
|
|
125
103
|
setTimeout(() => {
|
|
126
|
-
|
|
104
|
+
this.particleInit(container, particle);
|
|
127
105
|
});
|
|
128
106
|
return;
|
|
129
107
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
108
|
+
void (async () => {
|
|
109
|
+
let imageRes;
|
|
110
|
+
if (image.svgData && color) {
|
|
111
|
+
imageRes = await (0, Utils_js_1.replaceImageColor)(image, imageData, color, particle);
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
imageRes = {
|
|
115
|
+
color,
|
|
116
|
+
data: image,
|
|
117
|
+
element: image.element,
|
|
118
|
+
gif: image.gif,
|
|
119
|
+
gifData: image.gifData,
|
|
120
|
+
gifLoopCount: image.gifLoopCount,
|
|
121
|
+
loaded: true,
|
|
122
|
+
ratio: imageData.width && imageData.height
|
|
123
|
+
? imageData.width / imageData.height
|
|
124
|
+
: image.ratio ?? defaultRatio,
|
|
125
|
+
replaceColor: replaceColor,
|
|
126
|
+
source: imageData.src,
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
if (!imageRes.ratio) {
|
|
130
|
+
imageRes.ratio = 1;
|
|
131
|
+
}
|
|
132
|
+
const fill = imageData.fill ?? particle.shapeFill, close = imageData.close ?? particle.shapeClose, imageShape = {
|
|
133
|
+
image: imageRes,
|
|
134
|
+
fill,
|
|
135
|
+
close,
|
|
149
136
|
};
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
}
|
|
154
|
-
const fill = imageData.fill ?? particle.shapeFill, close = imageData.close ?? particle.shapeClose, imageShape = {
|
|
155
|
-
image: imageRes,
|
|
156
|
-
fill,
|
|
157
|
-
close,
|
|
158
|
-
};
|
|
159
|
-
particle.image = imageShape.image;
|
|
160
|
-
particle.shapeFill = imageShape.fill;
|
|
161
|
-
particle.shapeClose = imageShape.close;
|
|
137
|
+
particle.image = imageShape.image;
|
|
138
|
+
particle.shapeFill = imageShape.fill;
|
|
139
|
+
particle.shapeClose = imageShape.close;
|
|
140
|
+
})();
|
|
162
141
|
}
|
|
163
142
|
}
|
|
164
143
|
exports.ImageDrawer = ImageDrawer;
|
package/21.min.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
/*! For license information please see 21.min.js.LICENSE.txt */
|
|
2
|
-
(this.webpackChunk_tsparticles_shape_image=this.webpackChunk_tsparticles_shape_image||[]).push([[21],{21:(e,a,i)=>{i.d(a,{ImageDrawer:()=>s});var t=i(533);class s{constructor(e){this.loadImageShape=async e=>{if(!this._engine.loadImage)throw new Error(`${t.errorPrefix} image shape not initialized`);await this._engine.loadImage({gif:e.gif,name:e.name,replaceColor:e.replaceColor??!1,src:e.src})},this._engine=e}addImage(e){this._engine.images||(this._engine.images=[]),this._engine.images.push(e)}async draw(e){const{context:a,radius:t,particle:s,opacity:n}=e,o=s.image,r=o?.element;if(o){if(a.globalAlpha=n,o.gif&&o.gifData){const{drawGif:a}=await i.e(618).then(i.bind(i,618));a(e)}else if(r){const e=o.ratio,i={x:-t,y:-t},s=2*t;a.drawImage(r,i.x,i.y,s,s/e)}a.globalAlpha=1}}getSidesCount(){return 12}async init(e){const a=e.actualOptions;if(a.preload&&this._engine.loadImage)for(const e of a.preload)await this._engine.loadImage(e)}async loadShape(e){if("image"!==e.shape&&"images"!==e.shape)return;this._engine.images||(this._engine.images=[]);const a=e.shapeData;if(!a)return;this._engine.images.find((e=>e.name===a.name||e.source===a.src))||(await this.loadImageShape(a),await this.loadShape(e))}async particleInit(e,a){if("image"!==a.shape&&"images"!==a.shape)return;this._engine.images||(this._engine.images=[]);const t=this._engine.images,s=a.shapeData;if(!s)return;const n=a.getFillColor(),o=t.find((e=>e.name===s.name||e.source===s.src));if(!o)return;const r=s.replaceColor??o.replaceColor;if(o.loading)return void setTimeout((()=>{this.particleInit(e,a)}));let l;if(o.svgData&&n){const{replaceImageColor:e}=await Promise.resolve().then(i.bind(i,103));l=await e(o,s,n,a)}else l={color:n,data:o,element:o.element,gif:o.gif,gifData:o.gifData,gifLoopCount:o.gifLoopCount,loaded:!0,ratio:s.width&&s.height?s.width/s.height:o.ratio??1,replaceColor:r,source:s.src};l.ratio||(l.ratio=1);const g={image:l,fill:s.fill??a.shapeFill,close:s.close??a.shapeClose};a.image=g.image,a.shapeFill=g.fill,a.shapeClose=g.close}}}}]);
|
package/21.min.js.LICENSE.txt
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/*! tsParticles Image Shape v3.2.2 by Matteo Bruni */
|
package/618.min.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
/*! For license information please see 618.min.js.LICENSE.txt */
|
|
2
|
-
(this.webpackChunk_tsparticles_shape_image=this.webpackChunk_tsparticles_shape_image||[]).push([[618],{618:(t,e,a)=>{a.d(e,{drawGif:()=>p,loadGifImage:()=>w});const o=[0,4,2,1],i=[8,8,4,2];class r{constructor(t){this.pos=0,this.data=new Uint8ClampedArray(t)}getString(t){const e=this.data.slice(this.pos,this.pos+t);return this.pos+=e.length,e.reduce(((t,e)=>t+String.fromCharCode(e)),"")}nextByte(){return this.data[this.pos++]}nextTwoBytes(){return this.pos+=2,this.data[this.pos-2]+(this.data[this.pos-1]<<8)}readSubBlocks(){let t="",e=0;do{e=this.data[this.pos++];for(let a=e;--a>=0;t+=String.fromCharCode(this.data[this.pos++]));}while(0!==e);return t}readSubBlocksBin(){let t=this.data[this.pos],e=0;for(let a=0;0!==t;a+=t+1,t=this.data[this.pos+a])e+=t;const a=new Uint8Array(e);t=this.data[this.pos++];for(let e=0;0!==t;t=this.data[this.pos++])for(let o=t;--o>=0;a[e++]=this.data[this.pos++]);return a}skipSubBlocks(){for(const t=1,e=0;this.data[this.pos]!==e;this.pos+=this.data[this.pos]+t);this.pos++}}const s={x:0,y:0},n=0,l=.5,h=0,c=0,g=0;function f(t,e){const a=[];for(let o=0;o<e;o++)a.push({r:t.data[t.pos],g:t.data[t.pos+1],b:t.data[t.pos+2]}),t.pos+=3;return a}async function d(t,e,a,r,s,n){switch(t.nextByte()){case 59:return!0;case 44:await async function(t,e,a,r,s,n){const l=e.frames[r(!0)];l.left=t.nextTwoBytes(),l.top=t.nextTwoBytes(),l.width=t.nextTwoBytes(),l.height=t.nextTwoBytes();const h=t.nextByte(),c=128==(128&h),g=64==(64&h);l.sortFlag=32==(32&h),l.reserved=(24&h)>>>3;const d=1<<1+(7&h);c&&(l.localColorTable=f(t,d));const p=t=>{const{r:o,g:i,b:r}=(c?l.localColorTable:e.globalColorTable)[t];return t!==s(null)?{r:o,g:i,b:r,a:255}:{r:o,g:i,b:r,a:a?~~((o+i+r)/3):0}},w=(()=>{try{return new ImageData(l.width,l.height,{colorSpace:"srgb"})}catch(t){if(t instanceof DOMException&&"IndexSizeError"===t.name)return null;throw t}})();if(null==w)throw new EvalError("GIF frame size is to large");const u=t.nextByte(),m=t.readSubBlocksBin(),y=1<<u,b=(t,e)=>{const a=t>>>3,o=7&t;return(m[a]+(m[a+1]<<8)+(m[a+2]<<16)&(1<<e)-1<<o)>>>o};if(g){for(let a=0,s=u+1,h=0,c=[[0]],g=0;g<4;g++){if(o[g]<l.height){let t=0,e=0,r=!1;for(;!r;){const n=a;if(a=b(h,s),h+=s+1,a===y){s=u+1,c.length=y+2;for(let t=0;t<c.length;t++)c[t]=t<y?[t]:[]}else{a>=c.length?c.push(c[n].concat(c[n][0])):n!==y&&c.push(c[n].concat(c[a][0]));for(const r of c[a]){const{r:a,g:s,b:n,a:h}=p(r);w.data.set([a,s,n,h],o[g]*l.width+i[g]*e+t%(4*l.width)),t+=4}c.length===1<<s&&s<12&&s++}t===4*l.width*(e+1)&&(e++,o[g]+i[g]*e>=l.height&&(r=!0))}}n?.(t.pos/(t.data.length-1),r(!1)+1,w,{x:l.left,y:l.top},{width:e.width,height:e.height})}l.image=w,l.bitmap=await createImageBitmap(w)}else{let a=0,o=u+1,i=0,s=-4,h=!1;const c=[[0]];for(;!h;){const t=a;if(a=b(i,o),i+=o,a===y){o=u+1,c.length=y+2;for(let t=0;t<c.length;t++)c[t]=t<y?[t]:[]}else{if(a===y+1){h=!0;break}a>=c.length?c.push(c[t].concat(c[t][0])):t!==y&&c.push(c[t].concat(c[a][0]));for(const t of c[a]){const{r:e,g:a,b:o,a:i}=p(t);w.data.set([e,a,o,i],s+=4)}c.length>=1<<o&&o<12&&o++}}l.image=w,l.bitmap=await createImageBitmap(w),n?.((t.pos+1)/t.data.length,r(!1)+1,l.image,{x:l.left,y:l.top},{width:e.width,height:e.height})}}(t,e,a,r,s,n);break;case 33:!function(t,e,a,o){switch(t.nextByte()){case 249:{const i=e.frames[a(!1)];t.pos++;const r=t.nextByte();i.GCreserved=(224&r)>>>5,i.disposalMethod=(28&r)>>>2,i.userInputDelayFlag=2==(2&r);const s=1==(1&r);i.delayTime=10*t.nextTwoBytes();const n=t.nextByte();s&&o(n),t.pos++;break}case 255:{t.pos++;const a={identifier:t.getString(8),authenticationCode:t.getString(3),data:t.readSubBlocksBin()};e.applicationExtensions.push(a);break}case 254:e.comments.push([a(!1),t.readSubBlocks()]);break;case 1:if(0===e.globalColorTable.length)throw new EvalError("plain text extension without global color table");t.pos++,e.frames[a(!1)].plainTextData={left:t.nextTwoBytes(),top:t.nextTwoBytes(),width:t.nextTwoBytes(),height:t.nextTwoBytes(),charSize:{width:t.nextTwoBytes(),height:t.nextTwoBytes()},foregroundColor:t.nextByte(),backgroundColor:t.nextByte(),text:t.readSubBlocks()};break;default:t.skipSubBlocks()}}(t,e,r,s);break;default:throw new EvalError("undefined block found")}return!1}function p(t){const{context:e,radius:a,particle:o,delta:i}=t,r=o.image;if(!r?.gifData||!r.gif)return;const f=new OffscreenCanvas(r.gifData.width,r.gifData.height),d=f.getContext("2d");if(!d)throw new Error("could not create offscreen canvas context");d.imageSmoothingQuality="low",d.imageSmoothingEnabled=!1,d.clearRect(s.x,s.y,f.width,f.height),void 0===o.gifLoopCount&&(o.gifLoopCount=r.gifLoopCount??g);let p=o.gifFrame??n;const w={x:-r.gifData.width*l,y:-r.gifData.height*l},u=r.gifData.frames[p];if(void 0===o.gifTime&&(o.gifTime=h),u.bitmap){switch(e.scale(a/r.gifData.width,a/r.gifData.height),u.disposalMethod){case 4:case 5:case 6:case 7:case 0:d.drawImage(u.bitmap,u.left,u.top),e.drawImage(f,w.x,w.y),d.clearRect(s.x,s.y,f.width,f.height);break;case 1:d.drawImage(u.bitmap,u.left,u.top),e.drawImage(f,w.x,w.y);break;case 2:d.drawImage(u.bitmap,u.left,u.top),e.drawImage(f,w.x,w.y),d.clearRect(s.x,s.y,f.width,f.height),r.gifData.globalColorTable.length?d.putImageData(r.gifData.backgroundImage,w.x,w.y):d.putImageData(r.gifData.frames[c].image,w.x+u.left,w.y+u.top);break;case 3:{const t=d.getImageData(s.x,s.y,f.width,f.height);d.drawImage(u.bitmap,u.left,u.top),e.drawImage(f,w.x,w.y),d.clearRect(s.x,s.y,f.width,f.height),d.putImageData(t,s.x,s.y)}}if(o.gifTime+=i.value,o.gifTime>u.delayTime){if(o.gifTime-=u.delayTime,++p>=r.gifData.frames.length){if(--o.gifLoopCount<=g)return;p=c,d.clearRect(s.x,s.y,f.width,f.height)}o.gifFrame=p}e.scale(r.gifData.width/a,r.gifData.height/a)}}async function w(t){if("gif"===t.type){t.loading=!0;try{t.gifData=await async function(t,e,a){a||(a=!1);const o=await fetch(t);if(!o.ok&&404===o.status)throw new EvalError("file not found");const i=await o.arrayBuffer(),s={width:0,height:0,totalTime:0,colorRes:0,pixelAspectRatio:0,frames:[],sortFlag:!1,globalColorTable:[],backgroundImage:new ImageData(1,1,{colorSpace:"srgb"}),comments:[],applicationExtensions:[]},n=new r(new Uint8ClampedArray(i));if("GIF89a"!==n.getString(6))throw new Error("not a supported GIF file");s.width=n.nextTwoBytes(),s.height=n.nextTwoBytes();const l=n.nextByte(),h=128==(128&l);s.colorRes=(112&l)>>>4,s.sortFlag=8==(8&l);const c=1<<1+(7&l),g=n.nextByte();s.pixelAspectRatio=n.nextByte(),0!==s.pixelAspectRatio&&(s.pixelAspectRatio=(s.pixelAspectRatio+15)/64),h&&(s.globalColorTable=f(n,c));const p=(()=>{try{return new ImageData(s.width,s.height,{colorSpace:"srgb"})}catch(t){if(t instanceof DOMException&&"IndexSizeError"===t.name)return null;throw t}})();if(null==p)throw new Error("GIF frame size is to large");const{r:w,g:u,b:m}=s.globalColorTable[g];p.data.set(h?[w,u,m,255]:[0,0,0,0]);for(let t=4;t<p.data.length;t*=2)p.data.copyWithin(t,0,t);s.backgroundImage=p;let y=-1,b=!0,x=-1;const B=t=>(t&&(b=!0),y),T=t=>(null!=t&&(x=t),x);try{do{b&&(s.frames.push({left:0,top:0,width:0,height:0,disposalMethod:0,image:new ImageData(1,1,{colorSpace:"srgb"}),plainTextData:null,userInputDelayFlag:!1,delayTime:0,sortFlag:!1,localColorTable:[],reserved:0,GCreserved:0}),y++,x=-1,b=!1)}while(!await d(n,s,a,B,T,e));s.frames.length--;for(const t of s.frames){if(t.userInputDelayFlag&&0===t.delayTime){s.totalTime=1/0;break}s.totalTime+=t.delayTime}return s}catch(t){if(t instanceof EvalError)throw new Error(`error while parsing frame ${y} "${t.message}"`);throw t}}(t.source),t.gifLoopCount=function(t){for(const e of t.applicationExtensions)if(e.identifier+e.authenticationCode==="NETSCAPE2.0")return e.data[1]+(e.data[2]<<8);return NaN}(t.gifData)??g,t.gifLoopCount||(t.gifLoopCount=1/0)}catch{t.error=!0}t.loading=!1}else{const{loadImage:e}=await Promise.resolve().then(a.bind(a,103));await e(t)}}}}]);
|
package/618.min.js.LICENSE.txt
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/*! tsParticles Image Shape v3.2.2 by Matteo Bruni */
|
package/623.min.js.LICENSE.txt
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/*! tsParticles Image Shape v3.2.2 by Matteo Bruni */
|