Loading ...
Sorry, an error occurred while loading the content.
 

Pathdata in a non-userunit document

Expand Messages
  • Andreas Steichardt
    Hi! I ve got a little problem to define a path (sounds simple :P). My document is based on mm and should be viewable on different media: On a normal display
    Message 1 of 2 , Nov 6, 2006
      Hi!

      I've got a little problem to define a path (sounds simple :P).

      My document is based on mm and should be viewable on different media: On a
      normal display and on paper.

      I have fixed values for the stroke and the path data.

      The problem is that path data is always specified in user units. When
      rendering as a pdf in Batik one user unit equals 1pt. When rendering on a
      display or as a pixel based image one user unit equals 1px.

      This is a problem as my path data should be specified in mm as well. So i have
      to transform these values into user units (which might be pixel or points).
      What i can do is embed my path into a separate <svg> and specify a viewBox.

      Problem:

      The stroke is scaled as well (which should be 1pt).

      My current svg:

      <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
      <svg width="90mm" height="90mm" preserveAspectRatio="none">
      <rect x="0" y="0" width="30mm" height="30mm"/>
      <svg width="30mm" height="30mm" viewBox="0 0 100 100"
      preserveAspectRatio="none">
      <path d="M0,0 L100,100" stroke="red" stroke-width="1pt"/>
      </svg>
      </svg>

      How can i make a path from 0mm,0mm to 30mm,30mm and a stroke-width of exactly
      1pt?

      Javascript solutions are not a solution for me.

      Kind regards,

      Andreas Streichardt
    • Andreas Neumann
      Hi Andreas, I would avoid the use of units wherever you can. In my opinion the only place where units really make sense is in the root element of the svg
      Message 2 of 2 , Nov 6, 2006
        Hi Andreas,

        I would avoid the use of units wherever you can. In my opinion the only place where units
        really make sense is in the root element of the svg graphics, where you can define units
        for width and height, e.g. "mm". This means you can define your stroke-width unitless,
        which means in user units. And yes, a viewBox on the root element is the way to go. I
        always use a viewBox to enable scaling.

        Would this work?

        In SVG tiny 1.2 TransfomRef enables non-scaling strokes: http://www.w3.org/TR/
        SVGMobile12/coords.html#transform-ref - is that what you are looking for? Unfortunately,
        in SVG 1.1, the only way to do is with Javascript or during document generation. The good
        news is, that with Batik rasterizer you can still use javascript. It is executed prior to
        translating it into other formats.

        Hope this helps,
        Andreas


        --- In svg-developers@yahoogroups.com, Andreas Steichardt <mop@...> wrote:
        >
        > Hi!
        >
        > I've got a little problem to define a path (sounds simple :P).
        >
        > My document is based on mm and should be viewable on different media: On a
        > normal display and on paper.
        >
        > I have fixed values for the stroke and the path data.
        >
        > The problem is that path data is always specified in user units. When
        > rendering as a pdf in Batik one user unit equals 1pt. When rendering on a
        > display or as a pixel based image one user unit equals 1px.
        >
        > This is a problem as my path data should be specified in mm as well. So i have
        > to transform these values into user units (which might be pixel or points).
        > What i can do is embed my path into a separate <svg> and specify a viewBox.
        >
        > Problem:
        >
        > The stroke is scaled as well (which should be 1pt).
        >
        > My current svg:
        >
        > <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
        > <svg width="90mm" height="90mm" preserveAspectRatio="none">
        > <rect x="0" y="0" width="30mm" height="30mm"/>
        > <svg width="30mm" height="30mm" viewBox="0 0 100 100"
        > preserveAspectRatio="none">
        > <path d="M0,0 L100,100" stroke="red" stroke-width="1pt"/>
        > </svg>
        > </svg>
        >
        > How can i make a path from 0mm,0mm to 30mm,30mm and a stroke-width of exactly
        > 1pt?
        >
        > Javascript solutions are not a solution for me.
        >
        > Kind regards,
        >
        > Andreas Streichardt
        >
      Your message has been successfully submitted and would be delivered to recipients shortly.