gsap+tweakpane实现l可调节参数的led矩阵动画效果代码

代码语言:html

所属分类:动画

代码描述:gsap+tweakpane实现l可调节参数的led矩阵动画效果代码

代码标签: gsap tweakpane 调节 参数 led 矩阵 动画

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

<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  

  
  
<style>
* {
  box-sizing: border-box;
}
html {
  background: black;
}
.container {
  position: fixed;
  inset: 0;
  background: var(--cell, black);
}

.container::after {
  content: "";
  position: absolute;
  inset: 0;
  background: black;
  -webkit-mask: linear-gradient(white, transparent);
          mask: linear-gradient(white, transparent);
}

div.tp-dfwv {
  width: 320px;
}

.container canvas {
  height: 100%;
  width: 100%;
}
</style>

  
  
</head>

<body translate="no">
  <div class="container"></div>
  <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/gsap.3.12.2.js"></script>

      <script type="module" >
import { Pane } from '//repo.bfw.wiki/bfwrepo/js/tweakpane.4.0.3.js'
const CONTAINER = document.querySelector('.container')
const CONFIG = {
  cell: '#e816af',
  track: '#000000',
  frame: '#111111',
  fps: 24,
  amount: 1200,
  noise: 0.02,
  hOffset: undefined,
  vOffset: undefined,
  columns: undefined,
  rows: undefined,
  size: 12,
  border: 2,
}

const DPR = window.devicePixelRatio

const canvas = Object.assign(document.createElement('canvas'), {
  width: window.innerWidth * DPR,
  height: window.innerHeight * DPR,
})
const context = canvas.getContext('2d')

const gridCanvas = Object.assign(document.createElement('canvas'), {
  width: window.innerWidth * DPR,
  height: window.innerHeight * DPR,
})
const gridContext = gridCanvas.getContext('2d')

CONTAINER.appendChild(canvas)

const setGrid = () => {
  gridContext.clearRect(0, 0, gridCanvas.width, gridCanvas.height)
  gridContext.fillStyle = CONFIG.track
  const hTracks = Math.ceil(gridCanvas.width / CONFIG.size)
  const hOffset = (gridCanvas.width % CONFIG.size) * 0.5
  for (let h = 0; h < hTracks; h++) {
    gridContext.fillRect(h * CONFIG.size + (hOffset) - CONFIG.border, 0, CONFIG.border * 2, gridCanvas.height)
  }
  const vTracks = Math.ceil(gridCanvas.height / CONFIG.size)
  const vOffset = (gridCanvas.height % CONFIG.size) * 0.5
  for (let v = 0; v < vTracks; v++) {
    gridContext.fillRect(0, v * CONFIG.size + (vOffset) - CONFIG.border, gridCanvas.width, CONFIG.border * 2)
  }
  CONFIG.columns = hTracks
  CONFIG.hOffset = hOffset
  CONFIG.rows = vTra.........完整代码请登录后点击上方下载按钮下载查看

网友评论0