كود الأستخدام تدريج اللون داخل الفورم بشكل متحرك

القيصر

New member
26 فبراير 2019
1,003
0
0
كود الأستخدام تدريج اللون داخل الفورم بشكل متحرك




الأدوات:timer عدد 1+PictuerBox


كود:

Imports System.Drawing.Drawing2D
Public Class Form1
Private M_M As Single = 0
Private M_D As Single = 0.1
Private Sub PictureBox1_Paint(ByVal sender As Object, _
ByVal e As System.Windows.Forms.PaintEventArgs) Handles _
PictureBox1.Paint
Dim LB As New LinearGradientBrush(New Point(0, 0), New Point _
(Me.ClientSize.Width, 0), Color.Green, Color.Yellow)
Dim CB As New ColorBlend
CB.Colors = New Color() {Color.Green, Color.YellowGreen, Color.Yellow}
CB.Positions = New Single() {0, M_M, 1}
LB.InterpolationColors = CB
e.Graphics.FillRectangle(LB, Me.ClientRectangle)
LB.Dispose()
M_M += M_D
If (M_M > 1) OrElse (M_M < 0) Then M_D = -M_D
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
PictureBox1.Invalidate()
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Enabled = True
End Sub
End Class