[pstricks] Naive question

Herbert Voss hvoss at tug.org
Fri Apr 29 16:14:51 CEST 2005


Pedro Jorge Caridade wrote:

>I'm starting to get inside pstricks codes, and try to write some very
>simple. I have two questions, very naive, that I don't understand very
>clearly:
>
>How to pass arguments to my functions. For example I have this simple
>code:
>\makeatletter
>\def\ArrowPolygon{\pst at object{ArrowPolygon}}
>  
>
defining it as an PSTricks object implies the reading of the
optional parameters and the arrows

>\def\ArrowPolygon at i%
>{\@ifnextchar[{\ArrowPolygon@@ii}{\ArrowPolygon@@ii[]}}
>  
>
this is the reason why this line is not needed here.

>\def\ArrowPolygon@@ii[#1](#2)(#3,#4)(#5,#6){%
>\typeout#2%
>  
>
\typeout{#2} otherwise youÄll get only the first digit

Herbert


\documentclass[a4paper,12pt]{article}
\usepackage{pstricks}

\makeatletter
\def\ArrowPolygon{\pst at object{ArrowPolygon}}
\def\ArrowPolygon at i(#1,#2)(#3,#4)(#5,#6){%
  \begin at ClosedObj
  \typeout{#1}
  \typeout{#2}
  \typeout{#3}
  \typeout{#4}
  \typeout{#5}
  \typeout{#6}
  \psline{->}(#1,#2)(#3,#4)
  \psline{->}(#3,#4)(#5,#6)
  \psline{->}(#5,#6)(#1,#2)
  \end at ClosedObj%
}
\makeatother
\begin{document}

\ArrowPolygon[linecolor=red,xunit=0.5,yunit=0.25,arrowscale=3](1,-1)(20,5)(10,15)

\end{document}




More information about the PSTricks mailing list