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 @-webkit-keyframes blur-anim { |
| 15 from { -webkit-filter: blur(0); } |
| 16 to { -webkit-filter: blur(50px); } |
| 17 } |
| 18 canvas { |
| 19 -webkit-animation: blur-anim 1.5s linear; |
| 20 -webkit-animation-direction: alternate; |
| 21 -webkit-animation-iteration-count: infinite; |
| 22 } |
14 </style> | 23 </style> |
15 </head> | 24 </head> |
16 <body style="height:100%"> | 25 <body style="height:100%"> |
17 <canvas id="canvas" width="200" height="100"></canvas> | 26 <canvas id="canvas" width="200" height="100"></canvas> |
18 </body> | 27 </body> |
19 <script> | 28 <script> |
20 var canvas = document.querySelector('canvas'); | 29 var canvas = document.querySelector('canvas'); |
21 canvas.style.width ='100%'; | 30 canvas.style.width ='100%'; |
22 canvas.style.height='100%'; | 31 canvas.style.height='100%'; |
23 canvas.width = canvas.offsetWidth; | 32 canvas.width = canvas.offsetWidth; |
24 canvas.height = canvas.offsetHeight; | 33 canvas.height = canvas.offsetHeight; |
25 var ctx = canvas.getContext("2d"); | 34 var ctx = canvas.getContext("2d"); |
26 var rColor = 0; | |
27 | 35 |
28 function animate() { | 36 var grd=ctx.createLinearGradient(0,0,canvas.width,0); |
29 rColor += 1; | 37 grd.addColorStop(0,"red"); |
30 rColor %= 255; | 38 grd.addColorStop(1,"green"); |
31 ctx.fillStyle = 'rgb(' + rColor + ',0,0)'; | 39 ctx.fillStyle=grd; |
32 ctx.fillRect(0, 0, canvas.width, canvas.height); | 40 ctx.fillRect(0, 0, canvas.width, canvas.height); |
33 window.requestAnimationFrame(animate); | |
34 } | |
35 window.onload = animate; | |
36 </script> | 41 </script> |
37 </html> | 42 </html> |
OLD | NEW |