getting accurate coordinates/units in SVG code

Discuss SVG code, accessible via the XML Editor.
PeskyJ
Posts: 3
Joined: Sat Apr 26, 2008 6:37 am

getting accurate coordinates/units in SVG code

Postby PeskyJ » Fri Oct 02, 2009 4:11 am

I created a path approximately centered about (0, 0) extending from -0.5 to 0.5 on both the x and y axes, but when I look at the SVG, the numbers are not what I expect. I set up the units in inkscape to be in meters.

So how do I set up Inkscape such that when I exactly position a point on a path, the values are accurate in the SVG code?
The transofrmation I got in this case was that +0.5 went to about 1771, -0.5 went to about 0 - is there any way to reverse this?

Thanks,
J

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

Re: getting accurate coordinates/units in SVG code

Postby ~suv » Fri Oct 02, 2009 5:19 am

PeskyJ wrote:I set up the units in inkscape to be in meters.
The units used in the SVG file are always 'px' - independent of the units you choose as default (in document preferences). AFAIK this conversion (and any resulting precision issues and rounding errors) cannot be avoided or changed with a preference setting.

If you need accurate numbers, stay with 'px' as default values (and use pixel-grid-aligned page sizes). But even then the conversion of the coordinate system from <origin at bottom left corner, first quadrant> (Inkscape canvas) to <origin at top left, fourth quadrant> (SVG file) recalculates all coordinates and can result in different numbers and rounding errors, at least for y-values.

PeskyJ wrote:is there any way to reverse this?
it is automatically 'reversed' on-the-fly when rendering the svg elements on canvas, but in the file Inkscape still uses 'px' and the 'forth quadrant' coordinate system.

I'm not very good explaining this - if I find a better reference on the net I'll add a link here ;-)

hth, ~suv

PeskyJ
Posts: 3
Joined: Sat Apr 26, 2008 6:37 am

Re: getting accurate coordinates/units in SVG code

Postby PeskyJ » Wed Oct 07, 2009 11:28 am

Thanks, this is useful. I find pixels a somewhat nonsensical unit for vector data as it really depends on your viewing scale. I found an easier solution than attempting to control the units to known values, instead I calculate the bounds and determine a scale and offset from that to apply before my actual desired transformations.


Return to “SVG / XML Code”