- Код: Выделить всё
Option Explicit
' * FERN.C -- Generates fractal fern leaf. Initial coding by John Watne
' * 1/20/92.
'
' VB port by A. Skrobov, 2005
Dim Enough As Boolean
Private Sub Command1_Click()
Enough = True
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Enough = True
End Sub
Private Sub Form_DblClick()
Const MAXIT = 20 ' maximum number of iterations
Dim x As Double, y As Double, newx As Double, newy As Double
Dim i As Integer ' counter variable
Dim rand_num As Double
BackColor = vbBlack
ForeColor = vbGreen
Cls
' Set up window coordinate system
Scale (-5, 10)-(5, 0)
Randomize Timer
While Not Enough
x = Rnd * 32768 / 50000
y = Rnd * 32768 / 50000
For i = 1 To MAXIT
rand_num = Rnd
If rand_num < 0.01 Then
newx = 0
newy = 0.16 * y
x = newx
y = newy
ElseIf rand_num < 0.86 Then
newx = (0.85 * x) + (0.04 * y)
newy = (-0.04 * x) + (0.85 * y) + 1.6
x = newx
y = newy
ElseIf rand_num < 0.93 Then
newx = (0.2 * x) - (0.26 * y)
newy = (0.23 * x) + (0.22 * y) + 1.6
x = newx
y = newy
Else
newx = (-0.15 * x) + (0.28 * y)
newy = (0.26 * x) + (0.24 * y) + 0.44
x = newx
y = newy
End If
Next
PSet (x, y)
DoEvents
Wend
End Sub