VB.NET编程语言在对图形的操作上可以体现出其全面和灵活性。我们可以通过VB.NET操作GDI图形的相关操作方法和实现的功能来对这一方面的知识进行一个系统的认识,了解VB.NET在操作中的简便灵活性。#t#
下面的例子通过重载Form1窗体的OnPaint()方法绘制GDI图形
注释://///////////VB.NET操作GDI图形绘制任意直线
注释://///////////绘制矩形(任意直线构成的封闭图形)
- 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)
注释:////////////VB.NET操作GDI图形文本表示
- 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)
注释:////////////VB.NET操作GDI图形平面绘制
- 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图形的各种操作技巧就为大家介绍到这里。
网站名称:迅速掌握VB.NET操作GDI图形
文章位置:http://www.shufengxianlan.com/qtweb/news44/322444.html
网站建设、网络推广公司-创新互联,是专注品牌与效果的网站制作,网络营销seo公司;服务项目有等
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联