js蜘蛛网更随鼠标特效(博客园美化可将以下代码复制到页脚)
博客园美化需要添加该特效可将代码复制到页脚
代码

1 <script> 2 ! 3 function() { 4 function n(n, e, t) { 5 return n.getAttribute(e) || t 6 } 7 function e(n) { 8 return document.getElementsByTagName(n) 9 } 10 function t() { 11 var t = e("script"), 12 o = t.length, 13 i = t[o - 1]; 14 return { 15 l: o, 16 z: n(i, "zIndex", -1), 17 o: n(i, "opacity", .9), //透明度 18 c: n(i, "color", "255, 102, 153"), //颜色 19 n: n(i, "count", 99) 20 } 21 } 22 function o() { 23 a = m.width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth, 24 c = m.height = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight 25 } 26 function i() { 27 r.clearRect(0, 0, a, c); 28 var n, e, t, o, m, l; 29 s.forEach(function(i, x) { 30 for (i.x += i.xa, i.y += i.ya, i.xa *= i.x > a || i.x < 0 ? -1 : 1, i.ya *= i.y > c || i.y < 0 ? -1 : 1, r.fillRect(i.x - .5, i.y - .5, 1, 1), e = x + 1; e < u.length; e++) n = u[e], 31 null !== n.x && null !== n.y && (o = i.x - n.x, m = i.y - n.y, l = o * o + m * m, l < n.max && (n === y && l >= n.max / 2 && (i.x -= .03 * o, i.y -= .03 * m), t = (n.max - l) / n.max, r.beginPath(), r.lineWidth = t / 2, r.strokeStyle = "rgba(" + d.c + "," + (t + .2) + ")", r.moveTo(i.x, i.y), r.lineTo(n.x, n.y), r.stroke())) 32 }), 33 x(i) 34 } 35 var a, c, u, m = document.createElement("canvas"), 36 d = t(), 37 l = "c_n" + d.l, 38 r = m.getContext("2d"), 39 x = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || 40 function(n) { 41 window.setTimeout(n, 1e3 / 45) 42 }, 43 w = Math.random, 44 y = { 45 x: null, 46 y: null, 47 max: 2e4 48 }; 49 m.id = l, 50 m.style.cssText = "position:fixed;top:0;left:0;z-index:" + d.z + ";opacity:" + d.o, 51 e("body")[0].appendChild(m), 52 o(), 53 window.onresize = o, 54 window.onmousemove = function(n) { 55 n = n || window.event, 56 y.x = n.clientX, 57 y.y = n.clientY 58 }, 59 window.onmouseout = function() { 60 y.x = null, 61 y.y = null 62 }; 63 for (var s = [], f = 0; d.n > f; f++) { 64 var h = w() * a, 65 g = w() * c, 66 v = 2 * w() - 1, 67 p = 2 * w() - 1; 68 s.push({ 69 x: h, 70 y: g, 71 xa: v, 72 ya: p, 73 max: 6e3 74 }) 75 } 76 u = s.concat([y]), 77 setTimeout(function() { 78 i() 79 }, 80 100) 81 } (); 82 </script>
人生苦短,慢慢潇洒。
nsyw.run
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· winform 绘制太阳,地球,月球 运作规律
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现