[pstricks] Mysteriously shifting origin

ristow at ece.gatech.edu ristow at ece.gatech.edu
Tue Jul 20 19:01:49 CEST 2004


Hi,

I have been finding lately that when I use \addto at pscode the x-coordinate
of the origin is in a slightly different place that it is for other
commands. In the example below, I draw exactly the same shape twice, with
the intention of having it be centered on the origin each time. The code
in \pscustom performs as expected, but the code in \pscrosshair produces
an object shifted to the right of the origin. (The second \pscustom
command was necessary to change the linecolor -- for some reason \psset
did not work for this purpose after using \pscustom.)

Clearly something in \pscrosshair is responsible. If you uncomment the two
commented lines the code in \pscustom fails, drawing its object in the
same incorrect location as \pscrosshair. Successive executions of
\pscrosshair produce objects offset farther and farther to the right, as
can be seen after uncommenting the commented lines.

After hours of examining both the pstricks code and the PS output file I
cannot find the reason for this. Am I missing something obvious, or is
this a real mystery? Any ideas?

Thanks,

Alan


\documentclass[letterpaper]{article}
\usepackage{pstricks}%
\usepackage{pst-plot}%

\pagestyle{empty}

\makeatletter%
  \def\pscrosshair{
    \begin at OpenObj
    \addto at pscode{%
      newpath
        -25 0 moveto
        25 0 lineto
        0 -25 moveto
        0 25 lineto
      stroke
    }
    \end at OpenObj
  }%
\makeatother

\begin{document}
  \psset{unit=1in}%
  \begin{pspicture}(0,0)(3,1.5)%
    \psaxes(0,0)(0,0)(3.5,1.5)%
%	 	\psset{linecolor=blue,linewidth=1.5pt}%
% 	\pscrosshair%
    \pscustom[linecolor=red,linewidth=1.5pt]{%
      \code{%
        newpath
          -25 0 moveto
          25 0 lineto
          0 -25 moveto
          0 25 lineto
        stroke
      }%
    }%
    \pscustom[linecolor=blue,linewidth=1.5pt]{}%
    \pscrosshair%
  \end{pspicture}
\end{document}





More information about the PSTricks mailing list