OLD | NEW |
1 <canvas id="canvas" width="200" height="100"></canvas> | 1 <canvas id="canvas" width="200" height="100"></canvas> |
2 <script> | 2 <script> |
3 if (window.testRunner) | 3 if (window.testRunner) |
4 testRunner.dumpAsText(true); | 4 testRunner.dumpAsTextWithPixelResults(); |
5 | 5 |
6 var img = new Image(); | 6 var img = new Image(); |
7 // This is a 2x1 image, blue at (0, 0) and green at (1, 0). | 7 // This is a 2x1 image, blue at (0, 0) and green at (1, 0). |
8 img.src = 'data:image/png;base64,' + | 8 img.src = 'data:image/png;base64,' + |
9 'iVBORw0KGgoAAAANSUhEUgAAAAIAAAABCAIAAAB7QOjdAAAAAXNSR0IArs4c6QAAAAlwSFlzAAALEwA
A' + | 9 'iVBORw0KGgoAAAANSUhEUgAAAAIAAAABCAIAAAB7QOjdAAAAAXNSR0IArs4c6QAAAAlwSFlzAAALEwA
A' + |
10 'CxMBAJqcGAAAAAd0SU1FB9wIGxQKIbPpHtMAAAAPSURBVAjXY2Bg+M/wnwEABgEB/6KPEdkAAAAASUV
O' + | 10 'CxMBAJqcGAAAAAd0SU1FB9wIGxQKIbPpHtMAAAAPSURBVAjXY2Bg+M/wnwEABgEB/6KPEdkAAAAASUV
O' + |
11 'RK5CYII='; | 11 'RK5CYII='; |
12 | 12 |
13 img.onload = function() | 13 img.onload = function() |
14 { | 14 { |
15 // Start from the middle of the blue pixel and stretch to the entire | 15 // Start from the middle of the blue pixel and stretch to the entire |
16 // canvas. Canvas should have 1/3 blue on the left and 2/3 green on the | 16 // canvas. Canvas should have 1/3 blue on the left and 2/3 green on the |
17 // right, with gradient if interpolation allows. | 17 // right, with gradient if interpolation allows. |
18 var ctx = document.getElementById("canvas").getContext("2d"); | 18 var ctx = document.getElementById("canvas").getContext("2d"); |
19 ctx.drawImage(img, 0.5, 0, 1.5, 1, 0, 0, 200, 100); | 19 ctx.drawImage(img, 0.5, 0, 1.5, 1, 0, 0, 200, 100); |
20 } | 20 } |
21 </script> | 21 </script> |
OLD | NEW |