Unit 4
Graphics
Introduction to Graphics –
Graphics in C refers to the use of programming techniques and libraries to create visual elements, such
as images and animations, on a computer screen. C is a popular programming language for creating
graphics because it allows for direct memory manipulation and low-level control over hardware, making
it a good choice for creating fast and efficient graphical applications.
C graphics programming typically involves the use of libraries such as OpenGL, DirectX, or SDL (Simple
DirectMedia Layer) to create and manipulate graphical elements on the screen. These libraries provide
functions and tools for drawing shapes, rendering images, creating animations, and handling input from
users.
Graphics programming in C can be used to create a wide variety of applications, from simple games and
animations to more complex 3D modeling and simulation software. It is often used in scientific and
engineering applications, as well as in the development of user interfaces and multimedia applications.
#include<graphics.h>
#include<conio.h>
int main()
{
   int gd = DETECT, gm;
    initgraph(&gd, &gm, "C:\\TC\\BGI");
    getch();
    closegraph();
    return 0;
}
Graphics function in c
In C, graphics functions are used to create and manipulate graphical elements on the computer screen.
These functions are typically part of a graphics library or toolkit, such as OpenGL, DirectX, or SDL, and
provide a set of tools for drawing shapes, rendering images, creating animations, and handling input
from users.
Getpixel(): This function retrieves the color of a single pixel at the specified location.
and their syntax may vary depending on the graphics library being used.
These are just a few examples of the many graphics functions available in C. The exact set of functions
Here are some commonly used graphics functions in C:
Initgraph(): This function initializes the graphics system and sets up the graphics mode for the specified
device.
Getch(): This function waits for a key to be pressed and returns the ASCII code for that key.
Line(): This function draws a straight line between two points on the screen.
Circle(): This function draws a circle with the specified radius and center coordinates.
Rectangle(): This function draws a rectangle with the specified coordinates of its top-left and bottom-
right corners.
Arc(): This function draws an arc of the specified angle and radius, starting from the specified point.
Putpixel(): This function sets the color of a single pixel at the specified location.