Source Code:
(back to article)
Submit
Result:
Report an issue
<!DOCTYPE html> <html> <head> <title>Title of the document</title> </head> <body> <h2>Image</h2> <img id="photo" src="/uploads/media/default/0001/01/25acddb3da54207bc6beb5838f65f022feaa81d7.jpeg" alt="Aleq" width="200" height="185"> <h2>Image with canvas:</h2> <canvas id="exampleCanvas" width="240" height="225" style="border:2px solid #cccccc;"> Your browser doesn't support the canvas tag. </canvas> <script> window.onload = function() { var canvas = document.getElementById("exampleCanvas"); var ctx = canvas.getContext("2d"); var img = document.getElementById("photo"); ctx.drawImage(img, 20, 20); }; </script> </body> </html>