画刷的填充(vb.net)

'*********
'画刷的填充(vb.net)
'By wgscd
'date:05/05/01
Public Class Form1


    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub
    Friend WithEvents Button1 As System.Windows.Forms.Button
    Friend WithEvents Button2 As System.Windows.Forms.Button
    Friend WithEvents Button4 As System.Windows.Forms.Button
    Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox
    Friend WithEvents Button3 As System.Windows.Forms.Button

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.Container

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer. 
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.PictureBox1 = New System.Windows.Forms.PictureBox
        Me.Button4 = New System.Windows.Forms.Button
        Me.Button1 = New System.Windows.Forms.Button
        Me.Button2 = New System.Windows.Forms.Button
        Me.Button3 = New System.Windows.Forms.Button
        Me.SuspendLayout()
        '
        'PictureBox1
        '
        Me.PictureBox1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
        Me.PictureBox1.Location = New System.Drawing.Point(24, 8)
        Me.PictureBox1.Name = "PictureBox1"
        Me.PictureBox1.Size = New System.Drawing.Size(288, 184)
        Me.PictureBox1.TabIndex = 4
        Me.PictureBox1.TabStop = False
        '
        'Button4
        '
        Me.Button4.Location = New System.Drawing.Point(256, 216)
        Me.Button4.Name = "Button4"
        Me.Button4.TabIndex = 3
        Me.Button4.Text = "PathGradient"
        '
        'Button1
        '
        Me.Button1.Location = New System.Drawing.Point(24, 216)
        Me.Button1.Name = "Button1"
        Me.Button1.TabIndex = 0
        Me.Button1.Text = "hatch填充"
        '
        'Button2
        '
        Me.Button2.Location = New System.Drawing.Point(112, 216)
        Me.Button2.Name = "Button2"
        Me.Button2.Size = New System.Drawing.Size(128, 23)
        Me.Button2.TabIndex = 1
        Me.Button2.Text = "LinearGradient填充"
        '
        'Button3
        '
        Me.Button3.Location = New System.Drawing.Point(136, 256)
        Me.Button3.Name = "Button3"
        Me.Button3.TabIndex = 5
        Me.Button3.Text = "结束"
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
        Me.BackColor = System.Drawing.Color.FromArgb(CType(192, Byte), CType(192, Byte), CType(255, Byte))
        Me.ClientSize = New System.Drawing.Size(352, 293)
        Me.Controls.Add(Me.Button3)
        Me.Controls.Add(Me.PictureBox1)
        Me.Controls.Add(Me.Button4)
        Me.Controls.Add(Me.Button2)
        Me.Controls.Add(Me.Button1)
        Me.Name = "Form1"
        Me.Text = "画刷的填  -By wgscd"
        Me.ResumeLayout(False)

    End Sub

#End Region
    Dim brush2 As System.Drawing.Brush
    Dim brush1 As System.Drawing.Drawing2D.LinearGradientBrush
    Dim g As System.Drawing.Graphics
    Dim p1, p2, p3, p4 As System.Drawing.Point
    Dim p(3) As System.Drawing.Point
    Dim color1, color2 As System.Drawing.Color


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        brush2 = New System.Drawing.Drawing2D.HatchBrush(Drawing.Drawing2D.HatchStyle.Cross, Color.Blue, Color.Green)

        PictureBox1.Refresh()
        g = PictureBox1.CreateGraphics
        g.FillEllipse(brush2, 0, 0, 200, 150)

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        brush1 = New System.Drawing.Drawing2D.LinearGradientBrush(p1, p2, Color.Bisque, Color.DarkSalmon)
        PictureBox1.Refresh()
        g = PictureBox1.CreateGraphics
        g.FillEllipse(brush1, 0, 0, 200, 150)
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        p(1).X = 20 : p(1).Y = 40
        p(2).X = 60 : p(2).Y = 40
        ' p(3).X = 10 : p(3).Y = 10
        p1.X = 100 : p1.Y = 100
        p2.X = 20 : p2.Y = 50
        p3.X = 30 : p3.Y = 40
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        brush2 = New System.Drawing.Drawing2D.PathGradientBrush(p, Drawing.Drawing2D.WrapMode.Tile)


        PictureBox1.Refresh()
        g = PictureBox1.CreateGraphics
        g.FillEllipse(brush2, 0, 0, 200, 150)
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        End
    End Sub
End Class

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值