【发布时间】:2019-06-24 14:53:24
【问题描述】:
我正在使用 GSAP 围绕一个圆圈制作一个笔画动画。这是Codepen。
我想要做的是在外部粉红色和(应该是)内部圆形图像之间留出间距,如下所示:
这是我的 SVG 代码:
<svg id='svg1' width='48' height='48' viewBox='0 0 48 48'>
<defs>
<clipPath id='circleView'>
<circle cx='24' cy='24' r='22' fill='none' stroke='#FF62E1' strokeWidth='2' />
</clipPath>
</defs>
<image
width='100%'
height='100%'
xlinkHref={'https://source.unsplash.com/random'}
clipPath='url(#circleView)'
/>
<circle
cx='24'
cy='24'
r='22'
fill='none'
stroke='#FF62E1'
strokeWidth='2'
strokeDasharray='100.48'
strokeDashoffset='100.48'
// @ts-ignore
ref={(circle) => { this.circle = circle }} >
>
</circle>
</svg>
我玩过filter 并使用多个圆圈来创建效果,但无济于事。
关于如何实现这一点的任何想法?
【问题讨论】:
-
第二个圆需要更大的半径。如果更改半径,则需要重新计算 stroke-dasharray 和 stroke-dashoffset 的路径长度。您还需要重新计算 SVG 画布的大小
-
@enxaneta 或更小的clipPath 圈子?
标签: reactjs animation svg geometry gsap