
rectangle (x1, y1, x2, y2): where x1, y1 is the upper left side and the lower right is x2, y2.circle (x, y, radius): To draw a whole circle, we need a center radius.lineto(x,y): it moves from the current position to the user-defined position.line () – Creates a line with starting and ending points.įor example, to draw a simple line or a circle, the following parameters are added.circle () – Creates a circle with a given radius.
clear() – It returns the cursor position to (0,0). To end the program, this function is used it flushes the memory used before for the graphics. Closegraph () – This function shifts the screen back to text mode. followed by this, we can use a directory path. Next is to include a function initgraph () which starts the graphic mode and comes with two variables gd, a graphic driver and gm, graphic mode. The first step is to include a header file GRAPHICS.H with a graphic function, and graphic.lib has built-in library functions. Ok, let’s go with the working steps in graphics code. Position functions like getmaxx(), getx() and gety().
GOTOXY: It helps to move a cursor to any position on the screen. BLINK: It helps to blink a character on the screen window. Shading and coloring add extra effects to the image.įew functions make the code more attractive, which works well in graphics mode. To set a color, we can use setcolor (number) The number specifies the color code for example, a number 14 is given for yellow. Basics of Color: The default color elements are red, green, and blue the output of all these colors confines to the pixels of the screen. The Graphics screen has 640 X 480 pixels.Ģ. This co-ordinated system depicts how and where to perform a draw option is specified. Co-ordinates: This specifies how points are placed in a window the initial origin of the screening point is assumed as (0,0). To work with graphics, we need a few essentials before entering the code.ġ. Many GUI programming is stopped in C++ because they don’t have the default graphics library. The next step is to go to the project and select project options followed by the parameter tab and paste the following in a linker tab: lbgi -lgdi32 -lcomdlg32 -luuid -loleaut32 -lole32. To work with DevC++, we need to download graphics.h and libbgi. Since we need a good framework to develop a good feature to draw, here in this article, I have used DevC++ IDE for that we need a certain package in addition to work with Graphics, to download this, we can refer WinBGIm to install the graphics library. So, a window or canvas is the main feature to show the output. The graphics are a two-dimensional concept to implement this, we need implementation and few functions in C++ programming. Setcolor(color), setbkcolor(color), setlinestyle(style, pattern,thickness).