189 8069 5689

vb.net样条曲线 vb曲线控件

VB.NET 实时曲线

拖一个PictureBox1控件 创建一个Paint事件。在事件中加入 Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint ' Create pens. Dim redPen As New Pen(Color.Red, 3) Dim greenPen As New Pen(Color.Green, 3) ' Create points that define curve. Dim point1 As New Point(50, 50) Dim point2 As New Point(100, 25) Dim point3 As New Point(200, 5) Dim point4 As New Point(250, 50) Dim point5 As New Point(300, 100) Dim point6 As New Point(350, 200) Dim point7 As New Point(250, 250) Dim curvePoints As Point() = {point1, point2, point3, point4, _ point5, point6, point7} ' Draw lines between original points to screen. e.Graphics.DrawLines(redPen, curvePoints) ' Draw curve to screen. e.Graphics.DrawCurve(greenPen, curvePoints) End Sub 得到数据后,改point的数据。然后PictureBox1.Refresh()就行了

我们提供的服务有:网站建设、成都做网站、微信公众号开发、网站优化、网站认证、沐川ssl等。为千余家企事业单位解决了网站和推广的问题。提供周到的售前咨询和贴心的售后服务,是有科学管理、有技术的沐川网站制作公司

vb.net绘制曲线图

。net  其实还是很好绘制图形的

你可以看下 Graphics  类

Dim d As New Bitmap(Me.Width, Me.Height)  ‘一个图片吧

  Dim g As Graphics = Graphics.FromImage(d)’绘制  准备在这个图片是进行

然后  就是你绘制的东西了

线 就是   g.DrawLine()

圆 弧度  就用  g.DrawArc(Pens.Black, New Rectangle(0, 0, 400, 200), 0, 360)

复杂的就是      g.DrawBezier()

等  如果你用的是 VS的  编译  上面都有详细的参数说明

Dim d As New Bitmap(Me.Width, Me.Height)

Dim g As Graphics = Graphics.FromImage(d)

g.DrawArc(Pens.Black, New Rectangle(0, 0, 200, 200), 0, 360)

g.DrawLine(Pens.Red, New Point(0, 0), New Point(200, 200))

g.DrawLines(Pens.Green, New Point() {New Point(0, 0), New Point(50, 40), New Point(50, 80), New Point(90, 70), New Point(100, 400)})

g.DrawBezier(Pens.Yellow, New Point(0, 100), New Point(0, 0), New Point(200, 0), New Point(200, 200))

g.Dispose()

Me.BackgroundImage = d

vb中样条曲线问题

不引用的话,VB做不到。这事情要看VB的版本。如果是6.0的话,要去网上下载GDIPLUS的库文件或者自己声明GDI+的API。如果是VB.NET的话,VB自带GDI+,但是也可以下载GDIPLUS库来用。如果不知道去哪里下载,我下载有,你可以问我要。我使用VB6.0。下载gdiplus以后,在VB里面引用这个库,注意要选择“所有文件”才能看到这个库。gdi+里面的path功能可以实现样条:Private

TOKEN

As

Long'GDI+对象

Private

Graphics

As

Long'画板

Private

Sub

InitGDIPlus()

'初始化GDI+

Dim

uInput

As

GdiplusStartupInput

uInput.GdiplusVersion

=

1

If

GdiplusStartup(TOKEN,

uInput)

Ok

Then

'初始化错误

MsgBox

"GDI+

初始化错误。程序即将关闭。",

vbCritical,

"InitError"

End

End

If

GdipCreateFromHDC

Me.hDC,

Graphics'创建画板

GdipSetSmoothingMode

Graphics,

SmoothingModeAntiAlias'设置为反锯齿

End

SubPrivate

Sub

TerminateGDIPlus()

GdipDeleteGraphics

Graphics

'释放graphics占用的内存

GdiplusShutdown

TOKEN

'关闭GDI+

End

SubPrivate

Sub

Form_Load()

InitGDIPlus

'初始化End

SubPrivate

Sub

Command1_Click()

Dim

path

As

Long

Dim

m(3)

As

POINTF

'以下是坐标,你可以自由改变

m(0).x

=

m(0).y

=

m(1).x

=

10

m(1).y

=

100

m(2).x

=

20

m(2).y

=

3

m(3).x

=

500

m(3).y

=

100

Dim

pen

As

Long

GdipCreatePen1

HFF000000,

2,

UnitPixel,

pen

'创建画笔,用来画出样条

GdipCreatePath

FillModeAlternate,

path

'创建path

GdipAddPathBeziers

path,

m(0),

4

'创建样条'Count是说坐标的个数,points只能传递数组的第一个元素,不能传递数组。

GdipDrawPath

Graphics,

pen,

path

'画出样条

GdipDeletePen

pen

'删除画笔

GdipDeletePath

path

'删除样条End

SubPrivate

Sub

Form_Unload(Cancel

As

Integer)

TerminateGDIPlus

'删除GDI+

End

Sub


网页标题:vb.net样条曲线 vb曲线控件
文章路径:http://cdxtjz.com/article/hhhccp.html

其他资讯