用VB.NET绘制GDI图形
2007-11-03 21:31
381 查看
下面的例子通过重载Form1窗体的OnPaint()方法绘制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
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图形
- 用VB.NET绘制GDI图形
- 用VB.NET绘制GDI图形
- [VB.NET源码]53_绘制三维图形
- 利用asp.net绘制图形语言是vb.net
- vb.net 与c# 窗体绘制水晶按钮图形
- vb.net 与c# 窗体绘制水晶按钮图形
- n[VB.NET源码]51_绘制填充图形
- 【VB.NET2010】在PictureBox上绘制文字的相关问题
- GDI绘制图形
- 图形编辑器, 画图程序, 绘制, 设计, 打印, 矢量图转换, VC++, VB, 源代码
- vb.net里使用trackbar控件控制图形
- GDI绘制各种图形和文字
- GDI基础函数使用绘制线条和图形
- C#学习笔记之使用GDI绘制简单的图形
- vb.net GDI窗体
- VB图形绘制
- VB.NET 绘制 EAN13 (商品条码)
- GDI+ Programming in C# and VB .NET
- 超全面的.NET GDI+图形图像编程教程