I am still in the designing phase only because getting into Django is taking time as I was caught up in other stuff. But I promise you, I will be starting the Django part very soon. As the title suggests, today we will be drawing 12 designs from a single code. Now as soon as you heard about 12 designs, you must be wondering about the length of the code, right?? What if I tell you that the actual code which is responsible for all the design is having a length of just 3 lines!!! Fascinating right? So let’s start, shall we?

We will be using semi circles to make all the designs. In turtle we can make a circle by using turtle.circle(radius) command. In order to draw a semi circle, we have to give one more argument to our circle command which refers to the angle upto which the circle should be drawn. So, we can draw a semi circle of say, radius 50 in turtle by using the following command:

turtle.circle(50,180) #180 degree results in semi circle

So I will be using this property to draw all my designs along with left rotations and when we combine the result, we can get following 12 designs:

This is just for the purpose of showing the resulting images. Output screen will show only one design at a time, we can adjust the coordinates to get all the designs at one, that is upto you!!

We will be setting the background to black and color of our turtle to be white. The width and speed of our turtle would be 3 and 50 respectively. We will be showing one design after the other, hence in order to keep a certain design on screen we have to import time package. All the above mentioned basic settings can be done as shown below:

We will have a for loop which would have 12 iterations for our design, in each iteration it would first clear the screen, then draw the design and then wait for 3–5 seconds which is based on our choice. We will be using another function to draw our design which will be discussed later, above mentioned for loop would look as follows:

for i in range(1,13):
z.clear()
draw(i)
time.sleep(3)

Now comes the 3 line code which is responsible for everything going around here. I have used 40 iterations for this loop, but we can have lesser than that also. As I told earlier, we will be using semi circles, for which we know the command. Now comes the trick, we will be rotating our turtle to x*10 degrees in each iteration, where x is the nth time the first loop is executed. Let me explain in an easier manner, suppose for the second loop, it will draw the semi circle and then turn left 20 degrees, it will again draw and turn, this will go on for 40 times. Now for the third time, it will rotate 30 degrees and so on. So our draw() would look like:

So if we execute our code, first we would get the design which is on the top left corner and so on. So, say for the 6th iteration, we will be getting the following design:

It was fun, wasn’t it?? A 3 line code was able to do wonders today. I will be posting a video regarding this on my Facebook page soon, if you haven’t liked my page (Unofficial: Ashish Sharma) yet, please visit https://www.facebook.com/ashishsharma260696/, give a like and an honest review. So here is a codework for you, try to print all the codes on a same screen along with some text like Design Number or anything of your choice. I will be sharing the answer in the next blog or in a video on my page, stay safe, be happy and keep coding…

Thank you for reading, if you liked the article please click on the clap button and show your support. You can clap more than once, just keep pressing the icon!!!

VLSI Engineer with the urge for sharing knowledge.