拖一個PictureBox1控件 創(chuàng)建一個Paint事件。在事件中加入 Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint ' Create pens. Dim redPen As New Pen(Color.Red, 3) Dim greenPen As New Pen(Color.Green, 3) ' Create points that define curve. Dim point1 As New Point(50, 50) Dim point2 As New Point(100, 25) Dim point3 As New Point(200, 5) Dim point4 As New Point(250, 50) Dim point5 As New Point(300, 100) Dim point6 As New Point(350, 200) Dim point7 As New Point(250, 250) Dim curvePoints As Point() = {point1, point2, point3, point4, _ point5, point6, point7} ' Draw lines between original points to screen. e.Graphics.DrawLines(redPen, curvePoints) ' Draw curve to screen. e.Graphics.DrawCurve(greenPen, curvePoints) End Sub 得到數據后,改point的數據。然后PictureBox1.Refresh()就行了
我們提供的服務有:網站建設、成都做網站、微信公眾號開發(fā)、網站優(yōu)化、網站認證、沐川ssl等。為千余家企事業(yè)單位解決了網站和推廣的問題。提供周到的售前咨詢和貼心的售后服務,是有科學管理、有技術的沐川網站制作公司
。net ?其實還是很好繪制圖形的
你可以看下?Graphics ?類
Dim d As New Bitmap(Me.Width, Me.Height) ?‘一個圖片吧
? Dim g As Graphics = Graphics.FromImage(d)’繪制 ?準備在這個圖片是進行
然后 ?就是你繪制的東西了
線 就是 ??g.DrawLine()
圓 弧度 ?就用 ?g.DrawArc(Pens.Black, New Rectangle(0, 0, 400, 200), 0, 360)
復雜的就是 ? ? ?g.DrawBezier()
等 ?如果你用的是 VS的 ?編譯 ?上面都有詳細的參數說明
Dim?d?As?New?Bitmap(Me.Width,?Me.Height)
Dim?g?As?Graphics?=?Graphics.FromImage(d)
g.DrawArc(Pens.Black,?New?Rectangle(0,?0,?200,?200),?0,?360)
g.DrawLine(Pens.Red,?New?Point(0,?0),?New?Point(200,?200))
g.DrawLines(Pens.Green,?New?Point()?{New?Point(0,?0),?New?Point(50,?40),?New?Point(50,?80),?New?Point(90,?70),?New?Point(100,?400)})
g.DrawBezier(Pens.Yellow,?New?Point(0,?100),?New?Point(0,?0),?New?Point(200,?0),?New?Point(200,?200))
g.Dispose()
Me.BackgroundImage?=?d
不引用的話,VB做不到。這事情要看VB的版本。如果是6.0的話,要去網上下載GDIPLUS的庫文件或者自己聲明GDI+的API。如果是VB.NET的話,VB自帶GDI+,但是也可以下載GDIPLUS庫來用。如果不知道去哪里下載,我下載有,你可以問我要。我使用VB6.0。下載gdiplus以后,在VB里面引用這個庫,注意要選擇“所有文件”才能看到這個庫。gdi+里面的path功能可以實現樣條:Private
TOKEN
As
Long'GDI+對象
Private
Graphics
As
Long'畫板
Private
Sub
InitGDIPlus()
'初始化GDI+
Dim
uInput
As
GdiplusStartupInput
uInput.GdiplusVersion
=
1
If
GdiplusStartup(TOKEN,
uInput)
Ok
Then
'初始化錯誤
MsgBox
"GDI+
初始化錯誤。程序即將關閉。",
vbCritical,
"InitError"
End
End
If
GdipCreateFromHDC
Me.hDC,
Graphics'創(chuàng)建畫板
GdipSetSmoothingMode
Graphics,
SmoothingModeAntiAlias'設置為反鋸齒
End
SubPrivate
Sub
TerminateGDIPlus()
GdipDeleteGraphics
Graphics
'釋放graphics占用的內存
GdiplusShutdown
TOKEN
'關閉GDI+
End
SubPrivate
Sub
Form_Load()
InitGDIPlus
'初始化End
SubPrivate
Sub
Command1_Click()
Dim
path
As
Long
Dim
m(3)
As
POINTF
'以下是坐標,你可以自由改變
m(0).x
=
m(0).y
=
m(1).x
=
10
m(1).y
=
100
m(2).x
=
20
m(2).y
=
3
m(3).x
=
500
m(3).y
=
100
Dim
pen
As
Long
GdipCreatePen1
HFF000000,
2,
UnitPixel,
pen
'創(chuàng)建畫筆,用來畫出樣條
GdipCreatePath
FillModeAlternate,
path
'創(chuàng)建path
GdipAddPathBeziers
path,
m(0),
4
'創(chuàng)建樣條'Count是說坐標的個數,points只能傳遞數組的第一個元素,不能傳遞數組。
GdipDrawPath
Graphics,
pen,
path
'畫出樣條
GdipDeletePen
pen
'刪除畫筆
GdipDeletePath
path
'刪除樣條End
SubPrivate
Sub
Form_Unload(Cancel
As
Integer)
TerminateGDIPlus
'刪除GDI+
End
Sub