Draw Instagram Logo using Python Turtle

Draw Instagram Logo using Python Turtle

Introduction

This blog will discuss how to Draw Instagram Logo using Python Turtle module. Instagram is a very popular social media platform, primarily used for uploading and editing photos in the past, but it has now become a short-video platform with the introduction of Instagram Reels.

Click here to check how to draw Instagram Reels logo using Python Turtle.

Basics of the Python Turtle module: https://copyassignment.com/the-beginners-guide-to-python-turtle/

Official Documentation of the Turtle module: https://docs.python.org/3/library/turtle.html

Complete code to Draw Instagram Logo using Python Turtle

from turtle import * #importing the module

def backFrame():
    COLOR = (0.60156, 0, 0.99218)  # (154, 0, 254)
    TARGET = (0.86328, 0.47656, 0.31250)  # (221, 122, 80)

    screen = Screen()
    screen.tracer(False)

    WIDTH, HEIGHT = screen.window_width(), screen.window_height() #defining some useful variables

    deltas = [(hue - COLOR[index]) / HEIGHT for index, hue in enumerate(TARGET)]

    turtle = Turtle()
    turtle.color(COLOR)

    turtle.penup()
    turtle.goto(-WIDTH/2, HEIGHT/2)
    turtle.pendown()

    direction = 1

    #the gradient background
    for distance, y in enumerate(range(HEIGHT//2, -HEIGHT//2, -1)):

        turtle.forward(WIDTH * direction)
        turtle.color([COLOR[i] + delta * distance for i, delta in enumerate(deltas)])
        turtle.sety(y)

        direction *= -1

    screen.tracer(True)

def main():
    ## setting all the pre-defined values to be used in the program
    pen_color = 'white'
    width_val = 23
    round_coordA, round_coordB = 34, 90 
    circleAx, circleAy = 80, 360
    circleBx, circleBy = 7, 360
    gotoAx, gotoAy = 85, 30
    gotoBx, gotoBy = 160, -100

    pencolor(pen_color) #defining the color of the pen
    width(width_val) #defining the thickness of the pen
    penup() #start the draw
    goto(gotoBx, gotoBy) #set the origin for the graphics
    pendown() #stop the draw temporarily

    left(90) #turn at an angle 
    for i in range(4): #loop for 4 times for a square-type shape
        forward(250) 
        circle(round_coordA, round_coordB) #for border-radius

    penup() # for the big circle
    goto(gotoAx, gotoAy) # defining the new origin for the pen
    pendown() # stopping the draw
    circle(circleAx, circleAy) #built-in function for a circle in the middle

    penup() 
    goto(110,130) # setting the new origin 
    pendown()
    circle(circleBx, circleBy) # built-in function for a circle at the top-right

    done() # end the program

if __name__ == "__main__":
    backFrame()
    main()

Output:

Draw Instagram Logo using Python Turtle

Explanation the Code for the Instagram Logo using Python Turtle:

The backFrame() function for creating background:

def backFrame():
    COLOR = (0.60156, 0, 0.99218)  # (154, 0, 254)
    TARGET = (0.86328, 0.47656, 0.31250)  # (221, 122, 80)

    screen = Screen()
    screen.tracer(False)

    WIDTH, HEIGHT = screen.window_width(), screen.window_height() #defining some useful variables

    deltas = [(hue - COLOR[index]) / HEIGHT for index, hue in enumerate(TARGET)]

    turtle = Turtle()
    turtle.color(COLOR)

    turtle.penup()
    turtle.goto(-WIDTH/2, HEIGHT/2)
    turtle.pendown()

    direction = 1

    #the gradient background
    for distance, y in enumerate(range(HEIGHT//2, -HEIGHT//2, -1)):

        turtle.forward(WIDTH * direction)
        turtle.color([COLOR[i] + delta * distance for i, delta in enumerate(deltas)])
        turtle.sety(y)

        direction *= -1

    screen.tracer(True)

The main() function of Instagram Logo using Python Turtle:

1. Importing the Turtle module and defining variables to be used:

def main():
    ## setting all the pre-defined values to be used in the program
    pen_color = 'white'
    width_val = 23
    round_coordA, round_coordB = 34, 90 
    circleAx, circleAy = 80, 360
    circleBx, circleBy = 7, 360
    gotoAx, gotoAy = 85, 30
    gotoBx, gotoBy = 160, -100

    pencolor(pen_color) #defining the color of the pen
    width(width_val) #defining the thickness of the pen
    penup() #start the draw
    goto(gotoBx, gotoBy) #set the origin for the graphics
    pendown() #stop the draw temporarily

    left(90) #turn at an angle 
    for i in range(4): #loop for 4 times for a square-type shape
        forward(250) 
        circle(round_coordA, round_coordB) #for border-radius of Instagram Logo using Python Turtle

    penup() # for the big circle
    goto(gotoAx, gotoAy) # defining the new origin for the pen
    pendown() # stopping the draw
    circle(circleAx, circleAy) #built-in function for a circle in the middle

    penup() 
    goto(110,130) # setting the new origin 
    pendown()
    circle(circleBx, circleBy) # built-in function for a circle at the top-right

    done() # end the program

2. Setting the origin for the initial graphics

    pencolor(pen_color) #defining the color of the pen
    width(width_val) #defining the thickness of the pen
    penup() #start the draw
    goto(gotoBx, gotoBy) #set the origin for the graphics
    pendown() #stop the draw temporarily

3. Drawing the initial square-type shape with border-radius

    left(90) #turn at an angle 
    for i in range(4): #loop for 4 times for a square-type shape
        forward(250) 
        circle(round_coordA, round_coordB) #for border-radius of Instagram Logo using Python Turtle

4. Setting origin and drawing the big circle

    penup() # for the big circle
    goto(gotoAx, gotoAy) # defining the new origin for the pen
    pendown() # stopping the draw
    circle(circleAx, circleAy) #built-in function for a circle in the middle

5. Drawing the dot on the top right

    penup() 
    goto(110,130) # setting the new origin 
    pendown()
    circle(circleBx, circleBy) # built-in function for a circle at the top-right

6. End the program

    done() # end the program

7. Last Part

if __name__ == "__main__":
    backFrame()
    main()

After reading this article, I hope you have learned how to draw the Instagram Logo using Python Turtle.


Also Read:

Share:

Author: Ayush Purawr