vb.net graphic类 画圆,椭圆 画两点之间的坐标 画窗体改变跟随画图 图片的水平垂直翻转

前端之家收集整理的这篇文章主要介绍了vb.net graphic类 画圆,椭圆 画两点之间的坐标 画窗体改变跟随画图 图片的水平垂直翻转前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

画圆 圆心为(350,250)半径为200

Public Class Form1
    Private Sub Form1_Paint(ByVal sender As Object,ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
        Dim gr As Graphics = Me.CreateGraphics
        gr.DrawEllipse(Pens.Green,350,250,50,50)
        gr.Dispose()
    End Sub
End Class


画椭圆 和窗体相同大的椭圆

Public Class Form1
    Private Sub Form1_Paint(ByVal sender As Object,ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
        Dim gr As Graphics = Me.CreateGraphics
        gr.DrawEllipse(Pens.Red,Me.ClientSize.Width,Me.ClientSize.Height)
        gr.Dispose()
    End Sub
End Class


画椭圆 改 (跟随窗体大小改变)

Public Class Form1
    Private Sub Form1_Resize(ByVal sender As Object,ByVal e As System.EventArgs) Handles Me.Resize
        Me.Refresh() '刷新
        Dim gr As Graphics = Me.CreateGraphics
        gr.DrawEllipse(Pens.Red,Me.ClientSize.Height)
        gr.Dispose()
    End Sub
End Class


画两点之间的线 例如 (100,30)到(500,300)之间的线

Public Class Form1
    Private Sub Form1_Paint(ByVal sender As Object,ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
        Dim gr As Graphics = Me.CreateGraphics
        gr.DrawLine(Pens.Red,100,30,500,300)
        gr.Dispose()
    End Sub
End Class


图片的水平和垂直翻转

Public Class Form1
    Private Sub Form1_Paint(ByVal sender As Object,ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
        Dim gr As Graphics = Me.CreateGraphics
        Dim img As Image = Image.FromFile("C:\Users\lenovo\Downloads\1.jpg")
        gr.DrawImage(img,100)
        gr.DrawImage(img,220,-100) '垂直翻转
        gr.DrawImage(img,230,-100,100) '水平翻转
        gr.Dispose()
    End Sub
End Class

绘制正方形

Public Class Form1
    Private Sub Form1_Paint(ByVal sender As Object,ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
        Dim gr As Graphics = Me.CreateGraphics
        gr.DrawRectangle(Pens.Red,130,300,300)
        gr.Dispose()
    End Sub
End Class

猜你在找的VB相关文章