HTML and CSS Reference
In-Depth Information
Example 4-11. Placing an image on the canvas in a logical window
var photo = new Image();
photo.addEventListener('load', eventPhotoLoaded , false);
photo.src = "butterfly.jpg";
var windowWidth = 500;
var windowHeight = 500;
var windowX = 0;
var windowY = 0;
function eventPhotoLoaded() {
drawScreen()
}
function drawScreen(){
context.drawImage(photo, windowX, windowY, windowWidth, windowHeight,
0, 0, windowWidth,windowHeight);
}
Figure 4-12. An image in a small logical window
Search WWH ::




Custom Search