Internal Coordinate System in Inkscape
![](https://secure.gravatar.com/avatar/c9deb1c23208b72209fefc58f7c85f5e.jpg?s=120&d=mm&r=g)
Hi,
I’m writing here for the first time so nice to meet you all!
I started playing with Inkscape since a few weeks ago and one thing I haven’t really understood is the way coordinate system works on Inkscape. First of all, in the UI, the origin lies at the bottom-left corner of the canvas, with y-axis pointing upward (based on what Inkscape displayed when I moved my mouse around the canvas). However, when I created a path through an LPE and printed anchor positions as the path was moved around, I found that the internal coordinate system had y-axis pointing downward, with the origin (0,0) lying somewhere above the canvas instead. Is this an expected behavior? Is there a transformation matrix that transforms the internal positions to the canvas positions?
I compiled Inkscape 0.48 from trunk on OS X Mavericks using clang 3.4 with required libraries compiled using libc++.
If anyone knows about this I’d really appreciate your answer here.
Regards, _______________________ Papoj "Hua" Thamjaroenporn pt2277@...3110...
![](https://secure.gravatar.com/avatar/b47d036b8f12e712f4960ba78404c3b2.jpg?s=120&d=mm&r=g)
2014-04-25 8:57 GMT+02:00 Papoj Thamjaroenporn <pt2277@...3110...>:
Hi,
I’m writing here for the first time so nice to meet you all!
I started playing with Inkscape since a few weeks ago and one thing I haven’t really understood is the way coordinate system works on Inkscape. First of all, in the UI, the origin lies at the bottom-left corner of the canvas, with y-axis pointing upward (based on what Inkscape displayed when I moved my mouse around the canvas). However, when I created a path through an LPE and printed anchor positions as the path was moved around, I found that the internal coordinate system had y-axis pointing downward, with the origin (0,0) lying somewhere above the canvas instead. Is this an expected behavior? Is there a transformation matrix that transforms the internal positions to the canvas positions?
There are several coordinate systems in Inkscape:
- The standard SVG coordinate system, denoted in the source as "document coordinate system", starts in the top left corner and Y grows downwards; - The Inkscape "desktop coordinate system" starts in the bottom left corner and Y grows upwards - Window coordinates start in the top left corner of the visible area. - World coordinates are offset with respect to the window coordinates so that they start in top left corner of the document, but preserve the ratio of 1 unit = 1 screen pixel.
Describe in more detail what exactly did you print and I can describe what is happening.
Regards, Krzysztof
![](https://secure.gravatar.com/avatar/c9deb1c23208b72209fefc58f7c85f5e.jpg?s=120&d=mm&r=g)
Hi Krzysztof,
What I printed were the positions of the path using initialPoint(), finalPoint(), and valueAt() methods in Path class.
Regards, _______________________ Papoj "Hua" Thamjaroenporn pt2277@...3110...
On Apr 25, 2014, at 3:44 AM, Krzysztof Kosiński <tweenk.pl@...400...> wrote:
2014-04-25 8:57 GMT+02:00 Papoj Thamjaroenporn <pt2277@...3110...>:
Hi,
I’m writing here for the first time so nice to meet you all!
I started playing with Inkscape since a few weeks ago and one thing I haven’t really understood is the way coordinate system works on Inkscape. First of all, in the UI, the origin lies at the bottom-left corner of the canvas, with y-axis pointing upward (based on what Inkscape displayed when I moved my mouse around the canvas). However, when I created a path through an LPE and printed anchor positions as the path was moved around, I found that the internal coordinate system had y-axis pointing downward, with the origin (0,0) lying somewhere above the canvas instead. Is this an expected behavior? Is there a transformation matrix that transforms the internal positions to the canvas positions?
There are several coordinate systems in Inkscape:
- The standard SVG coordinate system, denoted in the source as
"document coordinate system", starts in the top left corner and Y grows downwards;
- The Inkscape "desktop coordinate system" starts in the bottom left
corner and Y grows upwards
- Window coordinates start in the top left corner of the visible area.
- World coordinates are offset with respect to the window coordinates
so that they start in top left corner of the document, but preserve the ratio of 1 unit = 1 screen pixel.
Describe in more detail what exactly did you print and I can describe what is happening.
Regards, Krzysztof
![](https://secure.gravatar.com/avatar/b47d036b8f12e712f4960ba78404c3b2.jpg?s=120&d=mm&r=g)
2014-04-26 0:23 GMT+02:00 Papoj Thamjaroenporn <pt2277@...3110...>:
Hi Krzysztof,
What I printed were the positions of the path using initialPoint(), finalPoint(), and valueAt() methods in Path class.
The path is typically stored in SVG document coordinates, e.g. the origin is at the top left corner of the document and Y grows downwards. However, these coordinates are affected by the viewbox and the current transformation matrix.
Regards, Krzysztof
![](https://secure.gravatar.com/avatar/88863982468c6bd63a4d732d12befb59.jpg?s=120&d=mm&r=g)
Hi Papoj,
if you want more control of the coordinate system you can adjust the values of the viewbox element accordingly. There are no gui options for this yet, but this could be used to e.g. invert the y-Axis.
Best, vaifrax
On 25.04.2014 08:57, Papoj Thamjaroenporn wrote:
Hi,
I'm writing here for the first time so nice to meet you all!
I started playing with Inkscape since a few weeks ago and one thing I haven't really understood is the way coordinate system works on Inkscape. First of all, in the UI, the origin lies at the bottom-left corner of the canvas, with y-axis pointing upward (based on what Inkscape displayed when I moved my mouse around the canvas). However, when I created a path through an LPE and printed anchor positions as the path was moved around, I found that the internal coordinate system had y-axis pointing downward, with the origin (0,0) lying somewhere above the canvas instead. Is this an expected behavior? Is there a transformation matrix that transforms the internal positions to the canvas positions?
I compiled Inkscape 0.48 from trunk on OS X Mavericks using clang 3.4 with required libraries compiled using libc++.
If anyone knows about this I'd really appreciate your answer here.
Regards, _______________________ Papoj "Hua" Thamjaroenporn pt2277@...3110... mailto:pt2277@...3110...
Start Your Social Network Today - Download eXo Platform Build your Enterprise Intranet with eXo Platform Software Java Based Open Source Intranet - Social, Extensible, Cloud Ready Get Started Now And Turn Your Intranet Into A Collaboration Platform http://p.sf.net/sfu/ExoPlatform
Inkscape-devel mailing list Inkscape-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/inkscape-devel
![](https://secure.gravatar.com/avatar/b47d036b8f12e712f4960ba78404c3b2.jpg?s=120&d=mm&r=g)
2014-04-25 21:06 GMT+02:00 vaifrax <inkscape-devel@...2944...>:
Hi Papoj,
if you want more control of the coordinate system you can adjust the values of the viewbox element accordingly. There are no gui options for this yet, but this could be used to e.g. invert the y-Axis.
No, the SVG viewbox does not allow you to invert the Y axis. You can only use it to scale and offset the coordinate system. Scaling by factors less than 0 is not supported because negative values for width / height are treated as an error.
Regards, Krzysztof
![](https://secure.gravatar.com/avatar/c9deb1c23208b72209fefc58f7c85f5e.jpg?s=120&d=mm&r=g)
Hi Krzysztof and vaifrax,
Thank you. The part that I still don’t understand is the purpose of “desktop coordinate system” that was mentioned (the one that grows upward).
The SVG coordinate seems to be the one that lib2geom depends on most of the time (the one that grows downward). I still don’t understand why Inkscape displays curve in a certain way. I have this very simple code:
PathVector path_out; Path path; std::vectorGeom::Point pts; pts.push_back(Point(0,0)); pts.push_back(Point(100, 50)); pts.push_back(Point(200, 150)); pts.push_back(Point(300, 350));
D2<SBasis> sb; bezier_to_sbasis(sb, pts); path_out.push_back(path_from_sbasis(sb, LPE_CONVERSION_TOLERANCE, true));
Point pt1 = path_out[0].initialPoint(); Point pt2 = path_out[0].finalPoint(); cout << "path_out[" << 0 << "]:" << endl; cout << "endpoints: " << pt1 << " " << pt2 << endl;
If this path is to be displayed on Inkscape, with y-axis going upward in desktop coordinate, we should see an upward parabola right? Something like this:
However, what I notice is that: 1) The output path displayed is inverted and offset by 1052, the width of the canvas (I am using landscape canvas 1052 x 744 here). It seems to ignore desktop coordinate and follow SVG coordinate convention.
2) In XML script editor, the curve would also be encoded in SVG coordinate: M 0,0 C 100,50 200,150 300,350. The print-out in Terminal I get also displays endpoints: X: 0 Y: 0 X: 300 Y: 350
So, what is the idea behind desktop coordinate? It doesn’t seem to be used as far as I have seen. Also, is the behavior in 1) to be expected? I mean, why is the path in SVG not “transformed” in coordinate before it’s being displayed on desktop?
Thank you.
_______________________ Papoj "Hua" Thamjaroenporn pt2277@...3110...
On Apr 26, 2014, at 3:58 PM, Krzysztof Kosiński <tweenk.pl@...400...> wrote:
2014-04-25 21:06 GMT+02:00 vaifrax <inkscape-devel@...2944...>:
Hi Papoj,
if you want more control of the coordinate system you can adjust the values of the viewbox element accordingly. There are no gui options for this yet, but this could be used to e.g. invert the y-Axis.
No, the SVG viewbox does not allow you to invert the Y axis. You can only use it to scale and offset the coordinate system. Scaling by factors less than 0 is not supported because negative values for width / height are treated as an error.
Regards, Krzysztof
Start Your Social Network Today - Download eXo Platform Build your Enterprise Intranet with eXo Platform Software Java Based Open Source Intranet - Social, Extensible, Cloud Ready Get Started Now And Turn Your Intranet Into A Collaboration Platform http://p.sf.net/sfu/ExoPlatform _______________________________________________ Inkscape-devel mailing list Inkscape-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/inkscape-devel
![](https://secure.gravatar.com/avatar/b47d036b8f12e712f4960ba78404c3b2.jpg?s=120&d=mm&r=g)
2014-04-28 1:19 GMT+02:00 Papoj Thamjaroenporn <pt2277@...3110...>:
So, what is the idea behind desktop coordinate? It doesn’t seem to be used as far as I have seen. Also, is the behavior in 1) to be expected? I mean, why is the path in SVG not “transformed” in coordinate before it’s being displayed on desktop?
Desktop coordinates are only used in the UI, for example in the X/Y controls in the selector tool and on the rulers.
The desktop coordinate system is basically a very old design mistake that is very hard to fix. We are planning to remove it for Inkscape 1.0.
Regards, Krzysztof
participants (3)
-
Krzysztof Kosiński
-
Papoj Thamjaroenporn
-
vaifrax