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.1 to 2.0.0-alpha.2

2

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

@@ -5,0 +5,0 @@ "homepage": "https://particles.matteobruni.it/",

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

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

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

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

/*! tsParticles Image Shape v2.0.0-alpha.1 by Matteo Bruni */
/*! tsParticles Image Shape v2.0.0-alpha.2 by Matteo Bruni */
!function(e,o){if("object"==typeof exports&&"object"==typeof module)module.exports=o(require("tsparticles-core"));else if("function"==typeof define&&define.amd)define(["tsparticles-core"],o);else{var t="object"==typeof exports?o(require("tsparticles-core")):o(e.window);for(var i in t)("object"==typeof exports?exports:e)[i]=t[i]}}(this,(function(e){return(()=>{"use strict";var o={73:(e,o,t)=>{t.r(o);var i=t(646),a=function(e,o,t,i){return new(t||(t=Promise))((function(a,r){function l(e){try{s(i.next(e))}catch(e){r(e)}}function n(e){try{s(i.throw(e))}catch(e){r(e)}}function s(e){var o;e.done?a(e.value):(o=e.value,o instanceof t?o:new t((function(e){e(o)}))).then(l,n)}s((i=i.apply(e,o||[])).next())}))};class r{constructor(){this.images=[]}getSidesCount(){return 12}getImages(e){const o=this.images.filter((o=>o.id===e.id));return o.length?o[0]:(this.images.push({id:e.id,images:[]}),this.getImages(e))}addImage(e,o){const t=this.getImages(e);null==t||t.images.push(o)}init(e){var o;return a(this,void 0,void 0,(function*(){const t=e.options.particles.shape;if(!(0,i.isInArray)("image",t.type)&&!(0,i.isInArray)("images",t.type))return;const a=null!==(o=t.options.images)&&void 0!==o?o:t.options.image;if(a instanceof Array){const o=[];for(const t of a)o.push(this.loadImageShape(e,t));yield Promise.allSettled(o)}else yield this.loadImageShape(e,a)}))}destroy(){this.images=[]}loadImageShape(e,o){return a(this,void 0,void 0,(function*(){try{const t=o.replaceColor?(0,i.downloadSvgImage)(o.src):(0,i.loadImage)(o.src),a=yield t;a&&this.addImage(e,a)}catch(e){console.warn(`tsParticles error - ${o.src} not found`)}}))}draw(e,o,t,i){var a,r;if(!e)return;const l=o.image,n=null===(a=null==l?void 0:l.data)||void 0===a?void 0:a.element;if(!n)return;const s=null!==(r=null==l?void 0:l.ratio)&&void 0!==r?r:1,c={x:-t,y:-t};(null==l?void 0:l.data.svgData)&&(null==l?void 0:l.replaceColor)||(e.globalAlpha=i),e.drawImage(n,c.x,c.y,2*t,2*t/s),(null==l?void 0:l.data.svgData)&&(null==l?void 0:l.replaceColor)||(e.globalAlpha=1)}loadShape(e){var o,t,a,r,l;if("image"!==e.shape&&"images"!==e.shape)return;const n=e.container,s=this.getImages(n).images,c=e.shapeData,d=null!==(o=s.find((e=>e.source===c.src)))&&void 0!==o?o:s[0],u=e.getFillColor();let g;if(!d)return;if(void 0!==d.svgData&&c.replaceColor&&u){const o=(0,i.replaceColorSvg)(d,u,e.opacity.value),a=new Blob([o],{type:"image/svg+xml"}),r=URL||window.URL||window.webkitURL||window,l=r.createObjectURL(a),n=new Image;g={data:d,ratio:c.width/c.height,replaceColor:null!==(t=c.replaceColor)&&void 0!==t?t:c.replace_color,source:c.src},n.addEventListener("load",(()=>{const o=e.image;o&&(o.loaded=!0,d.element=n),r.revokeObjectURL(l)})),n.addEventListener("error",(()=>{r.revokeObjectURL(l),(0,i.loadImage)(c.src).then((o=>{const t=e.image;t&&(d.element=null==o?void 0:o.element,t.loaded=!0)}))})),n.src=l}else g={data:d,loaded:!0,ratio:c.width/c.height,replaceColor:null!==(a=c.replaceColor)&&void 0!==a?a:c.replace_color,source:c.src};g.ratio||(g.ratio=1);const p={image:g,fill:null!==(r=c.fill)&&void 0!==r?r:e.fill,close:null!==(l=c.close)&&void 0!==l?l:e.close};e.image=p.image,e.fill=p.fill,e.close=p.close}}!function(e){const o=new r;e.addShape("image",o),e.addShape("images",o)}(i.tsParticles)},646:o=>{o.exports=e}},t={};function i(e){if(t[e])return t[e].exports;var a=t[e]={exports:{}};return o[e](a,a.exports,i),a.exports}return i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i(73)})()}));

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