I am trying to project a line from the center of a movable box(picturebox) at a specific angle . I get a line projection from the box at a radian angle but cannot get it to project from the center of the box and i need the angle based off the top of a second picture box. And would love a tutorial on how to contain the line in the picture box and when it comes to the border of the picture box reflect at the same angle as the original.
Here is my code that projects a line on the form not within the picture box.
Picture box 2 is teh one the line is projected from.
Thanks.
Here is my code that projects a line on the form not within the picture box.
VB.NET:
Private Sub Form1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox2.Click
' Draw line in picture box at radian angle
Dim myPen As New System.Drawing.Pen(Color.Black)
Dim formGraphics As System.Drawing.Graphics
Dim cx1 As New Integer
Dim cy1 As New Integer
Dim p2x As New Integer
Dim p2y As New Integer
p2x = PictureBox2.Location.X
p2y = PictureBox2.Location.Y
cy1 = Convert.ToInt32(Math.Cos(p2x) * 50)
cx1 = Convert.ToInt32(Math.Sin(p2y) * 50)
formGraphics = Me.CreateGraphics()
formGraphics.DrawLine(myPen, p2x, p2y, cx1, cy1)
myPen.Dispose()
formGraphics.Dispose()
End Sub
Thanks.