1 <!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.01 Transitional//EN"
2 "http://www.w3.org/TR/html4/loose.dtd">
7 var c
= document
.getElementById('console')
8 c
.appendChild(document
.createTextNode(str
+ '\n'));
13 function getContext(id
) {
14 return document
.getElementById(id
).getContext('2d');
17 function imageLoaded() {
18 var c1
= getContext('canvas1')
19 c1
.drawImage(i
, 0, 0, i
.width
* 2, i
.height
* 2)
21 var c2
= getContext('canvas2');
22 c2
.drawImage(i
, 0, 0, i
.width
, i
.height
, 0, 0, i
.width
, i
.height
)
24 var c3
= getContext('canvas3');
25 var pattern
= c3
.createPattern(i
, 'repeat');
26 c3
.fillStyle
= pattern
;
27 c3
.arc(75, 75, 60, 0, 2*Math
.PI
, 0);
30 var c4
= getContext('canvas4');
31 var pattern
= c4
.createPattern(i
, 'no-repeat');
32 c4
.fillStyle
= pattern
;
33 c4
.translate(i
.width
/ 2, i
.height
/ 2);
34 c4
.rotate(40.0 / 180 * Math
.PI
);
35 c4
.translate(- i
.width
/ 2, - i
.height
/ 2);
36 c4
.fillRect(0, 0, i
.width
, i
.height
);
38 if (window
.testRunner
) {
39 testRunner
.notifyDone();
44 if (window
.testRunner
) {
45 testRunner
.dumpAsTextWithPixelResults();
46 testRunner
.waitUntilDone();
50 i
.onload
= imageLoaded
;
51 i
.src
= 'resources/apple.gif';
56 <body onload=
"runTests();" style=
"overflow:hidden;">
57 <p>This tests that the Image JavaScript object works as expected when used in a canvas. If the test is successful, the Apple logo should appear scaled, normal and finally tiled in a circle.
</p>
58 <div><canvas id=
"canvas1" width=
"150" height=
"150"></canvas>Using drawImage.
</div>
59 <div><canvas id=
"canvas2" width=
"150" height=
"150"></canvas>Using drawImage with source rectangle.
</div>
60 <div><canvas id=
"canvas3" width=
"150" height=
"150"></canvas>Using ImagePattern.
</div>
61 <div><canvas id=
"canvas4" width=
"150" height=
"150"></canvas>Using ImagePattern and rotation.
</div>