How to use svg filters with raphael js?

前端 未结 3 1978
清歌不尽
清歌不尽 2021-01-13 10:02

i would like to know, which techniques should i use to apply svg filters to raphael paths?

I know that raphael tries to be as much cross browser with IE it can, but

3条回答
  •  伪装坚强ぢ
    2021-01-13 10:22

    One hacky way to use SVG filters with Raphael objects is the following technique. It creates Raphael rectangle and adds filter definition to the same SVG document. This of course doesn't work with older browsers which lack support for inline SVG. But this is not a big problem, because older browsers have also no SVG filter support.

    Although this is not jQuery tagged question, for simplicity the code uses jQuery for DOM manipulations. The namespace problem is solutioned using dummy SVG element, which has the advantage that SVG elements can be created using text strings (instead of DOM methods). Let the browser do what browser can!

    The working example is in http://jsbin.com/ilinan/1.

    
    
    
    
    
    
    
    
      

提交回复
热议问题