Bart644
Jun 3rd, 2001, 06:47 PM
Can anyone show me the code to draw a rectangle that tilts on
a angle.
I would like to be able to draw the rectangle with the line method
in a picture box at any angle that I want useing the mouse.
I would like to use a label to show the angle in degrees that the
rectangle is being drawn.
I know how to use the line method to draw one line ( or side ) on an angle,
but I don’t know the formula to draw the other three sides and keep
all the corners square.
Here is what i have:
Form name = Form1
StartUpPosition = Manual
ScaleMode = 1
Width = 7980
Height = 7560
Picture box name = Picture1
Appearance = 1-3D
BackColor = White
AutoRedraw = True
MousePointer = 2-Cross
Hieght = 5535
Left = 120
Top = 120
Width = 7215
ScaleMode = 3-Pixel
Line control named = Line1 ‘ Used for rubber banding effect
BorderColor = Red
Visable = False
X1 = 120
X2 = 224
Y1 = 312
Y2 = 312
*******************************************
Declarations
Dim a As Long
Dim b As Long
Dim c As Long
Dim d As Long
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
a = X
b = Y
c = X
d = Y
Line1.X1 = a
Line1.Y1 = b
Line1.X2 = c
Line1.Y2 = d
Line1.Visible = True
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
c = X
d = Y
Line1.X2 = c
Line1.Y2 = d
End Sub
Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim e As Long
Dim f As Long
Dim g As Long
Dim h As Long
e = Line1.X1
f = Line1.Y1
g = Line1.X2
h = Line1.Y2
Picture1.Line (e, f)-(g, h), RGB(50, 75, 255)
' Code for the other three sides i think goes here
Line1.X1 = 0
Line1.Y1 = 0
Line1.X2 = 0
Line1.Y2 = 0
Line1.Visible = False
Picture1.Visible = False
Picture1.Visible = True
End Sub
a angle.
I would like to be able to draw the rectangle with the line method
in a picture box at any angle that I want useing the mouse.
I would like to use a label to show the angle in degrees that the
rectangle is being drawn.
I know how to use the line method to draw one line ( or side ) on an angle,
but I don’t know the formula to draw the other three sides and keep
all the corners square.
Here is what i have:
Form name = Form1
StartUpPosition = Manual
ScaleMode = 1
Width = 7980
Height = 7560
Picture box name = Picture1
Appearance = 1-3D
BackColor = White
AutoRedraw = True
MousePointer = 2-Cross
Hieght = 5535
Left = 120
Top = 120
Width = 7215
ScaleMode = 3-Pixel
Line control named = Line1 ‘ Used for rubber banding effect
BorderColor = Red
Visable = False
X1 = 120
X2 = 224
Y1 = 312
Y2 = 312
*******************************************
Declarations
Dim a As Long
Dim b As Long
Dim c As Long
Dim d As Long
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
a = X
b = Y
c = X
d = Y
Line1.X1 = a
Line1.Y1 = b
Line1.X2 = c
Line1.Y2 = d
Line1.Visible = True
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
c = X
d = Y
Line1.X2 = c
Line1.Y2 = d
End Sub
Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim e As Long
Dim f As Long
Dim g As Long
Dim h As Long
e = Line1.X1
f = Line1.Y1
g = Line1.X2
h = Line1.Y2
Picture1.Line (e, f)-(g, h), RGB(50, 75, 255)
' Code for the other three sides i think goes here
Line1.X1 = 0
Line1.Y1 = 0
Line1.X2 = 0
Line1.Y2 = 0
Line1.Visible = False
Picture1.Visible = False
Picture1.Visible = True
End Sub