' Recursively draw a binary tree branch.
Private Sub DrawBranch(ByVal depth As Integer, ByVal X As _
Single, ByVal Y As Single, ByVal length As Single, _
ByVal theta As Single, ByVal length_scale As Single, _
ByVal dtheta As Single)
Dim x1 As Integer
Dim y1 As Integer
' See where this branch should end.
x1 = X + length * Cos(theta)
y1 = Y + length * Sin(theta)
picCanvas.Line (X, Y)(x1, y1)
' If depth > 1, draw the attached branches.
If depth > 1 Then
DrawBranch depth  1, x1, y1, length * _
length_scale, theta + dtheta, length_scale, _
dtheta
DrawBranch depth  1, x1, y1, length * _
length_scale, theta  dtheta, length_scale, _
dtheta
End If
End Sub
