How to make an inset shadow in SVG-PHP Chinese Network Q&A
How to make an inset shadow in SVG
P粉311089279
P粉311089279 2023-10-21 15:57:11
0
2
604

I need to make a box with an inline shadow, just like CSS3 has an inline box shadow. What I've found so far is a filter with feGaussianBlur, but the problem is that it also adds a shadow outside the box, which I don't want. This is the code I've got so far:

               

I made a demo and compared this code with the desired CSS production result. This filter works not only on rectangles, but also on trapezoids and more complex polygons.

I've tried using RadialGradient, but that's not good either since this makes the gradient circular.

P粉311089279
P粉311089279

reply all (2)
P粉287345251

Based mostly onexperiments I found, this is what I came up with:

                  

If you want to see padding, uncomment the last . Unfortunately,fill="transparent"does not give the filter a usable alpha, nor does it produce a shadow.

    P粉216203545

    If you have solid padding, you can add

    Towards the end of the filter, it will clip the blur to the shape of the SourceGraphic. Since your shape is transparent, you need to do more work. I recommend using a semi-transparent fill on the original shape so you get the correct composition selection, and using feFuncA to zero out the fill for the final operation. This turns out to be very complicated. But here is a solution that works for any solid line shape

                           

    This is my fiddle branch:http://jsfiddle.net/kkPM4/

      Latest Downloads
      More>
      Web Effects
      Website Source Code
      Website Materials
      Front End Template
      About us Disclaimer Sitemap
      php.cn:Public welfare online PHP training,Help PHP learners grow quickly!