Giter Site home page Giter Site logo

Comments (5)

tebjan avatar tebjan commented on May 21, 2024

Hello,

svg has an extra attribute for the opacity value, or to be precise a few:
http://www.w3.org/TR/SVG/masking.html#ObjectAndGroupOpacityProperties

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).

from svg.

 avatar commented on May 21, 2024

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.

from svg.

tebjan avatar tebjan commented on May 21, 2024

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:

 int alpha = (int)((opacity * (this.Colour.A/255.0f) ) * 255);

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.

from svg.

tebjan avatar tebjan commented on May 21, 2024

Nuget 1.0.1 is now also available.

from svg.

 avatar commented on May 21, 2024

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.

from svg.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.