gsap实现炫酷美丽的波浪纹动画效果代码

代码语言:html

所属分类:动画

代码描述:gsap实现炫酷美丽的波浪纹动画效果代码

代码标签: gsap 炫酷 美丽 波浪 动画

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

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

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


  
  
<style>
html, body {
  margin:0;
  padding:0;
  width:100%;
  height:100%;
  background:#000;
}
</style>

  
  
</head>

<body translate="no">
  <canvas></canvas>
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/gsap.3.12.2.js"></script>
      <script  >
const c = document.querySelector('canvas')
const ctx = c.getContext('2d')
let cw = c.width = innerWidth
let ch = c.height = innerHeight

const ticks = 150
const ring1 = []
const ring2 = []
const dur = 12

for (let i=0; i<ticks; i++){
  const angle = i / ticks * Math.PI * 2
  const radius = 250
  ring1[i] = {
    x1:0, x2:0, y1:0, y2:0,
    lineWidth: 6,
    a: angle,
    r: radius,
    h: 180+ gsap.utils.wrapYoyo(0, 40, i/ticks*160)
  }
  ring2[i] = {
    x1:0, x2:0, y1:0, y2:0,
    lineWidth: 2,
    a: angle,
    r: radius/2,
    h: 180+ gsap.utils.wrapYoyo(0, 40, i/ticks*160)
  }
}

const tl = gsap.timeline({onUpdate:update})
.fromTo([ring1,ring2], {
  x1:(i,t)=> Math.cos(t.a)*t.r*-2,
  y1:(i,t)=> Math.sin(t.a)*t.r*-2,
  x2:(i,t)=> Ma.........完整代码请登录后点击上方下载按钮下载查看

网友评论0