窗体代码如下:
Option Explicit
'视觉上看到的雨,可能是这样的:
'在近似位置反复看到雨丝,
'而不是完全杂乱无章,也不是看到同一个雨丝下落的全过程
'雨的颜色可能是浅灰色混合了背景色
'基于以上认识,用vb模拟下雨。
Dim tmItv As Long '定时器间隔毫秒,>0
Dim howMany As Integer '雨丝数量,≥0
Dim reNew As Single '每帧更新率,0到1的浮点数,比如0.15就是更新15%
Dim alP As Single '像素混合系数,0到1的浮点数,值越大、雨的颜色越接近背景色
Dim Swing As Integer '雨丝在两个相近位置“摆动”的幅度,≥0
Dim leNgth As Integer '雨丝的长度,>0
Dim angLe As Single '雨丝下落的角度,0到180
Dim preciSion As Single '位移的精度,0到1的浮点数,越大越精确
Dim angleHu As Single '雨丝下落的角度转换为弧度
Const PI = 3.14159265358979
Dim inputVar As String '输入的一组参数
Private Type Rain
Rx As Long '雨丝line上端点的坐标
Ry As Long
End Type
Dim rainArr() As Rain
Dim I As Integer
Private Sub Form_Load()
'设计时给窗体指定了一个picture作为背景图片。只有一个定时器控件
Form1.Caption = "It's raining outside...Click to set"
'点击窗体,设置各参数
Fo