畫點:
創(chuàng)新互聯(lián),為您提供成都網(wǎng)站建設(shè)、成都網(wǎng)站制作、網(wǎng)站營銷推廣、網(wǎng)站開發(fā)設(shè)計,對服務(wù)混凝土攪拌站等多個行業(yè)擁有豐富的網(wǎng)站建設(shè)及推廣經(jīng)驗。創(chuàng)新互聯(lián)網(wǎng)站建設(shè)公司成立于2013年,提供專業(yè)網(wǎng)站制作報價服務(wù),我們深知市場的競爭激烈,認(rèn)真對待每位客戶,為客戶提供賞心悅目的作品。 與客戶共同發(fā)展進步,是我們永遠(yuǎn)的責(zé)任!
在PictureBox的Paint事件里面:
dim myGraphics=e.Graphics
Dim myPointArray As Point() = {New Point(0, 0), New Point(50, 30), New Point(30, 60)}
myGraphics.DrawPolygon(myPen, myPointArray)
畫圓:
Dim g As Graphics
g = PictureBox1.CreateGraphics
g.FillEllipse(Brushes.Red, x, y, 10, 10)
要么在屬性欄設(shè)置,要么在?new?事件里?寫這句代碼
load事件無用
Public?Sub?New()
InitializeComponent()
Me.StartPosition?=?System.Windows.Forms.FormStartPosition.CenterScreen
End?Sub
可以直接顯示的。你看下面的示例,使用vb.net畫的齒輪:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
b = New Bitmap(PictureBox1.Width, PictureBox1.Height)
g = Graphics.FromImage(b)
'g.RotateTransform(90)
g.Clear(Color.White)
g.TranslateTransform(PictureBox1.Width / 2, PictureBox1.Height / 2)
g.ScaleTransform(1, -1)
'g.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
g.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
DrawCL(g, New PointF(Val(TextBox1.Text), Val(TextBox2.Text)), Val(TextBox3.Text), Val(TextBox4.Text), Val(TextBox5.Text), Val(TextBox6.Text), Val(TextBox7.Text), Val(TextBox8.Text), Val(TextBox9.Text))
DrawCL(g, New PointF(Val(TextBox18.Text), Val(TextBox17.Text)), Val(TextBox16.Text), Val(TextBox15.Text), Val(TextBox14.Text), Val(TextBox13.Text), Val(TextBox12.Text), Val(TextBox11.Text), Val(TextBox10.Text))
PictureBox1.Image = b
End Sub
在窗體上拉一個Timer控件,enabled設(shè)為true,Interval設(shè)為20。完整代碼如下: Dim myPen As New System.Drawing.Pen(System.Drawing.Color.Red)
Dim formGraphics As System.Drawing.Graphics
Dim num As Integer = 1
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Me.Refresh() '清屏
formGraphics = Me.CreateGraphics()
formGraphics.DrawEllipse(myPen, New Rectangle(100, 100, num, num)) '在坐標(biāo)(100,100)的位置畫圓
If num 200 Then '如果大于200則停止畫圓
myPen.Dispose()
formGraphics.Dispose()
Timer1.Enabled = False
Else
num = num + 1
End If
End Sub