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