熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

用VB.NET繪制GDI圖形

2013-11-13 09:52:11  來源: .NET編程 
下面的例子通過重載Form窗體的OnPaint()方法繪制GDI圖形
Protected Overrides Sub onpaint(ByVal e As SystemWindowsFormsPaintEventArgs)
注釋/////////////繪制任意直線
Dim g As Graphics = eGraphics
Dim mypen As Pen = New Pen(ColorRed )
gDrawLine(mypen )
注釋/////////////繪制矩形(任意直線構成的封閉圖形)
Dim point As PointF = New PointF(F F)
Dim point As PointF = New PointF(F F)
Dim point As PointF = New PointF(F F)
Dim point As PointF = New PointF(F F)
Dim curvepoints As PointF() = {point point point point}
gDrawPolygon(New Pen(ColorBlue ) curvepoints)
注釋////////////文本表示
Dim FFamily As FontFamily = New FontFamily(Arial)
Dim font As Font = New Font(FFamily FontStyleBold FontStyleItalic GraphicsUnitPixel)
Dim text As String = I love you!
Dim solidbrush As SolidBrush = New SolidBrush(ColorRed)
Dim pr As PointF = New PointF( )
eGraphicsDrawString(text font solidbrush pr)
注釋////////////平面繪制
Dim rec As RectangleF = New RectangleF( )
gDrawPie(mypen rec )
注釋///////////封閉圖形應該是個圓
gDrawClosedCurve(mypen curvepoints DrawingDrawingDFillModeAlternate)
注釋///////////大家自己試試看吧
gDrawArc(mypen )
gDrawCurve(mypen curvepoints)
gDrawBezier(mypen )
gDrawBeziers(mypen curvepoints)
注釋//////////這可是一個圓
Dim rec As RectangleF = New RectangleF( )
gDrawEllipse(mypen rec)
注釋//////////這是一個橢圓
Dim rec As RectangleF = New RectangleF( )
gDrawEllipse(mypen rec)

End Sub
這些是我自己試驗出來的當然了還有好多我只是開了一個頭大家要是發現什麼好東東別忘了通知一下
From:http://tw.wingwit.com/Article/program/net/201311/11800.html
    推薦文章
    Copyright © 2005-2013 電腦知識網 Computer Knowledge   All rights reserved.