ElinamLLC / SharpVectors

SharpVectors - SVG# Reloaded: SVG DOM and Rendering in C# for the .Net.
https://elinamllc.github.io/SharpVectors/
BSD 3-Clause "New" or "Revised" License
700 stars 134 forks source link

SVG -> XAML: Transparency #289

Closed PeterStefanicka closed 2 days ago

PeterStefanicka commented 1 month ago

Hi, I have an issue when using SharpVectors for conversion of SVG file to XAML resource. Here you can see very simple SVG:

<svg id="test" data-name="test" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
  <defs>
    <style>
      .cls-1 { fill: rgba(186, 208, 231, .5); stroke: #416596; stroke-linecap: round; stroke-linejoin: round; }
    </style>
  </defs>
  <rect class="cls-1" x="2.5" y="2.5" width="19" height="19"/>
</svg>

And here XAML result:

<ResourceDictionary xmlns="..." xmlns:x="..." xmlns:po="..." xmlns:mc="..." mc:Ignorable="po">
  <DrawingBrush x:Key="test" Stretch="Uniform" po:Freeze="true">
    <DrawingBrush.Drawing>
      <DrawingGroup>
        <DrawingGroup>
          <DrawingGroup.ClipGeometry>
            <RectangleGeometry Rect="0,0,24,24" />
          </DrawingGroup.ClipGeometry>
          <GeometryDrawing Brush="#00BAD0E7">
            <GeometryDrawing.Pen>
              <Pen Brush="#FF416596" Thickness="1" StartLineCap="Round" EndLineCap="Round" LineJoin="Round" />
            </GeometryDrawing.Pen>
            <GeometryDrawing.Geometry>
              <RectangleGeometry RadiusX="0" RadiusY="0" Rect="2.5,2.5,19,19" />
            </GeometryDrawing.Geometry>
          </GeometryDrawing>
        </DrawingGroup>
      </DrawingGroup>
    </DrawingBrush.Drawing>
  </DrawingBrush>
</ResourceDictionary>

If you compare those you see that: rgba(186, 208, 231, .5) does match Brush="#00BAD0E7" in R, G and B values but not A.

paulushub commented 3 weeks ago

@PeterStefanicka Thanks for reporting. Please can you verify the latest commit for this issue?

PeterStefanicka commented 3 weeks ago

@paulushub works well now, thanks a lot

PeterStefanicka commented 1 week ago

@paulushub may i ask, when you plan next release where this fix will be included? thanks

paulushub commented 1 week ago

@PeterStefanicka Sorry, will push a minor version this weekend. Was trying to fix other issues, but not successful yet.