Prerequisite: How to include graphics.h?, graphics.h
The task is to draw an ellipse that is intersected by a straight line passing through the center of the ellipse diagonally. And then color both segments with different colors.
Approach: To run the program we need to include the following header file:
We will create the desired ellipse with the help of the following functions:
- void ellipse(int x, int y, int from_angle, int to_angle, int x_rad, int y_rad): A function from graphics.h header file is responsible for creating ellipse on the screen.
void line(int x1, int y1, int x2, int y2): A function from graphics.h header file which draw a line.
- void floodfill(int x, int y, int border_color): A function from graphics.h header file is responsible function is used to fill an enclosed area. Current fill pattern and fill color is used to fill the area.
Below is the implementation of the above approach:
Rated as one of the most sought after skills in the industry, own the basics of coding with our C++ STL Course and master the very concepts by intense problem-solving.
- Equation of straight line passing through a given point which bisects it into two equal line segments
- Draw ellipse in C graphics
- Draw an Ellipse rotating over a Circle in C++ graphics
- Draw a line in C++ graphics
- How to discretize an Ellipse or Circle to a Polygon using C++ Graphics?
- Draw Rectangle in C graphics
- Draw circle in C graphics
- Draw a moving car using computer graphics programming in C
- Draw a smiley face using Graphics in C language
- Draw a triangle in C++ graphics
- DDA Line generation Algorithm in Computer Graphics
- OpenCV C++ Program to create a single colored blank image
- How to print Colored text in C++
- Program to delete a line given the line number from a file
- Program to find the Area of an Ellipse
- Biggest Reuleaux Triangle inscribed within a square which is inscribed within an ellipse
- Midpoint ellipse drawing algorithm
- Count of distinct remainders when N is divided by all the numbers from the range [1, N]
- Creating a Rainbow using Graphics Programming in C
- Point Clipping Algorithm 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 firstname.lastname@example.org. 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.
Improved By : bansalpriyal45