Option Explicit Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long '用来发送信息,因为画画的时间比较长,所以发送给另一个程序来监测完成度 Private p As COMPLEX, tP As COMPLEX Private C As COMPLEX Private MAXN As Long Private EachStep As Double Private i As Long, n As Long Private p1 As Long, q1 As Long Private ZoomV1 As Integer Private Draw As Boolean Private hMonitor As Long Private Const SC_MAXIMIZE = &HF030
Private Type COMPLEX x As Double y As Double End Type
Private Sub Command1_Click() On Error Resume Next
MAXN = Text3.Text EachStep = Text4.Text PIC.Scale (CSng(Text(0).Text), CSng(Text(1).Text))-(CSng(Text(2).Text), CSng(Text(3).Text)) ‘pic是一个picturebox PIC.Cls
For C.x = Text(0).Text To Text(2).Text Step EachStep For C.y = Text(3).Text To Text(1).Text Step EachStep p1 = VarPtr(C.x) q1 = VarPtr(C.y) SendMessage ByVal hMonitor, 0, p1, q1 '发送消息
p.x = C.x p.y = C.y Draw = True
For n = 1 To MAXN Step 1 FUNC p, tP p = tP If (p.x ^ 2 + p.y ^ 2) > 4 Then Draw = False Exit For End If Next
If Draw = True Then PIC.PSet (C.x, C.y)
Next Next
End Sub
Private Function FUNC(ByRef iP As COMPLEX, ByRef oP As COMPLEX) oP.x = iP.x ^ 2 - iP.y ^ 2 + C.x oP.y = 2 * iP.x * iP.y + C.y End Function
Private Sub Command2_Click() hMonitor = Text1.Text End Sub
Private Sub Command3_Click() Text(0).Text = -2 Text(1).Text = 1.5 Text(2).Text = 1 Text(3).Text = -1.5 Command1_Click End Sub
Private Sub Form_Initialize() Me.Caption = "Mandelbrot , Julia Set by Магсн v" & App.Major & "." & App.Minor & "." & App.Revision End Sub
Private Sub Form_Resize() On Error Resume Next PIC.Width = Me.ScaleWidth - (8670 - 6315) PIC.Height = Me.ScaleHeight - (6300 - 5835) End Sub '无关紧要的东西
Private Sub PIC_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single) If ZoomV1 <> 1 Then Text(0).Text = x Text(1).Text = y ZoomV1 = 1 Else Text(2).Text = x Text(3).Text = y Command1_Click ZoomV1 = 0 End If End Sub
Private Sub PIC_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single) Text2(0).Text = x Text2(1).Text = y End Sub
|
留言列表