作业帮 > 综合 > 作业

用Vb设计一个程序,使任意位置的一个矩形以其左下角为中心旋转15度.

来源:学生作业帮 编辑:大师作文网作业帮 分类:综合作业 时间:2024/11/10 11:31:03
用Vb设计一个程序,使任意位置的一个矩形以其左下角为中心旋转15度.
求的是简单的代码 不要那么复杂的!
用Vb设计一个程序,使任意位置的一个矩形以其左下角为中心旋转15度.
我用的是简单的平移和旋转,不知道能不能符合你的要求,在我的机子上能运行,有两个command控件
Dim x(4),y(4)
Private Sub Form_Load()
Scale (-320,240)-(320,-240)
Cls
End Sub
Private Sub Command2_Click()
x(0) = Val(InputBox("请输入矩形左下角的横坐标","矩形旋转",0))
y(0) = Val(InputBox("请输入矩形左下角的纵坐标","矩形旋转",0))
w = Val(InputBox("请输入矩形的宽","矩形旋转",100))
h = Val(InputBox("请输入矩形的高","矩形旋转",80))
x(1) = x(0) + w:x(2) = x(0) + w:x(3) = x(0):x(4) = x(0)
y(1) = y(0):y(2) = y(0) + h:y(3) = y(0) + h:y(4) = y(0)
Form1.Line (x(0),y(0))-(x(2),y(2)),QBColor(7),B
End Sub
Private Sub Command1_Click()
rad = 15 * 3.14159 / 180
a = x(0):b = y(0)
For i = 0 To 4
x(i) = x(i) - a
y(i) = y(i) - b
Next i
For i = 1 To 3
xx!= x(i) * Cos(rad) - y(i) * Sin(rad)
yy!= x(i) * Sin(rad) + y(i) * Cos(rad)
x(i) = xx
y(i) = yy
Next i
For i = 0 To 4
x(i) = x(i) + a
y(i) = y(i) + b
Next i
For i = 0 To 3
Line (x(i),y(i))-(x(i + 1),y(i + 1)),QBColor(12)
Next i
End Su