How can I add multiple feOffset shadows in an SVG filter? - Stack Overflow

I want to create a faux extrusion effect by stacking multiple feOffset in my filter.Is this possible?

I want to create a faux extrusion effect by stacking multiple feOffset in my filter.

Is this possible?

Something like:

<svg height="150" width="150" xmlns="">
  <defs>
    <filter id="f1" width="120" height="120">
      <feOffset in="SourceAlpha" dx="10" dy="10" />
      <feBlend in="SourceGraphic" in2="offOut" />
      <feOffset in="SourceAlpha" dx="20" dy="20" />
      <feBlend in="SourceGraphic" in2="offOut" />
    </filter>
  </defs>
  <rect width="90" height="90" fill="yellow" filter="url(#f1)" />
</svg>

I want to create a faux extrusion effect by stacking multiple feOffset in my filter.

Is this possible?

Something like:

<svg height="150" width="150" xmlns="http://www.w3./2000/svg">
  <defs>
    <filter id="f1" width="120" height="120">
      <feOffset in="SourceAlpha" dx="10" dy="10" />
      <feBlend in="SourceGraphic" in2="offOut" />
      <feOffset in="SourceAlpha" dx="20" dy="20" />
      <feBlend in="SourceGraphic" in2="offOut" />
    </filter>
  </defs>
  <rect width="90" height="90" fill="yellow" filter="url(#f1)" />
</svg>

Share Improve this question asked Mar 26 at 3:19 user500665user500665 1,3801 gold badge13 silver badges45 bronze badges 2
  • 1 Yes it's possible - multiple ways of doing it. The most straightforward is to do multiple offsets, label each one with a result and then use a feMerge to condense them. The code that you have won't retain the result of the first offset, it will be discarded. I wrote a tool for text effects that include extrusion - have a look: codepen.io/mullany/pen/qOqxpG – Michael Mullany Commented Mar 26 at 20:52
  • @MichaelMullany Yes feMerge is what I was after. Maybe add that as an answer? – user500665 Commented Mar 27 at 20:16
Add a comment  | 

1 Answer 1

Reset to default 0

Yes it's possible - multiple ways of doing it. The most straightforward is to do multiple offsets, label each one with a result and then use a feMerge to condense them. (The code that you have won't retain the result of the first offset, it will be discarded. You have to label something with a result= if you want to use it as an input to anything other than the next primitive.)

<svg height="150" width="150" xmlns="http://www.w3./2000/svg">
  <defs>
    <filter id="f1" width="120" height="120">
      <feOffset in="SourceAlpha" dx="10" dy="10" result="off1" />
      <feOffset dx="10" dy="10" result="off2"/>
      <feOffset dx="10" dy="10" result="off3"/>
      <feMerge>
          <feMergeNode in="SourceGraphic"/>   
          <feMergeNode in="off1"/>
          <feMergeNode in="off2"/>
          <feMergeNode in="off3"/>
      </feMerge>
    </filter>
  </defs>
  <rect width="90" height="90" fill="yellow" filter="url(#f1)" />
</svg>

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744166921a4561344.html

相关推荐

  • How can I add multiple feOffset shadows in an SVG filter? - Stack Overflow

    I want to create a faux extrusion effect by stacking multiple feOffset in my filter.Is this possible?

    8天前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信