gsap+svg实现拖影动画效果代码

代码语言:html

所属分类:动画

代码描述:gsap+svg实现拖影动画效果代码

代码标签: gsap svg 拖影 动画

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

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">





    <style>
        body {
         background-color: #1e1d1f;
         overflow: hidden;
         text-align:center;
          display: flex;
          align-items: center;
          justify-content: center; 
        }
        
        body,
        html {
         height: 100%;
         width: 100%;
         margin: 0;
         padding: 0;
        }
        
        svg {
         width: 100%;
         height: 100%;
         visibility: hidden;
         
        }
    </style>



</head>

<body>
    <svg id="mainSVG" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 800 600">
<defs>
	<circle class="dot" cx="0" cy="0" r="4" />

  <g id="spiral"  fill="none" stroke="#000" stroke-miterlimit="10">
    <circle cx="400" cy="300" r="150"/>
    <circle cx="400" cy="300" r="134.34"/>
    <circle cx="400" cy="300" r="118.68"/>
    <circle cx="400" cy="300" r="103.02"/>
    <circle cx="400" cy="300" r="87.37"/>
    <circle cx="400" cy="300" r="71.71"/>
    <circle cx="400" cy="300" r="56.05"/>
    <circle cx="400" cy="300" r="40.39"/>
    <circle cx="400" cy="300" r="24.73"/>
    <circle cx="400" cy="300" r="9.07"/>
  </g>	
	</defs>
		 
	<g id="container" >

		</g>
		 

</svg>
    <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/gsap.3.11.0.js"></script>
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/MotionPathPlugin.js"></script>
    <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/MorphSVGPlugin3.min.js"></script>
    <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/CustomEase3.js"></script>
    <script>
        gsap.config({trialWarn: false});
        MorphSVGPlugin.convertToPath("#spiral circle");
        let select = s => document.querySelector(s),
          selectAll = s =>  document.querySelectorAll(s),
        		mainSVG = select('#mainSVG'),
        		container = select('#container'),
        		dot = select('.dot'),
        		colorArray = ["ef476f","f78c6b","ffd166","c1d375","83d483","06d6a0","0cb0a9","118ab2","375297","5c197b"].reverse()
    .........完整代码请登录后点击上方下载按钮下载查看

网友评论0