I am using canvas lib for converting sag to canvas however I can't figure out how to get converted canvas and store it in the variable?
function converttoCanvas(svg, callback) {
var canvas = document.createElement("canvas"); // Create a Canvas element.
var ctx = canvas.getContext("2d"); // For Canvas returns 2D graphic.
var data = svg.outerHTML; // Get SVG element as HTML code.
Canvg(canvas, data); // Render SVG on Canvas.
callback(canvas); // Execute callback function.
}
I just found this code from the blog but seems like I am doing something wrong. How can I get the new canvas element stored in the variable?