📄 变幻线.frm
字号:
VERSION 5.00
Begin VB.Form frmMain
Caption = "Form1"
ClientHeight = 6240
ClientLeft = 60
ClientTop = 345
ClientWidth = 7410
LinkTopic = "Form1"
ScaleHeight = 6240
ScaleWidth = 7410
StartUpPosition = 3 '窗口缺省
Begin VB.Timer Timer1
Enabled = 0 'False
Interval = 50
Left = 6600
Top = 3840
End
Begin VB.CommandButton Command2
Caption = "停止"
Height = 495
Left = 6240
TabIndex = 2
Top = 5280
Width = 1095
End
Begin VB.CommandButton Command1
Caption = "开始"
Height = 495
Left = 6240
TabIndex = 1
Top = 4560
Width = 1095
End
Begin VB.PictureBox Picture1
BackColor = &H00000000&
ForeColor = &H00FFFFFF&
Height = 6015
Left = 120
ScaleHeight = 5955
ScaleWidth = 5955
TabIndex = 0
Top = 120
Width = 6015
End
End
Attribute VB_Name = "frmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim x1 As Long, x2 As Long, x3 As Long, x4 As Long
Dim y1 As Long, y2 As Long, y3 As Long, y4 As Long
Dim d1 As Long, d2 As Long, d3 As Long, d4 As Long
Dim iBrightness As Long, iDeltaBrightness As Long
Const Lft = 300
Const Rgt = 5655
Const Tp = 300
Const Btm = 5655
Private Sub Command1_Click()
Timer1.Enabled = True
End Sub
Private Sub Command2_Click()
Timer1.Enabled = False
End Sub
Private Sub Form_Load()
x1 = Lft: y1 = 2700: d1 = 4
x2 = 2400: y2 = Tp: d2 = 3
x3 = 4200: y3 = Btm: d3 = 1
x4 = Rgt: y4 = 3600: d4 = 2
Randomize
iBrightness = 255
iDeltaBrightness = -5
End Sub
Sub DrawLines()
Picture1.Line (x1, y1)-(x2, y2)
Picture1.Line (x2, y2)-(x3, y3)
Picture1.Line (x3, y3)-(x4, y4)
Picture1.Line (x4, y4)-(x1, y1)
End Sub
Private Sub Timer1_Timer()
Picture1.ForeColor = RGB(iBrightness, iBrightness, iBrightness)
Picture1.Cls
movepoint x1, y1, d1
movepoint x2, y2, d2
movepoint x3, y3, d3
movepoint x4, y4, d4
DrawLines
iBrightness = iBrightness + iDeltaBrightness
If iBrightness < 127 Then iDeltaBrightness = 5: iBrightness = 127
If iBrightness > 255 Then iDeltaBrightness = -5: iBrightness = 255
End Sub
Sub movepoint(ByRef px, ByRef py, ByRef d)
Const Spd As Long = 120
Select Case d
Case 1
px = px + Rnd * Spd
If px > Rgt Then px = Rgt: d = d + 1
Case 2
py = py - Rnd * Spd
If py < Tp Then py = Tp: d = d + 1
Case 3
px = px - Rnd * Spd
If px < Lft Then px = Lft: d = d + 1
Case 4
py = py + Rnd * Spd
If py > Btm Then py = Btm: d = d - 3
End Select
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -