Questions on paths/lines

This is NOT a support forum. You are welcome to discuss software issues here, but all issues should be reported on Launchpad if you want them fixed.
tstk
Posts: 2
Joined: Thu May 03, 2012 6:57 pm

Questions on paths/lines

Postby tstk » Thu May 03, 2012 7:16 pm

Hi,

I'm a casual Inkscape user. I just use Inkscape to create simple drawings that are read and displayed with a different software package. I've encountered the following issue and want to know if the problem is within Inkscape or in the package that should display the svg file:
When I create simple lines in Inkscape they are not displayed with the other package and I found out that Inkscape saves e.g. two point lines as:

<path
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 75.714286,99.505039 648.57143,865.21933"
id="path3772"
inkscape:connector-curvature="0" />

where the d attribute starts with an 'M' but does not have any following character. In the SVG documentation I can see that there should be e.g. an 'L' for line or some other character identifying the path type after the first coordinate like:

<path
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 75.714286,99.505039 L 648.57143,865.21933"
id="path3772"
inkscape:connector-curvature="0" />


If I add such an L into the attribute both Inkscape and the used package display the line correctly. I have to admit that e.g. Firefox displays the line also without needing an 'L'.
I have been able to make Inkscape to write such a line that the other package displays the line if I use the Path->Simplify command. But unlike the documentation says this command does not, at least in this case, remove unnecessary points rather than it makes the line a (Bezier?) curve and adds two points.

Questions:
1. Does Inkscape write paths (two point straight lines) correctly?
2. Does the Path->Simplify command work correctly (as specified and documented)?

TK

User avatar
Grobe
Posts: 411
Joined: Tue Feb 02, 2010 2:20 am

Re: Questions on paths/lines

Postby Grobe » Fri May 04, 2012 7:23 am

Hi.

I don't know what you mean with "package" here. Is that another svg complicant software?

Have you tried to save files as "plain svg" ?
:lol:

tstk
Posts: 2
Joined: Thu May 03, 2012 6:57 pm

Re: Questions on paths/lines

Postby tstk » Fri May 04, 2012 6:54 pm

I don't know what you mean with "package" here. Is that another svg complicant software?

It is wxsvg (http://sourceforge.net/projects/wxsvg/)

Have you tried to save files as "plain svg" ?

I just tried it, but it is even worse. It even removes such an 'L' that I manually added to the path, which was retained in a normal save operation...

TK

~suv
Posts: 2272
Joined: Sun May 10, 2009 2:07 am

Re: Questions on paths/lines

Postby ~suv » Fri May 04, 2012 8:00 pm

tstk wrote:If I add such an L into the attribute both Inkscape and the used package display the line correctly. I have to admit that e.g. Firefox displays the line also without needing an 'L'.
No surprise: Inkscape's optimized path data is valid and in accordance with the SVG specifications ('L' or 'l' is implicit after a 'M' / 'm'):
SVG 1.1 > Paths > 8.3.2 The "moveto" commands wrote:Start a new sub-path at the given (x,y) coordinate. M (uppercase) indicates that absolute coordinates will follow; m (lowercase) indicates that relative coordinates will follow. If a moveto is followed by multiple pairs of coordinates, the subsequent pairs are treated as implicit lineto commands. Hence, implicit lineto commands will be relative if the moveto is relative, and absolute if the moveto is absolute. If a relative moveto (m) appears as the first element of the path, then it is treated as a pair of absolute coordinates. In this case, subsequent pairs of coordinates are treated as relative even though the initial moveto is interpreted as an absolute moveto.


What you can try as workaround to adjust to the limited SVG capabilities of that "other package": change Inkscape's preferences for 'SVG Output > Path data:' to
  • [ ] Allow relative coordinates
  • [x] Force repeat commands
Note: changing this setting in Inkscape will only affect new paths or paths edited in such a way that a rewrite of the path data is triggered (e.g. by selecting all and nudging the selection a tick upwards and back downwards with the arrow keys). Inkscape does not automagically rewrite path data of un-edited objects (intentionally).


Return to “Discuss Software Issues”