Source Code:
(back to article)
<!DOCTYPE html> <html> <head> <title>Title of the Document</title> <style type="text/css"> canvas { border: 1px solid black; } </style> </head> <body onload="paint()"> <script type="text/javascript"> function paint() { let canvas = document.getElementById("canvas"); let ctx = canvas.getContext("2d"); let img = new Image(); img.onload = function() { ctx.drawImage(img, 0, 0); }; img.src = 'http://www.w3docs.com/uploads/media/book_gallery/0001/01/066705b46be05dfdde77a1bc60c120b76257b553.png'; } </script> <canvas id="canvas" width="250" height="250"></canvas> </body> </html>
Result:
Report an issue