效果:

实现可配置图像大小、水面高度、波浪高度、波浪速度等

<template><div class="wave-svg" :style="`width:${width}px;height:${height}px;`"><div style="width:100%;height:100%;"><svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" :width="width" :height="height" :viewbox="`0 0 ${width} ${height}`"><defs><linearGradient id="line1" x1="0%" y1="0%" x2="0%" y2="100%"><stop offset="0%" style="stop-color:#3DCDEA;stop-opacity:1"/><stop offset="100%" style="stop-color:#0070EA; stop-opacity:1"/></linearGradient></defs><defs><linearGradient id="line2" x1="0%" y1="0%" x2="0%" y2="100%"><stop offset="0%" style="stop-color:#4AB5FF;stop-opacity:1"/><stop offset="100%" style="stop-color:#3686FF; stop-opacity:1"/></linearGradient></defs><defs><linearGradient id="line3" x1="0%" y1="0%" x2="0%" y2="100%"><stop offset="0%" style="stop-color:#49A1FF;stop-opacity:1"/><stop offset="100%" style="stop-color:#3686FF;stop-opacity:1"/></linearGradient></defs><path v-if="topLinePath" :d="topLinePath" stroke="transparent" fill="url(#line3)"><animateTransform attributeType="XML" attributeName="transform" begin="0s" :dur="`${speedTop}s`" type="translate" from="0 0" :to="`${bulgeDistance*4} 0`" repeatCount="indefinite" /></path><path v-if="centerLinePath" :d="centerLinePath" stroke="transparent" fill="url(#line2)"><animateTransform attributeType="XML" attributeName="transform" begin="0s" :dur="`${speedCenter}s`" type="translate" from="0 0" :to="`${bulgeDistance*4} 0`" repeatCount="indefinite" /></path><path v-if="bottomLinePath" :d="bottomLinePath" stroke="transparent" fill="url(#line1)"><animateTransform attributeType="XML" attributeName="transform" begin="0s" :dur="`${speedBottom}s`" type="translate" from="0 0" :to="`${bulgeDistance*4} 0`" repeatCount="indefinite" /></path></svg></div></div>
</template>
<script>
export default {props:{width:{type:Number,      //图像宽度default:450},height:{type:Number,      //图像高度default:400},waterHeight:{type:Number,      //水面高度default:360},bulgeHeight:{type:Number,      //波浪起伏高度default:15},bulgeDistance:{type:Number,      //波浪起伏间隔default:30},lineDistance:{type:Number,      //三条线的距离default:20},speedTop:{type:Number,      //第一根线速度default:1},speedCenter:{type:Number,      //第一根线速度default:1},speedBottom:{type:Number,      //第一根线速度default:1},},data(){return{topLinePath:null,centerLinePath:null,bottomLinePath:null,}},mounted(){this.init()},methods:{init(){let num = Math.floor(this.width/this.bulgeDistance)let basicPoint = this.height - this.waterHeightlet basicPointCenter = this.height - this.waterHeight + this.lineDistancelet basicPointBottom = this.height - this.waterHeight + this.lineDistance*2let topLinePath = `M ${-4*this.bulgeDistance} ${basicPoint} Q ${-3*this.bulgeDistance} ${basicPoint - this.bulgeHeight} ${-2*this.bulgeDistance} ${basicPoint} T 0 ${basicPoint}`for(var i=1;i<num;i++){topLinePath += ` T ${this.bulgeDistance*i*2} ${basicPoint} `}topLinePath += `v ${this.height} h -${3*num*this.bulgeDistance} z`let centerLinePath = `M ${-5*this.bulgeDistance} ${basicPointCenter} Q ${-4*this.bulgeDistance} ${basicPointCenter - this.bulgeHeight} ${-3*this.bulgeDistance} ${basicPointCenter} T ${-this.bulgeDistance} ${basicPointCenter}`for(var i=1;i<num;i++){centerLinePath += ` T ${-this.bulgeDistance + this.bulgeDistance*i*2} ${basicPointCenter} `}centerLinePath += `v ${this.height} h -${3*num*this.bulgeDistance} z`let bottomLinePath = `M ${-4*this.bulgeDistance} ${basicPointBottom} Q ${-3*this.bulgeDistance} ${basicPointBottom - this.bulgeHeight} ${-2*this.bulgeDistance} ${basicPointBottom} T 0 ${basicPointBottom}`for(var i=1;i<num;i++){bottomLinePath += ` T ${this.bulgeDistance*i*2} ${basicPointBottom} `}bottomLinePath += `v ${this.height} h -${3*num*this.bulgeDistance} z`this.topLinePath = topLinePaththis.centerLinePath = centerLinePaththis.bottomLinePath = bottomLinePath}},watch:{waterHeight(){this.init()}}
}
</script>
<style lang="scss">
// .wave-svg{
//   width: 100%;
//   height: 100%;
// }
</style>

vue + svg 绘制水波纹、波浪动画效果相关推荐

  1. 【前端】CSS3、Canvas、SVG等5种方式实现水波纹波浪动画特效

    目录 一.CSS3动画+图片波浪效果 1. 效果图 2. 代码 3. 原理 二.纯CSS3圆盘波浪进度效果 三.纯CSS3涟漪效果 四.Canvas波浪效果 五.SVG+jQuery波浪效果 六.源码 ...

  2. css —— 按钮水波纹扩散动画效果实现

    一. 效果 ​​​​​​​ 二. 代码 <div class="feature"><div class="feature-box">&l ...

  3. vue+ svg实现水波纹

    <!--* @Author: 潘多拉平* @Description: --> <template><svgversion="1.1"id=" ...

  4. SVG滤镜波浪动画效果

    今天给大家分享一个用SVG实现的滤镜波浪动画效果,效果如下: 以下是代码实现,欢迎大家复制粘贴和收藏. <!DOCTYPE html> <html lang="en&quo ...

  5. SVG网页波浪动画效果背景

    给大家分享一个SVG网页波浪动画效果背景 CSS部分 <style> .body { min-height: 100vh; display: -webkit-box; display: f ...

  6. android动画水波纹外扩,Android实现水波纹外扩效果的实例代码

    微信曾经推出了一个查找附近好友的功能,大致功能是这样的:屏幕上有一个按钮,长按按钮的时候,会有一圈圈水波纹的动画向外扩散,松手后,动画结束. 现在简单来实现这样的一个动画功能: 思路: 主要用到了下面 ...

  7. android自定义控件几种,Android 自定义View一个控件搞定多种水波纹涟漪扩散效果 - CSDN博客...

    效果图 实现思路 这个效果实现起来并不难,重要的是思路 此View满足了多种水波纹涟漪扩散效果,这要求它能满足很多的变化 根据上面的样式,可以看出此View需要满足以下变化 圆圈从中心可循环向外扩散 ...

  8. android l 效果,[原]Android L中水波纹点击效果的实现

    博主参加了2014 CSDN博客之星评选,帮我投一票吧. 前言 前段时间android L(android 5.0)出来了,界面上做了一些改动,主要是添加了若干动画和一些新的控件,相信大家对view的 ...

  9. android曲线水波纹录音动画,Android-贝塞尔曲线实现水波纹动画

    Android 系统api提供了quadTo和rQuadTo实现二阶贝塞尔曲线,三阶贝塞尔曲线在这不做阐述,只不过是两个控制点. 效果图 首先看张二阶贝赛尔的曲线 Path path = new Pa ...

最新文章

  1. Python中的数据结构
  2. 浏览是不是计算机网络功能,什么是因特网——计算机网络是怎么为你服务的?...
  3. java 传 复合类型对象_struts复合类型传值(对象传值)
  4. acwing yxc总结时间算法复杂度
  5. jackson 问题定位
  6. 微软CEO鲍尔默力推HTML5:称其为平台的粘合剂
  7. Android锁机样本分析
  8. java爬虫下载付费html网页模板
  9. NEFU 560 半数集
  10. 北京科技大学研究生考试 《工程热力学》(2003年-2011年)
  11. 使用sikuli和Arquillian测试HTML5 canvas应用程序
  12. python大神的成长之路_我的Python成长之路
  13. 查找特定的值(信息学奥赛一本通-T1110)
  14. POST—GET—两种提交方式的区别
  15. Google App Engine已经支持JAVA了
  16. python编译备忘
  17. 为大家提供几个开发职位
  18. Python多进程实现原理
  19. 使用网络调试助手连接EMQ服务器
  20. USB Composite 组合设备之多路CDC实现

热门文章

  1. Android adb命令使用记录
  2. Linux内核Ramdisk(initrd)机制【转】
  3. Web前端:实现在一块区域(div)点击链接,在同一页面的指定区域显示链接的内容——基于css与div结合网页布局设计
  4. 医美企业如何玩转私域流量?
  5. 利用python实现两个文件夹的同步
  6. 一、jSP简介(前置知识)
  7. 如何不写代码通过爬虫软件采集表格数据
  8. 高校数字化实验室(实训室)综合管理系统
  9. 时间片轮转算法源代码
  10. 5.5.2指令流水线 影响因素分类