We use cookies to improve your experience. If you continue to use our site, we'll assume that you're happy with it. :)

A Complete Tutorial in Python to Design a “Pikachu” using Turtle

0 min read

In Today's Article, I'll Demonstrate you How to Design a Pikachu using Turtle in Python.

Step 1: Open any Editor (Eg. VS Code)

Step 2: Copy and Paste the Code Provided Below.

Note: Make Sure that you Have Installed Turtle Module on your System.

To Install: Type the Following Command in Command Prompt.

pip install PythonTurtle

Step 3: Source Code.

import turtle
class Pikachu:
 
    def __init__(self):
        self.t = turtle.Turtle()
        t = self.t
        t.pensize(3)
        t.speed(9)
 
    def move_pointer(self, x, y):
        self.t.penup()
        self.t.goto(x, y)
        self.t.pendown()
 
    def eye1(self, x, y):
        self.move_pointer(x, y)
        t = self.t
        t.seth(0)
        t.fillcolor('#333333')
        t.begin_fill()
        t.circle(22)
        t.end_fill()
 
        self.move_pointer(x, y + 10)
        t.fillcolor('#000000')
        t.begin_fill()
        t.circle(10)
        t.end_fill()
 
        self.move_pointer(x + 6, y + 22)
        t.fillcolor('#ffffff')
        t.begin_fill()
        t.circle(10)
        t.end_fill()
 
    def eye2(self, x, y):
        self.move_pointer(x, y)
        t = self.t
        t.seth(0)
        t.fillcolor('#333333')
        t.begin_fill()
        t.circle(22)
        t.end_fill()
 
        self.move_pointer(x, y + 10)
        t.fillcolor('#000000')
        t.begin_fill()
        t.circle(10)
        t.end_fill()
 
        self.move_pointer(x - 6, y + 22)
        t.fillcolor('#ffffff')
        t.begin_fill()
        t.circle(10)
        t.end_fill()
 
    def mouth(self, x, y):
        self.move_pointer(x, y)
        t = self.t
 
        t.fillcolor('#88141D')
        t.begin_fill()
        #
        l1 = []
        l2 = []
        t.seth(190)
        a = 0.7
        for i in range(28):
            a += 0.1
            t.right(3)
            t.fd(a)
            l1.append(t.position())
 
        self.move_pointer(x, y)
 
        t.seth(10)
        a = 0.7
        for i in range(28):
            a += 0.1
            t.left(3)
            t.fd(a)
            l2.append(t.position())
 
        t.seth(10)
        t.circle(5015)
        t.left(180)
        t.circle(-5015)
 
        t.circle(-5040)
        t.seth(233)
        t.circle(-5055)
        t.left(180)
        t.circle(5012.1)
        t.end_fill()
        self.move_pointer(1754)
        t.fillcolor('#DD716F')
        t.begin_fill()
        t.seth(145)
        t.circle(4086)
        t.penup()
        for pos in reversed(l1[:20]):
            t.goto(pos[0], pos[1] + 1.5)
        for pos in l2[:20]:
            t.goto(pos[0], pos[1] + 1.5)
        t.pendown()
        t.end_fill()
        self.move_pointer(-1794)
        t.seth(8)
        t.fd(4)
        t.back(8)
 
    #
    def cheek1(self, x, y):
        turtle.tracer(False)
        t = self.t
        self.move_pointer(x, y)
        t.seth(300)
        t.fillcolor('#DD4D28')
        t.begin_fill()
        a = 2.3
        for i in range(120):
            if 0 <= i < 30 or 60 <= i < 90:
                a -= 0.05
                t.lt(3)
                t.fd(a)
            else:
                a += 0.05
                t.lt(3)
                t.fd(a)
        t.end_fill()
        turtle.tracer(True)
 
    def cheek2(self, x, y):
        t = self.t
        turtle.tracer(False)
        self.move_pointer(x, y)
        t.seth(60)
        t.fillcolor('#DD4D28')
        t.begin_fill()
        a = 2.3
        for i in range(120):
            if 0 <= i < 30 or 60 <= i < 90:
                a -= 0.05
                t.lt(3)
                t.fd(a)
            else:
                a += 0.05
                t.lt(3)
                t.fd(a)
        t.end_fill()
        turtle.tracer(True)
 
    def ear1(self, x, y):
        t = self.t
        self.move_pointer(x, y)
        t.fillcolor('#000000')
        t.begin_fill()
        t.seth(330)
        t.circle(10035)
        t.seth(219)
        t.circle(-30019)
        t.seth(110)
        t.circle(-3050)
        t.circle(-30010)
        t.end_fill()
 
    def ear2(self, x, y):
        t = self.t
        self.move_pointer(x, y)
        t.fillcolor('#000000')
        t.begin_fill()
        t.seth(300)
        t.circle(-10030)
        t.seth(35)
        t.circle(30015)
        t.circle(3050)
        t.seth(190)
        t.circle(30017)
        t.end_fill()
 
    def draw(self):
        t = self.t
 
        t.fillcolor('#F6D02F')
        t.begin_fill()
        #
        t.penup()
        t.circle(13040)
        t.pendown()
        t.circle(100105)
        t.left(180)
        t.circle(-1005)
        t.seth(20)
        t.circle(30030)
        t.circle(3050)
        t.seth(190)
        t.circle(30036)
        t.seth(150)
        t.circle(15070)
        t.seth(200)
        t.circle(30040)
        t.circle(3050)
        t.seth(20)
        t.circle(30035)
        t.seth(240)
        t.circle(10595)
        t.left(180)
        t.circle(-1055)
        t.seth(210)
        t.circle(50018)
        t.seth(200)
        t.fd(10)
        t.seth(280)
        t.fd(7)
        t.seth(210)
        t.fd(10)
        t.seth(300)
        t.circle(1080)
        t.seth(220)
        t.fd(10)
        t.seth(300)
        t.circle(1080)
        t.seth(240)
        t.fd(12)
        t.seth(0)
        t.fd(13)
        t.seth(240)
        t.circle(1070)
        t.seth(10)
        t.circle(1070)
        t.seth(10)
        t.circle(30018)
 
        t.seth(75)
        t.circle(5008)
        t.left(180)
        t.circle(-50015)
        t.seth(250)
        t.circle(10065)
        t.seth(320)
        t.circle(1005)
        t.left(180)
        t.circle(-1005)
        t.seth(220)
        t.circle(20020)
        t.circle(2070)
 
        t.seth(60)
        t.circle(-10020)
        t.left(180)
        t.circle(10020)
        t.seth(300)
        t.circle(1070)
 
        t.seth(60)
        t.circle(-10020)
        t.left(180)
        t.circle(10020)
        t.seth(10)
        t.circle(10060)
        t.seth(180)
        t.circle(-10010)
        t.left(180)
        t.circle(10010)
        t.seth(5)
        t.circle(10010)
        t.circle(-10040)
        t.circle(10035)
        t.left(180)
        t.circle(-10010)
        t.seth(290)
        t.circle(10055)
        t.circle(1050)
 
        t.seth(120)
        t.circle(10020)
        t.left(180)
        t.circle(-10020)
 
        t.seth(0)
        t.circle(1050)
 
        t.seth(110)
        t.circle(10020)
        t.left(180)
        t.circle(-10020)
 
        t.seth(30)
        t.circle(2050)
 
        t.seth(100)
        t.circle(10040)
        t.seth(200)
        t.circle(-1005)
        t.left(180)
        t.circle(1005)
        t.left(30)
        t.circle(10075)
        t.right(15)
        t.circle(-30021)
        t.left(180)
        t.circle(3003)
        t.seth(43)
        t.circle(20060)
 
        t.right(10)
        t.fd(10)
 
        t.circle(5160)
        t.seth(90)
        t.circle(5160)
        t.seth(90)
 
        t.fd(10)
        t.seth(90)
        t.circle(5180)
        t.fd(10)
 
        t.left(180)
        t.left(20)
        t.fd(10)
        t.circle(5170)
        t.fd(10)
        t.seth(240)
        t.circle(5030)
 
        t.end_fill()
        self.move_pointer(130125)
        t.seth(-20)
        t.fd(5)
        t.circle(-5160)
        t.fd(5)
        self.move_pointer(166130)
        t.seth(-90)
        t.fd(3)
        t.circle(-4180)
        t.fd(3)
        t.seth(-90)
        t.fd(3)
        t.circle(-4180)
        t.fd(3)
        self.move_pointer(168134)
        t.fillcolor('#F6D02F')
        t.begin_fill()
        t.seth(40)
        t.fd(200)
        t.seth(-80)
        t.fd(150)
        t.seth(210)
        t.fd(150)
        t.left(90)
        t.fd(100)
        t.right(95)
        t.fd(100)
        t.left(110)
        t.fd(70)
        t.right(110)
        t.fd(80)
        t.left(110)
        t.fd(30)
        t.right(110)
        t.fd(32)
 
        t.right(106)
        t.circle(10025)
        t.right(15)
        t.circle(-3002)
        ##############
        t.seth(30)
        t.fd(40)
        t.left(100)
        t.fd(70)
        t.right(100)
        t.fd(80)
        t.left(100)
        t.fd(46)
        t.seth(66)
        t.circle(20038)
        t.right(10)
        t.fd(10)
        t.end_fill()
        t.fillcolor('#923E24')
        self.move_pointer(126.82, -156.84)
        t.begin_fill()
 
        t.seth(30)
        t.fd(40)
        t.left(100)
        t.fd(40)
        t.pencolor('#923e24')
        t.seth(-30)
        t.fd(30)
        t.left(140)
        t.fd(20)
        t.right(150)
        t.fd(20)
        t.left(150)
        t.fd(20)
        t.right(150)
        t.fd(20)
        t.left(130)
        t.fd(18)
        t.pencolor('#000000')
        t.seth(-45)
        t.fd(67)
        t.right(110)
        t.fd(80)
        t.left(110)
        t.fd(30)
        t.right(110)
        t.fd(32)
        t.right(106)
        t.circle(10025)
        t.right(15)
        t.circle(-3002)
        t.end_fill()
 
        self.cap(-134.07147.81)
        self.mouth(-525)
        self.cheek1(-12632)
        self.cheek2(10763)
        self.ear1(-250100)
        self.ear2(140270)
        self.eye1(-8590)
        self.eye2(50110)
        t.hideturtle()
 
    def cap(self, x, y):
        self.move_pointer(x, y)
        t = self.t
        t.fillcolor('#CD0000')
        t.begin_fill()
        t.seth(200)
        t.circle(4007)
        t.left(180)
        t.circle(-40030)
        t.circle(3060)
        t.fd(50)
        t.circle(3045)
        t.fd(60)
        t.left(5)
        t.circle(3070)
        t.right(20)
        t.circle(20070)
        t.circle(3060)
        t.fd(70)
        t.right(35)
        t.fd(50)
        t.circle(8100)
        t.end_fill()
        self.move_pointer(-168.47185.52)
        t.seth(36)
        t.circle(-27054)
        t.left(180)
        t.circle(27027)
        t.circle(-8098)
 
        t.fillcolor('#444444')
        t.begin_fill()
        t.left(180)
        t.circle(80197)
        t.left(58)
        t.circle(20045)
        t.end_fill()
 
        self.move_pointer(-58270)
        t.pencolor('#228B22')
        t.dot(35)
 
        self.move_pointer(-30280)
        t.fillcolor('#228B22')
        t.begin_fill()
        t.seth(100)
        t.circle(30180)
        t.seth(190)
        t.fd(15)
        t.seth(100)
        t.circle(-45180)
        t.right(90)
        t.fd(15)
        t.end_fill()
        t.pencolor('#000000')
 
    def start(self):
        self.draw()
 
 
def main():
    print('Painting the Pikachu... ')
    turtle.screensize(800600)
    turtle.title('Pikachu')
    cartoon = Pikachu()
    cartoon.start()
    turtle.mainloop()
 
 
if __name__ == '__main__':
    main()

Step 4: Now, Save the Code and Run it. Here's the Final Preview After all the Creating Animations.

Step 5: You're Done ! 

We Have Created a Pikachu using Turtle Module in Python. Here's a Video; How the Code Works after Compiling. It's a Animation of Designing a Pikachu.

Post a Comment