Option Explicit
Private Sub Clear_Click()
Picture1.Cls
End Sub
Private Sub resetVal()
X1 = 0
Y1 = 50
X2 = 30
Y2 = 0
X3 = 0
Y3 = -50
X4 = -30
Y4 = 0
End Sub
Private Sub DrawFigure_Click()
Picture1.Scale (-160, -120)-(160, 120)
resetVal
Picture1.Line (X1, Y1)-(X2, Y2)
Picture1.Line (X2, Y2)-(X3, Y3)
Picture1.Line (X3, Y3)-(X4, Y4)
Picture1.Line (X4, Y4)-(X1, Y1)
End Sub
Private Sub Rotate_Click()
Dim angle As Double
Dim Xn As Double
Dim Yn As Double
angle = Val(Phi.Text) / (180 / 3.141593)
Xn = X1 * Cos(angle) - Y1 * Sin(angle)
Yn = X1 * Sin(angle) + Y1 * Cos(angle)
X1 = Xn
Y1 = Yn
Xn = X2 * Cos(angle) - Y2 * Sin(angle)
Yn = X2 * Sin(angle) + Y2 * Cos(angle)
X2 = Xn
Y2 = Yn
Xn = X3 * Cos(angle) - Y3 * Sin(angle)
Yn = X3 * Sin(angle) + Y3 * Cos(angle)
X3 = Xn
Y3 = Yn
Xn = X4 * Cos(angle) - Y4 * Sin(angle)
Yn = X4 * Sin(angle) + Y4 * Cos(angle)
X4 = Xn
Y4 = Yn
Picture1.Line (X1, Y1)-(X2, Y2), vbRed
Picture1.Line (X2, Y2)-(X3, Y3), vbRed
Picture1.Line (X3, Y3)-(X4, Y4), vbRed
Picture1.Line (X4, Y4)-(X1, Y1), vbRed
End Sub
Private Sub Scale_Click()
Dim xscale As Double
Dim yscale As Double
xscale = Val(Sx.Text)
yscale = Val(Sy.Text)
X1 = X1 * xscale
X2 = X2 * xscale
X3 = X3 * xscale
X4 = X4 * xscale
Y1 = Y1 * yscale
Y2 = Y2 * yscale
Y3 = Y3 * yscale
Y4 = Y4 * yscale
Picture1.Line (X1, Y1)-(X2, Y2), vbGreen
Picture1.Line (X2, Y2)-(X3, Y3), vbGreen
Picture1.Line (X3, Y3)-(X4, Y4), vbGreen
Picture1.Line (X4, Y4)-(X1, Y1), vbGreen
End Sub
Private Sub Translate_Click()
Dim xtrans As Integer
Dim ytrans As Integer
xtrans = Val(Tx.Text)
ytrans = Val(Ty.Text)
X1 = X1 + xtrans
X2 = X2 + xtrans
X3 = X3 + xtrans
X4 = X4 + xtrans
Y1 = Y1 + ytrans
Y2 = Y2 + ytrans
Y3 = Y3 + ytrans
Y4 = Y4 + ytrans
Picture1.Scale (-160, -120)-(160, 120)
Picture1.Line (X1, Y1)-(X2, Y2), vbBlue
Picture1.Line (X2, Y2)-(X3, Y3), vbBlue
Picture1.Line (X3, Y3)-(X4, Y4), vbBlue
Picture1.Line (X4, Y4)-(X1, Y1), vbBlue
End Sub