
如圖,本人學VB不久,想問上圖坐標系是怎么編程實作的?
uj5u.com熱心網友回復:
自己畫圖,坐標轉換uj5u.com熱心網友回復:
Line 方法
在物件上畫直線和矩形。
語法
object.Line [Step] (x1, 1) [Step] (x2, y2), [color], [B][F]
Line 方法的語法有以下物件限定符和部分:
部分 描述
object 可選的。 物件運算式,其值為“應用于”串列中的物件。如果object 省略,具有焦點的表單作為object。
Step 可選的。關鍵字,指定起點坐標,它們相對于由 CurrentX 和 CurrentY 屬性提供的當前圖形位置。
(x1, y1) 可選的。Single (單精度浮點數),直線或矩形的起點坐標。ScaleMode 屬性決定了使用的度量單位。如果省略,線起始于由 CurrentX 和 CurrentY 指示的位置。
Step 可選的。關鍵字,指定相對于線的起點的終點坐標。
(x2, y2) 必需的。Single (單精度浮點數),直線或矩形的終點坐標。
color 可選的。Long (長整型數),畫線時用的 RGB 顏色。如果它被省略,則使用 ForeColor 屬性值。可用 RGB 函式或 QBColor 函式指定顏色。
B 可選的。如果包括,則利用對角坐標畫出矩形。
F 可選的。如果使用了 B 選項,則 F 選項規定矩形以矩形邊框的顏色填充。不能不用 B 而用 F。如果不用 F 光用 B,則矩形用當前的 FillColor 和 FillStyle 填充。FillStyle 的預設值為 transparent。
說明
畫聯結的線時,前一條線的終點就是后一條線的起點。
線的寬度取決于 DrawWidth 屬性值。在背景上畫線和矩形的方法取決于 DrawMode 和 DrawStyle 屬性值。
執行 Line 方法時, CurrentX 和 CurrentY 屬性被引數設定為終點。
這個方法不能用于With...End With 陳述句塊。
CurrentX、CurrentY 屬性
回傳或設定下一次列印或繪圖方法的 水平 (CurrentX) 或垂直 (CurrentY) 坐標。設計時不可用。
語法
object.CurrentX [= x]
object.CurrentY [= y]
CurrentX 和 CurrentY 屬性語法包含下面部分:
部分 描述
Object 物件運算式,其值是“應用于”串列中的一個物件。
X 確定水平坐標的數值。
Y 確定垂直坐標的數值。
說明
坐標從物件的左上角開始測量。在物件的左邊 CurrentX 屬性值為 0,上邊的 CurrentY 為 0。坐標以緹為單位表示,或以 ScaleHeight、ScaleWidth、ScaleLeft、ScaleTop 和 ScaleMode 屬性定義的度量單位來表示。
用下面的圖形方法時,CurrentX 和 CurrentY 的設定值按下述說明改變:
方法 設定 CurrentX, CurrentY 為:
Circle 物件的中心。
Cls 0,0。
EndDoc 0,0。
Line 線終點。
NewPage 0,0。
Print 下一個列印位置。
Pset 畫出的點。
uj5u.com熱心網友回復:
Print 方法
在 Immediate 視窗中顯示文本。
語法
object.Print [outputlist]
Print 方法的語法具有下列物件限定符和部分:
部分 描述
object 必需的。物件運算式,其值為“應用于”串列中的物件。
outputlist 可選的。要列印的運算式或運算式的串列。如果省略,則列印一空白行。
outputlist 引數具有以下語法和部分:
{Spc(n) | Tab(n)} expression charpos
部分 描述
Spc(n) 可選的。用來在輸出中插入空白字符,這里,n 為要插入的空白字符數。
Tab(n) 可選的。用來將插入點定位在絕對列號上,這里,n 為列號。使用無引數的 Tab(n) 將插入點定位在下一個列印區的起始位置。
expression 可選。要列印的數值運算式或字串運算式。
charpos 可選。指定下個字符的插入點。使用分號 (;) 直接將插入點定位在上一個被顯示的字符之后。使用 Tab(n) 將插入點定位在絕對列號上。使用無引數的 Tab 將插入點定位在下一個列印區的起始位置。如果省略 charpos,則在下一行列印下一字符。
說明
可以用空白或分號來分隔多個運算式。
對系統指定的國別設定,用小數點分隔符將所有列印到 Immediate 視窗的資料正確格式化。關鍵字要用適用于主應用程式的語言輸出。
對于 Boolean 資料,或者列印 True 或者列印 False。根據主機應用程式的地區設定來翻譯 True 和 False 關鍵字。
使用系統能識別的標準短日期格式書寫 Date 資料。當日期或時間部件丟失或為零時,只書寫已提供的部件。
如果 outputlist 資料是 Empty,則無內容可寫。但是,如果 outputlist 資料是 Null,則輸出 Null。在輸出 Null 關鍵字時,要把關鍵字正確翻譯出來。
要把錯誤資料作為 Error errorcode 輸出。在輸出 Error 關鍵字時,要把關鍵字正確翻譯出來。
如果在具有預設顯示空間的模塊外使用此方法,則需要 object。例如,如果沒有指定物件就在標準模塊上呼叫此方法,則將導致錯誤發生,但是,如果在表單模塊上進行呼叫,則會在表單上顯示“outputlist”。
注意 因為 Print 方法是按照字符比例進行列印,所以字符數與字符所占據的寬度固定的列的數目無關。例如,像 “W” 這樣的寬字母占據的寬度超過一固定列寬,而像 "i" 這樣的窄字母占據的寬度則較小。考慮到要使用比平均字符更寬的空間,表列一定要留有足夠余地。另外,也可以使用固定間距的字體(像 Courier 字體)來確保每一字符均只占一列。
uj5u.com熱心網友回復:
ScaleHeight、ScaleWidth 屬性
當使用圖形方法或調整控制元件位置時,回傳或設定物件內部的水平 (ScaleWidth) 或垂直 (ScaleHeight) 度量單位。對于 MDIForm 物件,在設計時 是不可用的,并且在運行時是只讀的。
語法
object.ScaleHeight [= value]
object.ScaleWidth [= value]
ScaleHeight 和 ScaleWidth 屬性的語法包含下面部分:
部分 描述
Object 物件運算式,其值是“應用于”串列中的一個物件。
Value 一個用來指定水平或垂直度量的數值運算式。
說明
能夠使用這些屬性來為繪圖或列印創建一個自定義的坐標比例尺。例如,陳述句 ScaleHeight = 100 將改變表單實際內部高度的度量單位。取代當前高度為 n 個單位(緹、像素、...),高度將變為 100 個自定義單位。因而,50 個單位的距離就是物件的高度/寬度的一半,101 個單位的距離將超出物件 1 個單位。
為了定義基于標準度量單位的比例尺,例如緹、磅、像素、字符、英寸、毫米、或厘米應使用 ScaleMode 屬性。
這些屬性設定為正值將使坐標從上向下及從左向右增加。它們設定為負值將使坐標從下向上及從右向左增加。
這些屬性和相關的 ScaleLeft 與 ScaleTop 屬性的使用,可以建立起一個完全的帶有正、負坐標的坐標系統。所有這四個 Scale 屬性與 ScaleMode 屬性按下面的方式進行互動作用:
把其它任何 Scale 屬性設定為任何值都將使 ScaleMode 自動地設定為 0。ScaleMode 等于 0 是用戶定義。
把 ScaleMode 設定為一個大于 0 的數,將使 ScaleHeight 和 ScaleWidth 的度量單位發生改變,并將 ScaleLeft 和 ScaleTop 設定為 0。另外,CurrentX 和 CurrentY 的設定值將發生改變以反映當前點的新坐標。
也可以在陳述句中使用 Scale 方法設定 ScaleHeight、ScaleWidth、ScaleLeft 和 ScaleTop 屬性。
注意 ScaleHeight 和 ScaleWidth 屬性與 Height 和 Width 屬性是不一樣的。
對于 MDIForm 物件,ScaleHeight 和 ScaleWidth 僅涉及表單中未被 PictureBox 控制元件覆寫的區域。在 MDIForm 的 Resize 事件中應避免使用這些屬性調整 PictureBox 的大小。
uj5u.com熱心網友回復:
全自己畫先建立一個坐標系,然后就按坐標往上畫好了。
uj5u.com熱心網友回復:
可以參考以下代碼修改實作繪制:Option Explicit
Dim i As Long
Dim j As Long
Dim X As Long
Dim Y As Long
Dim fnt As Long
Dim txt As Variant
Dim dd As Variant
Dim xx
Dim yy
Dim colvb
Dim wp
Public Function xp(colvb As Variant, xx As Variant, yy As Variant, txt As Variant)
Picture1.ForeColor = colvb
Picture1.CurrentX = xx
Picture1.CurrentY = yy
Picture1.Print txt '
End Function
Private Sub Form_Activate()
colvb = vbWhite
xx = 100
yy = 150
txt = "℃"
wp = xp(colvb, xx, yy, txt)
yy = 350
txt = "150"
wp = xp(colvb, xx, yy, txt)
xx = 200
yy = 1350
txt = "100"
wp = xp(colvb, xx, yy, txt)
yy = 2350
txt = " 50"
wp = xp(colvb, xx, yy, txt)
xx = 300
yy = 3350
txt = "0"
wp = xp(colvb, xx, yy, txt)
xx = 100
yy = 4350
txt = "-50"
wp = xp(colvb, xx, yy, txt)
xx = 0
yy = 5350
txt = "-100"
wp = xp(colvb, xx, yy, txt)
xx = 0
yy = 6350
txt = "-150"
wp = xp(colvb, xx, yy, txt)
xx = 10800 + 100
yy = 150
txt = "℃"
wp = xp(colvb, xx, yy, txt)
yy = 350
txt = "150"
wp = xp(colvb, xx, yy, txt)
xx = 10800 + 200
yy = 1350
txt = "100"
wp = xp(colvb, xx, yy, txt)
yy = 2350
txt = " 50"
wp = xp(colvb, xx, yy, txt)
yy = 3350
xx = 10800 + 300
txt = "0"
wp = xp(colvb, xx, yy, txt)
xx = 10800 + 100
yy = 4350
txt = "-50"
wp = xp(colvb, xx, yy, txt)
xx = 10800 + 0
yy = 5350
txt = "-100"
wp = xp(colvb, xx, yy, txt)
yy = 6350
txt = "-150"
wp = xp(colvb, xx, yy, txt)
'真空坐標
colvb = vbRed
xx = 11400
yy = 150
txt = "Pa"
wp = xp(colvb, xx, yy, txt)
yy = 350
txt = "10000"
wp = xp(colvb, xx, yy, txt)
xx = 11500
yy = 1850
txt = "1000"
wp = xp(colvb, xx, yy, txt)
yy = 3350
xx = 11600
txt = "100"
wp = xp(colvb, xx, yy, txt)
xx = 11700
yy = 4850
txt = "10"
wp = xp(colvb, xx, yy, txt)
xx = 11500
yy = 6350
txt = " 1"
wp = xp(colvb, xx, yy, txt)
xx = 500
yy = 150
txt = "Pa"
wp = xp(colvb, xx, yy, txt)
yy = 150
xx = 2200
txt = "6hr"
wp = xp(colvb, xx, yy, txt)
xx = 4000
txt = "12hr"
wp = xp(colvb, xx, yy, txt)
xx = 5800
txt = "18hr"
wp = xp(colvb, xx, yy, txt)
xx = 7600
txt = "24hr"
wp = xp(colvb, xx, yy, txt)
xx = 9400
txt = "30hr"
wp = xp(colvb, xx, yy, txt)
xx = 13000
txt = "42hr"
wp = xp(colvb, xx, yy, txt)
xx = 14800
txt = "48hr"
wp = xp(colvb, xx, yy, txt)
xx = 16600
txt = "54hr"
wp = xp(colvb, xx, yy, txt)
xx = 18400
txt = "60hr"
wp = xp(colvb, xx, yy, txt)
xx = 20200
txt = "66hr"
wp = xp(colvb, xx, yy, txt)
xx = 22000
txt = "72hr"
wp = xp(colvb, xx, yy, txt)
xx = 23800
txt = "78hr"
wp = xp(colvb, xx, yy, txt)
xx = 25600
txt = "84hr"
wp = xp(colvb, xx, yy, txt)
xx = 27400
txt = "90hr"
wp = xp(colvb, xx, yy, txt)
xx = 29200
txt = "96hr"
wp = xp(colvb, xx, yy, txt)
yy = 350
txt = "10000"
wp = xp(colvb, xx, yy, txt)
xx = 600
yy = 1850
txt = "1000"
wp = xp(colvb, xx, yy, txt)
yy = 3350
xx = 600
txt = "100"
wp = xp(colvb, xx, yy, txt)
xx = 700
yy = 4850
txt = "10"
wp = xp(colvb, xx, yy, txt)
xx = 600
yy = 6350
txt = "1"
wp = xp(colvb, xx, yy, txt)
xx = 22100
yy = 350
txt = "10000"
wp = xp(colvb, xx, yy, txt)
yy = 1850
txt = "1000"
wp = xp(colvb, xx, yy, txt)
yy = 3350
txt = "100"
wp = xp(colvb, xx, yy, txt)
yy = 4850
txt = " 10"
wp = xp(colvb, xx, yy, txt)
yy = 6350
txt = " 1"
wp = xp(colvb, xx, yy, txt)
'畫格
'Picture1.ForeColor = vbWhite
'Picture1.Line (450, 700)-(500, 700)
'Picture1.Line (450, 1000)-(500, 1000)
'Picture1.Line (450, 1300)-(500, 1300)
'Picture1.Line (450, 1600)-(500, 1600)
Picture1.ForeColor = vbRed
Picture1.Line (500, 1900)-(29300, 1900)
Picture1.Line (500, 4900)-(29300, 4900)
Picture1.Line (500, 566.7)-(550, 566.7)
Picture1.Line (500, 733.3)-(550, 733.3)
Picture1.Line (500, 900)-(550, 900)
Picture1.Line (500, 1066.7)-(550, 1066.7)
Picture1.Line (500, 1233.3)-(550, 1233.3)
Picture1.Line (500, 1400)-(550, 1400)
Picture1.Line (500, 1566.7)-(550, 1566.7)
Picture1.Line (500, 1733.3)-(550, 1733.3)
Picture1.Line (500, 2066.7)-(550, 2066.7)
Picture1.Line (500, 2233.3)-(550, 2233.3)
Picture1.Line (500, 2400)-(550, 2400)
Picture1.Line (500, 2566.7)-(550, 2566.7)
Picture1.Line (500, 2733.3)-(550, 2733.3)
Picture1.Line (500, 2900)-(550, 2900)
Picture1.Line (500, 3066.7)-(550, 3066.7)
Picture1.Line (500, 3233.3)-(550, 3233.3)
Picture1.Line (500, 3566.7)-(550, 3566.7)
Picture1.Line (500, 3733.3)-(550, 3733.3)
Picture1.Line (500, 3900)-(550, 3900)
Picture1.Line (500, 4066.7)-(550, 4066.7)
Picture1.Line (500, 4233.3)-(550, 4233.3)
Picture1.Line (500, 4400)-(550, 4400)
Picture1.Line (500, 4566.7)-(550, 4566.7)
Picture1.Line (500, 4733.3)-(550, 4733.3)
Picture1.Line (500, 5066.7)-(550, 5066.7)
Picture1.Line (500, 5233.3)-(550, 5233.3)
Picture1.Line (500, 5400)-(550, 5400)
Picture1.Line (500, 5566.7)-(550, 5566.7)
Picture1.Line (500, 5733.3)-(550, 5733.3) '000
Picture1.Line (500, 5900)-(550, 5900)
Picture1.Line (500, 6066.7)-(550, 6066.7)
Picture1.Line (500, 6233.3)-(550, 6233.3)
Picture1.ForeColor = vbWhite
Picture1.Line (450, 400)-(29300, 400)
Picture1.Line (450, 1400)-(29300, 1400)
Picture1.Line (450, 2400)-(29300, 2400)
Picture1.Line (450, 3400)-(29300, 3400)
Picture1.Line (450, 4400)-(29300, 4400)
Picture1.Line (450, 5400)-(29300, 5400)
Picture1.Line (450, 6400)-(29300, 6400)
For i = 1 To 30
Picture1.Line (450, 400 + i * 200)-(500, 400 + i * 200)
Next
Picture1.Line (500 + 0, 400)-(500 + 0, 6400)
Picture1.Line (1400 + 0, 400)-(1400 + 0, 6400)
Picture1.Line (2300 + 0, 400)-(2300 + 0, 6400)
Picture1.Line (3200 + 0, 400)-(3200 + 0, 6400)
Picture1.Line (4100 + 0, 400)-(4100 + 0, 6400)
Picture1.Line (5000 + 0, 400)-(5000 + 0, 6400)
Picture1.Line (5900 + 0, 400)-(5900 + 0, 6400)
Picture1.Line (6800 + 0, 400)-(6800 + 0, 6400)
Picture1.Line (7700 + 0, 400)-(7700 + 0, 6400)
Picture1.Line (8600 + 0, 400)-(8600 + 0, 6400)
Picture1.Line (9500 + 0, 400)-(9500 + 0, 6400)
Picture1.Line (10400 + 0, 400)-(10400 + 0, 6400)
Picture1.Line (11300, 400)-(11300, 6400)
Picture1.Line (12200, 400)-(12200, 6400)
Picture1.Line (13100, 400)-(13100, 6400)
Picture1.Line (14000, 400)-(14000, 6400)
Picture1.Line (14900, 400)-(14900, 6400)
Picture1.Line (15800, 400)-(15800, 6400)
Picture1.Line (16700, 400)-(16700, 6400)
Picture1.Line (17600, 400)-(17600, 6400)
Picture1.Line (18500, 400)-(18500, 6400)
Picture1.Line (19400, 400)-(19400, 6400)
Picture1.Line (20300, 400)-(20300, 6400)
Picture1.Line (21200, 400)-(21200, 6400)
Picture1.Line (22100, 400)-(22100, 6400)
Picture1.Line (23000, 400)-(23000, 6400)
Picture1.Line (23900, 400)-(23900, 6400)
Picture1.Line (24800, 400)-(24800, 6400) '000
Picture1.Line (25700, 400)-(25700, 6400) '000
Picture1.Line (26600, 400)-(26600, 6400) '000
Picture1.Line (27500, 400)-(27500, 6400) '000
Picture1.Line (28400, 400)-(28400, 6400) '000
Picture1.Line (29300, 400)-(29300, 6400)
End Sub
Private Sub Form_Load()
Picture1.BackColor = vbBlack
End Sub
uj5u.com熱心網友回復:
樓上的,畫那些“網格線”,不能用回圈嗎?
uj5u.com熱心網友回復:
可以用回圈,懶得改了。
uj5u.com熱心網友回復:
回圈和
展開后回圈
各有各的
優缺點。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/59422.html
標籤:多媒體
