forked from bext-lang/b
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmandelbrot.b
More file actions
53 lines (40 loc) · 766 Bytes
/
mandelbrot.b
File metadata and controls
53 lines (40 loc) · 766 Bytes
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
W 80;
H 40;
IT 100;
f 1000;
gradient "@%#*+=-:. ";
m(cr,ci) {
auto a, b, i, tmp;
cr -= 3*W/4;
ci -= H/2;
cr = (cr * f * 3) / W;
ci = (ci * f * 3) / H;
a = b = 0;
i = 0; while (i < IT) {
if (a*a/f + b*b/f > 2*2*f) {
return (9 - (i*10 / IT));
}
tmp = (a*a - b*b)/f + cr;
b = (a*b)/f*2 + ci;
a = tmp;
i++;
}
return (0);
}
main() {
extrn char, putchar;
// we can't use more precision on 16-bit systems.
if (&0[1] <= 2) {
f = 50;
IT = 90;
}
auto i, j;
j = 0; while (j < H) {
i = 0; while (i < W) {
putchar(char(gradient, m(i,j)));
i++;
}
putchar('\n');
j++;
}
}