Reputation: 925
I have an SVGimage element and I want that image to have a shadow using feOffset, feGaussianBlur, etc.
and at the same time, I need to set the image's brightness and contrast,
I tried the following code:
<image x="10" y="100" width="440" height="60" xlink:href="/images/pulpit.jpg" preserveAspectRatio="defer" filter="url(#drop)"></image>
<defs>
<filter id="drop" filterUnits="userSpaceOnUse">
<feComponentTransfer in="SourceAlpha" result="doo">
<feFuncR type="discrete" tablevalues="3" />
</feComponentTransfer>
<feOffset dx="80" dy="0" result="shadow" in="doo" />
<feGaussianBlur stdDeviation="20 0" in="shadow" result="blurOut"/>
<feBlend in="SourceGraphic" in2="blurOut" />
<feComponentTransfer in="SourceGraphic">
<feFuncR type="linear" slope="0.4" />
</feComponentTransfer>
</filter>
<defs>
</svg>
but it ended up only use the last filter (second feComponentTransfer), any ideas to apply for both filter?
the first feComponentTransfer until feBlend is to create a drop shadow, and the second feComponentTransfer is to set the brightness of the image itself(not the shadow)
Upvotes: 2
Views: 381
Reputation: 31715
It's always best to explicitly add "result" and "in"'s to your filters so you can keep track of what's feeding what. This is what has tripped you up here. As it stands, you have two filter chains that end with blurOut and an unnamed final result. You need to redo the order of your operations to adjust the sourcegraphic separately, then composite it on top of the shadow. Code below. And also...
A few cleanups:
Working code is:
<filter id="drop">
<feComponentTransfer in="SourceAlpha" result="doo">
<feFuncR type="discrete" tableValues="1 1" />
</feComponentTransfer>
<feOffset dx="80" dy="0" in="doo" result="shadow"/>
<feGaussianBlur stdDeviation="20 0" in="shadow" result="blurOut"/>
<feComponentTransfer in="SourceGraphic" result="unbrightsource">
<feFuncR type="linear" slope="0.4" />
</feComponentTransfer>
<feBlend mode="normal" in="unbrightsource" in2="blurOut" result="final"/>
</filter>
Upvotes: 0
Reputation: 124049
Presumably the in of the feComponentTransfer should be blurOut rather than the SourceGraphic which is the original input.
Upvotes: 1