svg+js实现视觉差异立体鱼塘金鱼游动动画效果代码

代码语言:html

所属分类:视觉差异

代码描述:svg+js实现视觉差异立体鱼塘金鱼游动动画效果代码

代码标签: svg js 视觉差异 立体 鱼塘 金鱼 游动 动画

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


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

<head>

  <meta charset="UTF-8">
  

  
  
  
  
<style>
HTML {
  overflow: hidden;
}

body {
  margin: 0;
  width: 100%;
  height: 100%;
}

.page {
  width: 100vw;
  height: 100vh;
  background-color: #fff;
  color: #fff;
  font-weight: bold;
  text-align: center;
  padding: 30px;
}

.cls-1 {
  fill: #8dcbdc;
}

.cls-2 {
  fill: #fff;
}

.cls-3 {
  fill: #68bad1;
}

.cls-4 {
  fill: #00559c;
}

.cls-5 {
  fill: #3aa5c2;
}

.cls-6 {
  fill: #2a8bbe;
}

svg {
  display: block;
  width: 500px;
  height: 500px;
  fill: #fff;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  overflow: hidden;
}
svg.base {
  transform: translate(-50%, -50%) perspective(200px) translateZ(-200px);
}
svg.cover {
  transform: translate(-50%, -50%) perspective(200px) translateZ(75px);
}
svg .fish {
  filter: drop-shadow(3px 3px 5px rgba(0, 0, 0, 0.5));
  transform-origin: 250px 250px;
  animation-name: fishAll;
  animation-duration: 80s;
  animation-iteration-count: infinite;
  animation-timing-function: linear;
}
svg .fish2 {
  transform-origin: 250px 250px;
  animation-name: fishAll2;
  animation-duration: 80s;
  animation-iteration-count: infinite;
  animation-timing-function: linear;
}
svg .fish2 .fish-body {
  animation-direction: alternate-reverse;
}
svg .fish2 .fish-tail {
  animation-direction: alternate;
}
svg .fish-body {
  fill: #e74e19;
  transform-origin: 327.66px 264.13px;
  animation-name: fishSwim;
  animation-direction: alternate;
  animation-timing-function: ease-in;
  animation-duration: 2.5s;
  animation-iteration-count: infinite;
}
svg .fish-tail {
  fill: #dc4817;
  transform-origin: 327.66px 264.13px;
  animation-name: fishSwim;
  animation-direction: alternate-reverse;
  animation-timing-function: ease-in;
  animation-duration: 2.5s;
  animation-iteration-count: infinite;
}
svg:nth-child(1) {
  filter: drop-shadow(3px 3px 5px rgba(0, 0, 0, 0.5));
  transform: translate(-50%, -50%) perspective(200px) translateZ(-160px);
  transition: transform 0.1s;
}
svg:nth-child(2) {
  filter: drop-shadow(3px 3px 5px rgba(0, 0, 0, 0.5));
  transform: translate(-50%, -50%) perspective(200px) translateZ(-120px);
  transition: transform 0.1s;
}
svg:nth-child(3) {
  filter: drop-shadow(3px 3px 5px rgba(0, 0, 0, 0.5));
  transform: translate(-50%, -50%) perspective(200px) translateZ(-80px);
  transition: transform 0.1s;
}
svg:nth-child(4) {
  filter: drop-shadow(3px 3px 5px rgba(0, 0, 0, 0.5));
  transform: translate(-50%, -50%) perspective(200px) translateZ(-40px);
  transition: transform 0.1s;
}
svg:nth-child(5) {
  filter: drop-shadow(3px 3px 5px rgba(0, 0, 0, 0.5));
  transform: translate(-50%, -50%) perspective(200px) translateZ(0px);
  transition: transform 0.1s;
}

@keyframes fishSwim {
  0% {
    transform: rotate(-10deg);
  }
  100% {
    transform: rotate(10deg);
  }
}
@keyframes fishAll {
  0% {
    transform: rotate(0);
  }
  100% {
    transform: rotate(-360deg);
  }
}
@keyframes fishAll2 {
  0% {
    transform: rotate(115deg);
  }
  100% {
    transform: rotate(-475deg);
  }
}
</style>


</head>

<body >
  <div class="page">
      <div class="svg-wrap">
        <svg class="base" viewBox="0 0 500 500">
          <g class="paths">
            <rect class="cls-4" y="0.25" width="500" height="500"/>
          </g>
        </svg>
        <svg class="move" viewBox="0 0 500 500">
          <g class="paths">
            <path class="cls-6" d="M0,0V500H500V0ZM406.35,244.87c-9.18,11.87-29.12,11.83-36.83,24.71-11.65,19.47,16.11,46.11,4.26,65.46-7,11.4-24.44,13.19-30.57,25.07-4.37,8.45-1.27,18.82-3.29,28.12-6.92,31.88-48.53,24.94-69.85,15.34-19.14-8.61-38.57-20.32-59.43-18.07-10.95,1.19-21.09,6.18-31.79,8.76s-23.32,2.2-31-5.65c-11.75-12-5.52-33.29-14.79-47.26-2.89-4.36-7.08-7.65-11.23-10.83-6-4.61-12.2-9.26-17.85-14.37-6.72-6.08-12.69-12.81-16.74-20.88-16.66-33.18,15.57-39.69,24.11-65.22,5.5-16.46-9.93-31.05-18.56-44.44-1.66-2.58-3.37-5.28-3.75-8.34-1-8.14,7.92-14.36,16.1-14.94s16.24,2.34,24.45,2.44c15,.2,28.58-9,38.69-20s17.72-24.14,27.58-35.4c3.83-4.38,8.35-8.66,14.05-9.82,8-1.64,15.91,3.35,21.48,9.32S241.24,122,247.69,127c14.7,11.41,36.19,8.24,52.94.13C310.7,122.28,320.15,115.81,331,113s24-1,30.51,8.1c8,11.1,2.7,26.69,5.55,40.09,3.46,16.22,18.16,27.06,29.52,39.15S416.5,231.75,406.35,244.87Z"/>
            <circle class="cls-2" cx="175.27" cy="150.82" r="14.95"/>
            <circle class="cls-2" cx="297.55" cy="419.84" r="6.79"/>
            <g class="fish2">
              <path class="fish-tail" d="M321.39,290.74l3.3-2.33a5.16,5.16,0,0,1,5.95,0l3.3,2.33c1.42,1,2.9-1.17,2.28-3.33l-.92-7.53a44.19,44.19,0,0,0-3.3-12.21l-4.34-10.06-4.43,10a40.28,40.28,0,0,0-3.2,11.74l-.92,8.07C318.49,289.57,320,291.74,321.39,290.74Z"/>
              <path class="fish-body" d="M337.43,241.29c-.82-9.29-4.21-16.22-9.77-16.22-5.82,0-9,6.94-9.78,16.22-4.72,1.85-11.78,6-7.2,13.3a1.28,1.28,0,0,0,2.23-.08,55.05,55.05,0,0,1,4.82-7.61c.34,11,6,19.25,9.93,19.77s9.6-8.73,9.94-19.77a55.05,55.05,0,0,1,4.82,7.61,1.28,1.28,0,0,0,2.23.08C349.24,247.29,342.15,243.13,337.43,241.29Z"/>
            </g>
          </g>
        </svg>
      <svg class="move" viewBox="0 0 500 500">
       <g class="paths">
        <path class="cls-5" d="M0,0V500H500V0ZM406.35,244.87c-9.18,11.87-29.12,11.83-36.83,24.71-11.65,19.47,16.11,46.11,4.26,65.46-7,11.4-24.44,13.19-30.57,25.07-4.37,8.45-1.27,18.82-3.29,28.12-6.92,31.88-48.53,24.94-69.85,15.34-19.14-8.61-38.57-20.32-59.43-18.07-10.95,1.19-21.09,6.18-31.79,8.76s-23.32,2.........完整代码请登录后点击上方下载按钮下载查看

网友评论0