溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

VB.NET中怎么操作GDI圖形

發(fā)布時(shí)間:2021-07-15 11:35:12 來(lái)源:億速云 閱讀:320 作者:Leah 欄目:編程語(yǔ)言

VB.NET中怎么操作GDI圖形,很多新手對(duì)此不是很清楚,為了幫助大家解決這個(gè)難題,下面小編將為大家詳細(xì)講解,有這方面需求的人可以來(lái)學(xué)習(xí)下,希望你能有所收獲。

通過(guò)重載Form1窗體的OnPaint()方法繪制GDI圖形

  1. Protected Overrides Sub onpaint
    (ByVal e As System.Windows.
    Forms.PaintEventArgs) 

注釋://///////////VB.NET操作GDI圖形繪制任意直線

  1. Dim g As Graphics = 
    e.Graphics  

  2. Dim mypen As Pen = 
    New Pen(Color.Red, 2)  

  3. g.DrawLine(mypen, 
    100, 100, 10, 10) 

注釋://///////////繪制矩形(任意直線構(gòu)成的封閉圖形)

  1. Dim point1 As PointF = 
    New PointF(100F, 100F)  

  2. Dim point2 As PointF = 
    New PointF(200F, 100F)  

  3. Dim point3 As PointF = 
    New PointF(200F, 200F)  

  4. Dim point4 As PointF = 
    New PointF(100F, 200F)  

  5. Dim curvepoints As PointF() 
    = {point1, point2,
     point3, point4}  

  6. g.DrawPolygon(New 
    Pen(Color.Blue, 2), 
    curvepoints) 

注釋:////////////VB.NET操作GDI圖形文本表示

  1. Dim FFamily As FontFamily = 
    New FontFamily("Arial")  

  2. Dim font As Font = New Font
    (FFamily, "20", FontStyle.
    Bold, FontStyle.Italic, 
    GraphicsUnit.Pixel)  

  3. Dim text As String =
     "I love you!" 

  4. Dim solidbrush As SolidBrush 
    = New SolidBrush(Color.Red)  

  5. Dim pr As PointF = 
    New PointF(100, 10)  

  6. e.Graphics.DrawString
    (text, font, solidbrush, pr) 

注釋:////////////VB.NET操作GDI圖形平面繪制

  1. Dim rec As RectangleF = 
    New RectangleF(10, 10, 
    200, 100)  

  2. g.DrawPie(mypen, rec, 
    150, 150) 

注釋:///////////封閉圖形,0.7應(yīng)該是個(gè)圓

  1. g.DrawClosedCurve(mypen, 
    curvepoints, 0.7, Drawing.
    Drawing2D.FillMode.Alternate) 

注釋:///////////大家自己試試看吧

  1. g.DrawArc(mypen, 300, 300, 
    200, 200, 100, 100)  

  2. g.DrawCurve(mypen, curvepoints)  

  3. g.DrawBezier(mypen, 50, 50, 
    100, 50, 100, 100, 50, 100)  

  4. g.DrawBeziers(mypen, curvepoints) 

注釋://////////這可是一個(gè)圓

  1. Dim rec1 As RectangleF = 
    New RectangleF(10, 10, 100, 100)  

  2. g.DrawEllipse(mypen, rec1) 

注釋://////////這是一個(gè)橢圓

  1. Dim rec2 As RectangleF = 
    New RectangleF(10, 10, 200, 100)  

  2. g.DrawEllipse(mypen, rec2)  

  3. End Sub  

看完上述內(nèi)容是否對(duì)您有幫助呢?如果還想對(duì)相關(guān)知識(shí)有進(jìn)一步的了解或閱讀更多相關(guān)文章,請(qǐng)關(guān)注億速云行業(yè)資訊頻道,感謝您對(duì)億速云的支持。

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI