十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
Dim g As Graphics = PictureBox1.CreateGraphics
创新互联专注于企业成都全网营销推广、网站重做改版、代县网站定制设计、自适应品牌网站建设、HTML5、商城网站建设、集团公司官网建设、外贸营销网站建设、高端网站制作、响应式网页设计等建站业务,价格优惠性价比高,为代县等各大城市提供网站开发制作服务。
g.TranslateTransform(2, 2) ‘定义原点坐标
g.ScaleTransform(1, -1) ’X轴不变,反转Y轴
以PictureBox1中(2,2)点为新的原点(0,0)
向右为X轴正方向 向上为Y轴正方向
scale(x1,y1)-(x2,y2)
你只要记住,这里的x1,y1是左上角的坐标,x2,y2是右下角的坐标,通过这两个点的坐标设定,就可以决定坐标原点的位置以及坐标轴的方向了,比如
Scale (-300,200)-(300,-200)
以上是把坐标原点设在窗体中心,x轴长600,方向从左到右,y轴长400,方向从下向上。
Scale (800,0)-(0,600)
以上是把坐标原点设在窗体右上角,x轴长800,方向从右到左,y轴长600,方向从上向下。
下面说坐标轴和原点的标示法:
假定自定义坐标设为:
Scale (-300, 200)-(300, -200)
则
Line (-300, 0)-(300, 0) '画x轴
Line (0, 200)-(0, -200) '画y轴
CurrentX = 290
CurrentY = -5
Print "x" '标示x轴
CurrentX = 5
CurrentY = 200
Print "y" '标示y轴
CurrentX = 5
CurrentY = -5
Print "0" '标示原点
自己用GDI+画的 无论什么什么尺寸的picturebox都行
不过别太小了o(∩_∩)o
代码放在哪里自己决定啊
最好是放在 picturebox的resize时间里
每次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
坐标原点默认是左上角,可以改变的,FORM1.SCALE
(X1,Y1)-(X2,Y2)横坐标范围是从X1到X2,纵坐标是从Y1到Y2,若坐标设在窗体中间,则FORM1.SCALE
(-ME.WIDTH/2,-ME.HEIGTH/2)-(ME.WIDTH/2,ME.HEIGTH/2),画横坐标ME.LINE
(-ME.WIDTH/2,0)-(ME.WIDTH/2,0)
画纵坐标FORM1.LINE
(0,-ME.HEIGTH/2,0,ME.HEIGTH/2)
Private Sub mainfrm_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
Dim pt(200) As PointF
Dim a As Integer
For a = 0 To 200
pt(a).X = 50 * a
pt(a).Y = 200 - 50 * Math.Sin(a - 1)
Next
Me.CreateGraphics.DrawLine(Pens.Blue, 0, 200, 800, 200)
Me.CreateGraphics.DrawLine(Pens.Blue, 50, 0, 50, 600)
Me.CreateGraphics.DrawCurve(Pens.Blue, pt)
End Sub