You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-dev@xmlgraphics.apache.org by Ilia Chibrikin <ic...@jet.msk.su> on 2001/04/27 11:23:27 UTC
Coordinats
Dear colleges!
I am trying to use SVG in order to plot geophysical data. So I need to have
final result in absolute units - cm for example. As a viewer I use
batik-1.0beta. Help me, please!
The question is the following:
1. Is it possible to use in one SVG file both absolute and relative units?
For example:
----------------------------------------------------------------------------
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20000802//EN"
"http://www.w3.org/TR/2000/CR-SVG-20000802/DTD/svg-20000802.dtd">
<svg width="10cm" height="4cm">
<rect x="1cm" y="1cm" width="4cm" height="1cm" style="fill:none;
stroke:blue; stroke-width:3"/>
<line x1="1cm" y1="1cm" x2="3cm" y2="3cm" style="stroke:red;
stroke-width:2" />
----------------------------------------------------------------------------
This draws both elements correctly. Adding of viewBox attribute changes the
output! The following example differs from the one above:
----------------------------------------------------------------------------
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20000802//EN"
"http://www.w3.org/TR/2000/CR-SVG-20000802/DTD/svg-20000802.dtd">
<svg width="10cm" height="4cm" viewBox="0 0 100 100">
<rect x="1cm" y="1cm" width="4cm" height="1cm" style="fill:none;
stroke:blue; stroke-width:3"/>
<line x1="1cm" y1="1cm" x2="3cm" y2="3cm" style="stroke:red;
stroke-width:2" />
---------------------------------------------------------------------------
Attempt to draw diagolal line by meas of relative units failed too. The green
line I want to plot from the left up corner to right bottom corner. In
absolute units it is from point x=1cm, y=1cm to the point x=5cm, y=2cm. In
relative units of viewBox it is like this:
X 1cm = 1 * 100/10 = 10
Y 1cm = 1 * 100/4 = 25
X 5cm = 5 * 100/10 = 50
Y 2cm = 2 * 100/4 = 50
The final svg file is:
--------------------------------------------------------------------------
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20000802//EN"
"http://www.w3.org/TR/2000/CR-SVG-20000802/DTD/svg-20000802.dtd">
<svg width="10cm" height="4cm" viewBox="0 0 100 100">
<rect x="1cm" y="1cm" width="4cm" height="1cm" style="fill:none;
stroke:blue; stroke-width:3"/>
<line x1="1cm" y1="1cm" x2="3cm" y2="3cm" style="stroke:red;
stroke-width:2" />
<path d="M 10 25 L 50 50 z" style="stroke:green; stroke-width:2" />
</svg>
---------------------------------------------------------------------------
path element is not diagonal line.
2. That is correct method to do plots with absolute units?
- Best regards, Ilia -
------------------------
Илья Чибрикин
<ic...@jet.msk.su>
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-dev-help@xml.apache.org
Re: Coordinats
Posted by Vincent Hardy <vh...@eng.sun.com>.
Ilia,
The way units are handled in SVG actually mandates the behavior
you are describing. Absolute units, such as cm, have a standard
conversion ratio to user space units. The viewBox in effect changes
the userSpace which is why you see a difference when you have a
viewBox and when you do not.
There are several tests from the SVG Basic Effectivity test suite that
show the expected behavior:
http://www.w3.org/Graphics/SVG/Test/20010127/coords-units-BE-01.svg
http://www.w3.org/Graphics/SVG/Test/20010127/coords-viewBox-BE-03.svg
http://www.w3.org/Graphics/SVG/Test/20010127/coords-unitsProc-BE-04.svg
You can try with the .png extension and see that Batik produces these
results.
I hope this answers your question.
Regards.
Vincent.
Ilia Chibrikin wrote:
>
> Dear colleges!
> I am trying to use SVG in order to plot geophysical data. So I need to have
> final result in absolute units - cm for example. As a viewer I use
> batik-1.0beta. Help me, please!
> The question is the following:
> 1. Is it possible to use in one SVG file both absolute and relative units?
> For example:
> ----------------------------------------------------------------------------
> <?xml version="1.0" standalone="no"?>
> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20000802//EN"
> "http://www.w3.org/TR/2000/CR-SVG-20000802/DTD/svg-20000802.dtd">
> <svg width="10cm" height="4cm">
> <rect x="1cm" y="1cm" width="4cm" height="1cm" style="fill:none;
> stroke:blue; stroke-width:3"/>
> <line x1="1cm" y1="1cm" x2="3cm" y2="3cm" style="stroke:red;
> stroke-width:2" />
> ----------------------------------------------------------------------------
> This draws both elements correctly. Adding of viewBox attribute changes the
> output! The following example differs from the one above:
> ----------------------------------------------------------------------------
> <?xml version="1.0" standalone="no"?>
> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20000802//EN"
> "http://www.w3.org/TR/2000/CR-SVG-20000802/DTD/svg-20000802.dtd">
> <svg width="10cm" height="4cm" viewBox="0 0 100 100">
> <rect x="1cm" y="1cm" width="4cm" height="1cm" style="fill:none;
> stroke:blue; stroke-width:3"/>
> <line x1="1cm" y1="1cm" x2="3cm" y2="3cm" style="stroke:red;
> stroke-width:2" />
> ---------------------------------------------------------------------------
> Attempt to draw diagolal line by meas of relative units failed too. The green
> line I want to plot from the left up corner to right bottom corner. In
> absolute units it is from point x=1cm, y=1cm to the point x=5cm, y=2cm. In
> relative units of viewBox it is like this:
> X 1cm = 1 * 100/10 = 10
> Y 1cm = 1 * 100/4 = 25
> X 5cm = 5 * 100/10 = 50
> Y 2cm = 2 * 100/4 = 50
> The final svg file is:
> --------------------------------------------------------------------------
> <?xml version="1.0" standalone="no"?>
> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20000802//EN"
> "http://www.w3.org/TR/2000/CR-SVG-20000802/DTD/svg-20000802.dtd">
> <svg width="10cm" height="4cm" viewBox="0 0 100 100">
> <rect x="1cm" y="1cm" width="4cm" height="1cm" style="fill:none;
> stroke:blue; stroke-width:3"/>
> <line x1="1cm" y1="1cm" x2="3cm" y2="3cm" style="stroke:red;
> stroke-width:2" />
> <path d="M 10 25 L 50 50 z" style="stroke:green; stroke-width:2" />
> </svg>
> ---------------------------------------------------------------------------
> path element is not diagonal line.
>
> 2. That is correct method to do plots with absolute units?
>
> - Best regards, Ilia -
> ------------------------
> éÌØÑ þÉÂÒÉËÉÎ
> <ic...@jet.msk.su>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-dev-help@xml.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-dev-help@xml.apache.org