How to draw a drop-shadow on a transparent rectangle?

后端 未结 4 1765
没有蜡笔的小新
没有蜡笔的小新 2021-01-06 07:55

When I add a dropshadow bitmap effect to a rectangle, the dropshadow takes into account the transparency of the rectangle (makes sense). Is there a way to render a dropshado

4条回答
  •  醉梦人生
    2021-01-06 08:09

    I'd love to see better solution, but here is what I usually do (beware: creepy code ahead).

    Wrap rectangle to three-four rectangles, and play with stroke color, making it darker and darker as it goes to original rectangle. Here is the code:

    
       
          
          
          
          
          
       
    
    

    This gives you:

    alt text http://img521.imageshack.us/img521/7664/shadowo.jpg

    Another approach would be with borders - it's better because you don't have to specify dimensions, when you put them inside Grid.

    And the best approach (never seen implemented though): custom pixel shader, which makes what you want.

提交回复
热议问题