Post by matthew on Oct 25, 2006 17:25:55 GMT -5
I've been interested in Fractals for a lot of years now.
A Sierpinski Triangle is a type of fractal.
It's a triangle made up of other smaller triangles.
When you run the programme below, dots will begin to appear at random positions on the screen, within about a minute you will see the triangle.
A Sierpinski Triangle is a type of fractal.
It's a triangle made up of other smaller triangles.
When you run the programme below, dots will begin to appear at random positions on the screen, within about a minute you will see the triangle.
OPTION Explicit
DIM AppRun : AppRun = TRUE
CONST Width = 640
CONST Height = 480
DIM X1, X2, Y1, Y2
X1 = X2 = 320
Y1 = Y2 = 0
DIM Iterate
DIM Direct
DIM DrawPoint
Randomize
SUB Main()
IF (Graphics.Initialize <> TRUE) THEN EXIT SUB
Graphics.SetTitle "Sierpinski Triangle"
Graphics.Clear &h000000
Key.Initialize
For Iterate = 0 TO 2^30
Direct = Int ((3 - 0 + 1) * Rnd + 0)
IF Direct = 0 THEN
X1 = ( X2 + 320 ) / 2
Y1 = ( Y2 + 0 ) / 2
ELSEIF Direct = 1 THEN
X1 = ( X2 + 0 ) / 2
Y1 = ( Y2 + 480 ) / 2
ELSEIF Direct = 2 THEN
X1 = ( X2 + 640 ) / 2
Y1 = ( Y2 + 480 ) / 2
End IF
For DrawPoint = 0 TO 2^5
Graphics.SetRect X1, Y1, 1, 1, ARGB(255, 255, 255, 255)
X2 = X1
Y2 = Y1
System.ProcessMessages
Next
Graphics.Display
IF Key.Pressed(1) Or Key.Pressed(0) = TRUE THEN
AppRun = FALSE
EXIT For
End IF
System.ProcessMessages
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