vb.net画圆命令 vb圆角矩形怎么画
vb.net怎么画圆的图形
Public a(8) As OvalShape
创新互联建站专注于袁州企业网站建设,成都响应式网站建设公司,商城网站制作。袁州网站建设公司,为袁州等地区提供建站服务。全流程按需求定制网站,专业设计,全程项目跟踪,创新互联建站专业和态度为您提供的服务
Dim canvas= New Microsoft.VisualBasic.PowerPacks.ShapeContainer
ConstCircleSize As Integer= 20
Const Dist As Integer = 10
Const Gap As Integer = 50
Dim i As Integer
canvas.Parent = Me.Panel1
For i =0 To 8
a(i) = NewOvalShape
a(i).Size = New Size(CircleSize,CircleSize)
a(i).Location = New Point(Dist +Gap * (i Mod 3), Dist + Gap * (i \ 3))
a(i).BorderWidth = 3
a(i).Enabled = True
a(i).Visible = True
a(i).Parent = canvas
Next
vb.net中绘制圆的代码是什么?
Dim myGraphics As Graphics = Me.CreateGraphics '声明并创建一个Graphics对象
Dim myPen As Pen = New Pen(Drawing.Color.Black, 3) '声明一个画笔,并设定颜色和粗细
myPen.DashStyle = Drawing.Drawing2D.DashStyle.Solid '线型,Solid是实线
myGraphics.DrawEllipse(myPen, 200, 200, 100, 100) '画圆,数值依次是:横坐标、纵坐标、宽度和高度(宽高相同为正圆,否则为椭圆)
myGraphics.Dispose() '释放Graphics占用的资源
在VB.Net中如何画实心的圆
在PictureBox1上画红色的实心圆:
Private Sub DrawCircle(ByVal cp As Point, ByVal radius As Integer, ByVal color As Brush)
Dim gr As Graphics
gr = PictureBox1.CreateGraphics
Dim rect As Rectangle = New Rectangle(cp.X - radius, cp.Y - radius, 2 * radius, 2 * radius)
gr.DrawEllipse(Pens.Black, rect)
gr.FillEllipse(color, rect)
End Sub
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
DrawCircle(New Point(120, 100), 80, Brushes.Red)
End Sub
如何用VB.NET画同心圆
窗体上添加一个按钮,在该按钮的单击事件里编写代码如下:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'声明窗体的Me.CreateGraphics对象
Dim MyGraphics As Graphics = Me.CreateGraphics
Dim Cx As Integer = 150 '圆心的X坐标
Dim Cy As Integer = 150 '圆心的Y坐标
Dim R As Integer '圆的半径
'绘制半径为R的圆
For R = 5 To 100 Step 5
MyGraphics.DrawEllipse(Pens.Black, New Rectangle(Cx - R, Cy - R, 2 * R, 2 * R))
Next
End Sub
‘用黑色画笔绘制一组同心圆,半径从5开始,增量为5。
说明:
DrawEllipse是VB.Net的Graphics类的绘制椭圆的方法;他有几种格式,上面使用的是一种;
DrawEllipse(画笔的颜色,绘制椭圆所需要的矩形区域)
其中:绘制椭圆所需要的矩形区域,如果被定义为正方形,就演变成绘制圆,定义该区域由死个数值确定,第1个数值,确定该区域左上角的X坐标,第2个数值,确定该区域左上角的Y坐标,第3个数值,确定该区域的宽度,第4个数值,确定该区域的高度。
例如1:
DrawEllipse(Pens.Black, New Rectangle(150, 150, 50, 50))
就是以圆心坐标为(100,100),绘制半径为50 的圆。其实在VB.NET中,是告诉系统在以左上角坐标(150,150),边长为50的正方形里绘制内切圆。理解了是在正方形里绘制内切圆,就可以通过数学计算,知道如何绘制了。
同理例如2:
DrawEllipse(Pens.Black, New Rectangle(150, 150, 100, 50))
就是以圆心坐标为(100,100),绘制半径为50 的圆。其实在VB.NET中,是告诉系统在以左上角坐标(150,150),长轴为100,短轴为50的内切椭圆。
文章题目:vb.net画圆命令 vb圆角矩形怎么画
文章链接:http://pwwzsj.com/article/dohdjjj.html