五颜六色的清屏效果,雨露式的展现图片



v画圆难题 自己生手碰到这些标题找不到原因希望大神支持
Dim x0 As Single, y0 As Single, x1 As Single, y1 As Single
Dim drawflag As Boolean, start As Boolean
Dim m As Integer
Dim shape As Integer

美高梅开户网址,    

 

 

Private Sub btnLine_Click()
shape = 1
End Sub
Private Sub btnRadiu_Click()
shape = 2
End Sub
Private Sub btnSquare_Click()
shape = 3
五颜六色的清屏效果,雨露式的展现图片。End Sub
Private Sub btnStart_Click()
Picture1.BackColor = RGB(255, 255, 255)
btnStart.Enabled = False
btnStop.Enabled = True
drawflag = True
shape = 1
End Sub
Private Sub btnStop_Click()
btnStart.Enabled = True
btnStop.Enabled = False
drawflag = False
End Sub
Private Sub btnDelete_Click()
Picture1.Cls
End Sub
Private Sub btnColor_Click()
CommonDialog1.ShowColor
Picture1.ForeColor = CommonDialog1.Color
End Sub
Private Sub btnStyle_Click()
Dim a As Integer
a = Val(InputBox(“请输入画笔宽度”, “提醒”, m))
If a = 0 Then
a = m
End If
Picture1.DrawWidth = a
m = Picture1.DrawWidth
End Sub
Private Sub btnExit_Click()
End
End Sub
Private Sub myPaint_Load()
Me.Scale –
Picture1.ForeColor = vbBlack
Picture1.DrawWidth = 1
m = 1
End Sub
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X
As Single, Y As Single)
If Button = 1 And drawflag = True Then
x0 = X
y0 = Y
start = True
End If
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X
As Single, Y As Single)
If Button = 1 And drawflag = True And start = True Then
Select Case shape
Case 1
x1 = X
y1 = Y
Picture1.Line –
x0 = x1
y0 = y1
Case 2
x1 = X
y1 = Y
Case 3
x1 = X
y1 = Y
End Select
End If
End Sub
Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As
Single, Y As Single)
Select Case shape
Case 1
x1 = X
y1 = Y
Picture1.Line –
x0 = x1
y0 = y1
start = False
Case 2
r = Sqr ^ 2 + ^ 2)
Picture1.Circle , r
Case 3
Picture1.Line -, , B
End Select
End Sub

本楷模是以二个stdPicture物件来存图形,之後於PictureBox中以特殊效果来体现。

 

 

本身赶过的标题是 画圆的时候只得呈现百分之三十 或许太大
大过控件大小不现实美高梅开户网址 1
急需化解 马上快要交作业了 qq 834789560

因为大家想体现的只有一个图,所以不想多用另二个PictureBox来存原始图,而後

VB提供了黄金时代对风姿罗曼蒂克强的文字输出和制图功效,
能够在窗口或图片框中利用各样吩咐展现字体或绘制各类图片。灵活选择那几个命令,不只能够成功大多分裂平时的成效,
何况可以为Windows的程序界面扩大相当多精力。上面用简短的例子演示VB中随便动漫的派头。

在有的软件演示中,那风流浪漫屏内容到下黄金年代屏内容间频繁以部分风趣的清屏图案来相互

再画到另叁个PictureBox上,那只有用StdPicture
物件来顶替PictureBox(存来源图)

 

切换,有的像演出舞台上的开幕、闭幕,有的像百叶窗,也是有豆蔻年华部分圆形、菱形等形

,不过BitBlt这一个绘图函式需来源与指标的hDc,而StdPicture物件未有hDc,它唯有

  (生机勃勃)、随机文字动漫

态各异的清屏图案。VB作为一门非凡的WINDOWS下的支付语言,其图形效率也很强。

一个Handle值,以本例来讲,那Handle值正是图片的hBitmap值。所以大家不能不接纳

  在VB中可接纳Print命令举行字符串的显得职业,此命令日常只在当前岗位展现字符串,
但具体操作时可因此CurrentX和CurrentY
调节字符串呈现地方,通过FontSize调节字体的尺寸,
通过ForeColor和BackColor调节字符的前途色和背景观。借使把上述的每一种属性值均使用宝马7系ND
进行自由产生,
即会产生随机字符显示效果。举例在叁个图形框中突显一些新春贺辞,
同期播放神奇的音乐,
那将是意气风发份极好的新春礼物。须求小心一点,由于字体互相覆盖,长日子展现会使窗口展现乱一些,所以最棒按一定时期用“CLS”命令实行窗口消灭。此处表明一下颜色的主宰技巧,假使运用QBColor(库罗德nd*15)格局定义随机颜色,只好在16种颜色中任性发生,
而采取大切诺基GB(昂Corand*256,Sportagend*256,Exigend*256)方式,则能够生出256*256*256种不一致的颜色。具体操作形式请见文后Command1-Click事件中的代码。

笔者们一起能够用其提供的画线语句作出上述的清屏图案,上面包车型客车主次提交了广大的

MemoryDC的方式来做,发生一个MemoryDc後将BitMap图放於其上,之後便能够使用BitBlt来绘图了。需要叁个PictureBox(
Named picture2),叁个Command按钮)

  (二)、立体图形随机动漫

清屏图案程序:

Option Explicit

  即便一向使用绘图语句即能够兑现简单的卡通,
但尽管由此这么些命令绘制作而成自然的立体图形, 并进行随机动漫操作,
那将更具有独特的章程功力。举例下边两行轻巧的一声令下将画出三个装有明显立体感效果的三角锥体,在那之中(M,N)为锥体的上方坐标:

  Sub FilSCrO设置背景象

Private Declare Function BitBlt Lib “gdi32” (ByVal
hDestDC As Long, _

 

  Me.BackColor=RGB(Int(Rnd*256),Int(Rnd*256),Int(Rnd*256))

ByVal x As Long, ByVal y As Long, ByVal nWidth As
Long, _

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

  End Sub

ByVal nHeight As Long, ByVal hSrcDC As Long,
_

 

  Sub ClrScrl()从左右两侧到中等清屏

ByVal xSrc As Long, ByVal ySrc As Long, _

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

  Dim i As
Integer:Randomize:color=RGB(Int(Rnd*256),Int(Rnd*256),

ByVal dwRop As Long) As Long

 

Int(Rnd*256))

Private Declare Function CreateCompatibleDC Lib
“gdi32” _

  假若把显示屏的底色置为暗羊毛白,
在这里窗口内的跋扈地点画出大小十分小器晚成的三角锥,
就疑似在海螺红的荒漠上建起了好多的金字塔,
具备生龙活虎种卓殊的情致。具体操作方法请见文后程序中的Command2-Click事件中的代码。

  For i=0 To ScaleWidth/2

(ByVal hdc As Long) As Long

 

  Line(i,0)-(i,ScaleHeight),color

Private Declare Function SelectObject Lib “gdi32”
_

 

  Line(ScaleWidth-i,0)-(ScaleWidth-i,ScaleHeight),color

(ByVal hdc As Long, ByVal hObject As Long) As
Long

  (三)、演示程序编写制定过程

  Next i

Private Declare Function DeleteDC Lib “gdi32” (ByVal
hdc As Long) As Long

 

  End Sub

Const SRCCOPY = &HCC0020

 

  Sub ClrSer20从南路到左右两侧清屏

Private Picture1 As New StdPicture

  文后是三个实现上述随机动漫的总体演示程序,供给在From1
窗体中放置一个图形框Picture1及四个指令按键Command1-3,
然后把下部的代码填入相应的平地风波处。运营此程序以往, 按下开关1
,则在图片框中张开随机文字展现。按下按钮2,则在图片框中随机突显三角锥体。按下按键3,则脱离程序。此程序在Windows
95系统上VB5.0 意况下调节和测量检验通过。

  Dim i As
Integer:Randomize:color=RGB(Int(Rnd*256),Int(Rnd*256),

 

 

Int(Rnd*256))

Private Sub Command1_Click()

 

  for i=ScaleWidth/2 To 0 Step -1

Dim i As Long

  ′程序策动:

  Line(i,0)-(i,ScaleHeight-1),color

Dim j As Long

 

  Line(ScaleWidth

Dim height5 As Long, width5 As Long

  Private Sub Form-Load()

Dim hMemDc As Long

  Command1.Caption = ″随机文字″

 

  Command2.Caption = ″立体图形″

stdPicture物件的胸襟单位是Himetric所以要转变到Pixel

  Command3.Caption = ″退出″

height5 = ScaleY(Picture1.Height, vbHimetric,
vbPixels)

  Form1.ScaleMode = 1

If height5 > Picture2.ScaleHeight Then

  Picture1.ScaleMode = 1

height5 = Picture2.ScaleHeight

  End Sub

End If

  ′随机文字动漫

width5 = ScaleX(Picture1.Width, vbHimetric,
vbPixels)

  Private Sub Command1-Click()

If width5 > Picture2.ScaleWidth Then

  Picture1.Cls

width5 = Picture2.ScaleWidth

  Do

End If

  nn = Int(45 * Rnd)

Create Memory DC

  If nn > 0 Then

hMemDc = CreateCompatibleDC(Picture2.hdc)

  Picture1.FontSize = nn

将Picture1的BitMap图钦命给hMemDc

  End If

Call SelectObject(hMemDc, Picture1.Handle)

  Picture1.CurrentX = Rnd * Picture1.ScaleWidth -
1000

For i = height5 To 1 Step -1

  Picture1.CurrentY = Rnd * Picture1.ScaleHeight

Call BitBlt(Picture2.hdc, 0, i, width5, 1, _

  Picture1.ForeColor = RGB(Rnd * 256, Rnd * 256,
Rnd * 256)

hMemDc, 0, i, SRCCOPY)

  Picture1.Print ″随机 OK!″

For j = i – 1 To 1 Step -1

  n = n + 1

Call BitBlt(Picture2.hdc, 0, j, width5, 1, _

  If n > 50 Then

hMemDc, 0, i, SRCCOPY)

  n = 0

Next j

  Picture1.BackColor = QBColor(Rnd * 15)

Next

  End If

Call DeleteDC(hMemDc)

  DoEvents

End Sub

  Loop

 

  End Sub

Private Sub Form_Load()

  ′立体随机动漫

Dim i As Long

  Private Sub Command2-Click()

Picture2.ScaleMode = 3 设定成Pixel的心胸单位

  Dim m, n

设定待Display的图

  Picture1.DrawWidth = 1

Set Picture1 =
LoadPicture(“c:windows素还真.bmp”)

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

^^^^^^^^^^^^^^^^^^^^^^

  Picture1.Cls

Load the picture we want to show

  Do

End Sub

  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 Command3-Click()

  End

  End Sub  

 

 

相关文章

发表评论

电子邮件地址不会被公开。 必填项已用*标注

网站地图xml地图