Created
October 25, 2018 01:49
-
-
Save philcon93/a14925b9c83fff7384f8592db2912158 to your computer and use it in GitHub Desktop.
Make a canvas, then convert it to an image
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<canvas id="viewport"></canvas> | |
<script> | |
var canvas = document.getElementById('viewport'); | |
var context = canvas.getContext('2d'); | |
make_base(); | |
var img = canvas.toDataURL("image/png"); | |
document.write('<img src="'+img+'"/>'); | |
function make_base(){ | |
var base_image = new Image(); | |
base_image.src = '/assets/thumbL/52.png'; | |
base_image.onload = function(){ | |
context.drawImage(base_image, 0, 0); | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment