summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/pstricks-examples/14-07-2.ltx
blob: 0f0cb74d8c809bdfec72f7ffd9c0fd52d5c5c9c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
%% 
%%  Ein Beispiel der DANTE-Edition
%% 
%% 
%%  Copyright (C) 2010 Herbert Voss
%% 
%%  It may be distributed and/or modified under the conditions
%%  of the LaTeX Project Public License, either version 1.3
%%  of this license or (at your option) any later version.
%% 
%%  See http://www.latex-project.org/lppl.txt for details.
%% 
%% 
%% ==== 
% Show page(s) 1
%% 
\documentclass[]{exaarticle}
\pagestyle{empty}
\setlength\textwidth{392.64803pt}
\StartShownPreambleCommands
\usepackage{pstricks,pst-xkey}
\SpecialCoor
\makeatletter
\pst@addfams{pst-chaos} % eine eigene Familie festlegen
\newdimen\psk@chaos@xWidth
\define@key[psset]{pst-chaos}{xWidth}{\pssetlength\psk@chaos@xWidth{#1}}
\newdimen\psk@chaos@yWidth
\define@key[psset]{pst-chaos}{yWidth}{\pssetlength\psk@chaos@yWidth{#1}}
\define@key[psset]{pst-chaos}{dColor}{\def\psk@dColor{#1 }}
\define@boolkey[psset]{pst-chaos}[Pst@]{Julia}[true]{}
\psset[pst-chaos]{xWidth=1cm,yWidth=1cm,dColor=1,Julia}

\define@key[psset]{pst-chaos}{plotpoints}{\pst@checknum{#1}\pst@chaos@plotpoints}
\psset[pst-chaos]{plotpoints=100}

\def\psSier{\pst@object{psSier}}
\def\psSier@i(#1)(#2)(#3){%
  \pst@getcoor{#1}\pst@tempA
  \pst@getcoor{#2}\pst@tempB
  \pst@getcoor{#3}\pst@tempC
  \begin@SpecialObj%
  \addto@pscode{
    /Koor [ \pst@tempA
            \pst@tempB
    \pst@tempC ] def
    /Sx 0 def /Sy 0 def
    /setzePixel { % x y auf dem Stack
0.5 0 360 arc stroke
    } def
    /neuePosition { % Punktnummer auf dem Stack
Koor 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 setzePixel
    } def
    /zeichneRahmen {
Koor aload pop
newpath
moveto
nKoor 1 sub { % nur noch n-1 mal
         lineto
} repeat
gsave 0.9 setgray fill grestore
\pst@usecolor\pslinecolor
closepath
stroke
% 0 setgray
    } def
    /nKoor Koor length 2 div 0.5 add cvi def % Anzahl Punkte
    zeichneRahmen
    \pst@chaos@plotpoints\space cvi {
rand nKoor mod
dup add neuePosition
    } repeat
  }% end add@pscode
  \end@SpecialObj%
}
\def\pschaos{\pst@object{pschaos}}
\def\pschaos@i{\@ifnextchar({\pschaos@ii}{\pschaos@ii(-1,-1)}}%
\def\pschaos@ii(#1,#2){\@ifnextchar({\pschaos@iii(#1,#2)}{\pschaos@ii(#1,#2)(1,1)}}%
\def\pschaos@iii(#1,#2)(#3,#4){%
  \begin@SpecialObj%
  \pspicture(\psk@chaos@xWidth,\psk@chaos@yWidth)%
  \addto@pscode{
    /MinX #1 def
    /MaxX #3 def
    /MinY #2 def
    /MaxY #4 def
    /MaxXPixel \pst@number\psk@chaos@xWidth def
    /MaxYPixel \pst@number\psk@chaos@yWidth def
    /PixelDicke 0.5 def
    /maxIter 100 def
    /maxR 100 def
%
    /dx MaxX MinX sub MaxXPixel div def
    /dy MaxY MinY sub MaxYPixel div def
%
    /convertX {% erwartet x-Wert auf dem Stack
      MaxX sub dx div % Umrechnung in Pixel
    } def
    /convertY {% erwartet x-Wert auf dem Stack
      MinY sub dy div % Umrechnung in Pixel
    } def
    /convertXY {% erwartet x y auf dem Stack
      convertY exch convertX exch
    } def
%
    /setzePixel {%  x y auf dem Stack in Benutzerkoordinaten
      convertXY
      PixelDicke 0 360 arc fill
    } def
    MinX dx MaxX {
      /x exch def
      MinY dy MaxY {
/y exch def
/iter 0 def
             \ifPst@Julia
               /cx 0 def
               /cy 0 def
/zx x def
/zy y def
             \else
              /cx x def
              /cy y def
/zx 0 def
/zy 0 def
             \fi
/plot true def
maxIter {
    zx dup mul zy dup mul add maxR 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@dColor add def
    } ifelse
} repeat
plot{
    0 0 0 setrgbcolor
    x y setzePixel
}{
    1 iter sub 0 1 setrgbcolor
    iter 1 ge {0 iter 1 sub 2 iter sub setrgbcolor} if
    iter 2 ge {iter 2 sub 1 0 setrgbcolor} if
    iter 3 ge {1 4 iter sub .35 mul .65 add 0 setrgbcolor} if
    iter 4 ge {1 5 iter sub .65 mul 0 setrgbcolor} if
    x y setzePixel stroke
}ifelse % Plot point if point is in set
    } for
  } for
  }% end add@pscode
  \endpspicture% end box
  \end@SpecialObj%
}
\makeatother
\StopShownPreambleCommands
\begin{document}
\begin{center}
\begin{minipage}{0.45\textwidth}\centering
Eine Mandelbrotmenge: \\[10pt]
\begin{pspicture}(6,6)
\pschaos[xWidth=6cm,yWidth=6cm,dColor=1,Julia=false](-2,-1.25)(0.5,1.25)
\end{pspicture}
\end{minipage}~
\begin{minipage}{0.45\textwidth}\centering
Ein Sierpinskidreieck: \\[10pt]
\begin{pspicture}(6,6)
  \psSier[plotpoints=5000](0,0)(2,6)(6,0)
\end{pspicture}
\end{minipage}

\bigskip
Eine Juliamenge:\\[10pt]
\pschaos[xWidth=5cm,yWidth=5cm,dColor=0.5](-1.5,-1.5)(1.5,1.5)
\end{center}
\end{document}