本文介绍了用渐变填充SVG形状的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何将线性渐变和阴影应用于此图案?
How can I apply Linear gradient and drop shadow to this pattern?
<svg viewbox="0 0 60 10">
<pattern x="-8" id="waves" patternUnits="userSpaceOnUse" width="10" height="10">
<path d="M0 10 V5 Q2.5 3.5 5 5 T10 5 V10" fill="#FFC338" />
</pattern>
<rect x="0" y="0" width="60" height="7" fill="url(#waves)" />
</svg>
推荐答案
,您需要将波浪形状转换为一条路径,然后才能用一个线性渐变,如以下示例所示:
As commented by Paul LeBeau, you need to convert the wavy shape to one path, then you can fill the wavy shape with a linear gradient as shown in this example:
<svg viewbox="7.5 0 60 10">
<defs>
<linearGradient id="gradient">
<stop offset="5%" stop-color="#FFC338" />
<stop offset="95%" stop-color="#FFEA68" />
</linearGradient>
</defs>
<path fill="url(#gradient)" d="M0 10 V5 Q2.5 2.5 5 5 t5 0 t5 0 t5 0 t5 0 t5 0 t5 0 t5 0 t5 0 t5 0 t5 0 t5 0 t5 0 t5 0 t5 0 V10" />
</svg>
这篇关于用渐变填充SVG形状的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!