Draw a line in C++ graphics
graphics.h library is used to include and facilitate graphical operations in program. graphics.h functions can be used to draw different shapes, display text in different fonts, change colors and many more. Using functions of graphics.h you can make graphics programs, animations, projects and games. You can draw circles, lines, rectangles, bars and many other geometrical figures. You can change their colors using the available functions and fill them.
For line 1, Input : x1 = 150, y1 = 150, x2 = 450, y2 = 150 For line 2, Input : x1 = 150, y1 = 200, x2 = 450, y2 = 200 For line 2, Input : x1 = 150, y1 = 250, x2 = 450, y2 = 250 Output :
Explanation :The header file graphics.h contains line() function which is described below :
Declaration : void line(int x1, int y1, int x2, int y2);
line function is used to draw a line from a point(x1,y1) to point(x2,y2) i.e. (x1,y1) and (x2,y2) are end points of the line.The code given below draws a line.