Fill an SVG shape with a gradient

Shahid picture Shahid · May 19, 2016 · Viewed 18.8k times · Source

Wavy shape with gradient

wavy shape

linear gradient

How can I apply Linear gradient and drop shadow to this pattern?

Answer

web-tiki picture web-tiki · May 20, 2016

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>