vb.net定义画笔的简单介绍

vb.net 绘制实时温度曲线

这个要用GDI+画。要看你.net版本。

茄子河网站制作公司哪家好,找创新互联公司!从网页设计、网站建设、微信开发、APP开发、成都响应式网站建设公司等网站项目制作,到程序开发,运营维护。创新互联公司成立与2013年到现在10年的时间,我们拥有了丰富的建站经验和运维经验,来保证我们的工作的顺利进行。专注于网站建设就选创新互联公司

以下是VS2005中的一段代码。

Me.PictureBox1.Height = 450

Me.PictureBox1.Width = 880

Dim gr As Graphics '定义画布

Dim bp As New Bitmap(880, 450) '定义位图,并进行赋值

Dim p As New Pen(Color.Black) '定义画笔

p.Width = 2 '宽度2

p.DashStyle = Drawing2D.DashStyle.Solid '样式直线

PictureBox1.Image = bp

gr = Graphics.FromImage(PictureBox1.Image)

gr.FillRectangle(Brushes.White, New Rectangle(0, 0, PictureBox1.Width, PictureBox1.Height))

gr.DrawLine(p, a, b, a, .Height - b) '绘制纵坐标

gr.DrawLine(p, a, .Height - b, .Width - a, .Height - b) '绘制横坐标

有关vb.net里的hatchbrush

Imports System.Drawing.Drawing2D

Public Class Form1

Private Sub Form1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Click

'定义一个 Graphics对象

'调用窗体的CreateGraphics 方法创建 Graphics 对象

Dim g As Graphics

g = Me.CreateGraphics

'创建用实心菱形图案进行绘制,并使用红色作为前景色,蓝色作为背景色的画笔

Dim aHatchBrush As HatchBrush = New HatchBrush(HatchStyle.SolidDiamond, Color.Red, Color.Blue)

'创建矩形的位置和大小

Dim x As Integer = 0

Dim y As Integer = 0

Dim width As Integer = 150

Dim height As Integer = 200

'调用图形方法FillRectangle 将定义的矩形绘制到创建Graphics 对象上

g.FillRectangle(aHatchBrush, x, y, width, height)

End Sub

End Class

VB.net的 使用画笔在窗体上绘制不同的图形的代码

首先引入System.Drawing和System.Drawing.Drawing2D

自己看得了

这里面说的有的可以填充的,是g.FillXXXX

VB.net中如何画图?

VB.net与VB不同。

VB.net已经有专门绘图的类。

可以定义笔刷然后用Drawing类中的方法绘制。

Private Sub DrawEllipse()

Dim myPen As New System.Drawing.Pen(System.Drawing.Color.Red)

Dim formGraphics as System.Drawing.Graphics

formGraphics = Me.CreateGraphics()

formGraphics.DrawEllipse(myPen, New Rectangle(0,0,200,300))

myPen.Dispose()

formGraphics.Dispose()

End Sub

Private Sub DrawRectangle()

Dim myPen As New System.Drawing.Pen(System.Drawing.Color.Red)

Dim formGraphics as System.Drawing.Graphics

formGraphics = Me.CreateGraphics()

formGraphics.DrawRectangle(myPen, New Rectangle(0,0,200,300))

myPen.Dispose()

formGraphics.Dispose()

End Sub

vb.net 画图 如何保持图形

不用PictureBoxTest.Image属性,直接把图形绘制到PictureBoxTest上面就可以了。

Dim button As Integer = 0

Private Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) _

Handles Button1.Click

Using g As Graphics = Graphics.FromHwnd(PictureBoxTest.Handle)

Dim penRed As Pen = New Pen(Color.Red, 1)     '定义红色画笔  

Dim penblue As Pen = New Pen(Color.Blue, 1) '定义蓝色画笔 

If button = 0 Then

g.DrawLine(penRed, 0, 0, 100, 100)

button = 1

ElseIf button = 1 Then

g.DrawLine(penblue, 100, 100, 200, 200)

button = 0

End If

End Using

End Sub


新闻名称:vb.net定义画笔的简单介绍
文章地址:http://scyanting.com/article/heijjs.html