VB2010中,想用System.Drawing.Graphics.DrawLine划线
答案:1 悬赏:80 手机版
解决时间 2021-04-05 00:10
- 提问者网友:了了无期
- 2021-04-04 01:38
VB2010中,想用System.Drawing.Graphics.DrawLine划线
最佳答案
- 五星知识达人网友:渊鱼
- 2021-04-04 02:36
你这有问题
给你一个画图的子过程吧
Private Sub DrawLine(ByVal Pic As PictureBox, ByVal a() As Double)
Dim H As Double = Pic.Height
Dim W As Double = Pic.Width
Dim b As New Bitmap(Pic.Width, Pic.Height)
Dim g As Graphics = Graphics.FromImage(b)
g.Clear(Color.White)
Dim p As New Pen(Color.Black)
p.EndCap = Drawing2D.LineCap.ArrowAnchor
p.Width = 2
g.DrawLine(p, 20, Pic.Height - 20, 20, 10)
'g.DrawLine(p, 20, Pic.Height, Pic.Width, Pic.Height - 1)
g.DrawLine(p, 20, Pic.Height - 20, Pic.Width, Pic.Height - 20)
p.EndCap = Drawing2D.LineCap.NoAnchor
p.Width = 1
Dim i As Integer
Dim PF(89) As PointF
For i = 0 To 89
PF(i).X = (i + 1) * ((W - 20) / 90) + 20
Next i
For i = 0 To 89
PF(i).Y = H - ((H - 20) / 500) * a(i + 1) - 20
Next
g.DrawLines(p, PF)
Dim Radius As Integer = 2
For i = 1 To 90
Dim rect As Rectangle = New Rectangle(i * ((W - 20) / 90) + 20, H - 20, 2 * Radius, 2 * Radius)
g.DrawEllipse(Pens.Black, rect)
g.FillEllipse(Brushes.Red, rect)
Next i
Dim bs As New SolidBrush(Color.Green)
Dim FoT As New Font("宋体", 8)
For i = 1 To 90
If i = 1 Or i Mod 5 = 0 Then
g.DrawString(i, FoT, bs, i * ((W - 20) / 90) + 20, H - 20)
End If
Next
For i = 0 To 500
If i Mod 100 = 0 Then
g.DrawString(i, FoT, bs, 20, (H - 20) - ((H - 20) / 500) * i)
Dim rect As Rectangle = New Rectangle(20, (H - 20) - ((H - 20) / 500) * i, 2 * Radius, 2 * Radius)
g.DrawEllipse(Pens.Black, rect)
g.FillEllipse(Brushes.Red, rect)
End If
Next
Pic.Image = b
End Sub
给你一个画图的子过程吧
Private Sub DrawLine(ByVal Pic As PictureBox, ByVal a() As Double)
Dim H As Double = Pic.Height
Dim W As Double = Pic.Width
Dim b As New Bitmap(Pic.Width, Pic.Height)
Dim g As Graphics = Graphics.FromImage(b)
g.Clear(Color.White)
Dim p As New Pen(Color.Black)
p.EndCap = Drawing2D.LineCap.ArrowAnchor
p.Width = 2
g.DrawLine(p, 20, Pic.Height - 20, 20, 10)
'g.DrawLine(p, 20, Pic.Height, Pic.Width, Pic.Height - 1)
g.DrawLine(p, 20, Pic.Height - 20, Pic.Width, Pic.Height - 20)
p.EndCap = Drawing2D.LineCap.NoAnchor
p.Width = 1
Dim i As Integer
Dim PF(89) As PointF
For i = 0 To 89
PF(i).X = (i + 1) * ((W - 20) / 90) + 20
Next i
For i = 0 To 89
PF(i).Y = H - ((H - 20) / 500) * a(i + 1) - 20
Next
g.DrawLines(p, PF)
Dim Radius As Integer = 2
For i = 1 To 90
Dim rect As Rectangle = New Rectangle(i * ((W - 20) / 90) + 20, H - 20, 2 * Radius, 2 * Radius)
g.DrawEllipse(Pens.Black, rect)
g.FillEllipse(Brushes.Red, rect)
Next i
Dim bs As New SolidBrush(Color.Green)
Dim FoT As New Font("宋体", 8)
For i = 1 To 90
If i = 1 Or i Mod 5 = 0 Then
g.DrawString(i, FoT, bs, i * ((W - 20) / 90) + 20, H - 20)
End If
Next
For i = 0 To 500
If i Mod 100 = 0 Then
g.DrawString(i, FoT, bs, 20, (H - 20) - ((H - 20) / 500) * i)
Dim rect As Rectangle = New Rectangle(20, (H - 20) - ((H - 20) / 500) * i, 2 * Radius, 2 * Radius)
g.DrawEllipse(Pens.Black, rect)
g.FillEllipse(Brushes.Red, rect)
End If
Next
Pic.Image = b
End Sub
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯