资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

vb.net图形函数库 vbnet chart

VB.net中如何在picturebox画线,有什么函数?

Dim b As New Bitmap(PictureBox1.Width, PictureBox1.Height)

创新互联自成立以来,一直致力于为企业提供从网站策划、网站设计、网站设计制作、成都网站建设、电子商务、网站推广、网站优化到为企业提供个性化软件开发等基于互联网的全面整合营销服务。公司拥有丰富的网站建设和互联网应用系统开发管理经验、成熟的应用系统解决方案、优秀的网站开发工程师团队及专业的网站设计师团队。

Dim g As Graphics = Graphics.FromImage(b)

g.Clear(Color.White)

Dim p As New Pen(Color.Black)

p.EndCap = Drawing2D.LineCap.ArrowAnchor

g.DrawLine(p, 30, PictureBox1.Height - 30, 30, 30)

g.DrawLine(p, 30, PictureBox1.Height - 30, PictureBox1.Width - 30, PictureBox1.Height - 30)

Dim i As Integer

Dim bs As New SolidBrush(Color.Green)

Dim po As New Point

po.X = 0

po.Y = PictureBox1.Height - 35

For i = 700 To 1000 Step 50

g.DrawString(i, Me.Font, bs, po.X, po.Y)

g.DrawLine(p, po.X + 28, po.Y + 5, po.X + 30, po.Y + 5)

po.Y -= (PictureBox1.Height - 100) / 6

Next

po.X = 30

po.Y = PictureBox1.Height - 30

For i = 0 To 40 Step 5

g.DrawString(i, Me.Font, bs, po.X, po.Y + 5)

g.DrawLine(p, po.X, po.Y + 2, po.X, po.Y)

po.X += (PictureBox1.Width - 100) / 8

Next

PictureBox1.Image = b

大佬们~VisualStudio中vb.net如何画三角函数图像?

VB系统的坐标原点在左上角,X轴的正方向是水平向右,而Y轴的正方向是垂直向下。所以,要绘制三角函数的曲线,自己可以通过改变点坐标的方法来实现,当然,VB.NET提供了相应的方法可以来实现坐标变换,也可以通过VB.Net的Graphics类提供的平移、旋转等转换来实现。

下面是我通过自己变换实现的示例,提供参考;我的环境是VB.NET 2010

Imports System.Math

Public Class Form1

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

  '1,获得一个Graphics对象

  Dim MyGraphics As Graphics

  MyGraphics = PictureBox1.CreateGraphics

  '2,定义一个Pen对象,用于绘制图形(轮廓线)

  Dim MyPen As New Pen(Color.Black, 1)

  '3,定义一个Brush对象,用于填充图形(如果需要填充的话)

  Dim MyBrush As New SolidBrush(Color.Orange)

  MyGraphics.DrawLine(MyPen, 0, 200, 700, 200)

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

  '1,获得一个Graphics对象

  Dim MyGraphics As Graphics

  MyGraphics = PictureBox1.CreateGraphics

  '2,定义一个Pen对象,用于绘制图形(轮廓线)

  Dim MyPen As New Pen(Color.Black, 1)

  '3,定义一个Brush对象,用于填充图形(如果需要填充的话)

  Dim MyBrush As New SolidBrush(Color.Orange)

  '声明横向和纵向比例变量

  Dim Heng As Integer = 20

  Dim Zong As Integer = 50

  '先获得正弦值,保存到点坐标数组

  Dim MyPoints(700) As Point

  Dim i As Integer

  For i = 0 To 700

      MyPoints(i) = New Point(i * Heng, 200 + Sin(i) * Zong)

  Next

  '采用绘制光滑线连接点的方式绘制曲线

  MyGraphics.DrawCurve(MyPen, MyPoints)

End Sub

End Class

显示的效果图:

vb.net的picturebox画直线的函数是哪个?vb6.0是picture1.line就可以,但是vb.net没有啊

Dim PtStart As Point '记录绘制直线的起始点

Dim PtEnd As Point '记录绘制直线的终点

Dim ShouldDrawLine As Boolean '是否绘制直线

'记录鼠标左键点击的位置,第二次点击后开始绘制直线

Private Sub Pic1_MouseDown()Sub Pic1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Pic1.MouseDown

If e.Button = Windows.Forms.MouseButtons.Left Then

If Not ShouldDrawLine Then

PtStart = New Point(e.X, e.Y)

ShouldDrawLine = True

Else

PtEnd = New Point(e.X, e.Y)

'下面两句根据需要进行取舍

'Call DrawLine(PtStart, PtEnd) '绘制一条直线

Call DrawLines(PtStart, PtEnd) '绘制多条直线

ShouldDrawLine = False

End If

End If

End Sub

'绘制鼠标两次点击位置之间的直线

Private Sub DrawLine()Sub DrawLine(ByVal mPoint1 As Point, ByVal mPoint2 As Point)

Pic1.Refresh() '用于刷新Picturebox表面

Pic1.CreateGraphics.DrawLine(Pens.Blue, mPoint1, mPoint2) '绘制两点间的直线

End Sub

'绘制多条直线,每两次鼠标点击确定一条线

Private Sub DrawLines()Sub DrawLines(ByVal mPoint1 As Point, ByVal mPoint2 As Point)

'此句不可删除,用于清除鼠标点击前的轨迹

ControlPaint.DrawReversibleLine(Pic1.PointToScreen(mPoint1), Pic1.PointToScreen(mPoint2), Color.Red)

Pic1.CreateGraphics.DrawLine(Pens.Blue, mPoint1, mPoint2) '绘制两点间的直线

End Sub


本文题目:vb.net图形函数库 vbnet chart
当前地址:http://cdkjz.cn/article/dohdsdd.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220