[texhax] pstricks, or postscript, question
Herbert Voss
Herbert.Voss at FU-Berlin.DE
Wed Mar 12 20:18:41 CET 2008
Zbigniew Nitecki schrieb:
> Is there a way to create a macro which can be used inside a pspicture
> environment which calls pstricks macros but calculates some parameters
> from its arguments?
>
> I am trying to create a macro to draw a figure which includes an
> elliptic arc whose beginning and ending angles are computed from the
> arguments of the macro. But it seems I cannot do something like
> \ellipticarc(0,0)(0.5,1){180 45 sub}{180 45 add}
> (never mind substituting #1 or #2 for the "45" above)---I get an error
> message:
> bad number: '180 45 sub' . 0 substituted.
>
> Is there a way in postscript to name a number, compute its value, and
> then use it as a parameter
> in a drawing command?
\listfiles
\documentclass{article}
\usepackage{pstricks}
\makeatletter
\def\psellipticarc at iv(#1)(#2)#3#4{%
\begin at OpenObj
\pst at getcoor{#1}\pst at tempa
\pst at getcoor{#2}\pst at tempb
\def\pst at tempc{#3 }% read verbatim
\def\pst at tempd{#4 }% read verbatim
\addto at pscode{\psellipticarc at definearg \psellipticarc at draw}%
\showpointsfalse
\end at OpenObj%
}
\makeatother
\SpecialCoor
\begin{document}
\begin{pspicture}[showgrid=true](-1,-1)(1,1)
\psellipticarc(0,0)(0.5,1){180 45 sub}{180 45 add}
\end{pspicture}
\end{document}
Herbert
More information about the texhax
mailing list