温馨提示×

温馨提示×

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

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

VB.NET绘制GDI图形的方法

发布时间:2021-08-19 18:21:35 来源:亿速云 阅读:141 作者:chen 栏目:编程语言

本篇内容主要讲解“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图形的方法”有了更深的了解,不妨来实际操作一番吧!这里是亿速云网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!

向AI问一下细节

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

AI