這是畫點(diǎn)的:
創(chuàng)新互聯(lián)成立于2013年,先為淮北等服務(wù)建站,淮北等地企業(yè),進(jìn)行企業(yè)商務(wù)咨詢服務(wù)。為淮北企業(yè)網(wǎng)站制作PC+手機(jī)+微官網(wǎng)三網(wǎng)同步一站式服務(wù)解決您的所有建站問(wèn)題。
Private Sub Form_Click()
Dim X(7) As Integer, Y(7) As Integer, i%
Form1.Scale (-15, 15)-(15, -15)
Form1.Line (0, 0)-(15, 0)
Form1.Line (0, 15)-(0, 0)
For i = 0 To 12 'Step 1.2 'X軸坐標(biāo)
Form1.Line (i, 0.1)-(i, 0)
CurrentX = i
CurrentY = -1
Form1.Print i
Next i
For i = 0 To 12 'Step 1.2 'Y軸坐標(biāo)
Form1.Line (0, i)-(0.3, i)
CurrentX = -0.5
CurrentY = i
Form1.Print i
Next i
X(0) = 0: X(1) = 2: X(2) = 4: X(3) = 6: X(4) = 8: X(5) = 10: X(6) = 12: X(7) = 14
Y(0) = 0: Y(1) = 1: Y(2) = 3: Y(3) = 4: Y(4) = 3: Y(5) = 2: Y(6) = 1: Y(7) = 0
For i = 0 To 7
Form1.PSet (X(i), Y(i)), vbRed
Next i
End Sub
。net ?其實(shí)還是很好繪制圖形的
你可以看下?Graphics ?類
Dim d As New Bitmap(Me.Width, Me.Height) ?‘一個(gè)圖片吧
? Dim g As Graphics = Graphics.FromImage(d)’繪制 ?準(zhǔn)備在這個(gè)圖片是進(jìn)行
然后 ?就是你繪制的東西了
線 就是 ??g.DrawLine()
圓 弧度 ?就用 ?g.DrawArc(Pens.Black, New Rectangle(0, 0, 400, 200), 0, 360)
復(fù)雜的就是 ? ? ?g.DrawBezier()
等 ?如果你用的是 VS的 ?編譯 ?上面都有詳細(xì)的參數(shù)說(shuō)明
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中繪制實(shí)時(shí)曲線是比較難的,一般要應(yīng)用第三方控件或是Windows
API函數(shù)來(lái)完成,但是如果你對(duì)實(shí)時(shí)曲線的要求不是很高,只要能表示出當(dāng)前的一般情況的話,我們可以直接應(yīng)用VB提供給我們的空間來(lái)完成.
原則上講,直接在Form里繪制曲線都是可以的,MSDN上面很多例程就是直接在Form里面繪制圖形的,Form作為繪制圖形的容器,不過(guò)一般應(yīng)用中Form中不可避免的會(huì)有很多其他控件,所以我們選擇PictureBox作為繪制曲線的容器.
實(shí)時(shí)曲線的繪制一般借助于Timer控件來(lái)完成,使用Timer控件,定期將串口或是其他儀器中監(jiān)測(cè)到的數(shù)據(jù)送往PictureBox1,而曲線的繪制一般畫成折線圖,采用PictureBox1的Line方法繪制.具體實(shí)現(xiàn)如下:
1.選擇需要顯示的窗體Picture1,加入圖片框Picture1,根據(jù)實(shí)際需要設(shè)置圖片的大小并移到合適的位置,并在圖片的外面畫好量程----時(shí)間坐標(biāo)系;然后加上Timer控件以及兩個(gè)CommandButton,界面就基本設(shè)置好了.
2.建立坐標(biāo)系,根據(jù)Picture1的大小和高度設(shè)置畫出坐標(biāo)系的X軸和Y軸:
Picture1
.ScaleMode
=
1
‘以VB的基本單位作為建立坐標(biāo)軸以及繪制圖形的單位;
Picture1.Refresh
Picture1.CurrentX
=
Picture1.ScaleLeft
+100
Picture1.CurrentY
=
Picture1.ScaleTop
Picture1.Print
Picture1.ScaleHeight
-
100
Picture1.Line(Picture1.ScaleLeft+100,Picture1.ScaleTop+100)-(Picture1.ScaleLeft+100,
Picture1.ScaleHeight
-
100)
Picture1.CurrentX
=
Picture1.ScaleLeft
+100
Picture1.CurrentY
=
Picture1.ScaleHeight
Picture1.Print
“(0,0)”
Picture1.Line
(Picture1.ScaleLeft
+
100,
Picture1.ScaleHeight
-
100)-(Picture1.ScaleWidth
-
100,
Picture1.ScaleHeight
-
100)
Picture1.CurrentX
=
Picture1.ScaleWidth
Picture1.CurrentY
=
Picture1.ScaleHeight
Picture1.Print
Picture1.ScaleWidth-100
Picture1.AutoRedraw
=
True
‘必要時(shí),用存儲(chǔ)在內(nèi)存中的圖象進(jìn)行重繪
3.繪制曲線并保存,我們這里以正弦曲線作為繪制曲線的數(shù)據(jù)來(lái)源,具體應(yīng)用是可以采用由串口或其他儀器采集得到的數(shù)據(jù).首先我們繪制一條中線,然后在Timer控件的Time事件中繪制曲線:
Picture1.Line
(Picture1.ScaleLeft,
CInt(Picture1.ScaleHeight
/
2))-(Picture1.ScaleWidth,
CInt(Picture1.ScaleHeight
/
2))
‘繪制中線
Private
Sub
Timer1_Timer()
Dim
y1
As
Integer
y1
=
CInt(Sin((x
-
Picture1.Left)
/
20
/
180
*
pi)
*
Picture1.ScaleHeight
/
2)
y1
=
CInt((Picture1.ScaleHeight
+
1000)
/
2)
-
y1
Picture1.Line
(x,
y)-(x
+
20,
y1)
x
=
x
+
20
y
=
y1
If
x
=
Picture1.ScaleWidth
Then
SavePicture
Picture1.Image,
"c:\sin.bmp"
‘保存圖畫,