Prev Demo
Canvasimage
Next Demo
Write code here
J
|
B
|
A
<!DOCTYPE html> <html> <head> <title>CanvasImage</title> </head> <body> <canvas id="myCanvas" width="500" height="200"></canvas> <script> var canvas = document.getElementById('myCanvas'); var context = canvas.getContext('2d'); var imageObj = new Image(); imageObj.onload = function () { context.drawImage(imageObj, 20, 40); }; imageObj.src = "http://techfunda.com/HTPictures/Generics/1-635716259621984414.jpg"; </script> </body> </html>
Note: We DO NOT save your trial code in our database.
Output