Last active
January 20, 2020 13:36
-
-
Save john92paul/a75a3df1457c39eefc9e103c996045ac to your computer and use it in GitHub Desktop.
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
<!-- HTML --> | |
<html> | |
<body> | |
<canvas id="myCanvas" width="750" height="500">your canvas loads here</canvas> | |
</body> | |
</html> | |
<!-- Javascript --> | |
<script> | |
var myCanvas = document.getElementById("myCanvas"); | |
var myContext = myCanvas.getContext("2d"); | |
myCanvas.width="750"; // Optional | |
myCanvas.height="500"; // Optional | |
var myImage=new Image(); | |
myImage.src="https://images.unsplash.com/photo-1572800578930-fd1013b506c1?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=750&q=80"; | |
myImage.onload=function(){ | |
myContext.drawImage(myImage,0,0,myCanvas.width,myCanvas.height); | |
}; | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment