gsap实现气球上升触顶爆炸动画效果代码

代码语言:html

所属分类:动画

代码描述:gsap实现气球上升触顶爆炸动画效果代码

代码标签: 上升 触顶 爆炸 动画 效果

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


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

<head>

  <meta charset="UTF-8">
  

  
  
  
<style>
html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  position: relative;
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
}

.color {
  fill: var(--color, black);
}

#svg {
  position: absolute;
  overflow: visible;
  top: 0;
  left: 0;
}

#content {
  text-align: center;
  font-family: sans-serif;
  user-select: none;
}

.balloon {
  cursor: pointer;
}

#behind_svg {
  z-index: 1;
}

#content {
  z-index: 2;
}

#svg {
  z-index: 3;
}
</style>



</head>

<body translate="no" >
  <svg width="1" height="1" id="svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
  <defs>
    
    <g id="balloon">
      <path class="color" d="M30.32,85.27l2.6-3.67,2.18,3.67a3.09,3.09,0,0,1-2.39,1A2.63,2.63,0,0,1,30.32,85.27Z"/>
<!--       <path d="M30.32,85.27l2.6-3.67,2.18,3.67a3.09,3.09,0,0,1-2.39,1A2.63,2.63,0,0,1,30.32,85.27Z" style="opacity: 0.3;fill: url(#linear-gradient)"/> -->
      <ellipse class="color" cx="32.92" cy="41.72" rx="32.92" ry="41.72"/>
      <ellipse cx="50.5" cy="20.4" rx="5.23" ry="13.48" transform="translate(-3 30.59) rotate(-32.78)" style="fill: #fff;opacity: 0.4"/>
    </g>
    <g id="pop">
        <path class="color" d="M10.4,1.06s23.25-3.73,31.65,2.8S52,21,52,21s-3.73-11-9.33-10.5-11.47,4.89-11.47,4.89,5.65-11.52,0-11.52-16.55.63-16.55.63Z" />
        <path class="color" d="M31.21,29.08s13,4.36,15.51,0,6.85,0,6.85,0L45.79,46.51S34.84,44.57,33,36.83Z"/>
        <path class="color" d="M14.86,6.71l-4,15.14,5.3,3.83s-5.85,3.84-1.43,7.81,13,3.27,13,3.27S-.89,43.33,0,30.93,14.86,6.71,14.86,6.71Z" />
      </g>
    <g id="confetti_1">
      <polygon class="color" points="0 6.23 12.76 0 17.43 6.23 9.96 16.81 0 6.23"/>
    </g>
<!--     <g id="confetti_2">
      <path class="color" d="M11.59,15.75a7.1,7.1,0,0,1-5.32-2.28,8.26,8.26,0,0,1-2.09-4.4A38.65,38.65,0,0,1,1.12,6.31,13.72,13.72,0,0,0,0,5.26l.1,0L1.26,2.54a7.49,7.49,0,0,1,2,1.63c.39.38.84.82,1.33,1.28a9.7,9.7,0,0,1,7-5.36c1.86-.32,3.32.23,4,1.48.77,1.45,2,4.24,1.17,6.68a4.92,4.92,0,0,1-2.6,2.93,7.21,7.21,0,0,1-5.55.35,4.19,4.19,0,0,0,3.5,1.2c3.31-.29,6.62-1.59,6.11-9l3-.2c.52,7.54-2.45,11.64-8.83,12.21ZM7.11,7.5c1.8,1.19,3.81,1.91,5.67,1a2,2,0,0,0,1.08-1.15,6.26,6.26,0,0,0-.93-4.29,3.77,3.77,0,0,0-2.38.48c-1.4.65-3.13,2-3.41,3.75Z"/>
    </g> -->
    <g id="confetti_2">
      <polygon class="color" points="0 21.79 10.53 0 15.2 2.18 4.93 25.21 0 21.79"/>
    </g>
  </defs>
</svg>

<svg id="behind" width="1" height="1" ></svg>
   
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/gsap.3.5.2.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/DrawSVGPlugin3.min.js"></script>

      <script  >
      
console.clear();

let size = { width: 0, height: 0 };

const svg = document.getElementById('svg');
const behind_svg = document.getElementById('behind');
const onResize = (e) =>
{
  size.width = window.innerWidth;
  size.height = window.innerHeight;
};

onResize();
window.addEventListener('resize', () => onResize());

const getColor = () => {
  return "hsl(" + 360 * Math.rand.........完整代码请登录后点击上方下载按钮下载查看

网友评论0