I need in a (La)TeX document a command that using PSTricks draws a
picture with a background and on top of that a ten-pointed star where
the distances from center to each of the points are arbitrary and
given in the argument to the command.
Something like this
...
\newcommand{\recoverystar}[1]{
% do something with #1 and put it in *something*
\begin{pspicture}(-10,-10)(10,10)
% do something
\SpecialCoor
\degrees[10]
\pspolygon *something*
\end{pspicture}
}
\recoverystar(3, 6, 9, 2, 5, 8, 1, 4, 7, 10)
witch should draw the background and on top of that a star like
\pspolygon(3, 0)(2, 0.5)(6, 1)(2, 1.5)(9, 2) ... (5, 3) ... (7, 8) ...
(10, 9)(2, 9.5)
Chris
> \recoverystar(3, 6, 9, 2, 5, 8, 1, 4, 7, 10)
>
> witch should draw the background and on top of that a star like
>
> \pspolygon(3, 0)(2, 0.5)(6, 1)(2, 1.5)(9, 2) ... (5, 3) ... (7, 8) ...
> (10, 9)(2, 9.5)
\documentclass{minimal}
\usepackage{pstricks}
\makeatletter
\def\recoverystar(#1){\expandafter\rstar@i#1,,\@nil}
\def\rstar@i#1,#2,,\@nil{%
\def\St@rt{#1}%
\rstar@ii#2}
\def\rstar@ii#1,#2,#3,#4,#5,#6,#7,#8,#9{%
\SpecialCoor%
\degrees[10]%
\begin{pspicture}(-10,-10)(10,10)
\pspolygon(\St@rt;0)(2;0.5)(#1;1)(2;1.5)(#2;2)(2;2.5)(#3;3)(2;3.5)%
(#4;4)(2;4.5)(#5;5)(2;5.5)(#6;6)(2;6.5)(#7;7)(2;7.5)%
(#8;8)(2;8.5)(#9;9)(2;9.5)
\end{pspicture}%
}
\makeatother
\begin{document}
\recoverystar(3, 6, 9, 2, 5, 8, 1, 4, 7, 10)
\end{document}
Herbert
But what I didn't write is that I also wish to make two other
commands: One which takes two sets og arguments like
\recoverystarFilled(...)(...)
and then makes two stars with filling in between.
And one which takes four sets making two stars with filling in between
and two other with filling in between on top of those.
Can I do that and how?
Chris
> But what I didn't write is that I also wish to make two other
> commands: One which takes two sets og arguments like
>
> \recoverystarFilled(...)(...)
>
> and then makes two stars with filling in between.
>
> And one which takes four sets making two stars with filling in between
> and two other with filling in between on top of those.
>
> Can I do that and how?
\documentclass{minimal}
\usepackage{pstricks}
\makeatletter
\define@key[psset]{}{innerRadius}[1]{\pst@getlength{#1}\psk@InnerRadius}
\psset{innerRadius=2cm}
\def\recoverystar{\pst@object{recoverystar}}
\def\recoverystar@i(#1){%
\begin@ClosedObj
\addto@pscode{
/coor [#1] def
coor length /no ED
/angleunit { 360 no div mul } def
/radius \psk@InnerRadius\space def
coor 0 get \pst@number\psrunit mul 0 moveto
radius 0.5 angleunit PtoC lineto
1 1 no 1 sub {
/relAngle ED
coor relAngle get \pst@number\psrunit mul relAngle angleunit PtoC
lineto
radius relAngle 0.5 add angleunit PtoC lineto
} for
closepath
}
\end@ClosedObj%
}
\makeatother
\begin{document}
\psset{unit=0.5}
\begin{pspicture}(-10,-10)(10,10)
\recoverystar(3 6 9 2 5 8 1 4 7 10)
\recoverystar[innerRadius=1.5,fillcolor=red!30,fillstyle=solid,
linecolor=blue](5 4 8 10 9 6 7 10)
\end{pspicture}
\end{document}
Herbert
I've tried it (copy and paste the document you wrote from
\documentclass{minimal} till \end{document}) and got the following
error massage:
...
(/usr/share/texmf/tex/generic/pstricks/pstricks.tex
`PSTricks' v1.26 <2008/07/31> (tvz)
(/usr/share/texmf/tex/generic/pstricks/pstricks.con))
(/usr/share/texmf/tex/latex/xcolor/xcolor.sty
(/usr/lib/texmf/tex/latex/config/color.cfg)
(/usr/share/texmf/tex/latex/graphics/dvips.def)))
! Undefined control sequence.
l.5 \define@key
[psset]{}{innerRadius}[1]
{\pst@getlength{#1}\psk@InnerRadius}
?
I suppose the fault is in the LaTeX or PSTricks at my machine. But how
do I fix it?
Chris
> I've tried it (copy and paste the document you wrote from
> \documentclass{minimal} till \end{document}) and got the following
> error massage:
> ! Undefined control sequence.
> l.5 \define@key
> [psset]{}{innerRadius}[1]
> {\pst@getlength{#1}\psk@InnerRadius}
> ?
>
> I suppose the fault is in the LaTeX or PSTricks at my machine. But how
> do I fix it?
your system is not up to date. Try
\documentclass{minimal}
\usepackage{pstricks}
\usepackage{pst-xkey}
...
Herbert
But, how could I make a command that takes two sets of arguments
drawing two stars with filling in between?
Something where
recoverystarfilled(5 6 ... 7)(7 8 ... 10)
would draw recoverystar(5 6 ... 7) and recoverystar(7 8 ... 10) and
make the filling between those two stars.
Chris
have a look at the clipping macro of PSTricks.
Examples are also available at http://PSTricks.tug.org
Herbert
One problem:
The second star is centered a few millimeters to the right compared to
the first, and a third star centers the same length to the right of
the center of the second one and so on.
I have searched and searched in the code for something that makes the
stars move to the right but with on luck.
Any ideas, anyone?
Chris
a trailing space:
....
}% <=== the % was missing ====
\end@ClosedObj%
...
Herbert