VB.NET中怎么操作GDI图形
VB.NET中怎么操作GDI图形,很多新手对此不是很清楚,为了帮助大家解决这个难题,下面小编将为大家详细讲解,有这方面需求的人可以来学习下,希望你能有所收获。
通过重载Form1窗体的OnPaint()方法绘制GDI图形
Protected Overrides Sub onpaint
(ByVal e As System.Windows.
Forms.PaintEventArgs)
注释://///////////VB.NET操作GDI图形绘制任意直线
Dim g As Graphics =
e.GraphicsDim 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)
注释:////////////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
看完上述内容是否对您有帮助呢?如果还想对相关知识有进一步的了解或阅读更多相关文章,请关注编程网行业资讯频道,感谢您对编程网的支持。
免责声明:
① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。
② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341