您好,登錄后才能下訂單哦!
本篇內容主要講解“VB.NET繪制GDI圖形的方法”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實用性強。下面就讓小編來帶大家學習“VB.NET繪制GDI圖形的方法”吧!
在向大家詳細介紹用VB.NET繪制GDI圖形之前,首先讓大家了解下VB.NET是什么,然后全面介紹VB.NET繪制GDI圖形。
Visual Basic.NET是基于微軟.NET Framework之上的面向對象的中間解釋性語言,可以看作是Visual Basic在.Net Framework平臺上的升級版本,增強了對面向對象的支持。但由于改動太大,導致VB.net對VB的向后兼容性不好,在業界引起不小的爭議。
大多的VB.Net程序員使用Visual Studio .Net作為IDE(integrated development environment). SharpDevelop是另一種可用的開源的IDE。VB.Net需要在.Net Framework平臺上才能執行。 VB.NET的主頁http://msdn.microsoft.com/vbasic
用VB.NET繪制GDI圖形
Protected Overrides Sub onpaint(ByVal e As System.Windows.Forms.PaintEventArgs) '繪制任意直線 Dim g As Graphics = e.Graphics Dim mypen As Pen = New Pen(Color.Red, 2) g.DrawLine(mypen, 100, 100, 10, 10) '繪制矩形(任意直線構成的封閉圖形) Dim point1 As PointF = New PointF(100F, 100F) Dim point2 As PointF = New PointF(200F, 100F) Dim point3 As PointF = New PointF(200F, 200F) Dim point4 As PointF = New PointF(100F, 200F) Dim curvepoints As PointF() = {point1, point2, point3, point4} g.DrawPolygon(New Pen(Color.Blue, 2), curvepoints) '文本表示 Dim FFamily As FontFamily = New FontFamily("Arial") Dim font As Font = New Font(FFamily, "20", FontStyle.Bold, FontStyle.Italic, GraphicsUnit.Pixel) Dim text As String = "I love you!" Dim solidbrush As SolidBrush = New SolidBrush(Color.Red) Dim pr As PointF = New PointF(100, 10) e.Graphics.DrawString(text, font, solidbrush, pr) '平面繪制 Dim rec As RectangleF = New RectangleF(10, 10, 200, 100) g.DrawPie(mypen, rec, 150, 150) '封閉圖形,0.7應該是個圓 g.DrawClosedCurve(mypen, curvepoints, 0.7, Drawing.Drawing2D.FillMode.Alternate) '大家自己試試看吧 g.DrawArc(mypen, 300, 300, 200, 200, 100, 100) g.DrawCurve(mypen, curvepoints) g.DrawBezier(mypen, 50, 50, 100, 50, 100, 100, 50, 100) g.DrawBeziers(mypen, curvepoints) '這可是一個圓 Dim rec1 As RectangleF = New RectangleF(10, 10, 100, 100) g.DrawEllipse(mypen, rec1) '這是一個橢圓 Dim rec2 As RectangleF = New RectangleF(10, 10, 200, 100) g.DrawEllipse(mypen, rec2) End Sub
到此,相信大家對“VB.NET繪制GDI圖形的方法”有了更深的了解,不妨來實際操作一番吧!這里是億速云網站,更多相關內容可以進入相關頻道進行查詢,關注我們,繼續學習!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。