vb.net连续绘制曲线图不消失

vb.net连续绘制曲线图不消失,第1张

您好,您是想问vb.net连续绘制曲线图消失怎么办?b.net连续绘制曲线图不消失的解决办法如下:

1、首先必须创建bitmap,关联到picturebox1.image上。

2、再在picturebox1.image上创建Graphics,再进行作图。即可显示线图。

Dim Points1(30) As Point

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

Timer1.Enabled = True

Timer1.Interval = 200

For i = 0 To 30

Points1(i) = New Point(i * 45, Math.Sin(i) * (PictureBox1.Height - 50) / 9)

Points1(i).Offset(-450, Math.Abs(Points1(i).Y - (PictureBox1.Height - 50) / 9) * 3.55 + 43)

Next

End Sub

Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick

Static j As Long

j = j + 1

PictureBox1.Image = x_y(PictureBox1, j)

End Sub

Private Function x_y(ByVal pic As PictureBox, ByVal x As Long) As Bitmap

Dim b As New Bitmap(pic.Width, pic.Height)

Dim g As Graphics = Graphics.FromImage(b)

Dim c

Dim j

g.Clear(Color.YellowGreen)

Dim p As New Pen(Color.WhiteSmoke)

p.EndCap = Drawing2D.LineCap.ArrowAnchor

g.DrawLine(p, 20, pic.Height - 20, 20, 10)

g.DrawLine(p, 20, pic.Height - 20, pic.Width - 20, pic.Height - 20)

Dim i As Double

Dim bs As New SolidBrush(Color.Red)

Dim po As New Point

g.DrawString(-2, Me.Font, bs, 12, pic.Height - 18)

po.X = 0

po.Y = pic.Height - 45

For i = -1.6 To 4 Step 0.4

g.DrawString(Math.Round(i, 1), Me.Font, bs, po.X, po.Y)

g.DrawLine(p, po.X + 18, po.Y + 5, po.X + 20, po.Y + 5)

Dim p1 As New Pen(Color.Blue)

p1.DashStyle = Drawing2D.DashStyle.Dash

g.DrawLine(p1, po.X + 28, po.Y + 5, pic.Width - 20, po.Y + 5)

po.Y -= (pic.Height - 50) / 9

Next

po.X = 20

po.Y = pic.Height - 20

For c = 0 To 14400 Step 1200

If (c / 1200) >0 Then

g.DrawString((c / 1200) + x, Me.Font, bs, po.X - j, po.Y + 5)

End If

g.DrawLine(p, po.X, po.Y + 2, po.X, po.Y)

po.X += (pic.Width - 50) / 12

Next

For i = 0 To Points1.Count - 1

Points1(i).Offset(45, 0)

Next

If x Mod 6 = 0 Then

For i = 0 To Points1.Count - 1

Points1(i).Offset(-270, 0)

Next

End If

g.DrawCurve(Pens.Red, Points1)

'For i = 0 To Points1.Count - 1

'g.DrawString(Math.Sin(i), Me.Font, Brushes.Red, Points1(i))

'Next

Return b

End Function


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/bake/11764276.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-18
下一篇 2023-05-18

发表评论

登录后才能评论

评论列表(0条)

保存