HTML5 Guidelines for Web Developers

(coco) #1

138 Chapter 5—Canvas


Figure 5.23 Taft Point in Yosemite National Park

If we want to represent the whole image in the canvas, we also have to specify the
desired width and height in the arguments dw/dh. The browser then takes care of
scaling the image to 600 × 400 pixels. The result is shown in Figure 5.24:

image.onload = function() {
context.drawImage(image,0,0,600,400);
};
Free download pdf