主题:[原创]水波荡漾——灰度合成与滚动条应用
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 5055
ClientLeft = 60
ClientTop = 600
ClientWidth = 7515
LinkTopic = "Form1"
ScaleHeight = 5055
ScaleWidth = 7515
StartUpPosition = 3 '窗口缺省
Begin VB.Frame Frame1
Caption = "Frame1"
Height = 2655
Left = 1440
TabIndex = 2
Top = 600
Width = 3975
Begin VB.HScrollBar HScroll4
Height = 135
Left = 2160
TabIndex = 14
Top = 2040
Width = 1335
End
Begin VB.HScrollBar HScroll3
Height = 135
Left = 1080
TabIndex = 5
Top = 2400
Width = 975
End
Begin VB.HScrollBar HScroll2
Height = 255
Left = 720
TabIndex = 4
Top = 1680
Width = 735
End
Begin VB.HScrollBar HScroll1
Height = 255
Left = 600
TabIndex = 3
Top = 720
Width = 735
End
Begin VB.Label Label8
Caption = "Label8"
Height = 255
Left = 3120
TabIndex = 13
Top = 1680
Width = 495
End
Begin VB.Label Label5
Caption = "Label5"
Height = 255
Left = 2040
TabIndex = 12
Top = 1680
Width = 615
End
Begin VB.Label Label7
Caption = "Label7"
Height = 135
Left = 1080
TabIndex = 11
Top = 1320
Width = 375
End
Begin VB.Label Label6
Caption = "Label6"
Height = 255
Left = 2040
TabIndex = 10
Top = 240
Width = 855
End
Begin VB.Label Label4
Caption = "Label4"
Height = 135
Left = 1200
TabIndex = 9
Top = 2160
Width = 135
End
Begin VB.Label Label3
Caption = "Label3"
Height = 135
Left = 120
TabIndex = 8
Top = 2160
Width = 495
End
Begin VB.Label Label2
Caption = "Label2"
Height = 135
Left = 120
TabIndex = 7
Top = 1320
Width = 495
End
Begin VB.Label Label1
Caption = "Label1"
Height = 15
Left = 120
TabIndex = 6
Top = 480
Width = 375
End
End
Begin VB.CommandButton Command1
Caption = "Command1"
Height = 375
Left = 240
TabIndex = 1
Top = 600
Width = 735
End
Begin VB.Timer Timer1
Left = 1800
Top = 1200
End
Begin VB.PictureBox Picture1
Height = 495
Left = 1800
ScaleHeight = 435
ScaleWidth = 1155
TabIndex = 0
Top = 1200
Width = 1215
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Const PI = 3.14159
Const BiaoShi = "水纹"
Const BiaoTiKuan = 650
Const BianKuangKuan = 90
Dim NianChouDu As Integer
Dim YanSeFuDu As Byte
Dim ZhongJianSe As Byte
Dim R As Single
Dim L As Single
Dim i As Byte
Dim ChuXiang As Single
Dim BiLi As Single
Dim YouXiaoGao As Single, YouXiaoKuan As Single
Dim ShuJuKuan As Single
Private Sub Command1_Click()
Dim TiaoGao As Single, ZuoBian As Single
If Command1.Caption = "设置" Then
Me.Caption = BiaoShi & ":设置"
Picture1.Visible = False
Timer1.Enabled = False
Frame1.Visible = True
Command1.Caption = "确定"
Frame1.Move YouXiaoKuan / 20, YouXiaoGao / 20, YouXiaoKuan * 0.75, YouXiaoGao * 0.9
TiaoGao = Frame1.Height / 13
ZuoBian = Frame1.Width / 10
Label1.Move ZuoBian, TiaoGao, TextWidth(Label1), TiaoGao
Label6.Move ZuoBian * 1.5 + Label1.Width, TiaoGao, ShuJuKuan, TiaoGao
Label6 = Int(BiLi * 100 + 0.5) & "%"
HScroll1.Move ZuoBian * 2, TiaoGao * 2.2, ZuoBian * 7, TiaoGao * 0.8
HScroll1.Max = 100
HScroll1.Min = 30
HScroll1.LargeChange = 10
HScroll1.Value = Int(BiLi * 100 + 0.5)
Label2.Move ZuoBian, TiaoGao * 4, TextWidth(Label2), TiaoGao
Label7.Move ZuoBian * 1.5 + Label2.Width, TiaoGao * 4, ShuJuKuan, TiaoGao
Label7 = ZhongJianSe
HScroll2.Move ZuoBian * 2, TiaoGao * 5.2, ZuoBian * 7, TiaoGao * 0.8
HScroll2.Max = 255
HScroll2.Min = 0
HScroll2.LargeChange = 20
HScroll2.Value = ZhongJianSe
Label5.Move ZuoBian, TiaoGao * 7, TextWidth(Label5), TiaoGao
Label8.Move ZuoBian * 1.5 + Label2.Width, TiaoGao * 7, ShuJuKuan, TiaoGao
Label8 = YanSeFuDu
HScroll4.Move ZuoBian * 2, TiaoGao * 8.2, ZuoBian * 7, TiaoGao * 0.8
HScroll4.LargeChange = 5
HScroll4.Min = 0
HScroll4.Value = YanSeFuDu
HScroll4.Max = 255 - HScroll2.Value
Label3.Move ZuoBian, TiaoGao * 10, TextWidth(Label3), TiaoGao
Label4.Move ZuoBian * 1.5 + Label2.Width, TiaoGao * 10, ShuJuKuan, TiaoGao
Label4 = NianChouDu
HScroll3.Move ZuoBian * 2, TiaoGao * 11.2, ZuoBian * 7, TiaoGao * 0.8
HScroll3.Min = 1
HScroll3.Value = NianChouDu
HScroll3.Max = 20
Else
Me.Caption = BiaoShi
Command1.Caption = "设置"
BiLi = HScroll1 / 100
ZhongJianSe = HScroll2
YanSeFuDu = HScroll4
NianChouDu = HScroll3
JieMianSheZhi
End If
End Sub
Private Sub Form_Click()
End
End Sub
Private Sub Form_Load()
ShuJuKuan = TextWidth("1111")
BiLi = 0.3
NianChouDu = 10
YanSeFuDu = 20
ZhongJianSe = 220
Command1.Caption = "设置"
Label1 = "窗口占屏幕的比例"
Label2 = "灰度中间值"
Label3 = "液体粘稠度"
Label5 = "灰度波动程度"
Frame1.Caption = ""
JieMianSheZhi
Timer1.Interval = 100
End Sub
Private Sub HScroll1_Change()
Label6 = HScroll1.Value
End Sub
Private Sub HScroll2_Change()
Label7 = HScroll2.Value
If HScroll2 > 255 - HScroll2 Then
HScroll4.Max = HScroll2
Else
HScroll4.Max = 255 - HScroll2
End If
End Sub
Private Sub HScroll3_Change()
Label4 = HScroll3
End Sub
Private Sub HScroll4_Change()
Label8 = HScroll4.Value
End Sub
Private Sub Picture1_Click()
End
End Sub
Private Sub Timer1_Timer()
ChuXiang = ChuXiang - 1 / NianChouDu
If ChuXiang < -L Then ChuXiang = ChuXiang + L
For R = 2 To Picture1.Height * 5 / 6
k = R / L
i = YanSeFuDu * (1 - R * 6 / 5 / Picture1.Height) * Cos(k * 2 * PI + ChuXiang) + ZhongJianSe
Picture1.Circle (Picture1.Width / 2, Picture1.Height / 2), R, RGB(i, i, i)
Next R
End Sub
Private Sub JieMianSheZhi()
Dim AnNiuGao As Single, AnNiuKuan As Single, AnNiuZuo As Single
Width = Screen.Width * BiLi
Height = Width * 0.75
Me.Move (Screen.Width - Width) / 2, (Screen.Height - Height) / 2
YouXiaoGao = Height - BiaoTiKuan
YouXiaoKuan = Width - BianKuangKuan
Picture1.Visible = True
Picture1.Move 0, 0, YouXiaoKuan * 0.8, YouXiaoGao
AnNiuGao = YouXiaoGao / 9
AnNiuKuan = YouXiaoKuan * 0.16
AnNiuZuo = YouXiaoKuan * 0.82
Command1.Move AnNiuZuo, 7 * AnNiuGao, AnNiuKuan, AnNiuGao
L = 7000 / NianChouDu
Me.Caption = BiaoShi
Frame1.Visible = False
Timer1.Enabled = True
End Sub
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 5055
ClientLeft = 60
ClientTop = 600
ClientWidth = 7515
LinkTopic = "Form1"
ScaleHeight = 5055
ScaleWidth = 7515
StartUpPosition = 3 '窗口缺省
Begin VB.Frame Frame1
Caption = "Frame1"
Height = 2655
Left = 1440
TabIndex = 2
Top = 600
Width = 3975
Begin VB.HScrollBar HScroll4
Height = 135
Left = 2160
TabIndex = 14
Top = 2040
Width = 1335
End
Begin VB.HScrollBar HScroll3
Height = 135
Left = 1080
TabIndex = 5
Top = 2400
Width = 975
End
Begin VB.HScrollBar HScroll2
Height = 255
Left = 720
TabIndex = 4
Top = 1680
Width = 735
End
Begin VB.HScrollBar HScroll1
Height = 255
Left = 600
TabIndex = 3
Top = 720
Width = 735
End
Begin VB.Label Label8
Caption = "Label8"
Height = 255
Left = 3120
TabIndex = 13
Top = 1680
Width = 495
End
Begin VB.Label Label5
Caption = "Label5"
Height = 255
Left = 2040
TabIndex = 12
Top = 1680
Width = 615
End
Begin VB.Label Label7
Caption = "Label7"
Height = 135
Left = 1080
TabIndex = 11
Top = 1320
Width = 375
End
Begin VB.Label Label6
Caption = "Label6"
Height = 255
Left = 2040
TabIndex = 10
Top = 240
Width = 855
End
Begin VB.Label Label4
Caption = "Label4"
Height = 135
Left = 1200
TabIndex = 9
Top = 2160
Width = 135
End
Begin VB.Label Label3
Caption = "Label3"
Height = 135
Left = 120
TabIndex = 8
Top = 2160
Width = 495
End
Begin VB.Label Label2
Caption = "Label2"
Height = 135
Left = 120
TabIndex = 7
Top = 1320
Width = 495
End
Begin VB.Label Label1
Caption = "Label1"
Height = 15
Left = 120
TabIndex = 6
Top = 480
Width = 375
End
End
Begin VB.CommandButton Command1
Caption = "Command1"
Height = 375
Left = 240
TabIndex = 1
Top = 600
Width = 735
End
Begin VB.Timer Timer1
Left = 1800
Top = 1200
End
Begin VB.PictureBox Picture1
Height = 495
Left = 1800
ScaleHeight = 435
ScaleWidth = 1155
TabIndex = 0
Top = 1200
Width = 1215
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Const PI = 3.14159
Const BiaoShi = "水纹"
Const BiaoTiKuan = 650
Const BianKuangKuan = 90
Dim NianChouDu As Integer
Dim YanSeFuDu As Byte
Dim ZhongJianSe As Byte
Dim R As Single
Dim L As Single
Dim i As Byte
Dim ChuXiang As Single
Dim BiLi As Single
Dim YouXiaoGao As Single, YouXiaoKuan As Single
Dim ShuJuKuan As Single
Private Sub Command1_Click()
Dim TiaoGao As Single, ZuoBian As Single
If Command1.Caption = "设置" Then
Me.Caption = BiaoShi & ":设置"
Picture1.Visible = False
Timer1.Enabled = False
Frame1.Visible = True
Command1.Caption = "确定"
Frame1.Move YouXiaoKuan / 20, YouXiaoGao / 20, YouXiaoKuan * 0.75, YouXiaoGao * 0.9
TiaoGao = Frame1.Height / 13
ZuoBian = Frame1.Width / 10
Label1.Move ZuoBian, TiaoGao, TextWidth(Label1), TiaoGao
Label6.Move ZuoBian * 1.5 + Label1.Width, TiaoGao, ShuJuKuan, TiaoGao
Label6 = Int(BiLi * 100 + 0.5) & "%"
HScroll1.Move ZuoBian * 2, TiaoGao * 2.2, ZuoBian * 7, TiaoGao * 0.8
HScroll1.Max = 100
HScroll1.Min = 30
HScroll1.LargeChange = 10
HScroll1.Value = Int(BiLi * 100 + 0.5)
Label2.Move ZuoBian, TiaoGao * 4, TextWidth(Label2), TiaoGao
Label7.Move ZuoBian * 1.5 + Label2.Width, TiaoGao * 4, ShuJuKuan, TiaoGao
Label7 = ZhongJianSe
HScroll2.Move ZuoBian * 2, TiaoGao * 5.2, ZuoBian * 7, TiaoGao * 0.8
HScroll2.Max = 255
HScroll2.Min = 0
HScroll2.LargeChange = 20
HScroll2.Value = ZhongJianSe
Label5.Move ZuoBian, TiaoGao * 7, TextWidth(Label5), TiaoGao
Label8.Move ZuoBian * 1.5 + Label2.Width, TiaoGao * 7, ShuJuKuan, TiaoGao
Label8 = YanSeFuDu
HScroll4.Move ZuoBian * 2, TiaoGao * 8.2, ZuoBian * 7, TiaoGao * 0.8
HScroll4.LargeChange = 5
HScroll4.Min = 0
HScroll4.Value = YanSeFuDu
HScroll4.Max = 255 - HScroll2.Value
Label3.Move ZuoBian, TiaoGao * 10, TextWidth(Label3), TiaoGao
Label4.Move ZuoBian * 1.5 + Label2.Width, TiaoGao * 10, ShuJuKuan, TiaoGao
Label4 = NianChouDu
HScroll3.Move ZuoBian * 2, TiaoGao * 11.2, ZuoBian * 7, TiaoGao * 0.8
HScroll3.Min = 1
HScroll3.Value = NianChouDu
HScroll3.Max = 20
Else
Me.Caption = BiaoShi
Command1.Caption = "设置"
BiLi = HScroll1 / 100
ZhongJianSe = HScroll2
YanSeFuDu = HScroll4
NianChouDu = HScroll3
JieMianSheZhi
End If
End Sub
Private Sub Form_Click()
End
End Sub
Private Sub Form_Load()
ShuJuKuan = TextWidth("1111")
BiLi = 0.3
NianChouDu = 10
YanSeFuDu = 20
ZhongJianSe = 220
Command1.Caption = "设置"
Label1 = "窗口占屏幕的比例"
Label2 = "灰度中间值"
Label3 = "液体粘稠度"
Label5 = "灰度波动程度"
Frame1.Caption = ""
JieMianSheZhi
Timer1.Interval = 100
End Sub
Private Sub HScroll1_Change()
Label6 = HScroll1.Value
End Sub
Private Sub HScroll2_Change()
Label7 = HScroll2.Value
If HScroll2 > 255 - HScroll2 Then
HScroll4.Max = HScroll2
Else
HScroll4.Max = 255 - HScroll2
End If
End Sub
Private Sub HScroll3_Change()
Label4 = HScroll3
End Sub
Private Sub HScroll4_Change()
Label8 = HScroll4.Value
End Sub
Private Sub Picture1_Click()
End
End Sub
Private Sub Timer1_Timer()
ChuXiang = ChuXiang - 1 / NianChouDu
If ChuXiang < -L Then ChuXiang = ChuXiang + L
For R = 2 To Picture1.Height * 5 / 6
k = R / L
i = YanSeFuDu * (1 - R * 6 / 5 / Picture1.Height) * Cos(k * 2 * PI + ChuXiang) + ZhongJianSe
Picture1.Circle (Picture1.Width / 2, Picture1.Height / 2), R, RGB(i, i, i)
Next R
End Sub
Private Sub JieMianSheZhi()
Dim AnNiuGao As Single, AnNiuKuan As Single, AnNiuZuo As Single
Width = Screen.Width * BiLi
Height = Width * 0.75
Me.Move (Screen.Width - Width) / 2, (Screen.Height - Height) / 2
YouXiaoGao = Height - BiaoTiKuan
YouXiaoKuan = Width - BianKuangKuan
Picture1.Visible = True
Picture1.Move 0, 0, YouXiaoKuan * 0.8, YouXiaoGao
AnNiuGao = YouXiaoGao / 9
AnNiuKuan = YouXiaoKuan * 0.16
AnNiuZuo = YouXiaoKuan * 0.82
Command1.Move AnNiuZuo, 7 * AnNiuGao, AnNiuKuan, AnNiuGao
L = 7000 / NianChouDu
Me.Caption = BiaoShi
Frame1.Visible = False
Timer1.Enabled = True
End Sub