六边形酷科技特效单页源码

embedded/2024/10/19 19:36:39/

源码介绍

基于canvas画布绘制多个六边形追踪鼠标,科技感的几何图形酷炫动画特效,

单页html源码,可以做网站动态背景,喜欢的朋友可以拿去

效果截图

liubianxing.gif

完整源码


<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>canvas六角型</title>
<!--QQ沐编程 www.qqmu.com 学习QQ群:290987565  域名抢注 https://www.juming.com/t/33210x2a49c4 -->
<style>
body {background: black;overflow: hidden;/* cursor: none; */
}
</style></head>
<body><canvas id='canvas-club'></canvas><script>
window.requestAnimationFrame = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame;var c = document.getElementById("canvas-club");
var w = c.width = window.innerWidth;
var h = c.height = window.innerHeight;
var ctx = c.getContext("2d");var maxParticles = 30;
var particles = [];
var hue = 183;mouse = {};
mouse.size = 200;
mouse.x = mouse.tx = w/2;
mouse.y = mouse.ty = h/2;var clearColor = "rgba(0, 0, 0, .2)";function random(min, max){return Math.random() * (max - min) + min
}function distance(x1, y1, x2, y2){return Math.sqrt( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) );
}function P(){}P.prototype = {init: function(){this.size = this.origSize = random(10, 100);this.x = random(0, w);this.y = Math.random() > .5 ? -this.size : h + this.size;this.speed = this.origSpeed = random(.01, .03);},draw: function(){this.distanceFromMouse = distance(this.x, this.y, mouse.x, mouse.y);ctx.strokeStyle = "hsla("+hue+", 90%, 50%, 1)";ctx.shadowColor = "hsla("+hue+", 100%, 55%, 1)";ctx.shadowBlur = this.size * 2;ctx.beginPath();ctx.moveTo(this.x + this.size * Math.cos(0), this.y + this.size *  Math.sin(0));for(var i=0; i<6; i++){ctx.lineTo(this.x + this.size * Math.cos(i * 2 * Math.PI / 6), this.y + this.size * Math.sin(i * 2 * Math.PI / 6));}   ctx.closePath();ctx.lineWidth = 3;ctx.stroke();this.update();},update: function(){if(this.distanceFromMouse > 20){this.x += (mouse.x - this.x) * this.speed;this.y += (mouse.y - this.y) * this.speed;if(this.distanceFromMouse < mouse.size){this.size += (0 - this.size) * this.speed;this.speed += .01;} else {this.size += (this.origSize - this.size) * this.speed;}} else {this.init();}}
}mouse.move = function(){if(!distance(mouse.x, mouse.y, mouse.tx, mouse.ty) <= .1){mouse.x += (mouse.tx - mouse.x) * .2;mouse.y += (mouse.ty - mouse.y) * .2;} 
};mouse.touches = function(e) {var touches = e.touches;if(touches){mouse.tx = touches[0].clientX;mouse.ty = touches[0].clientY;} else {mouse.tx = e.clientX;mouse.ty = e.clientY;}e.preventDefault();
};mouse.mouseleave = function(e){mouse.tx = w/2;mouse.ty = h/2;
};window.addEventListener("mousemove", mouse.touches);
window.addEventListener("touchstart", mouse.touches);
window.addEventListener("touchmove", mouse.touches)c.addEventListener("mouseleave", mouse.mouseleave)window.addEventListener("resize", function(){w = c.width = window.innerWidth;h = c.height = window.innerHeight;
});for(var i=1; i<=maxParticles; i++) {setTimeout(function(){var p = new P();p.init();particles.push(p);}, i * 50);
}function anim(){ctx.fillStyle = clearColor;ctx.shadowColor = clearColor;ctx.shadowBlur = 0;ctx.globalCompositeOperation = "source-over";ctx.fillRect(0,0,w, h);mouse.move();for(var i in particles){var p = particles[i];p.draw();}hue++;requestAnimationFrame(anim);
}anim();</script>
<script>
var _hmt = _hmt || [];
(function() {var hm = document.createElement("script");hm.src = "https://hm.baidu.com/hm.js?c8249987b56687e1763167bfea967a61";var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s);
})();
</script>
<!--QQ沐编程 www.qqmu.com 学习QQ群:290987565  域名抢注 https://www.juming.com/t/33210x2a49c4 -->
</body>
</html>

http://www.ppmy.cn/embedded/6064.html

相关文章

Python的pytest框架(2)--断言机制

接上篇文章&#xff0c;我们使用pytest框架&#xff0c;实现自动发现并执行用例&#xff0c;接着利用断言语句判断测试结果&#xff0c;最后生成报告。这篇文章我们就断言机制来展开&#xff0c;深入学习进阶pytest框架的断言机制&#xff1a; 目录 一、基本断言 使用Python…

HBase的数据模型与架构

官方文档&#xff1a;Apache HBase – Apache HBase™ Homehttps://hbase.apache.org/ 一、HBase概述 1.概述 HBase的技术源自Google的BigTable论文&#xff0c;HBase建立在Hadoop之上&#xff0c;是一个高可靠性、高性能、面向列、可伸缩的分布式存储系统&#xff0c;用于…

RabbitMQ-核心特性

已经不需要为RabbitMQ交换机的离去而感到伤心了&#xff0c;接下来登场的是RabbitMQ-核心特性!!! 文章目录 核心特性消息过期机制消息确认机制死信队列 核心特性 消息过期机制 官方文档&#xff1a;https://www.rabbitmq.com/ttl.html 可以给每条消息指定一个有效期&#xf…

java的总结

由于最近已经开始做项目了&#xff0c;所以对java的基础知识的学习都是一个离散化的状态没有一个很系统的学习&#xff0c;都是哪里不会就去学哪里。 先来讲一下前后端的区别吧 在我的理解前端就是&#xff1a;客户端在前端进行点击输入数据&#xff0c;前端将这些数据整合起来…

系统安全及应用

目录 1.账号安全控制 1系统账号清理 2密码安全控制 1 对已经存在的用户账号进行控制 2 对新建的用户密码默认设置 3 历史命令和终端自动注销的安全管理 1 历史命令的限制 2. 用户切换管理 1 su命令的使用 2 ssh 3.授权用户管理 1 sudo命令 2 sudo用户别名 3 查看su…

Hbase的shell命令(详细)

一、help 1.help 显示命名的分组情况 2.help 命令名称 查看命令的具体使用&#xff0c;包括命令的作用和用法。 举例&#xff1a;help list 二、general 组&#xff08;普通命令组&#xff09; 命令 描述 …

欢迎大家光临成都市

我现在就在家里&#xff0c;刚刚理个发&#xff0c;洗个澡 爸妈也在家里&#xff0c;一切正常&#xff0c;但是QQ上不了&#xff0c;哎呀,又长胖了&#xff0c;不好意思

51单片机入门_江协科技_31~32_OB记录的自学笔记_LCD1602液晶显示屏

31. LCD1602 31.1. LCD1602介绍 •LCD1602&#xff08;Liquid Crystal Display&#xff09;液晶显示屏是一种字符型液晶显示模块&#xff0c;可以显示ASCII码的标准字符和其它的一些内置特殊字符&#xff0c;还可以有8个自定义字符 •显示容量&#xff1a;162个字符&#xff0c…