■当前位置:首页 >
VB 小程序
100-199 >
VB 万花筒
105. VB 万花筒
本程序用大圆叠加正弦波、大圆叠加小圆的方式,画出千变万化的万花筒图案。
程序运行截图:
http://s16/middle/b1879bb4xc9a9e643265f&690代码 VB 小程序:万花筒" TITLE="VB 代码 VB 小程序:万花筒" />
http://s9/middle/b1879bb4x7a90fd6a28c8&690代码 VB 小程序:万花筒" TITLE="VB 代码 VB 小程序:万花筒" />
http://s8/middle/b1879bb4x7a90fd6b1667&690代码 VB 小程序:万花筒" TITLE="VB 代码 VB 小程序:万花筒" />
http://s14/middle/b1879bb4xc9a9e63aa3ed&690代码 VB 小程序:万花筒" TITLE="VB 代码 VB 小程序:万花筒" />
http://s7/middle/b1879bb4xc9a9e6304586&690代码 VB 小程序:万花筒" TITLE="VB 代码 VB 小程序:万花筒" />
' ''以下是窗体代码,在 VB6 和 WinXP
下调试通过。
'直接将代码粘贴到窗体代码区,不用放置任何控件。
'本人原创,转载请注明来源:http://blog.sina.com.cn/s/blog_b1879bb401018mbu.html
Dim WithEvents Timer1 As Timer
Dim Pic As PictureBox, Comb() As ComboBox, Labe() As Label
Dim Chec As CheckBox, ctP360, C1, C2
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As
Long)
Private Sub Form_Load()
Me.Caption =
"VB 万花筒"
Set Pic =
Controls.Add("vb.PictureBox", "Pic1")
Pic.AutoRedraw
= True: Pic.Visible = True
Pic.BackColor
= &HFFFFFF
Set Chec =
Controls.Add("vb.CheckBox", "Chec1")
Chec.Visible
= True: Chec.Caption = "显示单个图像"
Dim I As
Long, s As Long
s = 8
ReDim Comb(1
To s): ReDim Labe(1 To s)
For I = 1 To
UBound(Comb)
Set
Comb(I) = Controls.Add("vb.ComboBox", "Comb" &
I)
Set
Labe(I) = Controls.Add("vb.Label", "Labe" &
I)
Next
s = 1:
Labe(s).Caption = "花瓣数"
For I = 0 To
10
If
I = 0 Then Comb(s).AddItem I & " 随机"
If
I = 1 Then Comb(s).AddItem I & " 渐变"
If
I > 1 Then Comb(s).AddItem I & "
个"
Next
Comb(s).ListIndex
= 0
s = 2:
Labe(s).Caption = "花瓣高度"
For I = -1 To
11
If
I < 0 Then Comb(s).AddItem I & "
随机"
If
I > -1 And I < 11 Then
Comb(s).AddItem I
If
I = 11 Then Comb(s).AddItem I &
" 渐变"
Next
Comb(s).ListIndex
= 0
s = 3:
Labe(s).Caption = "旋转"
Comb(s).AddItem
"0 旋转"
Comb(s).AddItem
"1 随机"
Comb(s).AddItem
"2 不旋转"
Comb(s).ListIndex
= 1
s = 4:
Labe(s).Caption = "绘图周期"
For I = 1 To
10
Comb(s).AddItem
I & " 个"
Next
Comb(s).ListIndex
= 5
s = 5:
Labe(s).Caption = "周期偏移"
For I = -1 To
10
If
I = -1 Then Comb(s).AddItem I & " 随机"
If
I = 0 Then Comb(s).AddItem I & " 无"
If
I > 0 And I < 10 Then Comb(s).AddItem
I
If
I = 10 Then Comb(s).AddItem I & " 渐变"
Next
Comb(s).ListIndex
= 0
s = 6:
Labe(s).Caption = "线条宽度"
For I = 0 To
10
If
I = 0 Then Comb(s).AddItem I & " 随机"
If
I > 0 Then Comb(s).AddItem I
Next
Comb(s).ListIndex
= 0
s = 7:
Labe(s).Caption = "主圆半径"
For I = 0 To
2
If
I = 0 Then Comb(s).AddItem I & " 随机"