随机图形

本文介绍了一个使用Visual Basic编写的随机图形动画程序,包括随机画圆、随机文字、立体图形及随机图像显示等功能。通过不同的按钮触发各种图形动画效果,如动态绘制随机大小颜色的圆、随机位置大小的文字、立体感的线条图形以及图片的随机展示。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 Private Sub Form_Load()

Command1.Caption = "随机画圆"

Command2.Caption = "随机文字"

Command3.Caption = "立体图形"

Command4.Caption = "随机图像"

Command5.Caption = "退出"

Form1.ScaleMode = 1

Picture1.ScaleMode = 1

Picture2.Picture = LoadPicture

("d:\windows\256color.bmp")

End Sub

'随机画圆动画

Private Sub Command1_Click()

Dim XPos, YPos

Picture1.Cls

Do

nn = Int(100 * Rnd)

If nn > 0 Then

Picture1.DrawWidth = nn

End If

XPos = Rnd * Picture1.ScaleWidth

YPos = Rnd * Picture1.ScaleHeight

Picture1.PSet (XPos, YPos), RGB

(Rnd * 256, Rnd * 256, Rnd * 256)

DoEvents

Loop

End Sub

'随机文字动画

Private Sub Command2_Click()

Picture1.Cls

Do

nn = Int(45 * Rnd)

If nn > 0 Then

Picture1.FontSize = nn

End If

Picture1.CurrentX =

Rnd * Picture1.ScaleWidth - 1000

Picture1.CurrentY =

Rnd * Picture1.ScaleHeight

Picture1.ForeColor =

RGB(Rnd * 256, Rnd * 256, Rnd * 256)

Picture1.Print "随机 OK!"

n = n + 1

If n > 50 Then

n = 0

Picture1.BackColor = QBColor(Rnd * 15)

End If

DoEvents

Loop

End Sub

'立体随机动画

Private Sub Command3_Click()

Dim m, n

Picture1.DrawWidth = 1

Picture1.BackColor = RGB(210, 150, 0)

Picture1.Cls

Do

m = Rnd * Picture1.ScaleWidth

n = Rnd * Picture1.ScaleHeight - 500

For i = 0 To Rnd * 800

Picture1.Line(m,n+2.5*i)-(m+i/2,n+2*i),

RGB(180,180,180)

Picture1.Line(m,n+2.5*i)-(m-i/2,n+2*i),

RGB(80,80,80)

Next i

DoEvents

Loop

End Sub

'随机图像显示

Private Sub Command4_Click()

Do

xx = Rnd * Picture1.Width

yy = Rnd * Picture1.Height

Picture1.PaintPicture Picture2.

Picture, xx, yy,

Picture2.Width, Picture2.Height

DoEvents

Loop

End Sub

'退出按钮

Private Sub Command5_Click()

End

End Sub

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值