Draw Doraemon with Python Turtle

Draw Doraemon with Python Turtle

In this tutorial, we will be learning how to Draw Doraemon with Python Turtle module. This tutorial will mainly focus on the beginner and intermediate coders in python turtle. You will first read the code and then read all the explanations. You might see some errors in Python 3 but you can ignore them. We have other Turtle articles too.

Code to Draw Doraemon:

from turtle import *


# Doraemon with Python Turtle
def ankur(x, y):
    penup()
    goto(x, y)
    pendown()


def aankha():
    fillcolor("#ffffff")
    begin_fill()

    tracer(False)
    a = 2.5
    for i in range(120):
        if 0 <= i < 30 or 60 <= i < 90:
            a -= 0.05
            lt(3)
            fd(a)
        else:
            a += 0.05
            lt(3)
            fd(a)
    tracer(True)
    end_fill()


def daari():
    ankur(-32, 135)
    seth(165)
    fd(60)

    ankur(-32, 125)
    seth(180)
    fd(60)

    ankur(-32, 115)
    seth(193)
    fd(60)

    ankur(37, 135)
    seth(15)
    fd(60)

    ankur(37, 125)
    seth(0)
    fd(60)

    ankur(37, 115)
    seth(-13)
    fd(60)


def mukh():
    ankur(5, 148)
    seth(270)
    fd(100)
    seth(0)
    circle(120, 50)
    seth(230)
    circle(-120, 100)


def muflar():
    fillcolor('#e70010')
    begin_fill()
    seth(0)
    fd(200)
    circle(-5, 90)
    fd(10)
    circle(-5, 90)
    fd(207)
    circle(-5, 90)
    fd(10)
    circle(-5, 90)
    end_fill()


def nak():
    ankur(-10, 158)
    seth(315)
    fillcolor('#e70010')
    begin_fill()
    circle(20)
    end_fill()


def black_aankha():
    seth(0)
    ankur(-20, 195)
    fillcolor('#000000')
    begin_fill()
    circle(13)
    end_fill()

    pensize(6)
    ankur(20, 205)
    seth(75)
    circle(-10, 150)
    pensize(3)

    ankur(-17, 200)
    seth(0)
    fillcolor('#ffffff')
    begin_fill()
    circle(5)
    end_fill()
    ankur(0, 0)


def face():
    fd(183)
    lt(45)
    fillcolor('#ffffff')
    begin_fill()
    circle(120, 100)
    seth(180)
    # print(pos())
    fd(121)
    pendown()
    seth(215)
    circle(120, 100)
    end_fill()
    ankur(63.56, 218.24)
    seth(90)
    aankha()
    seth(180)
    penup()
    fd(60)
    pendown()
    seth(90)
    aankha()
    penup()
    seth(180)
    fd(64)


def taauko():
    penup()
    circle(150, 40)
    pendown()
    fillcolor('#00a0de')
    begin_fill()
    circle(150, 280)
    end_fill()


def Doraemon():
    taauko()

    muflar()

    face()

    nak()

    mukh()

    daari()

    ankur(0, 0)

    seth(0)
    penup()
    circle(150, 50)
    pendown()
    seth(30)
    fd(40)
    seth(70)
    circle(-30, 270)

    fillcolor('#00a0de')
    begin_fill()

    seth(230)
    fd(80)
    seth(90)
    circle(1000, 1)
    seth(-89)
    circle(-1000, 10)

    # print(pos())

    seth(180)
    fd(70)
    seth(90)
    circle(30, 180)
    seth(180)
    fd(70)

    # print(pos())
    seth(100)
    circle(-1000, 9)

    seth(-86)
    circle(1000, 2)
    seth(230)
    fd(40)

    # print(pos())

    circle(-30, 230)
    seth(45)
    fd(81)
    seth(0)
    fd(203)
    circle(5, 90)
    fd(10)
    circle(5, 90)
    fd(7)
    seth(40)
    circle(150, 10)
    seth(30)
    fd(40)
    end_fill()

    seth(70)
    fillcolor('#ffffff')
    begin_fill()
    circle(-30)
    end_fill()

    ankur(103.74, -182.59)
    seth(0)
    fillcolor('#ffffff')
    begin_fill()
    fd(15)
    circle(-15, 180)
    fd(90)
    circle(-15, 180)
    fd(10)
    end_fill()

    ankur(-96.26, -182.59)
    seth(180)
    fillcolor('#ffffff')
    begin_fill()
    fd(15)
    circle(15, 180)
    fd(90)
    circle(15, 180)
    fd(10)
    end_fill()

    ankur(-133.97, -91.81)
    seth(50)
    fillcolor('#ffffff')
    begin_fill()
    circle(30)
    end_fill()
    # Doraemon with Python Turtle

    ankur(-103.42, 15.09)
    seth(0)
    fd(38)
    seth(230)
    begin_fill()
    circle(90, 260)
    end_fill()

    ankur(5, -40)
    seth(0)
    fd(70)
    seth(-90)
    circle(-70, 180)
    seth(0)
    fd(70)

    ankur(-103.42, 15.09)
    fd(90)
    seth(70)
    fillcolor('#ffd200')
    # print(pos())
    begin_fill()
    circle(-20)
    end_fill()
    seth(170)
    fillcolor('#ffd200')
    begin_fill()
    circle(-2, 180)
    seth(10)
    circle(-100, 22)
    circle(-2, 180)
    seth(180 - 10)
    circle(100, 22)
    end_fill()
    goto(-13.42, 15.09)
    seth(250)
    circle(20, 110)
    seth(90)
    fd(15)
    dot(10)
    ankur(0, -150)

    black_aankha()


if __name__ == '__main__':
    screensize(800, 600, "#f0f0f0")
    pensize(3)
    speed(9)
    Doraemon()
    ankur(100, -300)
    write('by Ankur Gajurel', font=("Bradley Hand ITC", 30, "bold"))
    mainloop()

Output(Draw Doraemon):

Output for Draw Doraemon with Python Turtle
output to draw Doraemon with Python Turtle

Explanation(of above code to draw Doraemon with Python Turtle):

First Part ( 3 Body Parts inside functions ):

  • In the first part of our code to Draw Doraemon, import the turtle module and start a function name “ankur” and give the parameters “x” and “y”. Then, call the penup() method and go to (x, y). And put the pen down.
  • Now, start a function name “aankha”. Inside this function, fill the part with the color white as in “#ffffff”. Now start the fill and set the tracer to False. Then, set the value of the variable “a” to 2.5. Likewise, start a for loop with the range of 120. Inside this loop, check if “i” which loops from 0 to 120 falls under (0 – 30) or (60 – 90). If yes, subtract 0.5 from “a” and call the methods lt() and fd() with the arguments “3” and “a”. If no, add 0.5 tp “a” and call the methods lt() and fd() as above. Now, end the fill.
  • Accordingly, start a function named “daari()” and call “ankur” with the arguments (-32, 135), the Seth method with the argument 165, and the fd() method with the argument 60. Likewise, do the same as above by changing the seth, fd, and the second argument of “ankur” as written in the code above.

Second Part ( Another 3 Body Parts ):

  • Similarly, in the second part of our code to Draw Doraemon start a function mukh(). Inside this function, call the ankur() function with the arguments (5, 148). Likely, call the seth method with the argument “270” and fd() with “100”. Again, call the seth() method with 0 and draw a circle with the arguments “120, 100”. Then, call the seth(230) and circle(-120, 100).
  • Likewise, start a function muflar(). Inside this function, fill the part with the color #e70010. Then, begin the fill and call the seth(0) and fd(200) and draw a circle(-5, 90). Similarly, call the fd() method with the argument 207 and circle(-5, 90) . And again, fd(10) and circle (-5, 90).
  • Accordingly, start function name nak(). Inside this function, call the “ankur” function with the arguments (-10. 158) and seth(315). Then fill the part with the color #e70010 and begin the fill. As the nose is only one circle, draw a circle(20) and end the fill.

Third Part ( Last three Body Parts ):

  • Likewise, start a function named black_aankha(). Inside this function, call the seth(0) and ankur with the arguments (-20, 195). Then, fill the part with the color #00000 ( black ) and begin the fill. Draw a circle(13) and end the first half. Now, set the pen size to 6 and call the “ankur” function with the arguments (20, 205), seth(75), circle(-10, 150), and set the pen size to 3. Again, call the “ankur” function with the arguments(-17, 200). Then, call seth(0), fill the part with #ffffff (white), and begin fill. Now, draw a circle(5) and end fill.
  • Similarly, create a function name face() . Inside this function, call the fd(183), lt(45), fill with the color #ffffff (white) and begin the fill. Now, create a circle(120, 100), seth(180), fd(121) and put the down. Then, call seth(215), circle(120, 100), end the fill and call “ankur” with the arguments (63.56, 213.24). Likewise, call seth(90), aankha(), seth(180) and pick the pen up. Then, call fd(60), pendown(), seth(90), aankha(), penup(), seth(180) and fd(64).
  • Now, create a function tauko(). Inside this function, call penup(), circle(150, 40), pendown() and fill the part with the color #00a0de. Then, begin the fill and draw a circle(150, 280) and end the fill.

Fourth Part (Doraemon whole body function):

  • In this part, of “Draw Doraemon with python turtle”, create a function name Doraemon(). Everything in this part is coded inside this function. First, call the taauko() function, muflar() function, face() function, nak() function, mukh() function, daari() function and ankur() function with the arguments (0, 0)
  • Now, call the seth(0),pick the pen up() and draw a circle(150, 50) and put the pen down. Likewise, call the seth() with the angle 30, fd(40), seth(70) and circle(-30, 270). Then, fill the part with the color #00a0de and begin the fill. Similarly, call the seth() with the value of angle 230, fd() with the value 80, seth with the angle 90, circle(1000, 1), again seth() with the angle -89 and circle(-1000, 10).
  • Accordingly, call the seth() with the angle 180, fd() with the value 70, seth with the angle 90, circle(30, 180), again seth() with the angle 180 and fd() with the value 70.
  • Then, call the seth with the angle 100 and circle(-1000, 9). Again, call the seth() method with the angle -86, circle(1000, 2), seth(230) and fd(40).
  • Likewise, draw a circle(-30, 230), seth() method with the angle 45, fd() method with the value 81, seth(0) and fd(203). Now, draw a circle(5, 90), fd(10), circle(5, 90), fd() method with the value 7, seth() method with the angle 40. Similarly, draw a circle(150, 10), seth(30), fd(40) and end the fill.
  • Now, call the seth(70) and fill the part with the color #ffffff (white) and begin the fill. Draw a circle with the value -3- and end the fill.
  • Similarly, call the ankur() function with the arguments (103.74, -182.59) and fill the part with the color #ffffff (white) and begin the fill. Now, call the fd(15), circle(-15, 180), fd(90), circle(-15, 180), fd(10) and end the fill.
  • Again, call the “ankur()” function with the arguments (-96.26, -182.59) and seth with the angle 180. Then, fill the part with color #ffffff (white) and begin the fill. Now, call the fd(15) and draw a circle(15, 180). Again call the fd(90), circle(15, 180) and fd(10) and end the fill.
  • Accordingly, call the “ankur()” function with the arguments (-133.97, -91.81), seth() method with the angle 50, fill the part with the color white and begin the fill of circle(30) and end the fill.
  • Now, again, call the “ankur” function with the arguments (-103.42, 15.09), seth() method with the angle 0, fd() with the value 38, again seth() with the angle 230 and begin the fill. Draw a circle(90, 260) and the fill.
  • Call the ankur() function (5, -40), seth() method with angle of 0, fd() with the value 70, seth with the angle of -90, circle(-70, 180), again seth with 0 and at lat fd with the value 70.
  • As this is the last code to Draw Doraemon with Python Turtle, call the “ankur()” function with the arguments (-103.42, 15.09), fd() with the value of 90, seth() method with the angle of 70. Fill the part with the color #ffd200 and begin the fill. Now, draw a circle(-20) and end the fill. Call the seth() method with the angle of 170 and full the part with the color #ffd200 and again begin the fill, Draw a circle(-2, 180), seth() method with the angle of 10. Now, draw 2 circles with the arguments (-100, 22) and (-1, 180) respectively. Then, call the seth() method with the angle of 90, circle(100, 22), and end the fill.
  • Go to (-13.42, 15.09) and call the method seth() with the angle of 250. Draw a circle of (20, 110), seth with the angle of 90, fd() with the value of 15, dot() method with the value of 10. At last, ankur() function with the arguments (0, -150) and the black_aankha() function.

Last Part (Module Source File):

  • Lastly, write the module source file code of the main program. i. e __name__ == “__main__” and set the screensize to (800, 600) and the background color to #f0f0f0. Set the pen size to 3 and set the speed to 9. Now, call the Doraemon() function and the ankur() function with the arguents (100, -300). Run the Tkinter event loop “mainloop()”.

Thank You for reading till the end. If you found something wrong in the post, please let us know using comments.

Keep Coding, Keep Learning


Also Read:


Keywords->doraemon python code, python code for Doraemon, python Doraemon code, doraemon code in python,
doraemon turtle python, draw doraemon using python code, python turtle code for doraemon, python program to draw doraemon, doraemon in python, doraemon using python, draw doraemon using python, python turtle doraemon, python code for making doraemon, doraemon python source code, doraemon program in python, python code to draw doraemon, python program for doraemon, code doraemon, nobita python code, python code for drawing doraemon, how to draw doraemon in python, doraemon coding, doremon python code, how to make doraemon in python, doraemon drawing python code, violet-cat-415996.hostingersite.com shinchan,

Share:

Author: Ayush Purawr