[Top] JS实现线条动态背景
线条随机运动,鼠标移动过程中,有吸附性,话不多说,直接上代码吧!
!function () {
let num = 100;
//设置所画线的颜色
let colorLine = "138,43,226"
//创建画布
let canvas = document.createElement('canvas');
//将创建的画布添加至body标签当中
document.getElementsByTagName('div')[0].appendChild(canvas)
let ctx = canvas.getContext('2d');
//获取当前页面的宽高,并同时设置给予画布
let myWidth = canvas.width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
let myHeight = canvas.height = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
let newCircleArray,allCircle = []
//获取动画帧,用于更新动画
let ani = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame ||
function (n) {
window