diff options
Diffstat (limited to 'Master/texmf-dist/tex/generic/pst-fractal/pst-fractal.tex')
-rw-r--r-- | Master/texmf-dist/tex/generic/pst-fractal/pst-fractal.tex | 164 |
1 files changed, 164 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/generic/pst-fractal/pst-fractal.tex b/Master/texmf-dist/tex/generic/pst-fractal/pst-fractal.tex new file mode 100644 index 00000000000..c6f70147658 --- /dev/null +++ b/Master/texmf-dist/tex/generic/pst-fractal/pst-fractal.tex @@ -0,0 +1,164 @@ +%% +%% This is file `pst-fractal.tex', +%% +%% IMPORTANT NOTICE: +%% +%% Package `pst-fractal.tex' +%% +%% Herbert Voss <voss _at_ pstricks dot de> +%% +%% This program can be redistributed and/or modified under the terms +%% of the LaTeX Project Public License Distributed from CTAN archives +%% in directory macros/latex/base/lppl.txt. +%% +%% DESCRIPTION: +%% `pst-fractal' is a PSTricks package to draw Julia and +%% Mandelbrot sets as well as Sierpinski, ... +%% +\csname PSTfractalLoaded\endcsname +\let\PSTfractalLoaded\endinput +\ifx\PSTricksLoaded\endinput\else\input pstricks.tex\fi +\ifx\PSTricksAddLoaded\endinput\else\input pstricks-add.tex\fi +\ifx\PSTXKeyLoaded\endinput\else\input pst-xkey \fi +% +\def\fileversion{0.03} +\def\filedate{2007/04/05} +\message{`PST-fractal' v\fileversion, \filedate\space (hv)} +% +\edef\PstAtCode{\the\catcode`\@} \catcode`\@=11\relax +\pst@addfams{pst-fractal} +%\SpecialCoor +% +\newdimen\psk@fractal@xWidth +\define@key[psset]{pst-fractal}{xWidth}{\pssetlength\psk@fractal@xWidth{#1}} +\newdimen\psk@fractal@yWidth +\define@key[psset]{pst-fractal}{yWidth}{\pssetlength\psk@fractal@yWidth{#1}} +\psset[pst-fractal]{xWidth=1cm,yWidth=1cm} +\define@key[psset]{pst-fractal}{type}{\def\pst@fractal@type{#1}} +\psset[pst-fractal]{type=Julia}% or type=Mandel +\def\pst@fractal@Julia{Julia}\def\pst@fractal@Mandel{Mandel} +\define@key[psset]{pst-fractal}{baseColor}{\pst@getcolor{#1}\pst@fractal@baseColor} +\psset[pst-fractal]{baseColor=black} +% +\define@key[psset]{pst-fractal}{cx}{\def\psk@fractal@cx{#1 }} +\define@key[psset]{pst-fractal}{cy}{\def\psk@fractal@cy{#1 }} +\define@key[psset]{pst-fractal}{dIter}{\def\psk@fractal@dIter{#1 }} +\psset[pst-fractal]{cx=0,cy=0,dIter=1} +\define@key[psset]{pst-fractal}{maxIter}{\pst@checknum{#1}\pst@fractal@maxIter} +\define@key[psset]{pst-fractal}{maxRadius}{\pst@checknum{#1}\pst@fractal@maxRadius} +\psset[pst-fractal]{maxIter=255,maxRadius=100} +\define@key[psset]{pst-fractal}{plotpoints}{\pst@checknum{#1}\pst@fractal@plotpoints} +\psset[pst-fractal]{plotpoints=2000} +% +\def\psfractal{\pst@object{psfractal}} +\def\psfractal@i{\@ifnextchar({\psfractal@ii}{\psfractal@ii(-1,-1)}}% +\def\psfractal@ii(#1){\@ifnextchar({\psfractal@iii(#1)}{\psfractal@iii(#1)(1,1)}}% +\def\psfractal@iii(#1)(#2){% + \begin@SpecialObj + \psset{unit=1pt} + \pst@getcoor{#1}\pst@temp@A + \pst@getcoor{#2}\pst@temp@B + \pspicture(\psk@fractal@xWidth,\psk@fractal@yWidth)% + \addto@pscode{ + \pst@temp@A /MinY ED /MinX ED + \pst@temp@B /MaxY ED /MaxX ED + /MaxXPixel \pst@number\psk@fractal@xWidth def + /MaxYPixel \pst@number\psk@fractal@yWidth def + /PixelDicke 0.5 def + /cx \psk@fractal@cx def + /cy \psk@fractal@cy def + /totMaxIter \pst@fractal@maxIter\space \psk@fractal@dIter\space mul def +% + /DX MaxX MinX sub def + /DY MaxY MinY sub def + /dx DX MaxXPixel div def + /dy DY MaxYPixel div def +% + /convertX { MinX sub DX sub dx div } def % user -> pt + /convertY { MinY sub dy div } def % user -> pt + /convertXY { convertY exch convertX exch } def +% + /putPixel {% x y auf dem Stack in Benutzerkoordinaten + convertXY + PixelDicke 0 360 arc fill + } def +% + MinX dx MaxX { + \ifx\pst@fractal@type\pst@fractal@Julia /x exch def \else /cx exch def /x 0.0 def \fi + MinY dy MaxY { + \ifx\pst@fractal@type\pst@fractal@Julia /y exch def \else /cy exch def /y 0.0 def \fi + /iter 0 def + /zx x def + /zy y def + /plot true def + totMaxIter cvi { + zx dup mul zy dup mul add \pst@fractal@maxRadius\space gt { + /plot false def + exit + }{% Calculate next value + 2 zx zy mul mul cy add + /zx zx dup mul zy dup mul sub cx add def + /zy exch def + /iter iter \psk@fractal@dIter add def + } ifelse + } repeat + plot{ + \pst@usecolor\pst@fractal@baseColor + x y putPixel + }{ iter 400 add tx@addDict begin wavelengthToRGB + Red Green Blue setrgbcolor end + \ifx\pst@fractal@type\pst@fractal@Julia x y \else cx cy \fi + putPixel stroke + }ifelse % Plot point if point is in set + } for + } for + }% end add@pscode + \endpspicture% end box + \end@SpecialObj% + \ignorespaces} +% +\def\psSier{\pst@object{psSier}} +\def\psSier@i(#1)(#2)(#3){{% + \pst@getcoor{#1}\pst@temp@A + \pst@getcoor{#2}\pst@temp@B + \pst@getcoor{#3}\pst@temp@C + \begin@SpecialObj% + \addto@pscode{ + /Coor [ \pst@temp@A + \pst@temp@B + \pst@temp@C ] def + /Sx 0 def /Sy 0 def + /putPixel { 0.5 0 360 arc stroke } def % x y on stack + /newPosition { % point # on stack + Coor exch 2 getinterval aload pop + /y exch def /x exch def + x Sx sub 2 div Sx add /Sx exch def + y Sy sub 2 div Sy add /Sy exch def + Sx Sy putPixel + } def + /drawFrame { + Coor aload pop + newpath + moveto + nCoor 1 sub { lineto } repeat % n-1 times + gsave 0.9 setgray fill grestore + \pst@usecolor\pslinecolor + closepath + stroke + } def + /nCoor Coor length 2 div 0.5 add cvi def % # of dots + drawFrame + \pst@fractal@plotpoints\space cvi { + rand nCoor mod + dup add newPosition + } repeat + }% end add@pscode + \end@SpecialObj% +}} + +% +\catcode`\@=\PstAtCode\relax +% +%% END: pst-fractal.tex +\endinput + |