温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

VB.NET中怎么操作GDI图形

发布时间:2021-07-15 11:35:12 来源:亿速云 阅读:302 作者:Leah 栏目:编程语言

VB.NET中怎么操作GDI图形,很多新手对此不是很清楚,为了帮助大家解决这个难题,下面小编将为大家详细讲解,有这方面需求的人可以来学习下,希望你能有所收获。

通过重载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) 

注释://///////////绘制矩形(任意直线构成的封闭图形)

  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应该是个圆

  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) 

注释://////////这可是一个圆

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

  2. g.DrawEllipse(mypen, rec1) 

注释://////////这是一个椭圆

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

  2. g.DrawEllipse(mypen, rec2)  

  3. End Sub  

看完上述内容是否对您有帮助呢?如果还想对相关知识有进一步的了解或阅读更多相关文章,请关注亿速云行业资讯频道,感谢您对亿速云的支持。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI