-1
我正在創建一個程序,用戶可以在這裏命令一隻烏龜在一個名爲面板1的白色面板上移動。我已經使用烏龜旋轉rotatefliptype
我現在正在在它後面跟上一條線。我有一些想法,包括將像素放置在符合要求的地方。我的一個問題是位置。是否有可能使地點相對於某個點? 我當前的代碼是:VB.NET試圖畫一條線
Sub imageCloner(clonedImage As Image, clonedWidth As Int16, clonedHeight As Int16, clonedLocation As Point)
'clone image
Dim dotImage As New PictureBox()
dotImage.Image = clonedImage
dotImage.Location = clonedLocation
dotImage.Width = clonedWidth
dotImage.Height = clonedHeight
dotImage.SizeMode = picBoxTurtle.SizeMode
panel1.Controls.Add(dotImage)
End Sub
Sub findGradient()
'gradient = rise/run
turtleMovementGradient = (turtleYLocation - turtleOriginalYLocation)/(turtleXLocation - turtleOriginalXLocation)
End Sub
Sub drawLine()
find the gradient
findGradient()
create variables
Dim xcounter As Int16 = 0
Dim ycounter As Int16 = 0
For ycounter = 1 To panel1.Height
For xcounter = 1 To panel1.Width
If ycounter/xcounter = turtleMovementGradient Then
imageCloner(blackDotOnePixel.Image, 1, 1, New Point(panel1.Width - xcounter, panel1.Height - ycounter))
End If
Next
Next
End Sub
的的drawLine()子程序首先運行。 我需要幫助繪製線
我有什麼要放在括號** **來運行這個子程序 –
這是一個事件,所以它只要控制需要重新粉刷被調用,如果包括在你的計劃,你應該看到控件上的文本和行。 – Mike