'Press SpaceBar to make new trees, ESC to Exit
Uses "ui", "math"
#INCLUDE "abc.inc"
OpenWindow 800, 600
SetHandleDC hdc, hwnd
Dim depth As Long
Boolean cnt = FALSE
Sub MainDraw(x1, y1 As Long, angle As Single, d As Long)
Dim x2, y2 As Long
If d > 0 Then
x2 = x1 + Cos(DegToRad(angle)) * d * Rnd(5, 12)
y2 = y1 + Sin(DegToRad(angle)) * d * Rnd(5, 12)
Select Case Rnd(1,3)
Case 1 : DrawLine x1, y1, x2, y2, d, Rgb(180-d*10, 100-d, 100)
Case 2 : DrawLine x1, y1, x2, y2, d, Rgb(180-d*10, 90-d, 75)
Case 3 : DrawLine x1, y1, x2, y2, d, Rgb(180-d*10, 80-d, 50)
End Select
If cnt = TRUE Then
'DrawPoint(x2,y2,Rnd(5,20),Rnd(5,20),Rgb(0, 255-(d*25), 0))
DrawCircle(x2,y2,Rnd(5,20),Rnd(1,11),Rgb(0, 255-(d*25), 0))
EndIf
'Canvas_Redraw 'uncomment this if you want to see the tree draw
MainDraw(x2, y2, angle - 20, d-1)
MainDraw(x2, y2, angle + 20, d-1)
cnt = TRUE
End If
End Sub
Randomize
Do
Canvas_Clear &HFFF8F8
DrawPoint(0,550,800,50,Rgb(0, 175, 0))
For depth = 1 To 10000
SetPixel(Rnd(0,800),Rnd(550,600),Rgb(Rnd(50,200), Rnd(50,255), 0))
Next
depth = Rnd(8, 10)
MainDraw(400, 600, -90, depth)
Canvas_Redraw
cnt = FALSE
Loop While Asc(Canvas_WaitKey) <> 27
Canvas_Window End hwnd
Bookmarks