Why the image is not showing on the canvas? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
8th May 2020, 6:07 PM
Anutosh Kumar
Anutosh Kumar - avatar
1 Answer
+ 10
Here's how I fixed the JavaScript section: window.onload = () => { var cvs=document.getElementById("canvas"); var ctx=cvs.getContext("2d"); var image= new Image; image.onload = () => { ctx.drawImage(image,10,10); } image.src="https://upload.wikimedia.org/wikipedia/commons/4/4b/Phaethon_lepturus_-Midway_Atoll%2C_USA_-flying-8.jpg"; };
8th May 2020, 6:54 PM
Igor Makarsky
Igor Makarsky - avatar