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.
Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.
- Draw a smiley face using Graphics in C language
- Draw ellipse in C graphics
- Draw a line in C++ graphics
- Draw Rectangle in C graphics
- Draw circle in C graphics
- Draw an Ellipse rotating over a Circle in C++ graphics
- Draw a triangle in C++ graphics
- Creating a Rainbow using Graphics Programming in C
- DDA Line generation Algorithm in Computer Graphics
- Point Clipping Algorithm in Computer Graphics
- 2D Transformation in Computer Graphics | Set 1 (Scaling of Objects)
- Translation of objects in computer graphics
- Segments in Computer Graphics
- Computer Graphics | Cathode ray tube (video display device)
- Computer Graphics | Antialiasing
- Computer Graphics | The RGB color model
- Refresh type output devices in Computer Graphics
- Applications of Computer Graphics
- Window to Viewport Transformation in Computer Graphics with Implementation
- Display Processor in Computer Graphics
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.