static svgToCanvas(svg, canvas, width, height, callback = null) {
    svg.setAttributeNS(null, 'width', width);
    svg.setAttributeNS(null, 'height', height);
    let image = new Image();

    image.onload = function () {
      canvas.width = width;
      canvas.height = height;
      let context = canvas.getContext('2d');
      context.imageSmoothingEnabled = false;
      context.drawImage(image, 0, 0, width, height);

      if (callback) {
        callback(canvas);
      }
    };

    image.onerror = function (err) {
      console.log(err);
    };

    image.src = 'data:image/svg+xml;charset-utf-8,' + encodeURIComponent(svg.outerHTML);
    return canvas;
  }
Convert an SVG to a canvas. Warning: This happens async!

@param {SVGElement} svg 
@param {HTMLCanvasElement} canvas 
@param {Number} width 
@param {Number} height 
@param {CallableFunction} callback
@returns {HTMLCanvasElement} The input html canvas element after drawing to.