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

2024-04-19 11:52

本文主要是介绍六边形酷科技特效单页源码,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

源码介绍

基于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.chinasem.cn/article/917467

相关文章

Java 正则表达式URL 匹配与源码全解析

《Java正则表达式URL匹配与源码全解析》在Web应用开发中,我们经常需要对URL进行格式验证,今天我们结合Java的Pattern和Matcher类,深入理解正则表达式在实际应用中... 目录1.正则表达式分解:2. 添加域名匹配 (2)3. 添加路径和查询参数匹配 (3) 4. 最终优化版本5.设计思

Java调用C++动态库超详细步骤讲解(附源码)

《Java调用C++动态库超详细步骤讲解(附源码)》C语言因其高效和接近硬件的特性,时常会被用在性能要求较高或者需要直接操作硬件的场合,:本文主要介绍Java调用C++动态库的相关资料,文中通过代... 目录一、直接调用C++库第一步:动态库生成(vs2017+qt5.12.10)第二步:Java调用C++

Python实现无痛修改第三方库源码的方法详解

《Python实现无痛修改第三方库源码的方法详解》很多时候,我们下载的第三方库是不会有需求不满足的情况,但也有极少的情况,第三方库没有兼顾到需求,本文将介绍几个修改源码的操作,大家可以根据需求进行选择... 目录需求不符合模拟示例 1. 修改源文件2. 继承修改3. 猴子补丁4. 追踪局部变量需求不符合很

Spring 中 BeanFactoryPostProcessor 的作用和示例源码分析

《Spring中BeanFactoryPostProcessor的作用和示例源码分析》Spring的BeanFactoryPostProcessor是容器初始化的扩展接口,允许在Bean实例化前... 目录一、概览1. 核心定位2. 核心功能详解3. 关键特性二、Spring 内置的 BeanFactory

Go中sync.Once源码的深度讲解

《Go中sync.Once源码的深度讲解》sync.Once是Go语言标准库中的一个同步原语,用于确保某个操作只执行一次,本文将从源码出发为大家详细介绍一下sync.Once的具体使用,x希望对大家有... 目录概念简单示例源码解读总结概念sync.Once是Go语言标准库中的一个同步原语,用于确保某个操

Java汇编源码如何查看环境搭建

《Java汇编源码如何查看环境搭建》:本文主要介绍如何在IntelliJIDEA开发环境中搭建字节码和汇编环境,以便更好地进行代码调优和JVM学习,首先,介绍了如何配置IntelliJIDEA以方... 目录一、简介二、在IDEA开发环境中搭建汇编环境2.1 在IDEA中搭建字节码查看环境2.1.1 搭建步

JAVA智听未来一站式有声阅读平台听书系统小程序源码

智听未来,一站式有声阅读平台听书系统 🌟&nbsp;开篇:遇见未来,从“智听”开始 在这个快节奏的时代,你是否渴望在忙碌的间隙,找到一片属于自己的宁静角落?是否梦想着能随时随地,沉浸在知识的海洋,或是故事的奇幻世界里?今天,就让我带你一起探索“智听未来”——这一站式有声阅读平台听书系统,它正悄悄改变着我们的阅读方式,让未来触手可及! 📚&nbsp;第一站:海量资源,应有尽有 走进“智听

Java ArrayList扩容机制 (源码解读)

结论:初始长度为10,若所需长度小于1.5倍原长度,则按照1.5倍扩容。若不够用则按照所需长度扩容。 一. 明确类内部重要变量含义         1:数组默认长度         2:这是一个共享的空数组实例,用于明确创建长度为0时的ArrayList ,比如通过 new ArrayList<>(0),ArrayList 内部的数组 elementData 会指向这个 EMPTY_EL

如何在Visual Studio中调试.NET源码

今天偶然在看别人代码时,发现在他的代码里使用了Any判断List<T>是否为空。 我一般的做法是先判断是否为null,再判断Count。 看了一下Count的源码如下: 1 [__DynamicallyInvokable]2 public int Count3 {4 [__DynamicallyInvokable]5 get

工厂ERP管理系统实现源码(JAVA)

工厂进销存管理系统是一个集采购管理、仓库管理、生产管理和销售管理于一体的综合解决方案。该系统旨在帮助企业优化流程、提高效率、降低成本,并实时掌握各环节的运营状况。 在采购管理方面,系统能够处理采购订单、供应商管理和采购入库等流程,确保采购过程的透明和高效。仓库管理方面,实现库存的精准管理,包括入库、出库、盘点等操作,确保库存数据的准确性和实时性。 生产管理模块则涵盖了生产计划制定、物料需求计划、