-
Notifications
You must be signed in to change notification settings - Fork 470
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SvgColourServer with translucent color? #5
Comments
Hello, svg has an extra attribute for the opacity value, or to be precise a few: Its a float in the range 0..1 where 0 is fully transparent and 1 fully opaque. So instead of o.Fill, you should write a value to o.FillOpacity. There is also o.Opacity (overall opacity) and o.StrokeOpacity (opacity for strokes). |
I've set the FIllOpacity and Opacity on all SvgVisualElements to 1 already (did not include that part in my sample code, sorry). I looked through the source and it appears that the SvgColourServer attempts to extract and re-calculate the alpha channel to use for the brush (https://github.com/vvvv/SVG/blob/master/Source/Painting/SvgColourServer.cs line 27). I'm going to run some tests and see what's happening here. But it seems like a Color instance with an alpha channel is meant to be supported. |
Hm... Yes, there seems to be some work in that direction. But its as far as i know not in the official svg spec. To control the transparency you have to set the opacity attributes. In your case the FillOpacity to 0.25f. But anyways the code looks somehow correct. But there could be a problem with the division. Since both values are Integer, i think its always 0 because Colour.A is smaller than 255. it should be:
I fixed that by 457a82f. If you can compile the code you can check that right away. Otherwise you have to wait for the next Nuget package. |
Nuget 1.0.1 is now also available. |
I think what I was trying to do would result in deeper-nested elements becoming more and more transparent, so it's not right anyway. I appreciate the attempted fix, though. What I'm doing is programatically recoloring SVGs. So what I'll do when I need to make one translucent is move all of the SVG's child elements into a new group element with the opacity/fill set appropriately. |
Please forgive me if this is not an issue but a misunderstanding.
I've opened an SVG and then set all Children (who are ISvgStyleable) to have a fill of 25% transparent black:
This is called like this:
The resulting PNG, after saving is completely transparent. E.g.:
Are alpha channels not supported or am I missing something? Thanks!
The text was updated successfully, but these errors were encountered: