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
|
#!/usr/bin/env gbs3
Private Const MAXITER As Integer = 50
Private Const LIMIT As Float = 4.0
Sub Mandelbrot(W As Integer, H As Integer)
Dim XMin As Float = -1.5
Dim YMin As Float = -1
Dim InvN As Float = 2.0 / W
Dim CheckNext As Boolean = True
Dim X, Y, K As Integer
Dim Cr, Ci, Zr, Zi, {Tr}, Ti, T As Float
For Y = 0 To H - 1
Ci = Y * InvN + YMin
For X = 0 To W - 1
Zr = 0
Zi = 0
{Tr} = 0
Ti = 0
Cr = X * InvN + XMin
If CheckNext Then
For K = 1 To MAXITER
Zi = 2.0 * Zr * Zi + Ci
Zr = {Tr} - Ti + Cr
Ti = Zi * Zi
{Tr} = Zr * Zr
T = {Tr} + Ti
If IsNan(T) Or If T > LIMIT Then Break
Next
If K > MAXITER Then
Print "1";
CheckNext = False
Else
Print "0";
Endif
Else
For K = 1 To MAXITER
Zi = 2.0 * Zr * Zi + Ci
Zr = {Tr} - Ti + Cr
Ti = Zi * Zi
{Tr} = Zr * Zr
Next
T = {Tr} + Ti
If IsNan(T) Or If T > LIMIT Then
Print "0";
CheckNext = True
Else
Print "1";
Endif
Endif
Next
Print
Next
End
Dim I As Integer
For I = 1 To 20
Mandelbrot(200, 200)
Next
Error CStr(Jit.Time)
|