Typical Code:
Dim a, b, i, j, cx, cy, w As Variant
'These are defined in General
Dim iterations As Variant
Function My_Red(iterations)
If iterations < 10 Then
My_Red = 255
Else
My_Red = 0
End If
End Function
Function My_Green(iterations)
My_Green = (300 * iterations) Mod 128
End Function
Function My_Blue(iterations)
My_Blue = (400 * iterations) Mod 256
End Function
Function next_real(a, b, i, j)
RealC = (i - cx) / w * 2 - 1
IMc = (j - cy) / w * 2
next_real = a ^ 2 - b ^ 2 + RealC
End Function
Function next_imaginary(a, b, i, j)
RealC = (i - cx) / w * 2
IMc = (j - cy) / w * 2
next_imaginary = 2 * a * b + IMc
End Function
Private Sub Form_Load()
Show
w = Me.ScaleWidth
h = Me.ScaleHeight
cx = w / 2
cy = h / 2
For i = 0 To w
For j = 0 To h
RE = 0
IM = 0
iterations = 0
While iterations < 20 And RE ^ 2 + IM ^ 2 < 4
iterations = iterations + 1
n_r = next_real(RE, IM, i, j)
n_i = next_imaginary(RE, IM, i, j)
RE = n_r
IM = n_i
Wend
DoEvents
My_Color = RGB(My_Red(iterations), My_Green(iterations), My_Blue(iterations))
PSet (i, j), My_Color
Next j
Next i
End Sub