gsap+svg实现花朵图案曲线路径描边动画效果代码

代码语言:html

所属分类:动画

代码描述:gsap+svg实现花朵图案曲线路径描边动画效果代码

代码标签: 图案 曲线 路径 描边 动画 效果

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

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">




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


</head>

<body>
    <svg id="stage" viewBox="0 0 500 500" preserveAspectRatio="xMidYMid meet" stroke="#fff" stroke-width="3" stroke-linecap="round" fill="none"></svg>
    <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/gsap.3.5.2.js"></script>
    <script>
        let pts = [],
            nPts = 12,
            lineLength = 60,
            timeScale = 0.5
        
        const radius = 180,
              tl = gsap.timeline()
        
        for (let i=0; i<nPts; i++){ // plot points + add circles
          const c = document.createElementNS("http://www.w3.org/2000/svg", "circle"),
                angle = (i/nPts * Math.PI *2)- Math.PI/2,
                x = Math.cos(angle)*radius,
                y = Math.sin(angle)*radius
          
          pts.push( x.toFixed(2) + ',' + y.toFixed(2) + ' ')
        
          gsap.set(c, {
            x:250,
            y:250,
            scale:0.8,
            attr:{class:'c'+i, r:3, cx:x, cy:y, fill:'#fff', stroke:�.........完整代码请登录后点击上方下载按钮下载查看

网友评论0