窗体代码

Option Explicit
Private Sub Command1_Click()
Dim x, y As Integer
Dim x0, y0, x1, y1 As Integer
Dim zoom As Single '缩小倍数
zoom = 1
'以图片中心为圆心旋转
x0 = Picture1.Width / 2
y0 = Picture1.Height / 2
For x1 = 0 To Picture1.Width
For y1 = 0 To Picture1.Height
x = rotate_point(x0, y0, x1, y1, 0, rotate).x + 200
y = rotate_point(x0, y0, x1, y1, 0, rotate).y + 200
Form1.PSet (x / zoom, y / zoom), Picture1.Point(x1, y1)
Next
Next
rotate = rotate + 10
End Sub
模块代码Private Sub Command1_Click()
Dim x, y As Integer
Dim x0, y0, x1, y1 As Integer
Dim zoom As Single '缩小倍数
zoom = 1
'以图片中心为圆心旋转
x0 = Picture1.Width / 2
y0 = Picture1.Height / 2
For x1 = 0 To Picture1.Width
For y1 = 0 To Picture1.Height
x = rotate_point(x0, y0, x1, y1, 0, rotate).x + 200
y = rotate_point(x0, y0, x1, y1, 0, rotate).y + 200
Form1.PSet (x / zoom, y / zoom), Picture1.Point(x1, y1)
Next
Next
rotate = rotate + 10
End Sub

'coordinate type
Option Explicit
Type coodinate
x As Integer
y As Integer
End Type
Public rotate As Single
'function return x and y
Function rotate_point(x0, y0, x1, y1 As Integer, direction As Boolean, angle As Single) As coodinate 'center point(x0,y0) end point(x1,y1) direction=0 clockwise direction=1 counterclockwise
Dim temp, r As Single
r = ((y1 - y0) ^ 2 + (x1 - x0) ^ 2) ^ 0.5
If (x1 - x0) <> 0 Then temp = Atn((y1 - y0) / (x1 - x0))
If x1 < x0 Then temp = temp + 3.14
If x1 > x0 And y1 < y0 Then temp = temp + 6.28
temp = temp + ((-1) ^ direction) * (3.14 * angle / 180)
If temp > 6.28 Then temp = temp - 6.28
If temp < 0 Then temp = temp + 6.28
rotate_point.x = x0 + r * Cos(temp)
rotate_point.y = y0 + r * Sin(temp)
End Function
Option Explicit
Type coodinate
x As Integer
y As Integer
End Type
Public rotate As Single
'function return x and y
Function rotate_point(x0, y0, x1, y1 As Integer, direction As Boolean, angle As Single) As coodinate 'center point(x0,y0) end point(x1,y1) direction=0 clockwise direction=1 counterclockwise
Dim temp, r As Single
r = ((y1 - y0) ^ 2 + (x1 - x0) ^ 2) ^ 0.5
If (x1 - x0) <> 0 Then temp = Atn((y1 - y0) / (x1 - x0))
If x1 < x0 Then temp = temp + 3.14
If x1 > x0 And y1 < y0 Then temp = temp + 6.28
temp = temp + ((-1) ^ direction) * (3.14 * angle / 180)
If temp > 6.28 Then temp = temp - 6.28
If temp < 0 Then temp = temp + 6.28
rotate_point.x = x0 + r * Cos(temp)
rotate_point.y = y0 + r * Sin(temp)
End Function
只有本站会员才能查看附件,请 登录