W3C home > Mailing lists > Public > www-svg@w3.org > December 2000

Are centimeters second class units?

From: Elliotte Rusty Harold <elharo@metalab.unc.edu>
Date: Mon, 11 Dec 2000 08:34:19 -0500
Message-Id: <p04330100b65a88155b73@[]>
To: www-svg@w3.org
I'm still working my way through the SVG spec so I'm hoping I've 
missed something and someone will correct me. However, I've been 
through the coordinate section several times, and it's beginning to 
look to me like pixels have a very privileged place in the SVG 
universe. In particular paths, polylines, polygons and probably some 
other things are all effectively defined in terms of pixels. The 
non-dimensional units used in the points attributes of these elements 
are all defined in user coordinates, and user coordinates are pixels. 
There are a lot of times when it would be much more convenient to 
define these quantities in terms of real-world units like cm or mm or 

I can use various transforms to stretch or compress the coordinate 
system and thereby scale the connection between user coordinates and 
screen pixels. However, what I want to do, and can't seem to figure 
out how to do; is map-like scaling; e.g. I want to say that one 
kilometer in local coordinates equals one centimeter on the screen. 
For instance, if I draw a line that's 10000 cm long I'd like it to 
take up 1 cm on the screen. I can't seem to do this without an 
intermediate transformation into pixels, which introduces questions 
of local screen resolution. I want to specify everything in terms of 
units that don't change from one monitor to the next. The renderer 
knows how many pixels there are per inch when it draws a picture. I 
don't know that, and indeed I can't know that because it will be 
different from system to system.

There are some related issues I've encountered too. For instance, I 
tried to use a viewBox in Batik that had a width and height of 10 
each in an svg element that was 10cm square so that 1 in the user 
coordinates would equal 1 cm. However, the user coordinates seemed 
stuck with at most one pixel per user coordinate. That is, although 
each unit in the user coordinate space should have mapped to roughly 
30 pixels, it in fact mapped to exactly one pixel. In other words the 
ratio of pixels/coordinate is less than or equal to 1. I'm not sure 
if this is a flaw in Batik or in my understanding of SVG.

If SVG really doesn't allow me to describe shapes with arbitrary 
precision fixed units of known length like cm and in, rather than the 
very ambiguous pixel unit, then it seems seriously underpowered and 
unsuitable for many tasks. Some of the basic shapes like rect and 
circle let me use real units, but the most fundamental path element 
does not. How can I define a path that's a certain number of 
centimeters long? Any ideas? Am I missing something here?

| Elliotte Rusty Harold | elharo@metalab.unc.edu | Writer/Programmer |
|                  The XML Bible (IDG Books, 1999)                   |
|              http://metalab.unc.edu/xml/books/bible/               |
|   http://www.amazon.com/exec/obidos/ISBN=0764532367/cafeaulaitA/   |
|  Read Cafe au Lait for Java News:  http://metalab.unc.edu/javafaq/ |
|  Read Cafe con Leche for XML News: http://metalab.unc.edu/xml/     |
Received on Monday, 11 December 2000 08:35:59 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 8 March 2017 09:46:49 UTC