pstricks 좌표에서 포스트스크립트 좌표로 변환

pstricks 좌표에서 포스트스크립트 좌표로 변환

pstricks 위에 사용자 정의 그래픽 라이브러리를 만들고 있는데 pstricks 좌표를 포스트스크립트 좌표로 변환해야 합니다. 나는 고통스러운 시행착오 과정을 거쳐 만들어진 "작동하는" 예제를 가지고 있지만 그것이 제대로 수행될 수 있다고 확신합니다. pstricks.tex 파일을 읽으면서 나는 pstricks가 pstricks 좌표에서 포스트스크립트 좌표로 변환하기 위해 어떻게든 \pst@coor 또는 - 다른 매크로를 사용한다는 인상을 받았습니다. 나는 그것이 어떻게 작동하는지 해독할 수 없었습니다. 여기 내 작업 솔루션이 있습니다.

구체적인 질문은 다음과 같습니다. 아래 코드에서 \fcConvertPSXUnit 및 \fcConvertPSYUnit 대신 사용해야 하는 기본 pstricks 변환 함수는 무엇입니까? [편집] 아래 질문에 Herbert가 답변했습니다. 이 게시물에 그의 답변을 포함합니다.

올바르게 완료되면 아래 코드는 완벽한 정사각형 십자가를 표시해야 합니다(십자가의 위쪽 부분은 기본 pstrick을 사용하여 그려지고 아래쪽 부분은 변환 함수를 통해 그려집니다).

\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}

조언해주셔서 감사합니다!

위 파일을 컴파일한 결과

내 질문에 답하는 Herbert의 코드는 다음과 같습니다.

\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}

답변1

\documentclass{article}
\usepackage{pstricks} 

\begin{document}
\psset{xunit=1.2cm, yunit=1.2cm}
\begin{pspicture}[showgrid](-2.3,-2.7)(2.1,2.55)
\psline (0,0)(0,1)
\psline (0,0)(1,0)
\pscustom{
  \moveto(0,0) 
  \lineto(-1,0) 
  \moveto(0,0) 
  \lineto(0,-1) 
  \stroke[linewidth=2pt,linecolor=red] 
}
\end{pspicture}
\end{document}

\moveto기본 매크로 등 을 원하지 않으면 다음 예를 사용하십시오.

\code{0 0 moveto -1 0 \tx@ScreenCoor\space lineto}

내부 \pscustom및 환경 \makeatletter이전 pspicture:

\documentclass{article}
\usepackage{auto-pst-pdf}
\usepackage{pstricks}
\begin{document}

\makeatletter
\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)
\pscustom{% 
\code{
newpath 
2 setlinewidth 
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 
}}%
\end{pspicture}
\makeatother
\end{document}

관련 정보