xxxxxxxxxx
const Canvas = document.getElementById(Id); // Id here
return Canvas.toDataURL();
xxxxxxxxxx
<canvas id="viewport"></canvas>
<style>
canvas#viewport { border: 1px solid white; width: 900px; }
</style>
<script>
var canvas = document.getElementById('viewport'),
context = canvas.getContext('2d');
make_base();
function make_base()
{
base_image = new Image();
base_image.src = 'img/base.png';
context.drawImage(base_image, 100, 100);
}
</script>
xxxxxxxxxx
function canvasURL(id) {
let canvas = document.getElementById(id);
return canvas.toDataURL(1.0);
}