I am trying to create an SVG where black or white squares are overlayed on an image using various blend modes. I'm using a filter with an feImage primitive for the picture, making it partially transparent with feColorMatrix, and blending it with the square with feBlend. The normal
blend mode works as I would expect it to, but multiply
does not. Here's what I'm getting:
Here's a jsfiddle with the svg code
For multiplying with white (bottom-middle square), I expected it not to lighten the image at all, regardless of opacity, since multiplying with white is basically like multiplying by 1. For black (middle-top square), I expect it to darken the image according to its transparency. These are the things that happen when I play around in GIMP.
The SVG spec has the formulae for various blend modes here, if you're wondering (I can't post more than 2 links with my current reputation, sorry). www.w3.org/TR/SVG/filters.html#feBlendElement
What I think the problem is:
In my filter, I'm actually applying opacity to the feImage
, not the SourceGraphic
, simply because I couldn't figure out how to do it the other way around, despite much experimentation. Ideally it would be the squares that were partially transparent, and were then overlayed on the image. Setting in="SourceGraphic"
for the feColorMatrix
doesn't work right, nor does setting the opacity
attribute on the rect
s themselves (they seem to blend with the default white svg background before blending with the image). I'm sure there's some simple solution, but I just can't find it.
Please tell me if anything's unclear. Any assistance is appreciated :)