我想用VB做一个波形显示器,它的显示方式是先在黑背景下显示一段波形,当波形填充完整个区域后,后面的数据就会从右开始刷新以前的数据,刷新的方式是用pset花的点,先抹去上一场的波形,抹去上一场的波形的方式是将上一场波形的坐标点上过去的颜色(在画上一场波形的时候已经将该点的颜色保存下来了,其实就是背景颜色)替换掉波形的颜色,然后画上这一场的波形,我的代码在下面,可是我遇到了一个瓶颈,当我抹去过去的波形,填上颜色的时候总是有缺口,
背景中的一些线总是被切断,求高手相助!!!
Option Explicit
Dim TX(800) As Integer, TX_ago(800) As Long
Dim TX_xb As Integer, TX_cal As Integer, TY As Integer
Dim gallery0_cankao As Integer
Private Sub Form_Load()
Call clear_form
Call load_picture
Call load_others
End Sub
Public Function load_others()
Timer1.Enabled = False
'ReDim TX(0 To Picture1.ScaleWidth)
End Function
Public Function load_picture()
Dim CX, CY, F, i
Picture1.ScaleMode = 3
Picture1.DrawWidth = 1
Picture1.ScaleWidth = 800
Picture1.ScaleHeight = 400
Debug.Print Picture1.ScaleWidth
Debug.Print Picture1.ScaleHeight
Picture1.BackColor = vbBlack
For i = 1 To 20
F = i / 20
CX = F * Picture1.ScaleWidth
CY = F * Picture1.ScaleHeight
Picture1.Line (CX, 0)-(CX, Picture1.ScaleHeight), RGB(35, 35, 35) '列
Picture1.Line (0, CY)-(Picture1.ScaleWidth, CY), RGB(35, 35, 35) '行
Next
End Function
Private Function clear_form()
Dim i As Integer
For i = 0 To 200
Debug.Print
Next
End Function
Public Function point_set(X As Integer, Y As Integer)
Picture1.PSet (Val(X), Val(Y)), vbBlue
End Function
Public Function point_clear(X As Integer, Y As Integer, Color As Long)
Picture1.PSet (Val(X), Val(Y)), Color
End Function
Public Function cankaoxian(i As Integer)
Dim CX, CY
CX = Picture1.ScaleWidth
CY = Picture1.ScaleHeight
Picture1.Line (0, i)-(CX, i), vbRed
End Function
Private Sub Gallery0_start_Click()
gallery0_cankao = 200
Call cankaoxian(gallery0_cankao)
Timer1.Enabled = True
End Sub
Private Sub Gallery0_stop_Click()
Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
Dim i As Integer, a As Integer, temp As Long
i = TX_cal Mod Picture1.ScaleWidth
TX_cal = TX_cal + 1
TY = 60 * Cos(TX_cal * 3.1415 / 180) + 60 * Sin(3 * TX_cal * 3.1415 / 180) + gallery0_cankao
temp = Int(TX_cal / Picture1.ScaleWidth)
If temp <> 0 Then
Call point_clear(i, TX(i), TX_ago(i))
End If
temp = Picture1.Point(i, TY)
If temp <> -1 Then
TX_ago(i) = temp
Else
TX_ago(i) = 0
End If
TX(i) = TY
Call point_set(i, TY)
End Sub