OVH Cloud OVH Cloud

Animation graphique

1 réponse
Avatar
Phil
Bonjour,
Dans un premier temps :
Je désire faire un défilement d'une couleur prédéfinie de bas en haut dans
toute la largeur d'une picturebox.

Merci bcp.
Phil.

1 réponse

Avatar
François Picalausa
"Phil" a écrit dans le message de
news:3fd96c71$0$22335$
Bonjour,
Dans un premier temps :
Je désire faire un défilement d'une couleur prédéfinie de bas en haut
dans toute la largeur d'une picturebox.

Merci bcp.
Phil.



Bonjour/soir,

Essaye cet exemple:
'Sur une form, Form1
' comportant un picturebox, picture1
' et un timer, timer1
Option Explicit

Private Type POINT
X As Long
Y As Long
Color As Long
SpeedX As Long
SpeedY As Long
End Type

Dim Points(1) As POINT

Private Sub Form_Load()
Picture1.ScaleMode = 3
Picture1.Visible = False
Picture1.DrawWidth = 3
Picture1.AutoRedraw = True
Picture1.BorderStyle = 0
Picture1.Width = Form1.ScaleWidth
Picture1.Height = Form1.ScaleHeight

With Points(0)
.SpeedY = 1
.Color = vbRed
.X = Picture1.ScaleWidth / 2
.Y = 0
.SpeedX = 0
End With

With Points(1)
.SpeedY = 0
.Color = vbRed
.X = 0
.Y = Picture1.ScaleHeight / 2
.SpeedX = 3
End With

Timer1.Interval = 10
Timer1.Enabled = True
End Sub

Private Sub Timer1_Timer()
Dim i As Long

Picture1.Cls
For i = 0 To 1
Picture1.ForeColor = Points(i).Color
Picture1.PSet (Points(i).X, Points(i).Y)

Points(i).X = Points(i).X + Points(i).SpeedX
Points(i).Y = Points(i).Y + Points(i).SpeedY

If Points(i).X < 0 Then
Points(i).X = 0
Points(i).SpeedX = -Points(i).SpeedX
End If
If Points(i).Y < 0 Then
Points(i).Y = 0
Points(i).SpeedY = -Points(i).SpeedY
End If

If Points(i).X > Picture1.ScaleWidth - 1 Then
Points(i).X = Picture1.ScaleWidth - 1
Points(i).SpeedX = -Points(i).SpeedX
End If
If Points(i).Y > Picture1.ScaleHeight - 1 Then
Points(i).Y = Picture1.ScaleHeight - 1
Points(i).SpeedY = -Points(i).SpeedY
End If
Next i

Me.Picture = Picture1.Image
End Sub

--
François Picalausa (MVP VB)
FAQ VB : http://faq.vb.free.fr
MSDN : http://msdn.microsoft.com