RE: Path Coordinates

SVG's default coordinate system is screen pixels, but there are various
features that allow you to define user coordinate systems.

At 02:59 PM 2/22/00 +0000, Pawson, David wrote:
>A. J. Wilson wrote:
>
>>I am attempting to manually code some SVG paths and, as far as I can
>>tell, all coordinates that can be specified in the path cannot use unit
>>designators.  Do you see this as a shortcoming?
>
>I certainly do with paper as a target media.

It is unlikely at this late date that there will be unit designators within
a path specification for SVG 1.0, even though it is recognized that this is
a valuable feature in some circumstances. It is likely to be considered for
a future version of SVG.

>
>>
>>I am specifically trying to set up a page size (SVG viewport) that
>>mimics a 8" x 11.5" sheet of paper.  After that I want to draw paths
>>on the paper and have it rendered correctly both on a  monitor and on a
>>printer.
>>It seems that specifying path coordinates in pixel values defeats my
>>purpose,
>>because I do not know the resolution of the output device in advance.

One way you can accomplish this is to do something like:

<svg width="100%" height="100%" viewBox="0 0 8.5 11.5">
   <!-- Graphics go here -->
</svg

This will cause the SVG drawing to scale-to-fit to the target device. The
viewBox specification allows you to lay out your "page" as if the canvas
were 8.5x11.5 inches. (Of course, US paper is 8.5x11, not 8.5x11.5.)

You can get fancier using CSS @media rules:

<svg width="100%" height="100%" viewBox="0 0 8.5 11.5">
   <defs>
       <style><![CDATA[
  @media screen {
      svg { width: 3in; height: 5in }
  }
  @media print {
      svg { width: 8.5in; height: 11in }
  }
]]>
       </style>
   </defs>
   <!-- Graphics go here -->
</svg

This will cause the picture to render into a 3x5 area when viewed on a
screen display device, but take up the full page when printing.

Jon Ferraiolo
SVG Editor
Adobe Systems Incorporated


>>
>>What am I missing?
>
>I don't know, but I'm missing it too :-)
>
>
>regards, DaveP
> 

Received on Wednesday, 23 February 2000 14:56:21 UTC