JSFiddle - React, Tailwind, and code Playground
HTML
<canvas id="canvas" width="400" height="400"></canvas>
<div id="container">
<svg id="mySVG" xmlns="http://www.w3.org/2000/svg" version="1.1">
<rect width="150" height="150" fill="rgb(0, 255, 0)" stroke-width="1" stroke="rgb(0, 0, 0)"/>
<image preserveAspectRatio="none" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://upload.wikimedia.org/wikipedia/en/7/70/Example.png" width="80" height="80"></image>
</svg>
</div>
CSS
canvas {
border: 1px solid gray;
}
#container {
float: left;
}
JavaScript
var canvas = document.getElementById('canvas'),
ctx = canvas.getContext('2d'),
svg = document.getElementById('container').innerHTML,
img = new Image();
img.onload = function () {
ctx.drawImage(img, 0, 0);
};
img.src = 'data:image/svg+xml,' + svg;