超级绚丽的HTML 5的页面

开发 前端
超级绚丽的html5的页面:把鼠标放在页面上会出现绚丽的效果,鼠标缓慢移动会出现不同的效果,效果本身的显示也不同,可为十分绚丽。

超级绚丽的html5的页面

  1. <!DOCTYPE html> 
  2. <html xmlns=”http://www.w3.org/1999/xhtml” lang=”en”> 
  3. <head> 
  4. <title>超级绚丽的html5的页面</title> 
  5. <script type=”text/javascript”> 
  6. window.onload = function () {  
  7. C = Math.cos;  
  8. S = Math.sin;  
  9. U = 0;  
  10. canvas = document.getElementById(“myCanvas”);  
  11. c = canvas.getContext(“2d”);  
  12. var W = canvas.width = window.innerWidth;  
  13. var H = canvas.height = window.innerHeight;  
  14. c.fillRect(0, 0, W, H); // resize <canvas> and draw black rect (default)  
  15. c.globalCompositeOperation = “lighter”; // switch to additive color application  
  16. c.lineWidth = 0.2;//设置画笔的大小  
  17. c.lineCap = “round”;//设置圆滑  
  18. var bool = 0,  
  19. t = 0; // theta  
  20. canvas.onmousemove = function (e) {  
  21. if(window.T) {  
  22. if(D==9) {  
  23. D=Math.random()*15; f(1); }  
  24. clearTimeout(T);  
  25. }  
  26. X = e.pageX; // grab mouse pixel coords  
  27. Y = e.pageY;  
  28. a=0; // previous coord.x  
  29. b=0; // previous coord.y  
  30. A = X, // original coord.x  
  31. B = Y; // original coord.y  
  32. R=(e.pageX/W * 999>>0)/999;  
  33. r=(e.pageY/H * 999>>0)/999;  
  34. U=e.pageX/H * 360 >>0;  
  35. D=9;  
  36. g = 360 * Math.PI / 180;  
  37. T = setInterval(f = function (e) {  
  38. c.save();  
  39. c.globalCompositeOperation = “source-over”;  
  40. if(e!=1) {  
  41. c.fillStyle = “rgba(0,0,0,0.02)”;  
  42. c.fillRect(0, 0, W, H);  
  43. }  
  44. c.restore();  
  45. i = 25; while(i –) {  
  46. c.beginPath();  
  47. if(D > 450 || bool) { // decrease diameter  
  48. if(!bool) { // has hit maximum  
  49. bool = 1;  
  50. }  
  51. if(D < 0.1) { // has hit minimum  
  52. bool = 0;  
  53. }  
  54. -g; // decrease theta  
  55. -0.1; // decrease size  
  56. }  
  57. if(!bool) {  
  58. t += g; // increase theta  
  59. D += 0.1; // increase size  
  60. }  
  61. q = (R / r – 1) * t;  
  62. x = (R – r) * C(t) + D * C(q) + (A + (X – A) * (i / 25)) + (r – R); // center on xy coords  
  63. y = (R – r) * S(t) – D * S(q) + (B + (Y – B) * (i / 25));  
  64. if (a) {  
  65. c.moveTo(a, b);  
  66. c.lineTo(x, y)  
  67. }  
  68. c.strokeStyle = “hsla(” + (U % 360) + “,100%,50%,0.75)”; // draw rainbow hypotrochoid  
  69. c.stroke();  
  70. a = x; // set previous coord.x  
  71. b = y; // set previous coord.y  
  72. }  
  73. -0.5; // increment hue  
  74. A = X; // set original coord.x  
  75. B = Y; // set original coord.y  
  76. }, 16);  
  77. }  
  78. document.onkeydown = function(e) { a=b=0; R += 0.05 }  
  79. canvas.onmousemove({pageX:300, pageY:290})  
  80. }</script> 
  81. </head> 
  82. <body style=”margin:0px;padding:0px;width:100%;height:100%;overflow:hidden;”> 
  83. <canvas id=”myCanvas”></canvas> 
  84. </body> 
  85. </html> 

 

原文链接:http://gagahtml.sinaapp.com/2012/05/244.html

查看效果:http://gagahtml-wordpress.stor.sinaapp.com/uploads/2012/05/xuanli.html

责任编辑:张伟 来源: 嘎嘎html博客
相关推荐

2015-07-03 09:37:34

HTML5Figure图片字幕特效

2015-01-13 11:19:19

2012-09-04 09:23:45

HTML5消息传输传输机制

2011-09-08 15:06:33

HTML 5

2014-07-04 09:52:57

HTML5

2015-07-22 16:44:51

HTML5优化

2010-02-22 09:39:52

HTML 5Web

2011-07-14 09:16:10

HTML 5

2011-07-29 11:04:52

2011-09-14 14:25:00

HTML 5

2013-01-24 10:26:04

HTML5HTML 5HTML5的未来

2011-05-13 17:36:05

HTML

2009-10-26 15:18:39

HTML 5

2012-05-08 13:36:47

HTML5

2011-02-14 10:49:40

HTML 5

2009-07-02 15:03:00

HTML 5

2011-09-19 15:01:31

vistaAero特效

2023-03-16 09:00:00

HTML5HTML语言

2015-12-03 09:53:15

jQuery焦点图动画

2011-07-19 10:34:25

HTML 5
点赞
收藏

51CTO技术栈公众号