网页粒子背景插件 -Canvas-nest.js

2023-10-30

地址:https://github.com/hustcc/canvas-nest.js

如果以上的js有问题,直接点击下面的下载!

canvas-nest.js下载地址:https://cdn.bootcss.com/canvas-nest.js/1.0.1/canvas-nest.js

color=”255,0,0” 背景粒子线的颜色值

opacity=”0.5” 背景粒子线的透明度,一般设置成0.5-1之间

count=”99” 背景粒子线的密度,建议不要太大,否则页面容易卡死

实现效果:

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
<p>今天学习canvas-nest.js</p>
<script color="0,0,0" opacity="0.5" count="99"
        src="../js/canvas-nest.js"
        type="text/javascript" charset="utf-8">

</script>
</body>
</html>

canvas-nest.js

!function(){"use strict";function e(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function t(e,t){return e(t={exports:{}},t.exports),t.exports}var n=t(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var n=1;t.default=function(){return""+n++},e.exports=t.default});e(n);var o=t(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:30,n=null;return function(){for(var o=this,i=arguments.length,r=Array(i),a=0;a<i;a++)r[a]=arguments[a];clearTimeout(n),n=setTimeout(function(){e.apply(o,r)},t)}},e.exports=t.default});e(o);var i=t(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});t.SizeSensorId="size-sensor-id",t.SensorStyle="display:block;position:absolute;top:0;left:0;height:100%;width:100%;overflow:hidden;pointer-events:none;z-index:-1;opacity:0",t.SensorClassName="size-sensor-object"});e(i);i.SizeSensorId,i.SensorStyle,i.SensorClassName;var r=t(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.createSensor=void 0;var n,r=(n=o)&&n.__esModule?n:{default:n};t.createSensor=function(e){var t=void 0,n=[],o=(0,r.default)(function(){n.forEach(function(t){t(e)})}),a=function(){t&&t.parentNode&&(t.contentDocument.defaultView.removeEventListener("resize",o),t.parentNode.removeChild(t),t=void 0,n=[])};return{element:e,bind:function(r){t||(t=function(){"static"===getComputedStyle(e).position&&(e.style.position="relative");var t=document.createElement("object");return t.onload=function(){t.contentDocument.defaultView.addEventListener("resize",o),o()},t.setAttribute("style",i.SensorStyle),t.setAttribute("class",i.SensorClassName),t.type="text/html",e.appendChild(t),t.data="about:blank",t}()),-1===n.indexOf(r)&&n.push(r)},destroy:a,unbind:function(e){var o=n.indexOf(e);-1!==o&&n.splice(o,1),0===n.length&&t&&a()}}}});e(r);r.createSensor;var a=t(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.createSensor=void 0;var n,i=(n=o)&&n.__esModule?n:{default:n};t.createSensor=function(e){var t=void 0,n=[],o=(0,i.default)(function(){n.forEach(function(t){t(e)})}),r=function(){t.disconnect(),n=[],t=void 0};return{element:e,bind:function(i){t||(t=function(){var t=new ResizeObserver(o);return t.observe(e),o(),t}()),-1===n.indexOf(i)&&n.push(i)},destroy:r,unbind:function(e){var o=n.indexOf(e);-1!==o&&n.splice(o,1),0===n.length&&t&&r()}}}});e(a);a.createSensor;var s=t(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.createSensor=void 0;t.createSensor="undefined"!=typeof ResizeObserver?a.createSensor:r.createSensor});e(s);s.createSensor;var u=t(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.removeSensor=t.getSensor=void 0;var o,r=(o=n)&&o.__esModule?o:{default:o};var a={};t.getSensor=function(e){var t=e.getAttribute(i.SizeSensorId);if(t&&a[t])return a[t];var n=(0,r.default)();e.setAttribute(i.SizeSensorId,n);var o=(0,s.createSensor)(e);return a[n]=o,o},t.removeSensor=function(e){var t=e.element.getAttribute(i.SizeSensorId);e.element.removeAttribute(i.SizeSensorId),e.destroy(),t&&a[t]&&delete a[t]}});e(u);u.removeSensor,u.getSensor;var c=t(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.clear=t.bind=void 0;t.bind=function(e,t){var n=(0,u.getSensor)(e);return n.bind(t),function(){n.unbind(t)}},t.clear=function(e){var t=(0,u.getSensor)(e);(0,u.removeSensor)(t)}});e(c);var l=c.clear,d=c.bind,v=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame||window.oRequestAnimationFrame||function(e){return window.setTimeout(e,1e3/60)},f=window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.msCancelAnimationFrame||window.oCancelAnimationFrame||window.clearTimeout,m=function(e){return new Array(e).fill(0).map(function(e,t){return t})},h=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},p=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}();var y=function(){function e(t,n){var o=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.randomPoints=function(){return m(o.c.count).map(function(){return{x:Math.random()*o.canvas.width,y:Math.random()*o.canvas.height,xa:2*Math.random()-1,ya:2*Math.random()-1,max:6e3}})},this.el=t,this.c=h({zIndex:-1,opacity:.5,color:"0,0,0",pointColor:"0,0,0",count:99},n),this.canvas=this.newCanvas(),this.context=this.canvas.getContext("2d"),this.points=this.randomPoints(),this.current={x:null,y:null,max:2e4},this.all=this.points.concat([this.current]),this.bindEvent(),this.requestFrame(this.drawCanvas)}return p(e,[{key:"bindEvent",value:function(){var e=this;d(this.el,function(){e.canvas.width=e.el.clientWidth,e.canvas.height=e.el.clientHeight}),this.onmousemove=window.onmousemove,window.onmousemove=function(t){e.current.x=t.clientX-e.el.offsetLeft+document.scrollingElement.scrollLeft,e.current.y=t.clientY-e.el.offsetTop+document.scrollingElement.scrollTop,e.onmousemove&&e.onmousemove(t)},this.onmouseout=window.onmouseout,window.onmouseout=function(){e.current.x=null,e.current.y=null,e.onmouseout&&e.onmouseout()}}},{key:"newCanvas",value:function(){"static"===getComputedStyle(this.el).position&&(this.el.style.position="relative");var e,t=document.createElement("canvas");return t.style.cssText="display:block;position:absolute;top:0;left:0;height:100%;width:100%;overflow:hidden;pointer-events:none;z-index:"+(e=this.c).zIndex+";opacity:"+e.opacity,t.width=this.el.clientWidth,t.height=this.el.clientHeight,this.el.appendChild(t),t}},{key:"requestFrame",value:function(e){var t=this;this.tid=v(function(){return e.call(t)})}},{key:"drawCanvas",value:function(){var e=this,t=this.context,n=this.canvas.width,o=this.canvas.height,i=this.current,r=this.points,a=this.all;t.clearRect(0,0,n,o);var s=void 0,u=void 0,c=void 0,l=void 0,d=void 0,v=void 0;r.forEach(function(r,f){for(r.x+=r.xa,r.y+=r.ya,r.xa*=r.x>n||r.x<0?-1:1,r.ya*=r.y>o||r.y<0?-1:1,t.fillStyle="rgba("+e.c.pointColor+")",t.fillRect(r.x-.5,r.y-.5,1,1),u=f+1;u<a.length;u++)null!==(s=a[u]).x&&null!==s.y&&(l=r.x-s.x,d=r.y-s.y,(v=l*l+d*d)<s.max&&(s===i&&v>=s.max/2&&(r.x-=.03*l,r.y-=.03*d),c=(s.max-v)/s.max,t.beginPath(),t.lineWidth=c/2,t.strokeStyle="rgba("+e.c.color+","+(c+.2)+")",t.moveTo(r.x,r.y),t.lineTo(s.x,s.y),t.stroke()))}),this.requestFrame(this.drawCanvas)}},{key:"destroy",value:function(){l(this.el),window.onmousemove=this.onmousemove,window.onmouseout=this.onmouseout,f(this.tid),this.canvas.parentNode.removeChild(this.canvas)}}]),e}();y.version="2.0.4";var w,b;new y(document.body,(w=document.getElementsByTagName("script"),{zIndex:(b=w[w.length-1]).getAttribute("zIndex"),opacity:b.getAttribute("opacity"),color:b.getAttribute("color"),pointColor:b.getAttribute("pointColor"),count:Number(b.getAttribute("count"))||99}))}();

亲自实验通过,可用!

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

网页粒子背景插件 -Canvas-nest.js 的相关文章

随机推荐

  • 最大权闭合子图的简单证明

    文章目录 一 概念 二 证明 2 1流网络的构造 2 2首先证明原图G的任何一个闭合子图都与新图 G G
  • docker报错WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) afte

    完整报错 WARNING Retrying Retry total 4 connect None read None redirect None status None after connection broken by NewConne
  • springboot swagger2

    swagger2 介绍 Swagger Codegen 通过Codegen 可以将描述文件生成html格式和cwiki形式的接口文档 同时也能生成多钟语言的服务端和客户端的代码 支持通过jar包 docker node等方式在本地化执行生成
  • 查询练习题

    1 查询Student表中的所有记录的Sname Ssex和Class列 select Sname Ssex Class from Student 2 查询教师所有的单位即不重复的Depart列 select Depart count fr
  • AD20使用技巧和笔记

    AD20自学笔记 文章目录 AD20自学笔记 细节 规则 绘制PCB全流程 细节 AD20默认的铺铜 会出现相同网络的导线 如GND 将铺铜分隔开的情况 导致铜箔没有将区域完全覆盖 解决办法 选中铺铜区域 右键 属性 将 Pour Over
  • VS2022部署/安装 QT(以5.14.2为例)

    一 下载并安装Qt Visual Studio Tools 点击扩展 并选择管理扩展 二 搜索QT并下载Qt Visual Studio Tools 注意 如果wifi下载很慢 甚至不动 可以尝试用 热点 下载好后 关闭vs2022 它会自
  • Java基础 String StringBuffer StringBuilder的异同介绍

    一 String StringBuffer StringBuilder的对比 String StringBuffer StringBuilder 字符串类型 常量 不可变 变量 可变 变量 可变 线性安全 安全 final修饰 安全 方法s
  • 什么是PHP中的函数?它们如何使用?

    嘿 你好啊 PHP中的函数就像是一个超级有技能的工人 可以帮助我们更快更好地完成任务 它们就像是一个个工具箱 里面装满了各种用途的工具 函数可以执行各种任务 比如计算两个数的和 检查字符串是否包含某个字符 读取文件等等 使用函数可以让我们的
  • golang构造N叉树

    package main import fmt strconv sync type Spaninfo struct AppNames string json appNames ContainErr bool json containErr
  • STM32端口复用和重映射

    STM32的引脚可设置为可设置为 普通IO功能 复用功能 重映射功能 不过普通IO功能 复用功能用得比较多 复用 在TSM32里面 大部分的引脚都是有GPIO复用功能 也就是说 一个 GPIO如果可以复用为内置外设的功能引脚 那么当这个 G
  • Java使用POI导出Excel、合并单元格、插入网络图片

    假设存在这样一张表A audience 观众表 id zjhm name gender address 表B seat 座位表 表明这个观众主动坐过哪些座位 id 表C check 校核表 表明这个观众被系统管理人员校核过哪些座位 id 一
  • Python练习题——BNUZ

    python练习题 BNUZER 一 填空题 二 简答题 三 程序设计题 谏言 一 填空题 若world world 则print hello world 输出 helloworld 表达式 3 in 1 2 3 4 的值为 False 表
  • 基于Element-UI给Vue页面添加Loading效果

    基于Element UI给Vue页面添加Loading效果 1 引入 2 在标签里面添加v loading 3 在data中定义 4 调用后端接口之前设置true 返回数据画图后设置false 1 引入 import Loading fro
  • 如何搭建个人服务器(网站/游戏)?

    在现代这个互联网时代 不会建站就OUT啦 下面小编给大家分享一个最快捷的建站方法 用这个建站方法 不仅简单快速 而且不花一分钱 不用买域名 也不用买空间 尤其适合刚刚接触建站的新手 学建站的学生和想打造个人网页的朋友 准备工具 一台电脑 X
  • 轻量、便捷、高效—经纬恒润AETP助力车载以太网测试

    随着自动驾驶技术和智能座舱的不断发展 高宽带 高速率的数据通信对主干网提出了稳定 高效的传输要求 CAN FD LIN已无法充分满足汽车的通信需求 车载以太网作为一种快速且扩展性好的网络技术 已经逐步成为了汽车主干网的首选 此外 为了满足车
  • STM32CubeProgrammer V2.9.0版本 通过UART bootload下载STM32G030系列芯片有Bug

    文章目录 CubeProgrammerV2 9 0最新版本的Bug 友情提醒 CubeProgrammerV2 9 0最新版本的Bug 本人笔记本电脑最近新装系统 想着安装最先版本的Stm32CubeProgrammer软件试试 再使用Ua
  • Ubantu 系统下安装fasttext及重要函数

    因为最近遇到了一个文本向量化的问题 所以接触了很多fasttext这个工具 原理什么的就不讲 网上实在是太多了 但是我在实验的过程中遇到了很多的问题 其中绝大多数都是安装fasttext问题 我也看到了很多博主说是fasttext是在win
  • 性能测试——性能监控工具——ServerAgent的安装与使用

    一 下载 首先进入网址 http jmeter plugins org downloads all 下载资源 ServerAgent 2 2 1 zip JMeterPlugins Standard 1 3 1 zip JMeterPlug
  • 如何在Go中编写多行字符串?

    本文翻译自 How do you write multiline strings in Go Does Go have anything similar to Python s multiline strings Go是否与Python的多
  • 网页粒子背景插件 -Canvas-nest.js

    地址 https github com hustcc canvas nest js 如果以上的js有问题 直接点击下面的下载 canvas nest js下载地址 https cdn bootcss com canvas nest js 1