Here, we will be making “The Great Indian Flag” using Python Turtle Graphics. Here, we will be using many turtle functions like begin_fill(), end_fill() to fill color inside the Flag, penup(), pendown(), goto() etc to reaching the target.
In computer graphics, turtle graphics are vector graphics using a relative cursor upon a Cartesian plane. Turtle is a drawing board like feature which let us command the turtle and draw using it.
Features of turtle graphics:
- forward(x): moves the pen in forward direction by x units.
- backward(x): moves the pen in the backward direction by x units.
- right(x): rotate the pen in the clockwise direction by an angle x.
- left(x): rotate the pen in the anticlockwise direction by an angle x.
- penup(): stop drawing of the turtle pen.
- pendown(): start drawing of the turtle pen.
- begin_fill(): starts filling the color inside the shape.
- fillcolor(“color_name”): sets the color to be filled.
- end_fill(): stops filling the color.
1. import the turtle modules.
2. Get a screen to draw on.
screen = turtle.Screen()
3. Define an instance for turtle(here “t”).
4. For making Indian Flag lets divide the process into 4 steps:
- The rectangle with orange color.
- Then the middle rectangle.
- Then the last Green Rectangle.
- Then Ashoka Chakra inside the middle rectangle.
5. Here dimensions of all three Rectangles are (800 units x 167 units), which makes up dimensions of the flag as (800 units x 501 units).
6. The turtle starts from coordinates (-400, 250).
7. Then from that position it makes the First rectangle of orange color.
8. Then from the ending point of the first rectangle,Turtle makes the Second rectangle of no color.
9. Then the Third green color rectangle is made. Now for Ashoka Chakra we need to perform a set of operations
- A Big Blue circle and a white circle just smaller than blue.
- Set of small blue circles on the inner lining of a blue and white circle.
- And finally spokes inside the two blue and white circles starting from Centre towards the outer direction.
10. Finally, The pride of one’s Nation is ready.
Below is the implementation of the above approach:
- Program to make Indian Flag in Python | Step by Step
- Draw Indian Flag using matlab
- turtle.forward() method in Python-Turtle
- turtle.setpos() and turtle.goto() functions in Python
- Text transliteration from English to Indian languages - Using indic-transliteration
- Draw Sweden Flag using matlab
- How to draw Japan flag using MATLAB
- Draw Kuwait Flag using MATLAB
- Draw Sudan Flag using MATLAB
- How to make Triangle in Python Turtle using onscreenclick?
- Matplotlib.pyplot.flag() in Python
- Python - Flag None Element Rows in Matrix
- PyQtGraph – Setting Window Flag to Plot Window
- Draw Circle in Python using Turtle
- Python | Plotting Fibonacci spiral fractal using Turtle
- Python - Hilbert Curve using turtle
- Create a simple Animation using Turtle in Python
- Python - Write "GFG" using Turtle Graphics
- Y Fractal tree in Python using Turtle
- Create digital clock using Python-Turtle
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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 : anshitaagarwal