<script type="text/javascript">
onload = function() {
var click_cnt = 0;
var $html = document.getElementsByTagName("html")[0];
var $body = document.getElementsByTagName("body")[0];
var canvas = document.createElement("canvas");
var ctx = canvas.getContext("2d");
resize();
window.onresize = resize;
function resize() {
canvas.width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
canvas.height = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
}
var RAF = (function() {
return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame ||
function(callback) {
window.setTimeout(callback, 1000 / 60);
};
})();
var warea = {
x: null,
y: null,
max: 20000
};
window.onmousemove = function(e) {
e = e || window.event;
warea.x = e.clientX;
warea.y = e.clientY;
};
window.onmouseout = function(e) {
warea.x = null;
warea.y = null;
};
var dots = [];
for (var i = 0; i < 300; i++) {
var x = Math.random() * canvas.width;
var y = Math.random() * canvas.height;
var xa = Math.random() * 2 - 1;
var ya = Math.random() * 2 - 1;
dots.push({
x: x,
y: y,
xa: xa,
ya: ya,
max: 6000
})
}
setTimeout(function() {
animate();
},
100);
function animate() {
ctx.clearRect(0, 0, canvas.width, canvas.height);
var ndots = [warea].concat(dots);
dots.forEach(function(dot) {
dot.x += dot.xa;
dot.y += dot.ya;
dot.xa *= (dot.x > canvas.width || dot.x < 0) ? -1 : 1;
dot.ya *= (dot.y > canvas.height || dot.y < 0) ? -1 : 1;
ctx.fillRect(dot.x - 0.5, dot.y - 0.5, 1, 1);
for (var i = 0; i < ndots.length; i++) {
var d2 = ndots[i];
if (dot === d2 || d2.x === null || d2.y === null) continue;
var xc = dot.x - d2.x;
var yc = dot.y - d2.y;
var dis = xc * xc + yc * yc;
var ratio;
if (dis < d2.max) {
if (d2 === warea && dis > (d2.max / 2)) {
dot.x -= xc * 0.03;
dot.y -= yc * 0.03;
}
ratio = (d2.max - dis) / d2.max;
ctx.beginPath();
ctx.lineWidth = ratio / 2;
ctx.strokeStyle = 'rgba(137,129,150,' + (ratio + 0.2) + ')';
ctx.moveTo(dot.x, dot.y);
ctx.lineTo(d2.x, d2.y);
ctx.stroke();
}
}
ndots.splice(ndots.indexOf(dot), 1);
});
RAF(animate);
}
$body.appendChild(canvas);
$html.onclick = function(e) {
var $elem = document.createElement("h1");
$elem.style.color = getRandomColor();
$elem.style.zIndex = 9999;
$elem.style.position = "absolute";
$elem.style.select = "none";
var x = e.pageX;
var y = e.pageY;
$elem.style.left = (x - 10) + "px";
$elem.style.top = (y - 20) + "px";
clearInterval(anim);
click_cnt++;
if (click_cnt % 12 == 0) {
$elem.innerText = "友善";
} else if (click_cnt % 11 == 0) {
$elem.innerText = "诚信";
} else if (click_cnt % 10 == 0) {
$elem.innerText = "敬业";
} else if (click_cnt % 9 == 0) {
$elem.innerText = "爱国";
} else if (click_cnt % 8 == 0) {
$elem.innerText = "法治";
} else if (click_cnt % 7 == 0) {
$elem.innerText = "公正";
} else if (click_cnt % 6 == 0) {
$elem.innerText = "平等";
} else if (click_cnt % 5 == 0) {
$elem.innerText = "自由";
} else if (click_cnt % 4 == 0) {
$elem.innerText = "和谐";
} else if (click_cnt % 3 == 0) {
$elem.innerText = "文明";
} else if (click_cnt % 2 == 0) {
$elem.innerText = "民主";
} else if (click_cnt % 1 == 0) {
$elem.innerText = "富强";
}
$elem.style.fontSize = Math.random() * 10 + 10 + "px";
var increase = 0;
var anim;
setTimeout(function() {
anim = setInterval(function() {
if (++increase == 150) {
clearInterval(anim);
$body.removeChild($elem);
}
$elem.style.top = y - 20 - increase + "px";
$elem.style.opacity = (150 - increase) / 120;
},
8);
},
70);
$body.appendChild($elem);
};
};
var getRandomColor = function() {
return "rgb(" + Math.round(Math.random() * 255) + "," + Math.round(Math.random() * 255) + ',' + Math.round(Math.random() * 10) + ')';
}
</script>
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 零经验选手,Compose 一天开发一款小游戏!
· 通过 API 将Deepseek响应流式内容输出到前端