Coordinates in plane SVG File

General discussions about Inkscape.
Vipr0
Posts: 5
Joined: Tue Mar 28, 2017 5:00 am

Coordinates in plane SVG File

Postby Vipr0 » Tue Mar 28, 2017 5:18 am

Hi,

I was wondering why the coordinates in the SVG-file differentiate from the coordinates shown in the bottom right corner of Inkscape while drawing. I tested a bit and drew a path with following coordinates (shown in the bottom right corner of the inkscape screen):

Code: Select all

28.73,331.11 219.23,325.06 319.77,243.42 -123.98,250.22 -45.36,328.08 -108.1,300.11 102.81,-72.57 -168.58,-83.15 -374.95,379.49 315.23,413.51 238.88,164.04


The SVG-file shows:

Code: Select all

d="m 28.72619,-34.107143 190.5,6.04762 100.54166,81.642857 -443.74404,-6.803573 78.619048,-77.863093 -108.10119,-3.1130951 102.80952,369.57142 -271.3869,10.58334 -206.37501,-462.642854 690.18454,-34.017856 -76.3512,249.46428"


I dont understand the concept behind that.
Also after some testing with other files i found out that sometimes the x-coordinates are the same, while the y-coordinates are the ones shown +297.
In addition i would like to know how the coordinates of rectangle objects are generated. Are the x/y-coordinates the ones of the upper left corner of the rectangle? If yes why do they differentiate from the coordinates shown in the bottom left corner of the inkscape screen? Also why do the y-coordinates differentiate, while the x-coordinates are "ok"?.
Thank you in advance

Moini
Posts: 3381
Joined: Mon Oct 05, 2015 10:44 am

Re: Coordinates in plane SVG File

Postby Moini » Tue Mar 28, 2017 7:37 am

Let me guess: You're working in mm, and you have an A4 page.
297mm = height of A4

The coordinate system in Inkscape has its origin on the opposite end of the page, bottom left, instead of top left, as the SVG file format does.
Something doesn't work? - Keeping an eye on the status bar can save you a lot of time!

Inkscape FAQ - Learning Resources - Website with tutorials (German and English)

tylerdurden
Posts: 2344
Joined: Sun Apr 14, 2013 12:04 pm
Location: Michigan, USA

Re: Coordinates in plane SVG File

Postby tylerdurden » Tue Mar 28, 2017 9:05 am

To add to the above: this is partly due to SVG being a web graphic standard having the screen origin in the upper left and y-values increment positively in a downward direction, and many people having familiarity with Cartesian coordinates where Y-values increase from the origin in the upward direction.
Have a nice day.

I'm using Inkscape 0.92.2 (5c3e80d, 2017-08-06), 64 bit win8.1

The Inkscape manual has lots of helpful info! http://tavmjong.free.fr/INKSCAPE/MANUAL/html/

Vipr0
Posts: 5
Joined: Tue Mar 28, 2017 5:00 am

Re: Coordinates in plane SVG File

Postby Vipr0 » Wed Mar 29, 2017 4:46 am

So that basically means if i only care about the relative distances i can ignore the different formats of Inkscape and SVG?

Moini
Posts: 3381
Joined: Mon Oct 05, 2015 10:44 am

Re: Coordinates in plane SVG File

Postby Moini » Wed Mar 29, 2017 10:51 am

If you only care about the absolute values, yes. Else you'd need multiply by -1 (for the y distances).
Something doesn't work? - Keeping an eye on the status bar can save you a lot of time!

Inkscape FAQ - Learning Resources - Website with tutorials (German and English)

Vipr0
Posts: 5
Joined: Tue Mar 28, 2017 5:00 am

Re: Coordinates in plane SVG File

Postby Vipr0 » Thu Apr 13, 2017 6:56 am

Okay it turned out I need exactly the same coordinates like shown in Inkscape. So all I have to do is multiply the y-coordinates with -1 and subtract 297? Does this work for any kind of object (rect and path) even when I "paint" outside of the DIN A4 page as long as the format is still DIN A4?

Also I would like to know if someone could help me with the syntax of a path. It doesnt seem to be the one people explain when I google the SVG-syntax. (I save my files as standard SVG files, not Inkscape SVG files)
Example:

Code: Select all

d="M 25.702382,53.583333 H 90.714286 148.92262 V 95.916666 134.47025 L 86.934525,185.11906 25.702382,134.47025 V 83.821428 Z"

Can someone correct me where I am wrong? Ill write down of what i think these letters mean.

M (x and y value after it) means move to the point 25.702382,53.583333 (always at the beginning of a path)
m (x and y value after it) would mean move from the last point 25.702382 in x-direction and 53.583333 in y-direction (always at the beginning of a path; what would happen if the last path had a Z in the end? Would you have to move from the first point of the last path/object in general?)
z and Z (no value after it) are basically the same and mean the last point is the first one. So i could basically replace the z/Z with 25.702382,53.583333?
L (x and y value after it) means the next point is 86.934525,185.11906 (no letter basically means L?)
l (x and y value after it) move from the last point 86.934525 in x-direction and 185.11906 in y-direction
H (only x value after it) means move from the last point to 90.714286 in x-direction (Why are there 2 values in my example? The y-value should not change?)
h (only x value after it) means move from the last point 90.714286 in x-direction
V like H just y-value changes
v like h just y-value changes

I would appreciate any kind of help.

theozh
Posts: 437
Joined: Fri Mar 23, 2012 6:30 pm

Re: Coordinates in plane SVG File

Postby theozh » Thu Apr 13, 2017 4:58 pm

Vipr0 wrote:Also I would like to know if someone could help me with the syntax of a path.

Have you checked this page?
https://www.w3.org/TR/SVG/paths.html
Win7/64, Inkscape 0.92.2

Vipr0
Posts: 5
Joined: Tue Mar 28, 2017 5:00 am

Re: Coordinates in plane SVG File

Postby Vipr0 » Wed Apr 19, 2017 4:15 am

Have you checked this page?
https://www.w3.org/TR/SVG/paths.html


This is perfect. Thank you very much!

What about
Okay it turned out I need exactly the same coordinates like shown in Inkscape. So all I have to do is multiply the y-coordinates with -1 and subtract 297? Does this work for any kind of object (rect and path) even when I "paint" outside of the DIN A4 page as long as the format is still DIN A4?

patriciameow02
Posts: 1
Joined: Wed Apr 19, 2017 6:54 am

Can't clip a vector?

Postby patriciameow02 » Wed Apr 19, 2017 7:04 am

I follow all the instructions to crop or clip a vector but it is not working for me.

I group, and then create a rectangle where I want the image to be cropped and then object>clip>set except it doesn't do anything. I'm missing something? The vector image is exactly the same as before I clipped. Anyone else?

Moini
Posts: 3381
Joined: Mon Oct 05, 2015 10:44 am

Re: Coordinates in plane SVG File

Postby Moini » Wed Apr 19, 2017 8:42 am

@patriciameow02: please next time, create a new topic in the beginners forum instead of posting to a random unrelated thread. As for your problem, make sure to select both items before you try to clip.
Something doesn't work? - Keeping an eye on the status bar can save you a lot of time!

Inkscape FAQ - Learning Resources - Website with tutorials (German and English)


Return to “General Discussions”