canvas鼠标连点交互粒子效果

代码语言:html

所属分类:粒子

代码描述:canvas鼠标连点交互粒子效果

代码标签: 交互 粒子 效果

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">

<style>
canvas{
  display: fixed;
/*   border: 1px solid red; */
}

body{
  margin: 0;
}
</style>

</head>
<body translate="no">
<canvas id='canvas'></canvas>

<script>
// color palette used: https://lospec.com/palette-list/slso-clr17

// log to tell me that codepen has refreshed
console.log('refresh');

const cnvs = document.getElementById('canvas');
const ctx = cnvs.getContext('2d');


const global = {
  mouseX: -5000,
  mouseY: -5000,
  width: 0,
  height: 0,
  distanceToGlow: 75,
  glowSpeed: 0.01,
  minGlow: 0.4,
  maxOffset: 20,
  gravitateSpeed: 0.01,
  canvasObjects: [],
  defaultSpeed: 0.05,
  init() {
    ctx.canvas.width = w.........完整代码请登录后点击上方下载按钮下载查看

网友评论0