Inkscape Community

Help Using Inkscape => Inkscape Beginners' Questions => Topic started by: Wanderer on February 17, 2018, 04:45:27 AM

Title: Exporting to Xaml (correct way or it is broken)
Post by: Wanderer on February 17, 2018, 04:45:27 AM
Hello

I export graphics in to xaml for wpf application. I use rectangle or paths with gradient or radialgradient fills. Problem is, inkscape xaml exporter make lot of color export instead how many color is used. Another issue is, exported graphics not show fill if it is radial gradient due there is no gradientStops color (it is not exported).

Here is code:
svg:
Code: [Select]
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->

<svg
   xmlns:osb="http://www.openswatchbook.org/uri/2009/osb"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:cc="http://creativecommons.org/ns#"
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:svg="http://www.w3.org/2000/svg"
   xmlns="http://www.w3.org/2000/svg"
   xmlns:xlink="http://www.w3.org/1999/xlink"
   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
   width="30"
   height="30"
   viewBox="0 0 30 30.000001"
   version="1.1"
   id="svg8"
   sodipodi:docname="button_panel_pause.svg"
   inkscape:version="0.92.2 (5c3e80d, 2017-08-06)">
  <defs
     id="defs2">
    <linearGradient
       inkscape:collect="always"
       id="linearGradient831">
      <stop
         style="stop-color:#cb8a06;stop-opacity:1;"
         offset="0"
         id="stop827" />
      <stop
         style="stop-color:#845b09;stop-opacity:1"
         offset="1"
         id="stop829" />
    </linearGradient>
    <linearGradient
       id="Button_Pause_Gradient-2"
       osb:paint="gradient">
      <stop
         style="stop-color:#cb8a06;stop-opacity:1;"
         offset="0"
         id="stop12474" />
      <stop
         style="stop-color:#845b09;stop-opacity:1"
         offset="1"
         id="stop12476" />
    </linearGradient>
    <linearGradient
       id="Button_Pause-8"
       osb:paint="solid"
       gradientTransform="matrix(1.0618899,0,0,1.4097345,-1720.4333,4314.8685)">
      <stop
         style="stop-color:#cb8a06;stop-opacity:1;"
         offset="0"
         id="stop12424" />
    </linearGradient>
    <radialGradient
       inkscape:collect="always"
       xlink:href="#linearGradient831"
       id="radialGradient833"
       cx="20.000013"
       cy="1107.5197"
       fx="20.000013"
       fy="1107.5197"
       r="3"
       gradientTransform="matrix(1,0,0,3.4999991,0,-2768.7981)"
       gradientUnits="userSpaceOnUse" />
    <radialGradient
       inkscape:collect="always"
       xlink:href="#linearGradient831"
       id="radialGradient841"
       cx="10.000004"
       cy="1107.5197"
       fx="10.000004"
       fy="1107.5197"
       r="3"
       gradientTransform="matrix(1,0,0,3.4999991,0,-2768.7981)"
       gradientUnits="userSpaceOnUse" />
  </defs>
  <sodipodi:namedview
     id="base"
     pagecolor="#505050"
     bordercolor="#666666"
     borderopacity="1.0"
     inkscape:pageopacity="0"
     inkscape:pageshadow="2"
     inkscape:zoom="15.839192"
     inkscape:cx="14.672775"
     inkscape:cy="15.018553"
     inkscape:document-units="px"
     inkscape:current-layer="layer1"
     showgrid="false"
     units="px"
     inkscape:window-width="1538"
     inkscape:window-height="878"
     inkscape:window-x="-8"
     inkscape:window-y="-8"
     inkscape:window-maximized="1" />
  <metadata
     id="metadata5">
    <rdf:RDF>
      <cc:Work
         rdf:about="">
        <dc:format>image/svg+xml</dc:format>
        <dc:type
           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
        <dc:title />
      </cc:Work>
    </rdf:RDF>
  </metadata>
  <g
     inkscape:label="Layer 1"
     inkscape:groupmode="layer"
     id="layer1"
     transform="translate(0,-1092.5197)">
    <rect
       inkscape:label="button_panel_pause1"
       style="opacity:1;fill:url(#radialGradient841);fill-opacity:1.0;stroke:url(#Button_Pause-8);stroke-width:0.99999994;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal"
       id="button_panel_pause1"
       width="5"
       height="19.999994"
       x="7.5000038"
       y="1097.5197"
       ry="2.0000067" />
    <rect
       inkscape:label="button_panel_pause2"
       ry="2.0000067"
       y="1097.5197"
       x="17.500013"
       height="19.999994"
       width="5"
       id="button_panel_pause2"
       style="opacity:1;fill:url(#radialGradient833);fill-opacity:1;stroke:url(#Button_Pause-8);stroke-width:0.99999994;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal" />
  </g>
</svg>

saved as xaml (with silver light compatibility):
Code: [Select]
<?xml version="1.0" encoding="UTF-8"?>
<!--This file is compatible with Silverlight-->
<Canvas xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" Name="svg8" Width="30" Height="30.000001">
  <Canvas.RenderTransform>
    <TranslateTransform X="0" Y="0"/>
  </Canvas.RenderTransform>
  <Canvas.Resources>
    <LinearGradientBrush xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Key="linearGradient831" MappingMode="RelativeToBoundingBox" StartPoint="0,0" EndPoint="1,1">
      <LinearGradientBrush.GradientStops>
        <GradientStopCollection>
          <GradientStop Color="#FFCB8A06" Offset="0"/>
          <GradientStop Color="#FF845B09" Offset="1"/>
        </GradientStopCollection>
      </LinearGradientBrush.GradientStops>
    </LinearGradientBrush>
    <LinearGradientBrush xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Key="Button_Pause_Gradient-2" MappingMode="RelativeToBoundingBox" StartPoint="0,0" EndPoint="1,1">
      <LinearGradientBrush.GradientStops>
        <GradientStopCollection>
          <GradientStop Color="#FFCB8A06" Offset="0"/>
          <GradientStop Color="#FF845B09" Offset="1"/>
        </GradientStopCollection>
      </LinearGradientBrush.GradientStops>
    </LinearGradientBrush>
    <LinearGradientBrush xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Key="Button_Pause-8" MappingMode="RelativeToBoundingBox" StartPoint="0,0" EndPoint="1,1">
      <LinearGradientBrush.GradientStops>
        <GradientStopCollection>
          <GradientStop Color="#FFCB8A06" Offset="0"/>
        </GradientStopCollection>
      </LinearGradientBrush.GradientStops>
      <LinearGradientBrush.Transform>
        <MatrixTransform Matrix="1.0618899 0 0 1.4097345 -1720.4333 4314.8685"/>
      </LinearGradientBrush.Transform>
    </LinearGradientBrush>
    <RadialGradientBrush xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Key="radialGradient833" MappingMode="Absolute" Center="3,10" GradientOrigin="3,10" RadiusX="3" RadiusY="3">
      <RadialGradientBrush.GradientStops>
        <GradientStopCollection/>
      </RadialGradientBrush.GradientStops>
      <RadialGradientBrush.Transform>
        <MatrixTransform Matrix="1 0 0 3.4999991 0 -2768.7981"/>
      </RadialGradientBrush.Transform>
    </RadialGradientBrush>
    <RadialGradientBrush xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Key="radialGradient841" MappingMode="Absolute" Center="3,10" GradientOrigin="3,10" RadiusX="3" RadiusY="3">
      <RadialGradientBrush.GradientStops>
        <GradientStopCollection/>
      </RadialGradientBrush.GradientStops>
      <RadialGradientBrush.Transform>
        <MatrixTransform Matrix="1 0 0 3.4999991 0 -2768.7981"/>
      </RadialGradientBrush.Transform>
    </RadialGradientBrush>
  </Canvas.Resources>
  <!--Unknown tag: sodipodi:namedview-->
  <!--Unknown tag: metadata-->
  <Canvas Name="layer1">
    <Canvas.RenderTransform>
      <TranslateTransform X="0" Y="-1092.5197"/>
    </Canvas.RenderTransform>
    <Rectangle xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Canvas.Left="7.5000038" Canvas.Top="1097.5197" Width="5" Height="19.999994" RadiusY="2.0000067" RadiusX="2.0000067" Name="button_panel_pause1" Fill="{StaticResource radialGradient841}" StrokeThickness="0.99999994" Stroke="{StaticResource Button_Pause-8}" StrokeMiterLimit="4" StrokeLineJoin="Round" StrokeStartLineCap="Round" StrokeEndLineCap="Round" Opacity="1"/>
    <Rectangle xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Canvas.Left="17.500013" Canvas.Top="1097.5197" Width="5" Height="19.999994" RadiusY="2.0000067" RadiusX="2.0000067" Name="button_panel_pause2" Fill="{StaticResource radialGradient833}" StrokeThickness="0.99999994" Stroke="{StaticResource Button_Pause-8}" StrokeMiterLimit="4" StrokeLineJoin="Round" StrokeStartLineCap="Round" StrokeEndLineCap="Round" Opacity="1"/>
  </Canvas>
</Canvas>
I have to allways correct export with
1. convert object to path
2. use no swatches
3. delete gradients and extract its gradient stops in to radialGradient
4. delete all others colors, gradients etc.. which are not used

another issue is when objects are paths, inported graphics have strange object bounding - it is looks like it have very large size, but graphics stretched in to viewbox (if I move cursor in Blend in to object, it show some object bounding). If object are not convert in to path, object bounding looks normal - same as visible graphics.

btw it doesn't matter if silverlight is checked or not, I allways must do this steps

I think the exporter is have bugs, but maybe I am doing something wron, that is why I wrote this post.
If I am doing it wrong, is there way how to correct save as xaml?
Title: Re: Exporting to Xaml (correct way or it is broken)
Post by: Moini on February 17, 2018, 01:21:57 PM
You are describing a missing feature or a bug of Inkscape.

For bug reports and feature requests, please visit the Inkscape bug tracker at https://bugs.launchpad.net/inkscape.
Title: Re: Exporting to Xaml (correct way or it is broken)
Post by: Wanderer on February 18, 2018, 02:00:29 AM
Ok, I created report. Please keed this posts, because I have code here, and in Bugtracker, I don't see any code tag, then I use (add link in to this post) this post for "show code".
Title: Re: Exporting to Xaml (correct way or it is broken)
Post by: brynn on February 18, 2018, 02:34:40 AM
Welcome to the forum!

I'm sure it's fine to have a link in the bug report to this message.  I won't delete it.  But just fyi, for the bug report, I think people usually attach a text file, to share codes.  There's a way to attach files on the bug report (it's a pretty small button).  (can also attach images, etc.)

This must be your report?  https://bugs.launchpad.net/inkscape/+bug/1750220  (I put the link here, so it's easy to find.)
Title: Re: Exporting to Xaml (correct way or it is broken)
Post by: Wanderer on February 19, 2018, 01:13:47 AM
Yes, this is my report. Thanks for tip, I added attached files in to bugreport. I hope it is ok upload svg and xaml files.