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 = Array(200)
const dur = 4

for (let i=0; i<ticks.length; i++){
  ticks[i] = {
    x1:0, x2:0, y1:0, y2:0,
    lineWidth: 60,
    angle: i / ticks.length * Math.PI * 2,
    r: 390,
    h: 145+ gsap.utils.wrapYoyo(0, 80, i/ticks.length*160)
  }
}

const tl = gsap.timeline({onUpdate:update})
.fromTo(ticks, {
  x1:(i,t)=> Math.cos(t.angle)*t.r,
  y1:(i,t)=> Math.sin(t.angle)*t.r,
  x2:(i,t)=> Math.cos(t.angle)*t.r*-1.1,
  y2:(i,t)=> 0,//Math.sin(t.angle)*t.r*-1.1,
},{
  x1:(i,t)=> Math.cos(t.angle)*t.r*.7,
  y1:(i,t)=> Math.sin(t.angle)*t.r*..........完整代码请登录后点击上方下载按钮下载查看

网友评论0