CSDN博客

img cxmty

图形旋转

发表于2003/10/31 21:32:00  658人阅读

‘在窗体上加两个picturebox控件,五个option控件放在frame框架上,一个按钮

Option Explicit
Const Pi = 3.1416
Dim JiaoDu As Double
Function b(i)
Dim x As Integer, y As Integer
Dim X1 As Integer, Y1 As Integer
Dim X2 As Double, Y2 As Double
Dim X3 As Double, Y3 As Double
JiaoDu = Option1(i).Caption

Picture2.Visible = True
Picture2.Cls

Dim Hudu As Double
 Hudu = JiaoDu * Pi / 180

 Picture1.ScaleMode = vbPixels
 Picture2.ScaleMode = vbPixels
For x = 0 To Picture2.ScaleWidth

 X1 = x - Picture2.ScaleWidth / 2
For y = 0 To Picture2.ScaleHeight
   Y1 = y - Picture2.ScaleHeight / 2
   X2 = X1 * Cos(-Hudu) + Y1 * Sin(-Hudu)
   Y2 = Y1 * Cos(-Hudu) - X1 * Sin(-Hudu)
   X3 = X2 + Picture1.ScaleWidth / 2
   Y3 = Y2 + Picture1.ScaleHeight / 2
 If X3 > 0 And X3 < Picture1.ScaleWidth - 1 And Y3 > 0 And Y3 < Picture1.ScaleHeight - 1 Then
  Picture2.PSet (x, y), Picture1.Point(X3, Y3)
 End If
 Next y
Next x
 
   Picture1.Visible = False
  End Function


Private Sub Command1_Click()
Dim i As Single
If Option1(0).Value = True Then
    Shape1.Visible = False
 
   Call b(0)
ElseIf Option1(1).Value = True Then
 
   Shape1.Visible = False
   Call b(1)
ElseIf Option1(2).Value = True Then
   Shape1.Visible = False
  
   Call b(2)
ElseIf Option1(3).Value = True Then
   Shape1.Visible = False
   Call b(3)
 Else
   Shape1.Visible = True
   Picture2.Cls
End If
 
 End Sub

Private Sub Form_Load()
Picture2.Visible = True
Picture1.Visible = False

Shape1.Visible = True
End Sub

Private Sub Frame1_Click()  ‘单击框架恢复
 Shape1.Visible = True
   Picture2.Cls
End Sub

0 0

相关博文

我的热门文章

img
取 消
img