html5实现鼠标跟随.doc

上传人:人*** 文档编号:562381002 上传时间:2023-03-12 格式:DOC 页数:3 大小:55.01KB
返回 下载 相关 举报
html5实现鼠标跟随.doc_第1页
第1页 / 共3页
html5实现鼠标跟随.doc_第2页
第2页 / 共3页
html5实现鼠标跟随.doc_第3页
第3页 / 共3页
亲,该文档总共3页,全部预览完了,如果喜欢就下载吧!
资源描述

《html5实现鼠标跟随.doc》由会员分享,可在线阅读,更多相关《html5实现鼠标跟随.doc(3页珍藏版)》请在金锄头文库上搜索。

1、Html5 实现鼠标跟随,纯js代码,没有flash或者图片之类的,chrome浏览器,firefix或者ie9以上支持。代码很容易看懂效果图:源代码:var data = 0;window.onload = function() C = Math.cos;S = Math.sin;U = 0;w = window;j = document;d = j.getElementById(c);c = d.getContext(2d);W = d.width = w.innerWidth;H = d.height = w.innerHeight;c.fillRect(0, 0, W, H);c.gl

2、obalCompositeOperation = lighter;c.lineWidth = 0.2;c.lineCap = round;var count = 0;var bool = 0, t = 0; / thetavar fun = function(e) if (window.T) clearTimeout(T);count = 0;if (D = 9) D = Math.random() * 15;f();X = e.pageX;Y = e.pageY;a = 0; b = 0; A = X; B = Y ;R = (e.pageX / W * 999 0) / 999;r = (

3、e.pageY / H * 999 0) / 999;U = e.pageX / H * 360 0;D = 9;g = 360 * Math.PI / 180;f = function(e) count+;c.save();c.globalCompositeOperation = source-over; if (e != 1) c.fillStyle = rgba(0,0,0,0.04);c.fillRect(0, 0, W, H); c.restore();i = 25;if (count 450 | bool) if (!bool) bool = 1;if (D 0.1) bool =

4、 0;t -= g; D -= 0.1; if (!bool) t += g; D += 0.1; q = (R / r - 1) * t; x = (R - r) * C(t) + D * C(q)+ (A + (X - A) * (i / 25) + (r - R); y = (R - r) * S(t) - D * S(q)+ (B + (Y - B) * (i / 25);if (a) c.moveTo(a, b);c.lineTo(x, y);c.strokeStyle = hsla( + (U % 360) + ,100%,50%,1); c.stroke();a = x; b = y; U -= 0.5; A = X; B = Y; ;T = setInterval(f, 10);d.onmousemove = function(e) data = 2;fun(e);

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 生活休闲 > 科普知识

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号