【正文】
? = ? = ? Private Sub Button_Click(ByVal sender As , ByVal e As ) Handles , , , , ? = ? Call showARGB() ? End Sub 畫布對象 Graphics ?聲明與建立畫布對象 一般在繪圖時,需要一塊畫布供畫家作畫。 () 刪除畫布對象 例:將畫布對象 g從主存儲器中刪除。 畫筆對象顏色和粗細(xì)可用下列語法重新設(shè)置。 例:在畫布對象 g上用畫筆 p繪制坐標(biāo) (100,50)到(200, 270)之間的直線。 Dim rec as new rectangle(50,60,100,70) (p,rec) 或: (p,50,60,100,70) 繪制多邊形: drawPolygon方法 語法 : Dim 坐標(biāo)對象 () as point ={new point(x1,y1),new point(x2,y2),new point(x3,y3),… } 畫布對象 .drawPolygon(畫筆對象,坐標(biāo)對象 ) 或: Dim p1 as point=new point(x1,y1) Dim p2 as point=new point(x2,y2) Dim p3 as point=new point(x3,y3) … Dim 坐標(biāo)對象 as point()={p1,p2,p3,… } 畫布對象 .drawPolygon(畫筆對象,坐標(biāo)對象 ) 例:畫一個三角形,三個頂點分別為 (25,25)、 (0,50)、 (50, 50) Dim pts() as point={new point(25,25),new point(0,50),new point(50,50)} (p,pts) 或: Dim p1 as point=new point(25,25) Dim p2 as point=new point(0,50) Dim p3 as point=new point(50,50) … Dim pts as point()={p1,p2,p3,… } (p, pts) 創(chuàng)建圖形應(yīng)用程序的一般步驟 1. 創(chuàng)建畫布,聲明 graphics對象 2. 用畫筆對象 pen繪制圖形輪廓,并用color對象設(shè)置顏色 ? 實例練習(xí):以窗體為畫布,繪制直線、矩形、多邊形。 例:將畫布對象 g清理為白色 () ? 對象 .Refresh() 將畫布清理為原控件的底色。 () 繪制橢圓形: drawEllipse方法 語法: Dim 矩形對象 as new rectangle(x,y,w,h) 畫布對象