-
-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathmandel.bas
73 lines (58 loc) · 1.4 KB
/
mandel.bas
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
#define width 256
#define height 192
DIM x,y AS FIXED
DIM xstart,xstep,ystart,ystep AS FIXED
DIM xend,yend AS FIXED
DIM z,zi,newz,newzi AS FIXED
DIM colour AS BYTE
DIM iter AS UINTEGER
DIM col AS UINTEGER
DIM i,k AS UBYTE
DIM j AS UINTEGER
DIM inset AS UBYTE
xstart=-1.6
xend=0.65
ystart=-1.15
yend=-ystart
iter=24
xstep=(xend-xstart)/width
ystep=(yend-ystart)/height
'Main loop
x=xstart
y=ystart
BORDER 0
PAPER 0
INK 7
CLS
FOR i=0 TO ( height -1 )/2 +1
FOR j=0 TO width -1
z=0
zi=0
inset=1
FOR k=0 TO iter
';z^2=(a+bi)*(a+bi) = a^2+2abi-b^2
newz=(z*z)-(zi*zi)+x
newzi=2*z*zi+y
z=newz
zi=newzi
IF (z*z)+(zi*zi) > 4 THEN
inset=0
colour=k
GOTO screen
END IF
NEXT k
screen:
IF NOT inset THEN
IF colour BAND 1 THEN
PLOT j,i
PLOT j,192-i
END IF
END IF
x=x+xstep
NEXT j
y=y+ystep
x=xstart
PRINT AT 23,0;CAST(UINTEGER,i)*200/height;"%"
NEXT i
BEEP 1,1
PAUSE 0