svg+js实现曲线上下起伏波动动画效果代码
代码语言:html
所属分类:动画
代码描述:svg+js实现曲线上下起伏波动动画效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> body { margin: 0; background-color: #282c34; display: flex; justify-content: center; align-items: center; height: 100vh; } svg { width: 100%; max-width: 600px; height: auto; } .st0 { fill: #FFFFFF; } </style> </head> <body translate="no"> <svg id="wave" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 362.89 65.69" preserveAspectRatio="none"> <path class="st0" d="M0,30.76c0,0,24.49-26.11,64.33-26.11c43.59,0,104.58,54.91,145.23,54.91s49.6-16.94,87.48-16.94s65.84,16.94,65.84,16.94v6.13H0V30.76z"/> </svg> <script > const wavePath = document.querySelector("#wave path"); const duration = 2000; let currentState = 0; const waveStates = [ [ { x: 64.33, y: 10 }, { x: 134.23, y: 60 }, { x: 200, y: 20 }, { x: 278.35, y: 45 }, { x: 362.89, y: 15 }], [ { x: 64.33, y: 60 }, { x: 134.23, y: 10 }, { x: 200, y: 20 }, { x: 278.35, y: 40 }, { x: 362.89, y: 20 }], [ { x: 64.33, y: 60 }, { x: 134.23, y: 10 }, .........完整代码请登录后点击上方下载按钮下载查看
网友评论0