canvas-drawImage-slice-1b.html (751B)
1 <html class="reftest-wait"> 2 <head> 3 <script type="text/javascript"> 4 function go() { 5 var canvas = document.getElementById("canvas"); 6 var ctx = canvas.getContext("2d"); 7 8 // Draw some orange 9 ctx.fillStyle = "orange"; 10 ctx.fillRect(0, 0, 100, 100); 11 12 // Instantiate an image. Once it has loaded, draw it & take snapshot. 13 var image = new Image(); 14 image.onload = function() { 15 ctx.drawImage(image, 25, 25, 50, 50, 0, 0, 100, 100); 16 document.documentElement.removeAttribute("class"); 17 } 18 image.src ="limeInRed100x100.svg"; 19 } 20 </script> 21 </head> 22 <body onload="go()"> 23 <canvas id="canvas" width="100" height="100"></canvas> 24 </body> 25 </html>