Javascript examples for DOM HTML Element:Image
Place an image behind other drawings on Canvas
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=( function() {/*from w w w. j a v a 2 s. com*/ var can = document.getElementById('canvas1'); var ctx = can.getContext('2d'); var img = new Image(); img.onload = function() { ctx.drawImage(img, 0, 0); ctx.fillRect(50,50,150,150); } img.src = 'http://placekitten.com/500/500'; }); </script> </head> <body> <canvas id="canvas1" width="500" height="500"></canvas> </body> </html>