[pstricks] including PostScript code in pstricks
Herbert Voss
LaTeX at zedat.fu-berlin.de
Fri Mar 24 20:16:14 CET 2006
Germi Camps wrote:
> I have to draw a serie of arcs, but first I have to calculate the center
> point, the radius and the beginning and ending angle depending on a
> parameter
> I do not have any problem when calculating the center, because it is
> delimited by ( ). but for the other arguments, delimited by { },
> pstricks doesn't accepts PostScript code... how can I do it?
>
> \def\rad{3}
> \def\radb{5}
>
> \psarc(!\rad\space 1 \rad\space add div 10 mul 0){! \radb\space 2 div 1
> add}{0}{360}
>
> ! \radb\space 2 div 1 add -->> this doesn't work inside { }
this needs a redefinition of the \psarc macro
Herbert
\listfiles
\documentclass{minimal}
\usepackage{pstricks}
\SpecialCoor
\makeatletter
\def\psarc at iii(#1)#2#3#4{%
\begin at OpenObj
\pst at getangle{#3}\pst at tempa
\pst at getangle{#4}\pst at tempb
\pst@@getcoor{#1}%
\def\pst at tempA{#2}%
\addto at pscode{\psarc at iv \psarc at v}%
\gdef\psarc at type{0}%
\showpointsfalse
\end at OpenObj%
}
\def\psarc at iv{%
\pst at coor /y ED /x ED
/r \pst at tempA def
/c 57.2957 r \tx at Div def
/angleA
\pst at tempa
\psk at arcsepA c mul 2 div
\ifcase \psarc at type add \or sub \fi
def
/angleB
\pst at tempb
\psk at arcsepB c mul 2 div
\ifcase \psarc at type sub \or add \fi
def
\ifshowpoints\psarc at showpoints\fi
\ifx\psk at arrowA\@empty
\ifnum\psk at liftpen=2
r angleA \tx at PtoC
y add exch x add exch moveto
\fi
\fi}
\makeatother
\begin{document}
\def\rad{3}
\def\radb{5}
\psarc(!\rad\space 1 \rad\space add div 10 mul 0)%
{ \radb\space 2 div 1 add }{0}{360}
\end{document}
More information about the PSTricks
mailing list