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
Here we have successfully completed the drawing of the Chrome Logo.
Thank you for reading the article.
Also Read:
- Simple Code to compare Speed of Python, Java, and C++?
- Falling Stars Animation on Python.Hub October 2024
- Most Underrated Database Trick | Life-Saving SQL Command
- Python List Methods
- Top 5 Free HTML Resume Templates in 2024 | With Source Code
- How to See Connected Wi-Fi Passwords in Windows?
- 2023 Merry Christmas using Python Turtle
- 23 AI Tools You Won’t Believe are Free
- Python 3.12.1 is Now Available
- Best Deepfake Apps and Websites You Can Try for Fun
- Amazon launched free Prompt Engineering course: Enroll Now
- 10 GitHub Repositories to Master Machine Learning
- Hello World in 35 Programming Languages
- How to Scrape Data From Any Website with Python?
- Become Job Ready With Free Harvard Computer Science course: Enroll Now
- Free Python Certification course from Alison: Good for Resume
- Download 1000+ Projects, All B.Tech & Programming Notes, Job, Resume & Interview Guide, and More – Get Your Ultimate Programming Bundle!
- Udacity Giving Free Python Course: Here is how to Enroll
- Love Babbar’s Income Revealed
- Top 5 Websites to Learn Programming in 2024
- Python Internship for college students and freshers: Apply Here
- Microsoft Giving Free Python Course in 2023: Enroll Now
- Top 5 Free Python Courses on YouTube in 2024
- Complete Python Roadmap for Beginners in 2024
- New secrets to Earn money with Python in 2024
- Connect with HR Directly – Job Hack
- Google offering free Python course: Enroll Today
- What is an AI Tool?
- Google Internship 2024
- TCS Launched Free Certification Course with Industry Recognized Value