Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tsparticles-shape-image

Package Overview
Dependencies
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tsparticles-shape-image - npm Package Compare versions

Comparing version 2.0.0-alpha.5 to 2.0.0-alpha.6

4

package.json
{
"name": "tsparticles-shape-image",
"version": "2.0.0-alpha.5",
"version": "2.0.0-alpha.6",
"description": "tsParticles Image shape",

@@ -65,4 +65,4 @@ "homepage": "https://particles.js.org/",

"dependencies": {
"tsparticles-engine": "^2.0.0-alpha.5"
"tsparticles-engine": "^2.0.0-alpha.6"
}
}

@@ -7,3 +7,3 @@ /*!

* How to use? : Check the GitHub README
* v2.0.0-alpha.5
* v2.0.0-alpha.6
*/

@@ -10,0 +10,0 @@ (function webpackUniversalModuleDefinition(root, factory) {

@@ -1,2 +0,2 @@

/*! tsParticles Image Shape v2.0.0-alpha.5 by Matteo Bruni */
/*! tsParticles Image Shape v2.0.0-alpha.6 by Matteo Bruni */
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("tsparticles-engine"));else if("function"==typeof define&&define.amd)define(["tsparticles-engine"],t);else{var o="object"==typeof exports?t(require("tsparticles-engine")):t(e.window);for(var r in o)("object"==typeof exports?exports:e)[r]=o[r]}}(this,(function(e){return(()=>{"use strict";var t={731:(e,t,o)=>{o.r(t),o.d(t,{loadImageShape:()=>p});var r=o(414),n=function(e,t,o,r){return new(o||(o=Promise))((function(n,i){function a(e){try{l(r.next(e))}catch(e){i(e)}}function s(e){try{l(r.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?n(e.value):(t=e.value,t instanceof o?t:new o((function(e){e(t)}))).then(a,s)}l((r=r.apply(e,t||[])).next())}))};function i(e){return new Promise(((t,o)=>{if(!e)return void o("Error tsParticles - No image.src");const r={source:e,type:e.substr(e.length-3)},n=new Image;n.addEventListener("load",(()=>{r.element=n,t(r)})),n.addEventListener("error",(()=>{o("Error tsParticles - loading image: "+e)})),n.src=e}))}function a(e){return n(this,void 0,void 0,(function*(){if(!e)throw new Error("Error tsParticles - No image.src");const t={source:e,type:e.substr(e.length-3)};if("svg"!==t.type)return i(e);const o=yield fetch(t.source);if(!o.ok)throw new Error("Error tsParticles - Image not found");return t.svgData=yield o.text(),t}))}var s,l=function(e,t,o,r){return new(o||(o=Promise))((function(n,i){function a(e){try{l(r.next(e))}catch(e){i(e)}}function s(e){try{l(r.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?n(e.value):(t=e.value,t instanceof o?t:new o((function(e){e(t)}))).then(a,s)}l((r=r.apply(e,t||[])).next())}))},c=function(e,t,o){if(!t.has(e))throw new TypeError("attempted to set private field on non-instance");return t.set(e,o),o},d=function(e,t){if(!t.has(e))throw new TypeError("attempted to get private field on non-instance");return t.get(e)};class u{constructor(){s.set(this,void 0),c(this,s,[])}getSidesCount(){return 12}getImages(e){const t=d(this,s).find((t=>t.id===e.id));return t||(d(this,s).push({id:e.id,images:[]}),this.getImages(e))}addImage(e,t){const o=this.getImages(e);null==o||o.images.push(t)}init(e){const t=e.actualOptions.particles.shape;return this.initShape(e,t)}destroy(){c(this,s,[])}initShape(e,t){var o;return l(this,void 0,void 0,(function*(){const r=null!==(o=t.options.image)&&void 0!==o?o:t.options.images;if(r instanceof Array){const t=[];for(const o of r)t.push(this.loadImageShape(e,o));yield Promise.allSettled(t)}else yield this.loadImageShape(e,r)}))}loadImageShape(e,t){return l(this,void 0,void 0,(function*(){try{const o=t.replaceColor?a:i,r=yield o(t.src);r&&this.addImage(e,r)}catch(e){console.warn(`tsParticles error - ${t.src} not found`)}}))}draw(e,t,o,r){var n,i;if(!e)return;const a=t.image,s=null===(n=null==a?void 0:a.data)||void 0===n?void 0:n.element;if(!s)return;const l=null!==(i=null==a?void 0:a.ratio)&&void 0!==i?i:1,c={x:-o,y:-o};(null==a?void 0:a.data.svgData)&&(null==a?void 0:a.replaceColor)||(e.globalAlpha=r),e.drawImage(s,c.x,c.y,2*o,2*o/l),(null==a?void 0:a.data.svgData)&&(null==a?void 0:a.replaceColor)||(e.globalAlpha=1)}loadShape(e){var t,o,n,a,s;if("image"!==e.shape&&"images"!==e.shape)return;const l=e.container,c=this.getImages(l).images,d=e.shapeData,u=null!==(t=c.find((e=>e.source===d.src)))&&void 0!==t?t:c[0],p=e.getFillColor();let f;if(!u)return;if(void 0!==u.svgData&&d.replaceColor&&p){const t=function(e,t,o){return e.svgData?e.svgData.replace(/#([0-9A-F]{3,6})/gi,(()=>(0,r.getStyleFromHsl)(t,o))):""}(u,p,e.opacity.value),n=new Blob([t],{type:"image/svg+xml"}),a=URL||window.URL||window.webkitURL||window,s=a.createObjectURL(n),l=new Image;f={data:u,ratio:d.width/d.height,replaceColor:null!==(o=d.replaceColor)&&void 0!==o?o:d.replace_color,source:d.src},l.addEventListener("load",(()=>{const t=e.image;t&&(t.loaded=!0,u.element=l),a.revokeObjectURL(s)})),l.addEventListener("error",(()=>{a.revokeObjectURL(s),i(d.src).then((t=>{const o=e.image;o&&(u.element=null==t?void 0:t.element,o.loaded=!0)}))})),l.src=s}else f={data:u,loaded:!0,ratio:d.width/d.height,replaceColor:null!==(n=d.replaceColor)&&void 0!==n?n:d.replace_color,source:d.src};f.ratio||(f.ratio=1);const g={image:f,fill:null!==(a=d.fill)&&void 0!==a?a:e.fill,close:null!==(s=d.close)&&void 0!==s?s:e.close};e.image=g.image,e.fill=g.fill,e.close=g.close}}function p(e){const t=new u;e.addShape("image",t),e.addShape("images",t)}s=new WeakMap},414:t=>{t.exports=e}},o={};function r(e){if(o[e])return o[e].exports;var n=o[e]={exports:{}};return t[e](n,n.exports,r),n.exports}return r.d=(e,t)=>{for(var o in t)r.o(t,o)&&!r.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r(731)})()}));

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc