SVG画任意一段圆弧

先上设计图 要求实现效果

SVG圆弧

我们可以使用SVG的circle或者path画出任意一段圆弧
<path stroke-width="5" style="transition: 0.5s 0s linear;" fill="none" stroke="#00BCD4" stroke-linecap="round" stroke-linejoin="round" id="arc3" d="M <%print(1600+1600*Math.cos(Math.PI/2+(parseInt((screen.width-20)/6)-20)/1600))%> <%print(1600+1600*Math.sin(Math.PI/2+(parseInt((screen.width-20)/6)-20)/1600))%> A1600 1600 0 0 0 <%print(1600+1600*Math.cos(Math.PI/2-(parseInt((screen.width-20)/6)-20)/1600))%> <%print(1600+1600*Math.sin(Math.PI/2-(parseInt((screen.width-20)/6)-20)/1600))%>"></path>
<path stroke-width="5"  fill="none" stroke="#00BCD4" stroke-linecap="round" 
 d="M 1461 3194 A1600 1600 0 0 0 1511 3197"></path>
path的d属性用来绘制圆弧 “M cx cy A rx ry x-axis-rotation large-arc-flag sweep-flag x y”

cr cy为起点坐标,x y为终点坐标计算方法为(cx,cy为圆心所在坐标)
x=cx+rxcos(π/2+θ)
y=cy−ry
sin(π/2+θ)
sweep-flag 是标记向顺时针(1)还是逆时针(0)方向绘制。
x-axis-rotation 是椭圆相对于坐标系的旋转角度,角度数而非弧度数。
large-arc-flag 是标记绘制大弧(1)还是小弧(0)部分。

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

一颗小行星!

恰饭ing

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值