7. The HTML5 document shown in Figure 11.27 contains a canvas element and JavaScript that display
an image, tree.png, on the canvas. Fill in the blanks (i)-(iii) to complete the script.
2
3
4
5
6
7
8
9
10
11
<html>
<head>
<title>Canvas Example</title>
</head>
<body>
<canvas id=”gameCanvas” width=”1136″ height=”640″>
Your browser does not support canvas.
</canvas>
<script>
Figure 11.27. Script to be completed
8. What is the purpose of the onload statement in line 18 in the code shown in Figure 11.27?
A. To load the tree.png. Otherwise it will not load.
9. myContext.fillRect(250, 70, 120, 40);
The statement above draws a filled rectangle with x=___, y=___, width=___, ad height=___.
10. The moveTo() and lineTo() statements are used in drawing lines. The difference between moveTo()
and lineTo() is that ___.
11. Fill in the blanks to complete the statements for drawing the graphic as shown in Figure 11.28.
Assume the lines are drawn on a canvas with a rendering context, myContext.
myContext.moveTo(___, ___);