[VB.Net] 2D Graphics - color-changing, fading loading 04-29-2011, 07:59 AM
#1
![[Image: zTSHa.gif]](http://i.imgur.com/zTSHa.gif)
I was a bit bored yesterday, so I made this.
![Smile Smile](https://sinister.ly/images/smilies/set/smile.png)
No image has been used. Everything is rendered.
Spoiler: Source
Code:
Dim intRender As Integer = 0
Dim ArrOpacity As Integer() = {240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240}
Dim ArrLocation As Point() = {New Point(175, 0), New Point(235, 18), New Point(285, 50), New Point(325, 95), New Point(350, 160), _
New Point(325, 225), New Point(285, 275), New Point(240, 310), New Point(175, 325), New Point(120, 305), _
New Point(75, 275), New Point(35, 225), New Point(10, 160), New Point(35, 95), New Point(75, 50), New Point(120, 20)}
Dim g As Graphics, bmp As Bitmap, theColor As Color = Color.FromArgb(50, 255, 255)
Dim ThreadRunning As Boolean = True
Private Sub LoadingThread()
CheckForIllegalCrossThreadCalls = False
Try
Do While ThreadRunning = True
Me.BackgroundImage = New Bitmap(Me.Width, Me.Height)
For intI = 0 To ArrLocation.GetUpperBound(0)
ArrOpacity(intI) -= 15
theColor = Color.FromArgb(theColor.R, 255 - ArrOpacity(intI), ArrOpacity(intI))
RenderCircle(ArrOpacity(intI), theColor, ArrLocation(intI))
Next
RenderCircle(255, theColor, ArrLocation(intRender))
ArrOpacity(intRender) = 255
If intRender < 15 Then intRender += 1 Else intRender = 0
Me.BackgroundImage = bmp
Threading.Thread.Sleep(150)
If ThreadRunning = False Then Exit Do
Loop
Catch ex As Exception
End Try
End Sub
Private Sub RenderCircle(ByVal Opacity As Byte, ByVal Color As Color, ByVal Location As Point)
g.FillEllipse(New SolidBrush(Color.FromArgb(Opacity, Color)), New Rectangle(Location, New Size(30, 30)))
End Sub
Private Sub frmMain_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
ThreadRunning = False
End Sub
Private Sub frmMain_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
bmp = New Bitmap(Me.Width, Me.Height)
g = Graphics.FromImage(bmp)
Dim t As New Threading.Thread(AddressOf LoadingThread)
t.IsBackground = True
t.Start()
End Sub
![[Image: rytwG00.png]](http://i.imgur.com/rytwG00.png)
Redcat Revolution!