下面是编程之家 jb51.cc 通过网络收集整理的代码片段。
编程之家小编现在分享给大家,也给大家做个参考。
<!doctype html> <html xmlns="http://www.w3.org/1999/xhtml" lang="en"> <head> <meta charset="gb2312"> <title> 测试</title> <script type="text/javascript"> window.onload = function () { C = Math.cos; S = Math.sin; U=0; canvas = document.getElementById("myCanvas"); c = canvas.getContext("2d"); var W = canvas.width = window.innerWidth; var H = canvas.height = window.innerHeight; var U=180>>0; c.fillRect(0,W,H); // resize <canvas> and draw black rect (default) c.globalCompositeOperation = "lighter"; // switch to additive color application c.lineWidth = 10.0;//设置画笔的大小 c.lineCap = "round";//设置圆滑 t = 0; var bool = 0; canvas.onmousemove = function (e) { if(window.T) { if(D==0) { D=Math.random()*15;} clearTimeout(T); } X = e.pageX; // grab mouse pixel coords Y = e.pageY; R = e.pageX/W r = e.pageY/H a=0; // previous coord.x b=0; // previous coord.y A = X,// original coord.x B = Y; // original coord.y U=e.pageX/H * 360 >>0; D=0; g = Math.PI/180; T = setInterval(f = function (e) { c.save(); c.globalCompositeOperation = "source-over"; if(e!=1) { c.fillStyle = "rgba(0,0.1)"; c.fillRect(0,H); } c.restore(); i = 30; while(i --) { c.beginPath(); if(D > 200 || bool) { // decrease diameter if(!bool) { // has hit maximum bool = 1; } if(D < 0.1) { // has hit minimum bool = 0; } t -= g; // decrease theta D -= 0.1; // decrease size } if(!bool) { t += g; // increase theta D += 0.1; // increase size } x = D*C(t)+X; y = D*S(t)+Y; if (a) { c.moveTo(a,b); c.lineTo(x,y); } c.strokeStyle = "hsla(" + (U % 360) + ",100%,50%,0.75)"; // draw rainbow hypotrochoid c.stroke(); a = x; // set previous coord.x b = y; // set previous coord.y U -= 0.5; // increment hue A = X; // set original coord.x B = Y; // set original coord.y } },20); } } </script> </head> <body style="margin:0px;padding:0px;width:100%;height:100%;overflow:hidden;"> <canvas id="myCanvas"></canvas> </body> </html>
以上是编程之家(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。
如果觉得编程之家网站内容还不错,欢迎将编程之家网站推荐给程序员好友。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。