イメージを変形して描画
イメージデータを縦横サイズを変形して描画してみましょう
Sample08.html
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8"/> <title>Sample08.html</title> <script> function draw() { var canvas = document.getElementById("canvas1"); var c = canvas.getContext("2d"); var img = new Image(); img.src = "img/grand001.png"; c.drawImage(img, 0, 0, 320, 320); } </script> </head> <body onload="draw()"> <canvas id="canvas1" width="320" height="320"></canvas> </body> </html>