[pstricks] postscript calculation within pstricks arguments
Michael Sharpe
msharpe at ucsd.edu
Thu May 6 17:09:07 CEST 2010
On May 5, 2010, at 1:21 PM, Mathias Legrand wrote:
> Hi, I have the following:
>
> \documentclass{article}
> \usepackage{pstricks-add}
> \usepackage{multido}
>
> \begin{document}
> \thispagestyle{empty}
>
> \def\mypsframe#1#2{\psframe[linearc=#1 pt,cornersize=absolute,fillstyle=solid,fillcolor=black!#2](0,0)(1,1)}
>
> \psframe[fillstyle=solid,fillcolor=red!30](-8,-30)(21,30)
>
> \multido{\i=0+1}{22}{%
> \multido{\I=0+1}{30}{%
> \rput[cc]{!4 \I\space mul 4 \i\space mul add}(!1 dup \i\space mul 5.2 sub exch \I\space sub 2.7 add){%
> \mypsframe{\i}{\I}}%
> }%
> }%
> \end{document}
>
> but I would like to perform postscript calculations as follows (for instance) :
>
> \mypsframe{\i}{\I\space \i add 10 mul}
>
> but it does not work. Is there a systematic method for such requests?
>
I've never seen a case where a parameter value can be set using PostScript code. Any computations of parameter values have to be handled in TeX code. In the example you give, declare a new counter (outside the loop) and then use counter arithmetic. Eg
\newcount\MLcount%
\def\mypsframe#1#2{\psframe[linearc=#1 pt,cornersize=absolute,fillstyle=solid,fillcolor=black!#2](0,0)(1,1)}
\psframe[fillstyle=solid,fillcolor=red!30](-8,-30)(21,30)
\multido{\i=0+1}{22}{%
\multido{\I=0+1}{30}{%
\rput[cc]{!4 \I\space mul 4 \i\space mul add}(!1 dup \i\space mul 5.2 sub exch \I\space sub 2.7 add){%
\MLcount=\I\relax\advance\MLcount\i\relax\multiply\MLcount2\relax \mypsframe{\i}{\the\MLcount}}%
}%
}%
Michael
More information about the PSTricks
mailing list