Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <html> | |
| 3 <body> | |
| 4 <canvas id='output' width='300' height='250'></canvas> | |
| 5 <script> | |
| 6 if (window.testRunner) { | |
| 7 testRunner.waitUntilDone(); | |
| 8 testRunner.setBackingScaleFactor(2, function() { init(); }); | |
|
Justin Novosad
2016/05/16 15:56:49
function() { init(); } -> init
xidachen
2016/05/16 16:53:15
I tried this, but that doesn't work either. So I m
| |
| 9 } | |
| 10 | |
| 11 var repeat = 500; | |
| 12 var x = y = 0; | |
| 13 var canvas = document.getElementById("output"); | |
| 14 var ctx = canvas.getContext('2d'); | |
| 15 ctx.fillStyle = "#FF0000"; | |
| 16 | |
| 17 function init() { | |
| 18 requestAnimationFrame(animate); | |
| 19 } | |
| 20 | |
| 21 function animate() | |
| 22 { | |
| 23 ctx.clearRect(x, y, 50, 50); | |
| 24 x++; | |
| 25 y++; | |
| 26 ctx.fillRect(x, y, 50, 50); | |
| 27 repeat--; | |
| 28 if (repeat == 0 && window.testRunner) | |
| 29 testRunner.notifyDone(); | |
| 30 if (repeat > 0) | |
| 31 requestAnimationFrame(animate); | |
| 32 } | |
| 33 </script> | |
| 34 </body> | |
| 35 </html> | |
| 36 | |
| OLD | NEW |