usingMaths.com
Demonstrating and showing pupils and students one application of Mathematics.







<< PreviousNext >>

Code to Animate a Body (Circle) Across the Canvas Component in C#




How to Draw on the Window Form

We'll will draw a circle - our body - using the FillEllipse method of the Graphics object.



Animating a Body

To make the circle appear to move across the canvas, i.e., animate the circle, we'll simply draw the circle repeatedly, changing its position progressively as well as clearing the previous image.

Create 2 new classes;
Call them Dymetric and MovingBody.
Type out the adjoining C# code for animating an image body across the windows form.



Important: To generate the Form1_Paint code stub, select the form in design mode; go to its properties; click on the lightning bolt symbol and select Paint.

Note: The code for our Form1 class will remain the same for the rest of the demonstrations in this category.
Hence it will be left out hence forth.










<< PreviousNext >>