W3C home > Mailing lists > Public > www-svg@w3.org > January 2006

scaling geometry without scaling stroke-width

From: Jeffrey W. Baker <jwbaker@acm.org>
Date: Fri, 20 Jan 2006 17:19:19 -0800
To: www-svg@w3.org
Message-Id: <1137806359.28614.14.camel@noodles>

I wonder if I'm reading the SVG specification correctly, because it
seems to me impossible to scale an element without scaling the widths of
the strokes on that element.  It also seems to me that this would be a
handy feature.  So I wonder:

1) Is it possible to scale a coordinate system without scaling strokes?
2) Wouldn't that be nice?

The reason I ask this is because of line chart/graphs I am working with.
Suppose you have 400 data points in a time series where the vertical
values range from -1 to +1, and you want to put that in a 400x400 box.
The easiest thing to do would be to declare a polyline of your raw data,
y-scale by -1, y-transform by +1, y-scale by 200.

    <svg x="0" y="0" width="100%" height="100%" 
         viewBox="0 0 400 400" preserveAspectRatio="none">
        <polyline stroke="black" stroke-width="1pt"
             transform="scale(1,200) transform(0,+1) scale(1,-1)" 
             points="etc etc etc" />

The problem with this transform is that the line strokes will be 200
times larger than desired.  You can also see this effect if you take a
square graph and make it ten times wider than it is tall.  The stroke
will become one-tenth the desired width in the vertical direction,
giving it a strange anisotropic appearance.

The only (apparent) way to achieve what I need is to pre-compute the
scaled polyline vertices, and this still does not solve the problem of
the user stretching one axis or the other.

In short, what I want is a way to scale a line *before* stroking,
whereas it seems the only available functionality is to stroke, then

Jeffrey Baker
Received on Tuesday, 24 January 2006 04:38:47 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 8 March 2017 09:47:06 UTC