In computer graphics, use graphics.h which provide direct functions to draw different coordinate shapes (like circle, rectangle etc). By using these functions we can draw different objects like car, hut, trees etc. In this program, we will draw a moving car using line and circles.
Functions used in program:
- delay(n): This function is used for holding the program output for a small period of time since processing is very fast so use it to see the result.
- setcolor(n): A function from graphics.h header file which set the color of the pointer (cursor). There are some predefined colors in computer graphics. Here n is color number.
- line(x1, y1, x2, y2): A function from graphics.h header file which draw a line with (x1, y1) as first coordinate of line and (x2, y2) as second coordinate of the line.
- circle(x, y, r): A function from graphics.h header file which draw a circle with center (x, y) and radius r.
Example 1: This example create a moving car without using cleardevice() method.
Example 2: This example uses cleardevice() method to clear the screen.
- Draw circle in C graphics
- Draw a line in C++ graphics
- Draw ellipse in C graphics
- Draw Rectangle in C graphics
- Draw an Ellipse rotating over a Circle in C++ graphics
- Creating a Rainbow using Graphics Programming in C
- Segments in Computer Graphics
- Computer Graphics | Antialiasing
- Translation of objects in computer graphics
- Computer Graphics | The RGB color model
- 2D Transformation in Computer Graphics | Set 1 (Scaling of Objects)
- Point Clipping Algorithm in Computer Graphics
- DDA Line generation Algorithm in Computer Graphics
- Window to Viewport Transformation in Computer Graphics with Implementation
- Computer Graphics | Refresh type output devices
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.