资源描述
按一下以編輯母片標題樣式,按一下以編輯母片,第二層,第三層,第四層,第五層,*,Graphics物件,VB繪圖功能依賴,Graphics物件,,當在表單或控制項建當在表單或控制項建,Graphics物件,後,就可以將表單或控制項轉換成畫布,在畫布上繪出所需的圖形。,由Paint事件建立畫布,CreateGraphics()方法建畫布,由Paint事件產生畫布,在表單或控制項上繪圖時,就會觸發Paint事件,在Paint事件處程序的,PaintEventArgs,可以取得Graphics物件,。,Private,Sub,Form1_Paint(ByVal sender As _ Object,ByVal e As _ System.Windows.Forms.PaintEventArgs)_ Handles Me.Paint,Dim g As Graphics=e.Graphics,g.Clear(Color.Blue),End,Sub,CreateGraphics()方法建畫布,如果沒有使用Paint事件處程序,我們可以在其他事件處程序使CreateGraphics()方法建Graphics物件。如:表單物件。如:表單Form1的Click事件處程序,如下所示:,Private Sub,Form1_Click,(ByVal sender As _ Object,ByVal e As System.EventArgs)_ Handles Me.Click,建立Graphics方法二,Dim gg As Graphics=,Me.CreateGraphics(),End Sub,繪圖工具說明,在在VB表單或控制項建好畫布後,我們在開始繪圖前,需要一些繪圖工具,如下,物件與結構,明,Color結構,設定繪圖時使用的色彩,Font物件,在繪出文字內容時,使用的字型與其樣式,Pen物件,建繪圖的畫筆,可以指定畫筆的色彩和寬,Brush物件,填滿圖形的筆刷,建畫筆,我們要繪圖前,我們需要建畫筆,請使用Pen物件,我們利用New關鍵字建Pen物件,如下所示:,建立畫筆,Dim pen1 As Pen=New Pen(Color.Red,1),建筆刷-筆刷Brush,筆刷可以填滿圖形或顯示文字,其常用的別如下表所示:,Dim brush1 As SolidBrush=New SolidBrush(Color.Blue),別,說明,SolidBrush,建單一色彩的筆刷,TextureBrush,建圖片紋的筆刷,可以使用圖片檔案填滿圖形,繪出文字和圖形,方法,明,DrawString(String,Font,Brush,x,y),在(x,y)位置使用Font物件的字型和Brush筆刷,繪出String的文字內容,DrawLine(Pen,x1,y1,x2,y2),使用Pen畫筆從(x1,y1)座標到(x2,y2)座標繪,出一條直線,DrawRectangle(Pen,x,y,width,height),使用Pen畫筆在(x,y)座標的長方形左上角繪出寬width和高height的,長方形,DrawPolygon(Pen,Points),使用Pen畫筆以第2個Point物件陣的座標,繪出多邊形,DrawEllipse(Pen,x,y,width,height),使用Pen畫筆在(x,y)座標的長方形左上角,寬width和高height的長方形中,繪出橢圓形,DrawArc(Pen,x,y,width,height,startAngle,sweepAngle),使用Pen畫筆在(x,y)座標的長方形左上角,寬width和高height的長方形中,繪出從startAngle開始共sweepAngle角的,弧形,繪出填滿圖形,方法,明,FillRectangle(Brush,x,y,width,height),使用Brush筆刷在(x,y)座標的長方形左上角繪出寬width和高height填滿的長方形,FillPolygon(Brush,Points),使用Brush筆刷以第2個Point物件陣的座標繪出填滿的多邊形,DrawPie(Brush,x,y,width,height,startAngle,sweepAngle),使用Brush筆刷在(x,y)座標的長方形左上角,寬width和高height的長方形中,繪出從startAngle開始共sweepAngle角的填滿扇形,DrawEllipse(Brush,x,y,width,height),使用Brush畫筆在(x,y)座標的長方形左上角,寬width和高height的長方形中,繪出填滿的橢圓形,PeMbJ7G4D1z-w&t!qYmVjSgOdLaI6F3B0y)v%s#pXlUiQfNcK8H5E2A+x*u$rZnWkThPeMaJ7G4C1z-w&t!pYmVjRgOdL9I6E3B0y(v%s#oXlTiQfNbK8H5D2A+x*u$qZnWkShPeMaJ7F4C1z)w&t!pYmUjRgOcL9I6E3B+y(v%r#oXlTiQeNbK8G5D2A-x*t$qZnVkShPdMaI7F4C0z)w&s!pXmUjRfOcL9H6E3B+y(u%r#oWlTiQeNbJ8G5D1A-x*t$qYnVkSgPdMaI7F3C0z)v&s!pXmUiRfOcK9H6E2B+x(u%rZoWlThQeMbJ8G4D1A-w*t$qYnVjSgPdLaI7F3C0y)v&s#pXmUiRfNcK9H5E2B+x(u$rZoWkThQeMbJ7G4D1z-w*t!qYmVjSgOdLaI6F3B0y)v%s#pXlUiRfNcK8H5E2A+x(u$rZnWkThPeMbJ7G4C1z-w&t!qYmVjRgOdL9I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