Post by matthew on Oct 25, 2006 14:57:20 GMT -5
It's Yet Another Mandelbrot Fractal. ;D
The code for the first fractal that I wrote in Brutus2D wasn't as good as it could have been, so I've written a new one.
This programme was originally written in the AMOS programming language on the Amiga over Ten years ago.
I hope at some point in the future to add a feature to this programme which will allow you to zoom in on the Fractal.
The code for the first fractal that I wrote in Brutus2D wasn't as good as it could have been, so I've written a new one.
This programme was originally written in the AMOS programming language on the Amiga over Ten years ago.
I hope at some point in the future to add a feature to this programme which will allow you to zoom in on the Fractal.
OPTION Explicit
DIM AppRun : AppRun = TRUE
DIM ScrX : ScrX = 640
DIM ScrY : ScrY = 512
DIM AMin : AMin = -2
DIM AMax : AMax = 0.8
DIM BMin : BMin = -1.2
DIM BMax : BMax = 1.2
DIM ARange, BRange, PNew, QNew
DIM MxIters : MxIters = 96
DIM X, Y, A, B, P, Q
DIM N
SUB Main()
IF (Graphics.Initialize <> TRUE) THEN EXIT SUB
Graphics.SetTitle "AMOS Mandelbrot Fractal"
Graphics.SetViewPort 0, 0, 640, 512
Key.Initialize
Graphics.Clear &h000000
X = 0
Y = ScrY-1
ARange = (AMax - AMin) / ScrX
BRange = (BMax - BMin) / ScrY
For A = AMin To AMax Step ARange
For B = BMin To BMax Step BRange
P = 0
Q = 0
N = 0
While P^2 + Q^2 < 4 And N < MxIters
PNew = P^2 - Q^2 + A
QNew = 2 * P * Q + B
P = PNew
Q = QNew
N = N + 1
System.ProcessMessages
Wend
Graphics.SetRect X, Y, 1, 1, ARGB(255, N*16, N*16, N*16)
Graphics.Display
Y = Y - 1
Next
IF Key.Pressed(1) Or Key.Pressed(0) = TRUE THEN
AppRun = FALSE
EXIT For
End IF
System.ProcessMessages
Y = ScrY - 1
X = X + 1
Next
Do While AppRun = TRUE
IF Key.Pressed(1) Or Key.Pressed(0) = TRUE THEN AppRun = FALSE
System.ProcessMessages
Loop
Graphics.Terminate
Key.Terminate
End SUB
CALL Main