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

tsparticles-shape-image

Package Overview
Dependencies
Maintainers
2
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.6.0 to 2.7.0

4

browser/index.js
import { ImageDrawer } from "./ImageDrawer";
export async function loadImageShape(engine) {
const imageDrawer = new ImageDrawer();
await engine.addShape("image", imageDrawer);
await engine.addShape("images", imageDrawer);
await engine.addShape(["image", "images"], new ImageDrawer());
}

@@ -16,7 +16,5 @@ "use strict";

return __awaiter(this, void 0, void 0, function* () {
const imageDrawer = new ImageDrawer_1.ImageDrawer();
yield engine.addShape("image", imageDrawer);
yield engine.addShape("images", imageDrawer);
yield engine.addShape(["image", "images"], new ImageDrawer_1.ImageDrawer());
});
}
exports.loadImageShape = loadImageShape;
import { ImageDrawer } from "./ImageDrawer";
export async function loadImageShape(engine) {
const imageDrawer = new ImageDrawer();
await engine.addShape("image", imageDrawer);
await engine.addShape("images", imageDrawer);
await engine.addShape(["image", "images"], new ImageDrawer());
}
{
"name": "tsparticles-shape-image",
"version": "2.6.0",
"version": "2.7.0",
"description": "tsParticles image shape",

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

"dependencies": {
"tsparticles-engine": "^2.6.0"
"tsparticles-engine": "^2.7.0"
}
}

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

* How to use? : Check the GitHub README
* v2.6.0
* v2.7.0
*/

@@ -324,5 +324,3 @@ (function webpackUniversalModuleDefinition(root, factory) {

async function loadImageShape(engine) {
const imageDrawer = new ImageDrawer();
await engine.addShape("image", imageDrawer);
await engine.addShape("images", imageDrawer);
await engine.addShape(["image", "images"], new ImageDrawer());
}

@@ -329,0 +327,0 @@ })();

/*! For license information please see tsparticles.shape.image.min.js.LICENSE.txt */
!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 r="object"==typeof exports?t(require("tsparticles-engine")):t(e.window);for(var o in r)("object"==typeof exports?exports:e)[o]=r[o]}}(this,(e=>(()=>{"use strict";var t={961:t=>{t.exports=e}},r={};function o(e){var a=r[e];if(void 0!==a)return a.exports;var i=r[e]={exports:{}};return t[e](i,i.exports,o),i.exports}o.d=(e,t)=>{for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),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:()=>l});var e=o(961);const t=/(#(?:[0-9a-f]{2}){2,4}|(#[0-9a-f]{3})|(rgb|hsl)a?\((-?\d+%?[,\s]+){2,3}\s*[\d.]+%?\))|currentcolor/gi;async function r(e){return new Promise((t=>{e.loading=!0;const r=new Image;e.element=r,r.addEventListener("load",(()=>{e.loading=!1,t()})),r.addEventListener("error",(()=>{e.element=void 0,e.error=!0,e.loading=!1,console.error(`Error tsParticles - loading image: ${e.source}`),t()})),r.src=e.source}))}async function i(e){if("svg"!==e.type)return void await r(e);e.loading=!0;const t=await fetch(e.source);t.ok||(console.error("Error tsParticles - Image not found"),e.error=!0),e.error||(e.svgData=await t.text()),e.loading=!1}function s(o,a,i,s){var n,l,c;const d=function(r,o,a){const{svgData:i}=r;if(!i)return"";const s=(0,e.getStyleFromHsl)(o,a);if(i.includes("fill"))return i.replace(t,(()=>s));const n=i.indexOf(">");return`${i.substring(0,n)} fill="${s}"${i.substring(n)}`}(o,i,null!==(l=null===(n=s.opacity)||void 0===n?void 0:n.value)&&void 0!==l?l:1),g={color:i,data:Object.assign(Object.assign({},o),{svgData:d}),loaded:!1,ratio:a.width/a.height,replaceColor:null!==(c=a.replaceColor)&&void 0!==c?c:a.replace_color,source:a.src};return new Promise((e=>{const t=new Blob([d],{type:"image/svg+xml"}),a=URL||window.URL||window.webkitURL||window,i=a.createObjectURL(t),s=new Image;s.addEventListener("load",(()=>{g.loaded=!0,g.element=s,e(g),a.revokeObjectURL(i)})),s.addEventListener("error",(async()=>{a.revokeObjectURL(i);const t=Object.assign(Object.assign({},o),{error:!1,loading:!0});await r(t),g.loaded=!0,g.element=t.element,e(g)})),s.src=i}))}class n{constructor(){this._images=[]}addImage(e,t){const r=this.getImages(e);null==r||r.images.push(t)}destroy(){this._images=[]}draw(e,t,r,o){var a;const i=t.image,s=null==i?void 0:i.element;if(!s)return;const n=null!==(a=null==i?void 0:i.ratio)&&void 0!==a?a:1,l={x:-r,y:-r};e.globalAlpha=o,e.drawImage(s,l.x,l.y,2*r,2*r/n),e.globalAlpha=1}getImages(e){const t=this._images.find((t=>t.id===e.id));return t||(this._images.push({id:e.id,images:[]}),this.getImages(e))}getSidesCount(){return 12}loadShape(e){if("image"!==e.shape&&"images"!==e.shape)return;const t=e.container,r=this.getImages(t).images,o=e.shapeData;r.find((e=>e.source===o.src))||this.loadImageShape(t,o).then((()=>{this.loadShape(e)}))}particleInit(e,t){var r;if("image"!==t.shape&&"images"!==t.shape)return;const o=this.getImages(e).images,a=t.shapeData,i=t.getFillColor(),n=null!==(r=a.replaceColor)&&void 0!==r?r:a.replace_color,l=o.find((e=>e.source===a.src));l&&(l.loading?setTimeout((()=>{this.particleInit(e,t)})):(async()=>{var e,r;let o;o=l.svgData&&i?await s(l,a,i,t):{color:i,data:l,element:l.element,loaded:!0,ratio:a.width/a.height,replaceColor:n,source:a.src},o.ratio||(o.ratio=1);const c={image:o,fill:null!==(e=a.fill)&&void 0!==e?e:t.fill,close:null!==(r=a.close)&&void 0!==r?r:t.close};t.image=c.image,t.fill=c.fill,t.close=c.close})())}async loadImageShape(e,t){var o;const a=t.src;if(!a)throw new Error("Error tsParticles - No image.src");try{const s={source:a,type:a.substring(a.length-3),error:!1,loading:!0};this.addImage(e,s);const n=(null!==(o=t.replaceColor)&&void 0!==o?o:t.replace_color)?i:r;await n(s)}catch(e){throw new Error(`tsParticles error - ${t.src} not found`)}}}async function l(e){const t=new n;await e.addShape("image",t),await e.addShape("images",t)}})(),a})()));
!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={961: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:()=>l});var e=o(961);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;e.element=t,t.addEventListener("load",(()=>{e.loading=!1,r()})),t.addEventListener("error",(()=>{e.element=void 0,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);r.ok||(console.error("Error tsParticles - Image not found"),e.error=!0),e.error||(e.svgData=await r.text()),e.loading=!1}function s(o,a,i,s){var n,l,c;const d=function(t,o,a){const{svgData:i}=t;if(!i)return"";const s=(0,e.getStyleFromHsl)(o,a);if(i.includes("fill"))return i.replace(r,(()=>s));const n=i.indexOf(">");return`${i.substring(0,n)} fill="${s}"${i.substring(n)}`}(o,i,null!==(l=null===(n=s.opacity)||void 0===n?void 0:n.value)&&void 0!==l?l:1),g={color:i,data:Object.assign(Object.assign({},o),{svgData:d}),loaded:!1,ratio:a.width/a.height,replaceColor:null!==(c=a.replaceColor)&&void 0!==c?c:a.replace_color,source:a.src};return new Promise((e=>{const r=new Blob([d],{type:"image/svg+xml"}),a=URL||window.URL||window.webkitURL||window,i=a.createObjectURL(r),s=new Image;s.addEventListener("load",(()=>{g.loaded=!0,g.element=s,e(g),a.revokeObjectURL(i)})),s.addEventListener("error",(async()=>{a.revokeObjectURL(i);const r=Object.assign(Object.assign({},o),{error:!1,loading:!0});await t(r),g.loaded=!0,g.element=r.element,e(g)})),s.src=i}))}class n{constructor(){this._images=[]}addImage(e,r){const t=this.getImages(e);null==t||t.images.push(r)}destroy(){this._images=[]}draw(e,r,t,o){var a;const i=r.image,s=null==i?void 0:i.element;if(!s)return;const n=null!==(a=null==i?void 0:i.ratio)&&void 0!==a?a:1,l={x:-t,y:-t};e.globalAlpha=o,e.drawImage(s,l.x,l.y,2*t,2*t/n),e.globalAlpha=1}getImages(e){const r=this._images.find((r=>r.id===e.id));return r||(this._images.push({id:e.id,images:[]}),this.getImages(e))}getSidesCount(){return 12}loadShape(e){if("image"!==e.shape&&"images"!==e.shape)return;const r=e.container,t=this.getImages(r).images,o=e.shapeData;t.find((e=>e.source===o.src))||this.loadImageShape(r,o).then((()=>{this.loadShape(e)}))}particleInit(e,r){var t;if("image"!==r.shape&&"images"!==r.shape)return;const o=this.getImages(e).images,a=r.shapeData,i=r.getFillColor(),n=null!==(t=a.replaceColor)&&void 0!==t?t:a.replace_color,l=o.find((e=>e.source===a.src));l&&(l.loading?setTimeout((()=>{this.particleInit(e,r)})):(async()=>{var e,t;let o;o=l.svgData&&i?await s(l,a,i,r):{color:i,data:l,element:l.element,loaded:!0,ratio:a.width/a.height,replaceColor:n,source:a.src},o.ratio||(o.ratio=1);const c={image:o,fill:null!==(e=a.fill)&&void 0!==e?e:r.fill,close:null!==(t=a.close)&&void 0!==t?t:r.close};r.image=c.image,r.fill=c.fill,r.close=c.close})())}async loadImageShape(e,r){var o;const a=r.src;if(!a)throw new Error("Error tsParticles - No image.src");try{const s={source:a,type:a.substring(a.length-3),error:!1,loading:!0};this.addImage(e,s);const n=(null!==(o=r.replaceColor)&&void 0!==o?o:r.replace_color)?i:t;await n(s)}catch(e){throw new Error(`tsParticles error - ${r.src} not found`)}}}async function l(e){await e.addShape(["image","images"],new n)}})(),a})()));

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

* How to use? : Check the GitHub README
* v2.6.0
* v2.7.0
*/

@@ -25,3 +25,3 @@ import type { IHsl, Particle } from "tsparticles-engine";

}
export declare type ImageParticle = Particle & {
export type ImageParticle = Particle & {
image?: IParticleImage;

@@ -28,0 +28,0 @@ };

@@ -15,7 +15,5 @@ (function (factory) {

async function loadImageShape(engine) {
const imageDrawer = new ImageDrawer_1.ImageDrawer();
await engine.addShape("image", imageDrawer);
await engine.addShape("images", imageDrawer);
await engine.addShape(["image", "images"], new ImageDrawer_1.ImageDrawer());
}
exports.loadImageShape = loadImageShape;
});

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