我有一本VB分形的书,附有源代码。如果了解分形的原理,绘图是不难的。

解决方案 »

  1.   

    贴个给大家玩一玩:
    Private Sub drawTree2(ByVal x As Integer, ByVal y As Integer, ByVal L As Integer, ByVal a As Integer, ByVal tt As Integer)  Const PI As Single = 3.14159265358979 / 180
      
      Dim X1 As Integer, Y1 As Integer
      Dim i As IntegerFor i = -1 To 1
      X1 = x + L * Cos((a + i * (Int(Rnd * 40) + 20)) * PI)
      Y1 = y + L * Sin((a + i * (Int(Rnd * 40) + 20)) * PI)
      Picture1.Line (x, y)-(X1, Y1)
      If L > 40 Then
        Call drawTree2(X1, Y1, L - 8, a + i * Int(Rnd * 40) + 10, tt)
      Else
        If tt = 1 Then Picture1.Circle (X1, Y1), 2, 180
        If tt = 2 Then Picture1.Line (X1, Y1)-(X1 + Int(Rnd * 5) * i, Y1 + Int(Rnd * 20) + 50), &H1F060
      End If
    Next i
    End SubPrivate Sub Form_Load()
    Picture1.ScaleHeight = 600
    Picture1.ScaleWidth = 800
    r = 255: g = 255: B = 255
    End SubPrivate Sub Picture1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
    Picture1.Refresh
        Picture1.ForeColor = vbBlack
        Picture1.Line (x - 50, y - 50)-(x - 50, y - 50 + 120)
        Call drawTree2(x - 50, y - 50, 90, -90, 1) 
    End Sub
      

  2.   

    有关分形图形的例子网上很多。下载下来看看吧。