270 likes | 379 Views
Dim MyBrush As New SolidBrush(Color.Black) EamonnsPicBox.CreateGraphics.FillEllipse(MyBrush, 50, 150, 20, 20). Dim MyBrush As New SolidBrush(Color.Black) Dim shtXOffset, shtYOffset As Short For shtXOffset = 0 To 500
E N D
Dim MyBrush As New SolidBrush(Color.Black) EamonnsPicBox.CreateGraphics.FillEllipse(MyBrush, 50, 150, 20, 20)
Dim MyBrush As New SolidBrush(Color.Black) Dim shtXOffset, shtYOffset As Short For shtXOffset = 0 To 500 EamonnsPicBox.CreateGraphics.FillEllipse(MyBrush, 50 + shtXOffset, 150, 20, 20) Sleep(30) Next shtXOffset Demo one
Dim MyBrush As New SolidBrush(Color.Black) Dim shtXOffset, shtYOffset As Short For shtXOffset = 0 To 500 Step EamonnsPicBox.CreateGraphics.FillEllipse(MyBrush, 50 + shtXOffset, 150, 20, 20) Sleep(30) Next shtXOffset
Dim MyBrush As New SolidBrush(Color.Black) Dim shtXOffset, shtYOffset As Short For shtXOffset = 0 To 500 Step shtYOffset = shtXOffset / 4 EamonnsPicBox.CreateGraphics.FillEllipse(MyBrush, 50 + shtXOffset, 150 - shtYOffset , 20, 20) Sleep(30) Next shtXOffset Note that the arguments to the graphics functions can be fractions, the function will convert them to integers
Dim MyBrush As New SolidBrush(Color.Black) Dim shtXOffset, shtYOffset As Short EamonnsPicBox.CreateGraphics.DrawEllipse(Pens.Black, 100, 10, 200, 200) EamonnsPicBox.CreateGraphics.FillEllipse(MyBrush, 120, 110, 20, 20)
EamonnsPicBox.CreateGraphics.DrawEllipse(Pens.Black, 100, 10, 200, 200) For shtXOffset = 0 To 120 EamonnsPicBox.CreateGraphics.FillEllipse(MyBrush, 120 + shtXOffset, 110, 20, 20) Sleep(30) Next shtXOffset
EamonnsPicBox.CreateGraphics.DrawEllipse(Pens.Black, 100, 10, 200, 200) For shtXOffset = 0 To 120 MyBrush.Color = Color.Black EamonnsPicBox.CreateGraphics.FillEllipse(MyBrush, 120 + shtXOffset, 110, 20, 20) Sleep(30) MyBrush.Color = Color.White EamonnsPicBox.CreateGraphics.FillEllipse(MyBrush, 120 + shtXOffset, 110, 20, 20) Next shtXOffset Demo Two
EamonnsPicBox.CreateGraphics.DrawEllipse(Pens.Black, 100, 10, 200, 200) EamonnsPicBox.CreateGraphics.DrawEllipse(Pens.Black, 350, 10, 200, 200) For shtXOffset = 0 To 120 MyBrush.Color = Color.Black EamonnsPicBox.CreateGraphics.FillEllipse(MyBrush, 120 + shtXOffset, 110, 20, 20) EamonnsPicBox.CreateGraphics.FillEllipse(MyBrush, 370 + shtXOffset, 110, 20, 20) Sleep(30) MyBrush.Color = Color.White EamonnsPicBox.CreateGraphics.FillEllipse(MyBrush, 120 + shtXOffset, 110, 20, 20) EamonnsPicBox.CreateGraphics.FillEllipse(MyBrush, 370 + shtXOffset, 110, 20, 20) Next shtXOffset Demo Three
Dim MyBrush As New SolidBrush(Color.RoyalBlue) Dim shtI As Short EamonnsPicBox.CreateGraphics.DrawEllipse(Pens.Black, 100, 10, 200, 200) EamonnsPicBox.CreateGraphics.FillEllipse(MyBrush, 150, 60, 100, 100) MyBrush.Color = Color.Black EamonnsPicBox.CreateGraphics.FillEllipse(MyBrush, 190, 100, 20, 20)
Dim MyBrush As New SolidBrush(Color.RoyalBlue) Dim shtI As Short EamonnsPicBox.CreateGraphics.DrawEllipse(Pens.Black, 100, 10, 200, 200) EamonnsPicBox.CreateGraphics.FillEllipse(MyBrush, 150, 60, 100, 100) MyBrush.Color = Color.Black EamonnsPicBox.CreateGraphics.FillEllipse(MyBrush, 190, 100, 20, 20) For shtI = 0 To 20 EamonnsPicBox.CreateGraphics.FillEllipse(MyBrush, 190 - shtI, 100 - shtI, 20 + (shtI * 2), 20 + (shtI * 2)) Sleep(50) Next shtI Demo Four
Squinting eye Dim MyBrush As New SolidBrush(Color.RoyalBlue) Dim shtI, shtYOffset As Short EamonnsPicBox.CreateGraphics.DrawEllipse(Pens.Black, 100, 10, 200, 200) EamonnsPicBox.CreateGraphics.FillEllipse(MyBrush, 150, 60, 100, 100) MyBrush.Color = Color.Black EamonnsPicBox.CreateGraphics.FillEllipse(MyBrush, 190, 100, 20, 20) For shtI = 0 To 40 EamonnsPicBox.CreateGraphics.DrawEllipse(Pens.Black, 100, 10 + shtI, 200, 200 - (shtI * 2)) Sleep(70) EamonnsPicBox.CreateGraphics.DrawEllipse(Pens.White, 100, 10 + shtI, 200, 200 - (shtI * 2)) Next shtI
Dim shtI, shtX, shtY As Short For shtI = 1 To 200 shtX = ((696 + 1) * Rnd()) shtY = ((224 + 1) * Rnd()) EamonnsPicBox.CreateGraphics.DrawLine(Pens.White, shtX, shtY, shtX, shtY + 1) Next shtI
Dim shtI, shtX, shtY As Short For shtI = 1 To 200 shtX = shtX + ((Rnd() * 3)) - 1 EamonnsPicBox.CreateGraphics.DrawLine(Pens.Yellow, 200 + shtX, 0 + shtI, 200 + shtX, 1 + shtI) Sleep(3) Next shtI
Dim MyBrush As New SolidBrush(Color.Wheat) EamonnsPicBox.CreateGraphics.FillEllipse(MyBrush, 100, 10, 80, 80) MyBrush.Color = Color.Black EamonnsPicBox.CreateGraphics.FillEllipse(MyBrush, 80, 10, 80, 80) There is a mistake above, how do we fix it?
For shtI= 1 To 224 MyBrush.Color = Color.White EamonnsPicBox.CreateGraphics.FillEllipse(MyBrush, 200 + shtI, 0 + shtI, 5, 5) Sleep(10) MyBrush.Color = Color.Black EamonnsPicBox.CreateGraphics.FillEllipse(MyBrush, 200 + shtI, 0 + shtI, 5, 5) Next shtI Demo Five
Dim shtI As Short For shtI = 0 To 400 myBrush.Color = Color.Red EamonnsPicBox.CreateGraphics.FillPie(myBrush, 100, 10, 200, 200, 0 + shtI, 180) myBrush.Color = Color.Yellow EamonnsPicBox.CreateGraphics.FillPie(myBrush, 100, 10, 200, 200, 180 + shtI, 180) Sleep(20) Next shtI Demo Six
Dim shtI As Short For shtI = 0 To 40 myBrush.Color = Color.Red EamonnsPicBox.CreateGraphics.FillPie(myBrush, 100, 10, 200, 200, 0 + shtI, 90) EamonnsPicBox.CreateGraphics.FillPie(myBrush, 100, 10, 200, 200, 180 + shtI, 90) myBrush.Color = Color.Yellow EamonnsPicBox.CreateGraphics.FillPie(myBrush, 100, 10, 200, 200, 90 + shtI, 90) EamonnsPicBox.CreateGraphics.FillPie(myBrush, 100, 10, 200, 200, 270 + shtI, 90) Sleep(20) Next shtI
Dim MyFont = New Font("Arial", 46) Dim shtX, shtY As Short Dim strLocation As String shtX = EamonnsPicBox.MousePosition.X() shtY = EamonnsPicBox.MousePosition.Y() strLocation = "(" & Str(shtX) & "," & Str(shtY) & ")" EamonnsPicBox.CreateGraphics.DrawString(strLocation, MyFont, myBrush, 100, 100)
Dim MyFont = New Font("Arial", 46) Dim shtX, shtY As Short Dim strLocation As String shtX = EamonnsPicBox.MousePosition.X() shtY = EamonnsPicBox.MousePosition.Y() strLocation = "(" & Str(shtX) & "," & Str(shtY) & ")" EamonnsPicBox.CreateGraphics.DrawString(strLocation, MyFont, myBrush, shtX, shtY)
Dim myBrush As New SolidBrush(Color.Yellow) EamonnsPicBox.CreateGraphics.DrawRectangle(Pens.Black, 300, 100, 50, 50) EamonnsPicBox.CreateGraphics.FillRectangle(myBrush, 300, 100, 50, 50) myBrush.Color = Color.Red EamonnsPicBox.CreateGraphics.DrawRectangle(Pens.Black, 400, 100, 50, 50) EamonnsPicBox.CreateGraphics.FillRectangle(myBrush, 400, 100, 50, 50)
Dim shtX As Short shtX = EamonnsPicBox.MousePosition.X() If shtX < 350 Then EamonnsPicBox.BackColor = Color.Yellow Else EamonnsPicBox.BackColor = Color.Red End If Dim myBrush As New SolidBrush(Color.Yellow) EamonnsPicBox.CreateGraphics.DrawRectangle(Pens.Black, 300, 100, 50, 50) EamonnsPicBox.CreateGraphics.FillRectangle(myBrush, 300, 100, 50, 50) myBrush.Color = Color.Red EamonnsPicBox.CreateGraphics.DrawRectangle(Pens.Black, 400, 100, 50, 50) EamonnsPicBox.CreateGraphics.FillRectangle(myBrush, 400, 100, 50, 50)
Dim Top As New Point(200, 30) Dim Right As New Point(250, 75) Dim Bottom As New Point(200, 200) Dim Left As New Point(150, 75) Dim myKite As Point() = {Top, Right, Bottom, Left} EamonnsPicBox.CreateGraphics.FillPolygon(myBrush, myKite) Point(200, 30) Point(250, 75) Point(150, 75) Point(200, 200)
Dim myBrush As New SolidBrush(Color.Yellow) Dim lngI, lngYoffset As Long For lngI = -300 To 300 lngYoffset = Int((lngI * lngI) / 500) EamonnsPicBox.CreateGraphics.FillEllipse(myBrush, 320 + lngI, 50 + lngYoffset, 5, 5) Sleep(20) Next lngI
Dim myBrush As New SolidBrush(Color.Yellow) Dim lngI, lngYoffset As Long For lngI = -300 To 300 lngYoffset = Int((lngI * lngI) / 500) myBrush.Color = Color.Yellow EamonnsPicBox.CreateGraphics.FillEllipse(myBrush, 320 + lngI, 50 + lngYoffset, 15, 15) Sleep(5) myBrush.Color = Color.Black EamonnsPicBox.CreateGraphics.FillEllipse(myBrush, 320 + lngI, 50 + lngYoffset, 15, 15) Next lngI Demo Seven
For lngI = -200 To 200 lngYoffset = Int((lngI * lngI) / 500) myBrush.Color = Color.Yellow EamonnsPicBox.CreateGraphics.FillEllipse(myBrush, 320 + lngI, 50 + lngYoffset, 15, 15) Sleep(5) myBrush.Color = Color.Black EamonnsPicBox.CreateGraphics.FillEllipse(myBrush, 320 + lngI, 50 + lngYoffset, 15, 15) Next lngI For lngI = -200 To 200 lngYoffset = Int((lngI * lngI) / 500) myBrush.Color = Color.Yellow EamonnsPicBox.CreateGraphics.FillEllipse(myBrush, 400 + 320 + lngI, 50 + lngYoffset, 15, 15) Sleep(5) myBrush.Color = Color.Black EamonnsPicBox.CreateGraphics.FillEllipse(myBrush, 400 + 320 + lngI, 50 + lngYoffset, 15, 15) Next lngI Demo eight
The Sleep function I have been using will not work for you! (in the lab) You can use mySleep… Private Function mySleep(ByVal intValue As Integer) As Integer Dim lngWasteTime As Long For lngWasteTime = 0 To intValue * 10000' Waste some time Next lngWasteTime End Function
Animation Hints Don’t try to move large amounts of graphics, it will cause flicker. Play with the examples I have given you, go home, think about it, then plan your animation, then code it. Simple ideas work best.