Draw Chrome Logo using Python Turtle

Draw Chrome Logo using Python Turtle

Introduction

Hello and welcome friends to violet-cat-415996.hostingersite.com.  We all know the chrome browser very well as most of our surfing activities are done on chrome. We also look at the Chrome logo every now and then while browsing. But have you ever tried to draw the Logo? In this article, we are going to do the same. We are drawing the Chrome logo using Python Turtle module.

You will find the lines of code a little bit tricky, but don’t worry!! We are providing a detailed explanation of the code for better understanding. We are also putting comments for the lines of code which are easy to understand.

For the complete code, you just have to move down to the bottom of the page. Here you will get the code as well as the output.

So let’s begin drawing the Chrome Logo

Import Function

from turtle import *

Here we are importing all the turtle module methods and functions.

Draw the red shape of the Chrome Logo using Python Turtle

radius=120
#heading position -150 is opposite of 150 degree angle
setheading(-150)
penup()
#-Red shape of the Chrome Logo
color("red")
begin_fill()
forward(radius)
pendown()
right(90) #set the angle to 90
circle(-radius, 120)

#forward distance is equal to 180
forward(radius*3**.5)
left(120)
#draw the circle angle 120 and radius of 240
circle(2*radius, 120)
left(60)
forward(radius*3**.5)
end_fill()

In this code block, we are drawing the red shape of the chrome Logo. First, we have initialized the radius to 120. Set the heading position to -150. Initialized the color to red. We have set an angle of the turtle to right(90). The circle radius is initialized to -120 and the angle of 120 degrees. We have used the forward(radius*3**.5) function which equals to forward(180) distance to draw the straight line. Moved left to 120 degrees and drew another circle(2*radius,120)  whose radius is 240 and the angle 120 degrees.  After that moved to left(60) and drew a straight line of 180 distances using the function forward(radius*3**.5) . It completes the red shape.

Draw the green shape of the Chrome Logo

#------------Green -------------

left(180)
color("green")
begin_fill()
forward(radius*3**.5)
left(120)
circle(2*radius, 120)
left(60)
forward(radius*3**.5)
left(180)
circle(-radius, 120)
end_fill()

Here we have drawn the green shape of the chrome logo. We have made an angle of left(180). Draw a straight line using forward(radius*3**.5) function i.e 180 steps . Then provided angle of left(120). Draw a circle with a radius of 240 with an extent of 120 degrees. Set an angle left(60) and draw a straight line of 180 steps. After that set the angle to left(180) and draw a circle with a radius of -120 and an extent of 120 degrees.

Draw the yellow shape of the Chrome Logo

#-------------Yellow -------------

left(180)
circle(radius,120)
color("yellow")
begin_fill()
circle(radius, 120)
right(180)
forward(radius*3**.5)
right(60)
circle(-2*radius, 120)
right(120)
forward(radius*3**.5)
end_fill()

In the piece of code, we are drawing the yellow shape of the chrome logo. The circle radius and extent is 120. Here while filling the yellow color, again we have to set the radius and the extent to 120. Angle is set to the right(180). Draw a straight line of 180 distances. Again set the angle to the right(60). Draw a circle of radius -240 with the extent of 120 degrees by using the function circle(-2*radius,120). Set the angle to the right(120) and draw a straight line of 180 steps. This completes the yellow shape.

Draw the middle Blue Circle of the Chrome Logo

#-------------Blue Circle-------------

penup()
left(98)
forward(radius/20)
setheading(60)
color("blue")
pendown()
begin_fill()
circle(distance(0,0))
end_fill()
hideturtle()

done()

In this last part of the code, we are drawing the circle of the Chrome logo. The angle is set to the left(98), We have to move them forward(radius/20) i.e 60 steps. Set the head position of the turtle to 60 degrees. Set the color of the circle to blue. And drawing the circle ends up the completion of logo designing.

Complete Code to Draw Chrome Logo using Python Turtle

from turtle import *

radius=120
#heading position -150 is opposite of 150 degree angle
setheading(-150)
penup()
#-Red shape of the Chrome Logo
color("red")
begin_fill()
forward(radius)
pendown()
right(90) #set the angle to 90
circle(-radius, 120)
#forward distance is equal to 180
forward(radius*3**.5)
left(120)
#draw the circle angle 120 and radius of 240
circle(2*radius, 120)
left(60)
forward(radius*3**.5)
end_fill()

#-------------Green -------------

left(180)
color("green")
begin_fill()
forward(radius*3**.5)
left(120)
circle(2*radius, 120)
left(60)
forward(radius*3**.5)
left(180)
circle(-radius, 120)
end_fill()

#-------------Yellow -------------

left(180)
circle(radius,120)
color("yellow")
begin_fill()
circle(radius, 120)
right(180)
forward(radius*3**.5)
right(60)
circle(-2*radius, 120)
right(120)
forward(radius*3**.5)
end_fill()

#-------------Blue Circle-------------

penup()
left(98)
forward(radius/20)
setheading(60)
color("blue")
pendown()
begin_fill()
circle(distance(0,0))
end_fill()
hideturtle()

done()

Output

Output of Chrome Logo using PythonTurtle

Here we have successfully completed the drawing of the Chrome Logo.

Thank you for reading the article.


Also Read:

Share:

Author: Ayush Purawr