Note2024081501_画笔画刷测试VB.Net

画布画笔画刷测试

1.画布分类

画布可以分为窗体画布和控价画布两类

声明窗体画布

Dim 画布 As Graphics = Me.CreateGraphics

声明控件画布

 Dim 按钮画布 As Graphics = Button4.CreateGraphics

2. 画笔

声明方式

Dim 画笔 As New Pen(Color.Red)

3. 画刷

4. 其他色刷

具体细节没看,用到再说。

5. 程序过程

  1. 画面设计
    在这里插入图片描述

  2. 模块设计

Module 文件

    Public Sub 生成指定文件(路径 As String)
        IO.File.Create(路径)
    End Sub
    Public Sub 删除指定文件(路径 As String)
        Try
            IO.File.Delete(路径)
        Catch ex As Exception

        End Try

    End Sub


End Module
  1. 背景程序

Imports Microsoft.Office.Interop



Public Class Form1
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim a As String = "D:\2.txt"
        文件.删除指定文件(a)
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Dim a As String = "D:\2.txt"
        文件.生成指定文件(a)
    End Sub

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        Button3.BackColor = Color.FromArgb(255, 255, 0, 0)
        Dim myLoc As New Point(100, 100)
        Button3.Location = myLoc

        Dim mySize As New Size(200, 200)
        Dim myRec As New Rectangle(0, 0, 180, 200) '起始坐标和宽高

        Dim myRec2 As New Rectangle(myLoc, mySize)
    End Sub

    Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
        Dim 画布 As Graphics = Me.CreateGraphics
        Dim 画笔 As New Pen(Color.Red)
        Dim 起点位置 As New Point(10, 50)
        Dim 终点位置 As New Point(200, 200)
        画布.DrawLine(画笔, 起点位置, 终点位置)
        画布.DrawRectangle(画笔, 200, 20, 200, 300) '画矩形
        '画重载


        '在按钮上创建画布
        Dim 按钮画布 As Graphics = Button4.CreateGraphics
        按钮画布.DrawLine(画笔, 0, 0, 10, 20)
    End Sub

    Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click


    End Sub

    Private Sub Form1_Paint(sender As Object, e As PaintEventArgs) Handles Me.Paint
        Dim 画布 As Graphics = Me.CreateGraphics
        画布.Clear(Color.Coral)
        Dim 色刷 As New SolidBrush(Color.SaddleBrown) '单色色刷
        画布.FillEllipse(色刷, 10, 10, Width - 200, Height - 100)
    End Sub

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
        BackColor = Color.Coral
    End Sub
End Class


以上

r As Object, e As EventArgs) Handles Me.Load
BackColor = Color.Coral
End Sub
End Class


*以上*

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值