[pstricks] how to get absolute coordinates

Franco Bagnoli bagnoli at dma.unifi.it
Thu Jul 8 19:31:46 CEST 2004


On Thu, 8 Jul 2004, Herbert Voss wrote:

> Franco Bagnoli wrote:
> 
> >>1066.63416
> >>1205.01978
> >>494.633972
> >>1205.01978
> > 
> > 
> > I do not understand which is the origin and scale of these coordinates. 
> > After some tries I realized that the origin is in the middle of the paper, 
> > 1 inch at the right of the margin (this should depend on (la)tex, I 
> > suppose), but I would like to know if there is a simple way of getting the 
> > "real" postscript coordinates, or at least the scale factor for the x and 
> > the y. 
> 
> the above coordinates have nothing to do with latex
> they are absolute to the lower left of the paper

I found that: 

1) if I insert the postscript fragment via \special  or \pstverb it is 
surrounded by @beginspecial @setspecial .. @endspecial which causes on 
origin shift to the middle of the paper (at least in my trials). 

2) if I counteract it (by writing  @endspecial <postscript fragment> 
@beginspecial @setspecial) then I get numbers similar to yours, but the 
origin and scale are still odd (the origin is somewhere in the upper-left 
part of the page)

3) by inserting initmatrix one is reverted to the original coordinate 
system (1/72 inc, lower-left part), the same displayed by gv.

So, I finally wrote these macros that do the job: 

------------------------------------------------------

\newenvironment{PrintCoords}[1]{\pstVerb{
/outfile (#1) (w) file def
 /ws {outfile exch writestring} bind def
 /wl {ws (^^J) ws} bind def
 /wt {=string cvs ws ( ) ws} bind def
}}{\pstVerb{outfile closefile quit}}
\newcommand\Coords[1]{\pstVerb{
tx at Dict begin
  tx at NodeDict begin
  initmatrix
   (#1 ) ws
    /N@#1 load  GetCenter  exch wt wt (^^J) ws
    end
end
}}

and then 

\cnodeput(0,0){A}{A} 

...

\begin{PrintCoords}{coords.txt}
\Coords{A}
\end{PrintCoords}

----------------------------------------------------------

A question: 
Which information is  associated to a node? I was not able to understand 
what GetCenter does. I need the "bounding box" of a frame, and maybe the 
node already contains this information.  

-- 
Franco Bagnoli (franchino) <bagnoli at dma.unifi.it> 
virtual location: Dipartimento di Energetica "S. Stecco"
ultra-virtual affiliation: Centro Dinamiche Complesse (CSDC-Firenze)
real location: Dip. Matematica Applicata "G. Sansone", Universita' Firenze,
Via S. Marta, 3 I-50139 Firenze, Italy. Tel. +39 0554796422, fax: +39 055471787




More information about the PSTricks mailing list