Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If you had a solid fill, you could just add</p> <pre><code>&lt;feComposite operator="in" in2="SourceGraphic"/&gt; </code></pre> <p>to the end of your filter and it would clip the blur to the shape of the SourceGraphic. Since your shape is transparent, you'll have to do a little more work. What I'd suggest is using a semi-transparent fill on the original graphic in order to get the right selection for compositing and using an feFuncA to zero out the fill for the final operation. This turns out to be surprisingly complicated. But here is a solution that will work for any solid-stroke shape</p> <pre><code>&lt;filter id="inset-shadow" &gt; &lt;!-- dial up the opacity on the shape fill to "1" to select the full shape--&gt; &lt;feComponentTransfer in="SourceAlpha" result="inset-selection"&gt; &lt;feFuncA type="discrete" tableValues="0 1 1 1 1 1"/&gt; &lt;/feComponentTransfer&gt; &lt;!-- dial down the opacity on the shape fill to "0" to get rid of it --&gt; &lt;feComponentTransfer in="SourceGraphic" result="original-no-fill"&gt; &lt;feFuncA type="discrete" tableValues="0 0 1"/&gt; &lt;/feComponentTransfer&gt; &lt;!-- since you can't use the built in SourceAlpha generate your own --&gt; &lt;feColorMatrix type="matrix" in="original-no-fill" result="new-source-alpha" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0" /&gt; &lt;feGaussianBlur in="new-source-alpha" result="blur" stdDeviation="5" /&gt; &lt;feGaussianBlur in="new-source-alpha" result="blur2" stdDeviation="10" /&gt; &lt;feGaussianBlur in="new-source-alpha" result="blur3" stdDeviation="15" /&gt; &lt;feMerge result="blur"&gt; &lt;feMergeNode in="blur" mode="normal"/&gt; &lt;feMergeNode in="blur2" mode="normal"/&gt; &lt;feMergeNode in="blur3" mode="normal"/&gt; &lt;/feMerge&gt; &lt;!-- select the portion of the blur that overlaps with your shape --&gt; &lt;feComposite operator="in" in="inset-selection" in2="blur" result="inset-blur"/&gt; &lt;!-- composite the blur on top of the original with the fill removed --&gt; &lt;feComposite operator="over" in="original-no-fill" in2="inset-blur"/&gt; &lt;/filter&gt; </code></pre> <p>here is my fork of your fiddle: <a href="http://jsfiddle.net/kkPM4/" rel="noreferrer">http://jsfiddle.net/kkPM4/</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload