十年網(wǎng)站開發(fā)經(jīng)驗(yàn) + 多家企業(yè)客戶 + 靠譜的建站團(tuán)隊(duì)
量身定制 + 運(yùn)營維護(hù)+專業(yè)推廣+無憂售后,網(wǎng)站問題一站解決
坐標(biāo)原點(diǎn)默認(rèn)是左上角,可以改變的,F(xiàn)ORM1.SCALE
成都創(chuàng)新互聯(lián)公司主要從事成都做網(wǎng)站、成都網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計(jì)、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)白銀,十年網(wǎng)站建設(shè)經(jīng)驗(yàn),價(jià)格優(yōu)惠、服務(wù)專業(yè),歡迎來電咨詢建站服務(wù):028-86922220
(X1,Y1)-(X2,Y2)橫坐標(biāo)范圍是從X1到X2,縱坐標(biāo)是從Y1到Y(jié)2,若坐標(biāo)設(shè)在窗體中間,則FORM1.SCALE
(-ME.WIDTH/2,-ME.HEIGTH/2)-(ME.WIDTH/2,ME.HEIGTH/2),畫橫坐標(biāo)ME.LINE
(-ME.WIDTH/2,0)-(ME.WIDTH/2,0)
畫縱坐標(biāo)FORM1.LINE
(0,-ME.HEIGTH/2,0,ME.HEIGTH/2)
Sub?Draw(Form?As?PictureBox,?x?As?Integer,?y?As?Integer)
Const?Offset?AsSingle?=?0.5
Dim?i?As?Long
Form.AutoRedraw=?True
Form.Scale?(-x,y)-(x,?-y)??'定義坐標(biāo)系
Form.Line?(-x,0)-(x,?0)????'X軸
Form.Line?(0,-y)-(0,?y)????'Y軸
For?i?=?-x?To?x-?1
Form.Line(i,?0)-(i,?0.2)???'X軸點(diǎn)
Next?i
For?i?=?-y?To?y-?1
Form.Line(0,?i)-(0.2,?i)???'Y軸點(diǎn)
Next?i
Form.Line?(x,0)-(x?-?Offset,?Offset)??????'X箭頭
Form.Line?(x,0)-(x?-?Offset,?-Offset)
Form.Line?(0,y)-(-Offset,?y?-?Offset)?????'Y箭頭
Form.Line?(0,y)-(Offset,?y?-?Offset)
End?Sub
Private?Sub?Command2_Click()
Picture1.Cls
Draw?Picture1,10,?10
End?Sub
scale(x1,y1)-(x2,y2)
你只要記住,這里的x1,y1是左上角的坐標(biāo),x2,y2是右下角的坐標(biāo),通過這兩個(gè)點(diǎn)的坐標(biāo)設(shè)定,就可以決定坐標(biāo)原點(diǎn)的位置以及坐標(biāo)軸的方向了,比如
Scale (-300,200)-(300,-200)
以上是把坐標(biāo)原點(diǎn)設(shè)在窗體中心,x軸長600,方向從左到右,y軸長400,方向從下向上。
Scale (800,0)-(0,600)
以上是把坐標(biāo)原點(diǎn)設(shè)在窗體右上角,x軸長800,方向從右到左,y軸長600,方向從上向下。
下面說坐標(biāo)軸和原點(diǎn)的標(biāo)示法:
假定自定義坐標(biāo)設(shè)為:
Scale (-300, 200)-(300, -200)
則
Line (-300, 0)-(300, 0) '畫x軸
Line (0, 200)-(0, -200) '畫y軸
CurrentX = 290
CurrentY = -5
Print "x" '標(biāo)示x軸
CurrentX = 5
CurrentY = 200
Print "y" '標(biāo)示y軸
CurrentX = 5
CurrentY = -5
Print "0" '標(biāo)示原點(diǎn)
自己用GDI+畫的 無論什么什么尺寸的picturebox都行
不過別太小了o(∩_∩)o
代碼放在哪里自己決定啊
最好是放在 picturebox的resize時(shí)間里
每次picturebox大小改變都重畫一次坐標(biāo)
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