English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
所有分類

以下程式碼執行出來是一個太極的圖形(須先加入一個TIMER)
要如何讓這太極圖形能夠以他的中心點來自轉(旋轉)
請各位敎敎我吧
Dim x As Integer
Dim y As Integer
Dim num As Integer



Private Sub Form_Load()
x = 2000
y = 1200
num = 0
End Sub

Private Sub Timer1_Timer()
Const pi = 3.1415926
Const r = 1000
num = num + 1
If num > 6 Then
Exit Sub
End If
w = RGB(255, 255, 255)
b = RGB(0, 0, 0)
FillStyle = 0
Select Case num
Case 1
FillColor = w
Circle (x, y), r
FillColor = b
Case 2
Circle (x, y), r, , -1 / 2 * pi, -3 / 2 * pi
Case 3
Circle (x, y - (r / 2)), r / 2
Case 4
FillColor = w
ForeColor = w
Circle (x, y + (r / 2)), r / 2
Case 5
Circle (x, y - (r / 2)), r / 6
Case 6
FillColor = b
ForeColor = b
Circle (x, y + (r / 2)), r / 6
End Select
End Sub

2007-01-01 17:36:25 · 1 個解答 · 發問者 Anonymous in 電腦與網際網路 程式設計

1 個解答

請注意: num 的作用改變了, 太極圖的起始位置也不一樣
Const sp = 36
Dim x1 As Single, y1 As Single, c(1) As Single
Dim i As Integer

num = num + 1
If (num = sp) Then
num = 0
End If
x1 = r * Cos(pi * num / sp) / 2
y1 = r * Sin(pi * num / sp) / 2
c(0) = RGB(255, 255, 255)
c(1) = RGB(0, 0, 0)
FillStyle = 0

For i = 1 To 6
Select Case i
Case 1
FillColor = c(r1)
Circle (x, y), r
Case 2
FillColor = c(1 - r1)
Circle (x, y), r, , -pi / 180 - pi * num / sp, -pi - pi * num / sp
Case 3
Circle (x + x1, y - y1), r / 2
Case 4
FillColor = c(r1)
ForeColor = c(r1)
Circle (x - x1, y + y1), r / 2
Case 5
Circle (x + x1, y - y1), r / 6
Case 6
FillColor = c(1 - r1)
ForeColor = c(1 - r1)
Circle (x - x1, y + y1), r / 6
End Select
Next i
如果有問題, 請來函討論. 不然, 我可能會錯失你再補充的疑點.

2007-01-02 05:24:38 · answer #1 · answered by JJ 7 · 0 0

fedest.com, questions and answers