Every line of 'npm html2canvas' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.
63 var toCanvas = function toCanvas(svgData, width, height, callback) { 64 var src = 'data:image/svg+xml;charset=utf-8;base64,' + svgData; 65 var canvas = document.createElement('canvas'); 66 var context = canvas.getContext('2d'); 67 var image = new window.Image(); 68 canvas.width = width; 69 canvas.height = height; 70 image.onload = function () { 71 context.drawImage(image, 0, 0); 72 callback(canvas); 73 }; 74 image.src = src; 75 };
167 function createCanvas (elm, p) { 168 const $canvas = document.createElement('canvas') 169 $canvas.width = p.cw 170 $canvas.height = p.ch 171 const ctx = $canvas.getContext('2d') 172 ctx.drawImage(elm, p.sx, p.sy, p.sw, p.sh, 0, 0, $canvas.width, $canvas.height) 173 return $canvas 174 }
326 function canvasToBuffer(canvas) { 327 // https://github.com/mattdesl/electron-canvas-to-buffer/blob/master/index.js 328 const url = canvas.toDataURL("image/png", 1); 329 const nativeImage = electron.nativeImage.createFromDataURL(url); 330 const buffer = nativeImage.toPNG(); 331 332 return buffer; 333 }
184 function toCanvas(o) { 185 var canvas; 186 if (typeof o == "object") { 187 if (typeof o.tagName == "string") { 188 if (o.tagName.toLowerCase() == "canvas" || o.tagName.toLowerCase() == "img") { 189 canvas = document.createElement("canvas"); 190 canvas.width = o.width; 191 canvas.height = o.height; 192 canvas.getContext("2d").drawImage(o, 0,0); 193 } 194 } else if ((window.ImageData && o instanceof window.ImageData) 195 || (typeof o.width == "number" && typeof o.height == "number" && typeof o.data == "object")) { 196 canvas = document.createElement("canvas"); 197 canvas.width = o.width; 198 canvas.height = o.height; 199 canvas.getContext("2d").putImageData(o, 0, 0); 200 } 201 } 202 return canvas; 203 };
3 export function createCanvas(width, height) { 4 const canvas = document.createElement('canvas'); 5 canvas.width = width; 6 canvas.height = height; 7 return canvas; 8 }
4 function createCanvas() { 5 return new Canvas(); 6 }
3 module.exports = function convertImageToCanvas(image) { 4 var canvas = new Canvas(image.width, image.height); 5 canvas.getContext("2d").drawImage(image, 0, 0); 6 return canvas; 7 };
68 function canvas() { 69 return canvasElement; 70 }