日期:2014-05-16 浏览次数:20280 次
<!DOCTYPE html> </html> <head> <title>canvas中drawImage</title> <script> window.addEventListener('load', function () { var canvas = document.getElementById('myCanvas'); // 取得canvas 2d context. var context = canvas.getContext('2d'); //三个参数:图像位置,x,y在canvas中的位置 context.drawImage("image/Opera96.png", 10, 10); // 五个参数,最后两个是宽高 context.drawImage("image/Opera96.png", 100, 10, 200, 200); },false); </script> </head> <body> <div id="myCanvas" width="500" height="650"> Fallback content, in case the browser does not support Canvas. </div> </body> </html>