aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/llgcode/ps/samples/Mand.ps
blob: 1f0d4271762124a2630d8309a8a69dc9e153be85 (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
%!PS-Adobe-2.0

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                       %
%   Mandelbrot set via PostScript code. Not optimized   %
%   in any way. Centered in A4 paper. Escape time, B&W  %
%                                                       %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

/fun {
    4 3 roll 		% y c1 c2 x
    dup dup		% y c1 c2 x x x
    mul 		% y c1 c2 x x^2
    5 4 roll		% c1 c2 x x^2 y
    dup dup mul		% c1 c2 x x^2 y y^2
    2 index exch sub	% c1 c2 x x^2 y (x^2-y^2)
    6 1 roll 2 index  	% (x^2-y^2) c1 c2 x x^2 y x
    2 mul mul		% (x^2-y^2) c1 c2 x x^2 2xy
    6 1 roll		% 2xy (x^2-y^2) c1 c2 x x^2
    pop pop 4 1 roll	% c2 2xy (x^2-y^2) c1
    dup 5 1 roll add	% c1 c2 2xy (x^2-y^2+c1)
    4 1 roll		% (x^2-y^2+c1) c1 c2 2xy
    1 index		% (x^2-y^2+c1) c1 c2 2xy c2
    add	4 3 roll	% c1 c2 (2xy+c2) (x^2-y^2+c1)
    exch 4 2 roll	% (x^2-y^2+c1) (2xy+c2) c1 c2
} def

/res 500 def 
/iter 50 def


300 300 translate
90 rotate
-150 -260 translate
0 1 res {
    /x exch def
    0 1 res {
	/y exch def 
	    0 0
	    -2.5 4 x mul res div add
	    2 4 y mul res div sub
	    iter -1 0  {
		/n exch store
		fun
		2 index dup mul
		4 index dup mul
		add sqrt
		4 gt
		{exit} if
	    } for
	    pop pop pop pop


	    n 0 gt
	    {1 setgray
		x y 0.7 0 360 arc
		fill
	    }
	    {
		0 setgray
		x y 0.5 0 360 arc
		fill
	    } ifelse
	    } for
	}for
showpage