Private p2vbW As Integer Private p2vbH As Integer Private p2vbX1 As Integer Private p2vbY1 As Integer Private p2vbX2 As Integer Private p2vbY2 As Integer Private myPen as Pen Private formGraphics As System.Drawing.Graphics Private myBrush As System.Drawing.SolidBrush ' Test animation of a group of objects making a face. ' ' from graphics import * ' import time Public Sub moveAll(shapeList As Object, dx As Object, dy As Object) ' Move all shapes in shapeList by (dx, dy). for shape= 0 To shapeList.Length - 1 shapeList(shape).X = shapeList(shape).X + dx shapeList(shape).Y = shapeList(shape).Y + dy Next End Sub Public Sub moveAllOnLine(shapeList As Object, dx As Integer, dy As Integer, repetitions As Integer, delay As Single) ' Animate the shapes in shapeList along a line. ' Move by (dx, dy) each time. ' Repeat the specified number of repetitions. ' Have the specified delay (in seconds) after each repeat. ' for i = 0 To repetitions - 1 moveAll(shapeList, dx, dy) Threading.Thread.Sleep(delay * 1000) Next End Sub Public Sub main() Dim winWidth As Integer winWidth = 300 Dim winHeight As Integer winHeight = 300 Dim win As Integer Form1.Text = "Back and Forth" Form1.Width = winWidth + 100 p2vbW = winWidth Form1.Height = winHeight + 100 p2vbH = winHeight p2vbX1 = 0 p2vbY1 = 0 p2vbX2 = winWidth p2vbY2 = winHeight ' make right side up coordinates! Dim rect As Rectangle rect = New Rectangle(New Point(200, 90), New Point(220, 100)) myPen = New Pen(Drawing.Color.Black, 1) formGraphics = Form1.CreateGraphics() formGraphics.DrawRectangle(myPen, rect) myBrush = New System.Drawing.SolidBrush(System.Drawing.Color.blue) formGraphics.FillRectangle(myBrush, New Rectangle(200, 90, 220, 100)) Dim head As RectangleF myPen = New Pen(Drawing.Color.Black, 1) head.X = 40 head.Y = 100 head.Width = 25 head.Height = 25 formGraphics.DrawEllipse(myPen, head) myBrush = New System.Drawing.SolidBrush(System.Drawing.Color.yellow) formGraphics.FillEllipse(myBrush, head) Dim eye1 As RectangleF myPen = New Pen(Drawing.Color.Black, 1) eye1.X = 30 eye1.Y = 105 eye1.Width = 5 eye1.Height = 5 formGraphics.DrawEllipse(myPen, eye1) myBrush = New System.Drawing.SolidBrush(System.Drawing.Color.blue) formGraphics.FillEllipse(myBrush, eye1) Dim eye2 As Integer myPen = New Pen(Drawing.Color.Black, 3) formGraphics.DrawLine(myPen, 45, 105, 55, 105) Dim mouth As RectangleF mouth = New RectangleF(New Point(30, 90), New SizeF(50, 85)) myPen = New Pen(Drawing.Color.Black, 1) formGraphics.DrawEllipse(myPen, mouth) myBrush = New System.Drawing.SolidBrush(System.Drawing.Color.red) formGraphics.FillEllipse(myBrush, mouth) Dim faceList As Object faceList = {head, eye1, eye2, mouth} Dim cir2 As RectangleF myPen = New Pen(Drawing.Color.Black, 1) cir2.X = 150 cir2.Y = 125 cir2.Width = 25 cir2.Height = 25 formGraphics.DrawEllipse(myPen, cir2) myBrush = New System.Drawing.SolidBrush(System.Drawing.Color.red) formGraphics.FillEllipse(myBrush, cir2) moveAllOnLine(faceList, 5, 0, 46, .05) moveAllOnLine(faceList, -5, 0, 46, .05) Dim Control1 As New Label Control1.Left = p2vbW * ((winWidth/2) / (p2vbX2 - p2vbX1)) Control1.Top = p2vbH - (p2vbH * (( 20) / (p2vbY2 - p2vbY1))) Control1.Text = "Click anywhere to quit." Control1.AutoSize = True Form1.Controls.Add(Control1) End Sub 'main()