I am making a custom graphics library on top of pstricks and I need to convert from pstricks coordinates to postscript coordinates. I have a "working" example, cooked up via painful trial-and-error process, but I am sure it can be done properly. Reading the pstricks.tex file, I was left with the impression that pstricks uses somehow \pst@coor or - some other macro - perhaps you know better - to convert from pstricks coordinates to postscript coordinates. I have not been able to decode how that works. So here is my working solution.
My concrete question to you is: what are the native pstricks conversion functions I should use in place of \fcConvertPSXUnit and \fcConvertPSYUnit in the code below? [Edit] Question was answered below by Herbert. Including his answer in this post.
If done properly, the code below should display a perfect square cross (the top part of the cross is drawn using native pstricks, and the bottom part is drawn via the conversion functions).
\documentclass{article}
\usepackage{auto-pst-pdf}
%to convert points to numbers, macro copied from stackexchange
\makeatletter
\begingroup
\catcode `P=12 % digits and punct. catcode
\catcode `T=12 % digits and punct. catcode
\lowercase{%
\def\x{\def\rem@pt##1.##2PT{##1\ifnum##2>\z@.##2\fi}}}
\expandafter\endgroup\x%
\newcommand{\stripPoints}[1]{\expandafter\rem@pt\the#1}
\newcommand{\fcConvertPSXUnit}{\stripPoints{\psxunit} 72.27 div 8000 mul mul\space %
\pst@number\pst@dima\space %3 sub
72.27 div 8000 mul sub %
}%
\newcommand{\fcConvertPSYUnit}{\stripPoints{\psyunit} 72.27 div -8000 mul mul\space %
\pst@number\pst@dimb\space 72.27 div -8000 mul sub %
}%
\makeatother
\begin{document}
\psset{xunit=1.2cm, yunit=1.2cm}
\begin{pspicture}(-2.3,-2.7)(2.1,2.55)%
\psline (0,0)(0,1)%
\psline (0,0)(1,0)%
\pstVerb{ %
100 setlinewidth %
newpath %
0 \fcConvertPSXUnit 0 \fcConvertPSYUnit moveto %
-1 \fcConvertPSXUnit 0 \fcConvertPSYUnit lineto %
0 \fcConvertPSXUnit 0 \fcConvertPSYUnit moveto %
0 \fcConvertPSXUnit -1 \fcConvertPSYUnit lineto %
stroke %
}%
\end{pspicture}
\end{document}
Thanks for your advice!
The code from Herbert that answers my question:
\documentclass{article}
\usepackage{auto-pst-pdf}
\usepackage{pstricks} %that should had been included
\begin{document}
\psset{xunit=1.2cm, yunit=1.2cm}
\begin{pspicture}(-2.3,-2.7)(2.1,2.55)%
\makeatletter
\psline (0,0)(0,1)%
\psline (0,0)(1,0)%
\pscustom{ %
\code{ %
100 setlinewidth %
newpath %
0 0 \tx@ScreenCoor\space moveto %
-1 0 \tx@ScreenCoor\space lineto %
0 0 \tx@ScreenCoor\space moveto %
0 -1 \tx@ScreenCoor\space lineto %
stroke %
}%
}%
\makeatother
\end{pspicture}
\end{document}
pstricks
!%
inside\pstVerb
are cpmpletely superflous2 \pst@number\psunit mul setlinewidth
. However, as I already wrote your origin is not the one frompspicture
.