浅析VB.NET绘制GDI图形的方法

开发 后端
这里介绍用VB.NET绘制GDI图形,Visual Basic.NET是基于微软.NET Framework之上的面向对象的中间解释性语言,可以看作是Visual Basic在.Net Framework平台上的升级版本,增强了对面向对象的支持。

在向大家详细介绍用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图形

  1. Protected Overrides Sub onpaint(ByVal e As System.Windows.Forms.PaintEventArgs)  
  2. '绘制任意直线  
  3. Dim g As Graphics = e.Graphics  
  4. Dim mypen As Pen = New Pen(Color.Red, 2)  
  5. g.DrawLine(mypen, 100, 100, 10, 10)  
  6. '绘制矩形(任意直线构成的封闭图形)  
  7. Dim point1 As PointF = New PointF(100F, 100F)  
  8. Dim point2 As PointF = New PointF(200F, 100F)  
  9. Dim point3 As PointF = New PointF(200F, 200F)  
  10. Dim point4 As PointF = New PointF(100F, 200F)  
  11. Dim curvepoints As PointF() = {point1, point2, point3, point4}  
  12. g.DrawPolygon(New Pen(Color.Blue, 2), curvepoints)  
  13. '文本表示  
  14. Dim FFamily As FontFamily = New FontFamily("Arial")  
  15. Dim font As Font = New Font(FFamily, "20", FontStyle.Bold, FontStyle.Italic,  
  16. GraphicsUnit.Pixel)  
  17. Dim text As String = "I love you!" 
  18. Dim solidbrush As SolidBrush = New SolidBrush(Color.Red)  
  19. Dim pr As PointF = New PointF(100, 10)  
  20. e.Graphics.DrawString(text, font, solidbrush, pr)  
  21. '平面绘制  
  22. Dim rec As RectangleF = New RectangleF(10, 10, 200, 100)  
  23. g.DrawPie(mypen, rec, 150, 150)  
  24. '封闭图形,0.7应该是个圆  
  25. g.DrawClosedCurve(mypen, curvepoints, 0.7,  
  26. Drawing.Drawing2D.FillMode.Alternate)  
  27. '大家自己试试看吧  
  28. g.DrawArc(mypen, 300, 300, 200, 200, 100, 100)  
  29. g.DrawCurve(mypen, curvepoints)  
  30. g.DrawBezier(mypen, 50, 50, 100, 50, 100, 100, 50, 100)  
  31. g.DrawBeziers(mypen, curvepoints)  
  32. '这可是一个圆  
  33. Dim rec1 As RectangleF = New RectangleF(10, 10, 100, 100)  
  34. g.DrawEllipse(mypen, rec1)  
  35. '这是一个椭圆  
  36. Dim rec2 As RectangleF = New RectangleF(10, 10, 200, 100)  
  37. g.DrawEllipse(mypen, rec2)  
  38. End Sub 

以上介绍VB.NET绘制GDI图形,这些是我自己试验出来的,当然了,还有好多,我只是开了一个头,大家要是发现什么好东东,别忘了通知一下。

【编辑推荐】

  1. 讲解VB.NET访问注册表方法
  2. 浅析VB.NET开发自动分页
  3. VB.NET ListView控件经验总结
  4. 概括VB.NET获取网卡地址的步骤
  5. 讲述VB.NET制作透明窗体
责任编辑:佚名 来源: IT168
相关推荐

2010-01-12 10:19:02

VB.NET操作GDI

2009-11-03 09:26:13

VB.NET方法

2009-10-23 16:43:01

VB.NET绘制图形

2009-11-03 10:00:20

VB.NET New方

2009-10-13 15:20:02

VB.NET使用Dra

2010-01-13 17:16:37

VB.NET冒号

2009-10-15 17:41:14

VB.NET Impo

2009-10-27 09:31:32

VB.NET启动Sma

2009-11-03 13:48:02

VB.NET枚举

2011-05-20 16:56:11

VB.NETGDI

2010-01-22 18:08:18

VB.NET与GDI结

2009-12-24 14:30:56

VB.NET

2009-10-12 14:32:40

VB.NET实现定时关

2009-10-10 15:43:51

2009-10-16 14:07:18

VB.NET使用Mon

2009-10-13 11:28:39

VB.NET面向对象编

2009-10-14 10:08:05

VB.NET编写DEC

2009-11-02 17:49:05

VB.NET抽象类

2009-11-03 12:52:38

VB.NET Wind

2009-10-26 17:24:42

VB.NET终端服务启
点赞
收藏

51CTO技术栈公众号