In C/C++ there is graphics.h header file which is used to create the object like line, circle, etc.
Given an array arr of N integers, the task is to write C++ program to create the Tree using graphics.h.
Approach: To run the program we have the include the below header file:
We will create a Tree with the help below functions:
- setcolor(color): This function present in graphic.h header file which is used to set the current drawing color to the new color.
- floodfill(pattern, color): function is used to fill an enclosed area. The current fill pattern and fill color is used to fill the area.
- circle(x, y, radius): The header file graphics.h contains circle() function which draws a circle with center at (x, y) and given radius.
- outtextxy(): The header file graphics.h contains outtextxy() function which displays the text or string at a specified point (x, y) on the screen.
Below is the implementation of to draw Tree using graphics in C++:
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Check if a given array can represent Preorder Traversal of Binary Search Tree
- Check if the given array can represent Level Order Traversal of Binary Search Tree
- Creating a Rainbow using Graphics Programming in C
- Sierpinski Triangle using Graphics
- Flood fill algorithm using C graphics
- Draw a moving car using computer graphics programming in C
- Creating Butterfly themed Fractal in C++ Using Graphics
- Mandlebrot Set in C/C++ Using Graphics
- Julia Fractal set in C/C++ Using Graphics
- How to discretize an Ellipse or Circle to a Polygon using C++ Graphics?
- How to create a Heart using C Graphics
- C Program to create a House using Graphics
- Draw a smiley face using Graphics in C language
- Check given array of size n can represent BST of n levels or not
- Why floating-point values do not represent exact value
- DDA Line generation Algorithm in Computer Graphics
- Point Clipping Algorithm in Computer Graphics
- How to add "graphics.h" C/C++ library to gcc compiler in Linux
- 2D Transformation in Computer Graphics | Set 1 (Scaling of Objects)
- Translation of objects 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 : arpit7714