[pstricks] Centering psPrintValues

Herbert Voss LaTeX at zedat.fu-berlin.de
Fri Jun 16 09:21:30 CEST 2006


Poul Riis wrote:
> How can I make the numbers accurately centered in the circles in the
> example below?

not possible with printValue, it works only on PostScript
side. Calculate the Fibinacci numbers on the TeX side.

-- load pstricks _always_ as last package
-- use package geometry for page margins
-- don't put a % at the end of PostScript lines! It causes
    an error, when the next line begins not with a slash or {

Herbert


\documentclass{article}
\usepackage{pst-func,pstricks-add}
\usepackage{ifthen}
\usepackage[margin=1cm]{geometry}

\newcounter{fiba}\newcounter{fibb}\newcounter{fibc}\newcounter{fibrun}
% \fib{k} returns the k-te Fibonaccinumber F_k
\newcommand*\fib[1]{%
   \init\whiledo{\thefibrun<#1}{\step\stepcounter{fibrun}}\thefiba}
\newcommand*\init{%
   \setcounter{fiba}{1}\setcounter{fibb}{1}\setcounter{fibrun}{0}}
\newcommand*\step{\add \rotate}
\newcommand*\add{\setcounter{fibc}{\thefiba}\addtocounter{fibc}{\thefibb}}
\newcommand*\rotate{\setcounter{fiba}{\thefibb}\setcounter{fibb}{\thefibc}}

\pagestyle{empty}

\pstVerb{%
   /phigylden 137.5078 def
   /storephi 5 sqrt 1 add 2 div def
   /antalfroe 25 def
   /radius 8 def
   /kk antalfroe radius div radius div def
   /xfroe {kk div dup kk mul phigylden mul cos exch sqrt mul} def
   /yfroe {kk div dup kk mul phigylden mul sin exch sqrt mul neg} def
   /fib {dup dup 1 eq exch 0 eq or not {dup 1 sub fib exch 2 sub fib 
add} if} def%
   /b 12 def}%
\definecolor[ps]{bl}{rgb}{tx at addDict begin Red Green Blue end}
\newcommand*\rainbowcolor[1]{%
   \pstVerb{/lambda #1 def lambda tx at addDict begin wavelengthToRGB end}}%
\SpecialCoor%

\begin{document}

\psset{unit=1.4cm}%
\begin{pspicture}(-6,-6)(6,6)%
\parametricplot[plotstyle=curve,linecolor=blue,%
     linewidth=5pt,plotpoints=100]{0}{11}{t xfroe t yfroe}
\multido{\iA=1+1,\iB=0+1}{11}{%
   \rainbowcolor{\iA\space 10 mul 590 add}%
   \Cnode*[radius=20pt,linecolor=bl](!\iA\space xfroe \iA\space 
yfroe){F\iA}%
   \rput(F\iA){\Huge\bfseries\fib{\iB}}}%
\multido{\iA=1+1,\iB=2+1}{10}{\ncline{F\iA}{F\iB}}
\end{pspicture}

\end{document}





More information about the PSTricks mailing list