tsparticles-shape-image
Advanced tools
Comparing version 2.1.1 to 2.1.2
{ | ||
"name": "tsparticles-shape-image", | ||
"version": "2.1.1", | ||
"version": "2.1.2", | ||
"description": "tsParticles image shape", | ||
@@ -47,4 +47,4 @@ "homepage": "https://particles.js.org/", | ||
"dependencies": { | ||
"tsparticles-engine": "^2.1.1" | ||
"tsparticles-engine": "^2.1.2" | ||
} | ||
} |
@@ -7,3 +7,3 @@ /*! | ||
* How to use? : Check the GitHub README | ||
* v2.1.1 | ||
* v2.1.2 | ||
*/ | ||
@@ -10,0 +10,0 @@ (function webpackUniversalModuleDefinition(root, factory) { |
@@ -1,2 +0,2 @@ | ||
/*! tsParticles Image Shape v2.1.1 by Matteo Bruni */ | ||
/*! tsParticles Image Shape v2.1.2 by Matteo Bruni */ | ||
!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=>(()=>{"use strict";var r={818:r=>{r.exports=e}},t={};function o(e){var a=t[e];if(void 0!==a)return a.exports;var i=t[e]={exports:{}};return r[e](i,i.exports,o),i.exports}o.d=(e,r)=>{for(var t in r)o.o(r,t)&&!o.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},o.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var a={};return(()=>{o.r(a),o.d(a,{loadImageShape:()=>u});var e=o(818);const r=/(#(?:[0-9a-f]{2}){2,4}|(#[0-9a-f]{3})|(rgb|hsl)a?\((-?\d+%?[,\s]+){2,3}\s*[\d.]+%?\))|currentcolor/gi;async function t(e){return new Promise((r=>{e.loading=!0;const t=new Image;t.addEventListener("load",(()=>{e.element=t,e.loading=!1,r()})),t.addEventListener("error",(()=>{e.error=!0,e.loading=!1,console.error(`Error tsParticles - loading image: ${e.source}`),r()})),t.src=e.source}))}async function i(e){if("svg"!==e.type)return void await t(e);e.loading=!0;const r=await fetch(e.source);e.loading=!1,r.ok||(console.error("Error tsParticles - Image not found"),e.error=!0),e.error||(e.svgData=await r.text())}function n(o,a,i,n){var s,l,c;const d=function(t,o,a){const{svgData:i}=t;if(!i)return"";const n=(0,e.getStyleFromHsl)(o,a);if(i.includes("fill"))return i.replace(r,(()=>n));const s=i.indexOf(">");return`${i.substring(0,s)} fill="${n}"${i.substring(s)}`}(o,i,null!==(l=null===(s=n.opacity)||void 0===s?void 0:s.value)&&void 0!==l?l:1),u=new Blob([d],{type:"image/svg+xml"}),g=URL||window.URL||window.webkitURL||window,f=g.createObjectURL(u),p=new Image,v={data:Object.assign(Object.assign({},o),{svgData:d}),ratio:a.width/a.height,replaceColor:null!==(c=a.replaceColor)&&void 0!==c?c:a.replace_color,source:a.src};return p.addEventListener("load",(()=>{const e=n.image;e&&(e.loaded=!0,o.element=p),g.revokeObjectURL(f)})),p.addEventListener("error",(()=>{g.revokeObjectURL(f);const e=Object.assign(Object.assign({},o),{error:!1,loading:!0});t(e).then((()=>{const r=n.image;r&&(o.element=e.element,r.loaded=!0)}))})),p.src=f,v}var s,l=function(e,r,t,o,a){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!a)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof r?e!==r||!a:!r.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?a.call(e,t):a?a.value=t:r.set(e,t),t},c=function(e,r,t,o){if("a"===t&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof r?e!==r||!o:!r.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===t?o:"a"===t?o.call(e):o?o.value:r.get(e)};class d{constructor(){s.set(this,void 0),l(this,s,[],"f")}addImage(e,r){const t=this.getImages(e);null==t||t.images.push(r)}destroy(){l(this,s,[],"f")}draw(e,r,t,o){var a,i;const n=r.image,s=null===(a=null==n?void 0:n.data)||void 0===a?void 0:a.element;if(!s)return;const l=null!==(i=null==n?void 0:n.ratio)&&void 0!==i?i:1,c={x:-t,y:-t};(null==n?void 0:n.data.svgData)&&(null==n?void 0:n.replaceColor)||(e.globalAlpha=o),e.drawImage(s,c.x,c.y,2*t,2*t/l),(null==n?void 0:n.data.svgData)&&(null==n?void 0:n.replaceColor)||(e.globalAlpha=1)}getImages(e){const r=c(this,s,"f").find((r=>r.id===e.id));return r||(c(this,s,"f").push({id:e.id,images:[]}),this.getImages(e))}getSidesCount(){return 12}loadShape(e){var r,t,o;if("image"!==e.shape&&"images"!==e.shape)return;const a=this.getImages(e.container).images,i=e.shapeData,s=a.find((e=>e.source===i.src));let l;if(!s)return void this.loadImageShape(e.container,i).then((()=>{this.loadShape(e)}));if(s.error)return;const c=e.getFillColor();l=s.svgData&&i.replaceColor&&c?n(s,i,c,e):{data:s,loaded:!0,ratio:i.width/i.height,replaceColor:null!==(r=i.replaceColor)&&void 0!==r?r:i.replace_color,source:i.src},l.ratio||(l.ratio=1);const d={image:l,fill:null!==(t=i.fill)&&void 0!==t?t:e.fill,close:null!==(o=i.close)&&void 0!==o?o:e.close};e.image=d.image,e.fill=d.fill,e.close=d.close}async loadImageShape(e,r){const o=r.src;if(!o)throw new Error("Error tsParticles - No image.src");try{const a={source:o,type:o.substr(o.length-3),error:!1,loading:!0};this.addImage(e,a);const n=r.replaceColor?i:t;await n(a)}catch(e){throw new Error(`tsParticles error - ${r.src} not found`)}}}async function u(e){const r=new d;await e.addShape("image",r),await e.addShape("images",r)}s=new WeakMap})(),a})())); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Updatedtsparticles-engine@^2.1.2