SVG 画出动态线条流动效果

2024-02-21 23:08
文章标签 动态 效果 svg 流动 线条

本文主要是介绍SVG 画出动态线条流动效果,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

版權聲明: 著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

最近做了一个项目 UI图长这样

中间的线条没有gif 需要用代码画出来
尝试了很多种方法 最终选择了用svg画

下面是全部的代码

<template><div class="right-page"><Subtitles :hanzi="title.zh" :yingyu="title.en" class="title"></Subtitles><div class="tab-box"><divclass="tab-item"v-for="(item, index) in TabList":key="index":class="{ active: currentIndex === index }"@click.stop="activeClick(index)">{{ item }}</div></div><imgsrc="../img/leftbtn.png"alt=""class="leftBtn"@click.stop="leftBtnClick"/><imgsrc="../img/leftbtn.png"alt=""class="rightBtn"@click.stop="rightBtnClick"/><img src="../img/xiamtu.png" alt="" class="tab-content" /><!--  4条svg 线条 --><div class="container"><div class="line-wrap"><!-- 111 --><svgversion="1.1"xmlns="http://www.w3.org/2000/svg"xmlns:xlink="http://www.w3.org/1999/xlink"xml:space="preserve"class="circle-load-rect-svg"viewbox="0 0 600 400"><polyline:points="svgData[currentIndex][0]"fill="none"class="g-rect-path"stroke="#007084"/><polyline:points="svgData[currentIndex][0]"fill="none"class="g-rect-fill"stroke="#00e9f9"/></svg><!-- 222 --><svgversion="1.1"xmlns="http://www.w3.org/2000/svg"xmlns:xlink="http://www.w3.org/1999/xlink"xml:space="preserve"class="circle-load-rect-svg"viewbox="0 0 600 400"><polyline:points="svgData[currentIndex][1]"fill="none"class="g-rect-path"stroke="#805c2c"/><polyline:points="svgData[currentIndex][1]"fill="none"class="g-rect-fill"stroke="#feee3c"/></svg><!-- 333 --><svgversion="1.1"xmlns="http://www.w3.org/2000/svg"xmlns:xlink="http://www.w3.org/1999/xlink"xml:space="preserve"class="circle-load-rect-svg"viewbox="0 0 600 400"><polyline:points="svgData[currentIndex][2]"fill="none"class="g-rect-path"stroke="#19875c"/><polyline:points="svgData[currentIndex][2]"fill="none"class="g-rect-fill"stroke="#3aeca1"/></svg><!-- 444 --><svgversion="1.1"xmlns="http://www.w3.org/2000/svg"xmlns:xlink="http://www.w3.org/1999/xlink"xml:space="preserve"class="circle-load-rect-svg"viewbox="0 0 600 400"><polyline:points="svgData[currentIndex][3]"fill="none"class="g-rect-path"stroke="#18808e"/><polyline:points="svgData[currentIndex][3]"fill="none"class="g-rect-fill"stroke="#36f4fb"/></svg></div></div><span class="bottom-title">信息机房应用成效</span></div>
</template><script>
import Subtitles from '../../../publicoComponents/Subtitles.vue'export default {props: {},data () {return {title: {zh: '信息机房应用成效',en: 'Application effectiveness of information room'},TabList: ['联通互通', '云边协作', '数字可视化', '系统对接'],currentIndex: 0,svgData: [['200,0 200,30 930,30 930,97', '180,0 180,50 753,50 753,97', '160,0 160,70 580,70 580,97', '140,0 140,90 405,90 405,96'],['530,0 530,30 930,30 930,97', '510,0 510,50 753,50 753,97', '490,0 490,70 580,70 580,97', '470,0 470,90 405,90 405,96'],['860,0 860,97 930,97 930,97', '840,0 840,50 840,97 753,97', '820,0 820,83 580,83 580,97', '800,0 800,70 405,70 405,96'],['1190,0 1190,97 930,97 930,97', '1170,0 1170,83 753,83 753,97', '1150,0 1150,70 580,70 580,97', '1130,0 1130,58 405,58 405,96']]}},computed: {},mounted () {},methods: {activeClick (index) {this.currentIndex = index},leftBtnClick () {if (this.currentIndex === 0) {this.currentIndex = 3return}this.currentIndex--},rightBtnClick () {if (this.currentIndex === 3) {this.currentIndex = 0return}this.currentIndex++}},components: {Subtitles}
}
</script><style scoped lang="less">
.right-page {height: 100%;background-image: url("../img/dizuo.png");background-repeat: no-repeat;background-position: 50% 90%;position: relative;
}
.title {padding-top: 30px;
}
.tab-box {display: flex;width: 1320px;margin: 0 auto;padding-top: 80px;.tab-item {background-image: url("../img/3hdfa.png");background-repeat: no-repeat;background-position: center;width: 224px;margin: 0 auto;height: 164px;line-height: 122px;text-align: center;color: #fff;font-size: 24px;font-family: MicrosoftYaHei;opacity: 0.6;}.active {opacity: 1;}
}
.leftBtn {position: absolute;top: 19.5%;left: 13%;
}
.rightBtn {position: absolute;transform: rotate(180deg);top: 19.5%;left: 84%;
}
.tab-content {position: absolute;left: 50%;top: 50%;transform: translate(-50%, -46%);
}
.container {width: 100%;margin-top: -20px;
}
.line-wrap {width: 1350px;margin: 0 auto;position: relative;
}
.line-wrap svg:nth-child(2) {position: absolute;top: 0;
}
.line-wrap svg:nth-child(3) {position: absolute;top: 0;
}
.line-wrap svg:nth-child(4) {position: absolute;top: 0;
}
.circle-load-rect-svg {width: 1350px;margin: 10px;
}.g-rect-path {fill: none;stroke-width: 3;stroke-linejoin: round;stroke-linecap: round;
}.g-rect-fill {fill: none;stroke-width: 5;stroke-linejoin: round;stroke-linecap: round;stroke-dasharray: 3, 900;stroke-dashoffset: -100;animation: lineMove 3s cubic-bezier(0, 0, 0.74, 0.74) infinite;
}@keyframes lineMove {0% {stroke-dashoffset: -850;}100% {stroke-dashoffset: -0;}
}
.bottom-title {position: absolute;bottom: 30%;width: 100%;font-size: 36px;font-family: Microsoft YaHei;font-weight: bold;color: #38dcff;text-align: center;line-height: 38px;background: linear-gradient(0deg, #2de9ff 0.146484375%, #2fa9ff 99.31640625%);-webkit-background-clip: text;-webkit-text-fill-color: transparent;
}
</style>

这篇关于SVG 画出动态线条流动效果的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/733380

相关文章

以canvas方式绘制粒子背景效果,感觉还可以

这个是看到项目中别人写好的,感觉这种写法效果还可以,就存留记录下 就是这种的背景效果。如果想改背景颜色可以通过canvas.js文件中的fillStyle值改。 附上demo下载地址。 https://download.csdn.net/download/u012138137/11249872

echarts省份标注加散点效果

这个是安徽的效果图,鼠标移到红色标注或者对应的市区位置都会显示对应的数值。 先直接上代码: import anhuiMapJson from './anhui.json'getCoords: function(city) {var res = [];if (city != null) {for (var c in this.cityMap.features) {if (this.cityMa

【杂记-浅谈DHCP动态主机配置协议】

DHCP动态主机配置协议 一、DHCP概述1、定义2、作用3、报文类型 二、DHCP的工作原理三、DHCP服务器的配置和管理 一、DHCP概述 1、定义 DHCP,Dynamic Host Configuration Protocol,动态主机配置协议,是一种网络协议,主要用于在IP网络中自动分配和管理IP地址以及其他网络配置参数。 2、作用 DHCP允许计算机和其他设备通

JavaWeb系列六: 动态WEB开发核心(Servlet) 上

韩老师学生 官网文档为什么会出现Servlet什么是ServletServlet在JavaWeb项目位置Servlet基本使用Servlet开发方式说明快速入门- 手动开发 servlet浏览器请求Servlet UML分析Servlet生命周期GET和POST请求分发处理通过继承HttpServlet开发ServletIDEA配置ServletServlet注意事项和细节 Servlet注

XMG 抽屉效果

1.比如说我创建了3个View -(void)viewDidLoad{  [ super viewDidLoad]; [self setUpChild] ;         UIPanGestureRecognizer *pan=[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(pan:)];

OSG学习:LOD、数据分页、动态调度

LOD(level of detail):是指根据物体模型的结点在显示环境中所处的位置和重要度,决定物体渲染的资源分配,降低非重要物体的面数和细节度,从而获得高效率的渲染运算。在OSG的场景结点组织结构中,专门提供了场景结点osg::LOD来表达不同的细节层次模型。其中,osg::LOD结点作为父节点,每个子节点作为一个细节层次,设置不同的视域,在不同的视域下显示相应的子节点。 数据分页:在城市

Java代理-动态字节码生成代理的5种方式

上篇讲到了代理模式出现的原因,实现方式以及跟其他相似设计模式的区别。传送门@_@ http://blog.csdn.net/wonking666/article/details/79497547 1.静态代理的不足 设计模式里面的代理模式,代理类是需要手动去写的。但是手写代理的问题颇多 1.如果不同类型的目标对象需要执行同样一套代理的逻辑,比如说在方法调用前后打印参数和结果,那么仍然需要为每

33个jQuery与CSS3实现的绚丽鼠标悬停效果

只要你有创意,完全可以使用CSS3来实现漂亮的动效,当然如果配合jQuery,这样会更加强大,实现更多高级绚丽的动画效果。鼠标hover效果是很常用的,虽然很细微的东西,但网站的细节注定的网站的体验,所以也不要忽视这些小细节。 今天设计达人网整理了33个使用jQuery与CSS3实现绚丽的鼠标悬停效果,有些是纯CSS3的,这些效果你完全可以用在你的网页上,让网站获得更好的体验。 Anim

Android插件化学习之路(一)之动态加载综述

前段时间,公司项目完成了插件化的开发,自己也因此学习了很多Android插件化的知识,于是想把这些内容记录下来,本次带来Android插件化的第一篇:动态加载综述 Android插件化学习之路(一)之动态加载综述 Android插件化学习之路(二)之ClassLoader完全解析 Android插件化学习之路(三)之调用外部.dex文件中的代码 Android插件化学习之路(四)之使用插件中的R

自定义recyclerView实现时光轴效果

时光轴效果在很多app上都有出现,例如淘宝中快递的跟踪,本文将使用recyclerView实现时光轴效果,我们会到自定义控件,首先先看一下效果图: 接下来是步骤分析 1自定义属性 这个大家应该都了解了,根据我们之前的分析,直接在attrs.xml中进行声明 <declare-styleable name="TimeLine"><attr name="beginLine" f