fabric
Version:
Object model for HTML5 canvas, and SVG-to-canvas parser. Backed by jsdom and node-canvas.
2 lines • 740 B
JavaScript
import{FabricError as e}from"../internals/console.min.mjs";import{getFabricDocument as t}from"../../env/index.min.mjs";const n=()=>{let n=t().createElement(`canvas`);if(!n||n.getContext===void 0)throw new e("Failed to create `canvas` element");return n},r=()=>t().createElement(`img`),i=e=>{var t;let n=a(e);return(t=n.getContext(`2d`))==null||t.drawImage(e,0,0),n},a=e=>{let t=n();return t.width=e.width,t.height=e.height,t},o=(e,t,n)=>e.toDataURL(`image/${t}`,n),s=e=>!!e&&e.getContext!==void 0,c=(e,t,n)=>new Promise((r,i)=>{e.toBlob(r,`image/${t}`,n)});export{i as copyCanvasElement,n as createCanvasElement,a as createCanvasElementFor,r as createImage,s as isHTMLCanvas,c as toBlob,o as toDataURL};
//# sourceMappingURL=dom.min.mjs.map