0

I want to apply a filter on a svg clip-path.

Here is my code,

<svg>
    <filter id="filter">
        <feGaussianBlur stdDeviation="10"></feGaussianBlur>
    </filter>
    <clipPath id="clip-path">
        <rect width="200" height="100" x="0" y="0" filter="url(#filter)"/>
    </clipPath>
    <g clip-path="url(#clip-path)">
        <image xlink:href="image.png" width="100%" height="100%" />
    </g> 
</svg>

Any idea?

4

1 回答 1

2

I don't believe that you can apply a filter directly to a clip-path, but you can apply the blur on a wrapper g element like this:

<svg width="600px" height="300px">
    <filter id="filter">
        <feGaussianBlur stdDeviation="10"></feGaussianBlur>
    </filter>
    <clipPath id="clip-path">
        <rect width="200" height="100" x="0" y="0" />
    </clipPath>
  <g filter="url(#filter)">
    <g clip-path="url(#clip-path)">
        <image xlink:href="http://image.png" width="100%" height="100%" />
    </g> 
  </g>
</svg>
于 2016-06-03T15:26:12.540 回答