OLD | NEW |
(Empty) | |
| 1 <!doctype html> |
| 2 <!-- |
| 3 Copyright 2016 The Chromium Authors. All rights reserved. |
| 4 Use of this source code is governed by a BSD-style license that can be |
| 5 found in the LICENSE file. |
| 6 --> |
| 7 <html style="height:100%"> |
| 8 <head> |
| 9 <style> |
| 10 html, body { |
| 11 margin: 0; |
| 12 padding: 0; |
| 13 } |
| 14 </style> |
| 15 </head> |
| 16 <body style="height:100%"> |
| 17 <canvas id="canvas" width="200" height="100"></canvas> |
| 18 </body> |
| 19 <script> |
| 20 var canvas = document.querySelector('canvas'); |
| 21 canvas.style.width ='100%'; |
| 22 canvas.style.height='100%'; |
| 23 canvas.width = canvas.offsetWidth; |
| 24 canvas.height = canvas.offsetHeight; |
| 25 var ctx = canvas.getContext("2d"); |
| 26 var rColor = 0; |
| 27 |
| 28 function animate() { |
| 29 rColor += 1; |
| 30 rColor %= 255; |
| 31 ctx.fillStyle = 'rgb(' + rColor + ',0,0)'; |
| 32 ctx.fillRect(0, 0, canvas.width, canvas.height); |
| 33 window.requestAnimationFrame(animate); |
| 34 } |
| 35 window.onload = animate; |
| 36 </script> |
| 37 </html> |
OLD | NEW |