Ganpati Drawing using Python Turtle: A Python Tutorial

Hello Doston, Python ke Turtle graphics library ka upyog karke Ganpati (Ganesha) ki drawing banane wale code ko ek blog article ke liye vistar se samjhein.
Ganpati Drawing using Python Turtle

Ganpati Drawing using Python Turtle: A Python Tutorial

Python, ek shaktishali aur prachin programming bhasha hai jo aapko vividh upyogon mein madad karta hai. Aaj hum dekhenge kaise Python ke Turtle graphics library ka upyog karke Ganpati (Ganesha) ki drawing banayi jaa sakti hai. Turtle graphics, ek aise module hai jo sketching aur drawing karne ke liye banaya gaya hai aur yeh programming ko aakarshak aur prakrutik banata hai.

Step 1: Importing Necessary Libraries

Sabse pehle, hume zaroori pustake (libraries) import karni hoti hain. Is code mein, hum Turtle ko import karte hain, jo hamein drawing banane ke liye avsar deta hai.
from turtle import*

Step 2: Setting Up the Environment

Uske baad, hum Turtle graphics environment ko set karte hain. Yahan, hum ek nayi screen banate hain, jiska background black hota hai aur hum uska title bhi set karte hain. Fir, hum uski drawing speed ko set karte hain aur color set karte hai.
title('www.programmingkakeeda.com')
bgcolor("#343434")
speed(4)
pencolor('red')
fillcolor('orange')

Step 3: Drawing the Body and Head

Ab hum Turtle ka upyog karke Ganpati ka sharir aur sir banayenge. Iske baad, hum Ganpati ke chehre ke kuch gun jodte hain. Aankhon, naak aur muh ko dots aur curve line se banate hain. Ganpati ke kaano ko represent karne ke liye, hum Turtle ka upyog karke kaano ki shape banate hain.
def misu(x,y):
    penup()
    goto(x,y)
    pendown()

# trunk    
misu(-130,150)
seth(-120)
begin_fill()
circle(100,90)
circle(280,10)
circle(-120,90)
circle(-60,150)
circle(-30,60)
seth(-120)
circle(30,60)
circle(55,150)
circle(120,77)
circle(-100,115)
end_fill()
misu(0,50)
seth(20)
begin_fill()
circle(-50,80)
circle(-200,70)
circle(-50,60)
seth(-20)
circle(50,70)
circle(205,70)
circle(50,85)
end_fill()
misu(70,10)
seth(15)
begin_fill()
circle(90,120)
seth(-52)
circle(-90,110)
end_fill()

# eyes
def eye():
    seth(-55)
    begin_fill()
    circle(20,120)
    seth(-90)
    circle(-17,165)
    end_fill()
misu(-100,110)    
eye()
misu(40,110)
eye()

# tilak
def cir(r):
    begin_fill()
    circle(r)
    end_fill()
misu(0,150)    
cir(10)
misu(-2,125)
cir(8)
misu(-4,105)
cir(5)

# crown
misu(-80,200)
seth(30)
begin_fill()
circle(-150,60)
seth(141)
circle(120,80)
end_fill()
misu(-70,225)
seth(30)
begin_fill()
circle(-120,60)
seth(141)
circle(95,80)
end_fill()
misu(-30,280)
seth(-120)
begin_fill()
circle(20,250)
circle(-50,40)
seth(-100)
circle(50,42)
circle(-15,240)
end_fill()
misu(-5,268)
cir(9)

# left ear
misu(-160,130)
seth(120)
begin_fill()
circle(70,60)
circle(15,100)
circle(90,30)
circle(-15,40)
circle(90,30)
circle(20,100)
seth(-130)
circle(-20,100)
circle(-90,30)
circle(15,35)
circle(-90,50)
circle(-18,80)
circle(-70,80)
end_fill()

# right ear
misu(140,130)
seth(60)
begin_fill()
circle(-70,60)
circle(-15,100)
circle(-90,30)
circle(15,40)
circle(-90,30)
circle(-20,100)
seth(-50)
circle(20,100)
circle(90,30)
circle(-15,35)
circle(90,50)
circle(18,80)
circle(70,80)
end_fill()

# belly
misu(-130,-20)
seth(-60)
begin_fill()
circle(-20,60)
circle(150,50)
circle(60,60)
seth(175)
circle(-70,70)
circle(-132,50)
circle(40,40)
end_fill()

# left leg
misu(-90,-250)
seth(180)
begin_fill()
circle(-100,60)
circle(20,90)
circle(40,40)
circle(20,60)
circle(120,40)
seth(178)
circle(-120,40)
circle(-25,60)
circle(-50,50)
circle(-30,90)
circle(70,50)
end_fill()

# right leg
misu(120,-260)
seth(15)
begin_fill()
circle(120,50)
circle(20,90)
circle(70,40)
circle(120,40)
circle(-60,60)
circle(70,60)
circle(20,90)
seth(-120)
circle(20,120)
circle(40,50)
circle(-70,40)
seth(180)
circle(65,40)
circle(-35,40)
circle(-17,120)
seth(120)
circle(-14,70)
circle(-65,60)
circle(40,70)
circle(-115,50)
circle(-60,20)
circle(-15,98)
circle(-110,50)
end_fill()

# left hand
misu(-170,-60)
seth(180)
begin_fill()
circle(20,80)
circle(-30,150)
circle(20,80)
seth(0)
circle(-20,80)
circle(32,170)
circle(-20,80)
end_fill()
misu(-205,-80)
seth(75)
begin_fill()
circle(40,60)
seth(-150)
circle(40,60)
seth(65)
circle(-40,40)
seth(-45)
circle(-40,35)
end_fill()

# right hand
misu(240,-60)
seth(180)
begin_fill()
circle(20,80)
circle(-30,150)
circle(20,80)
seth(0)
circle(-20,80)
circle(32,170)
circle(-20,80)
end_fill()
misu(205,-80)
seth(75)
begin_fill()
circle(40,60)
seth(-150)
circle(40,60)
seth(65)
circle(-40,40)
seth(-45)
circle(-40,35)
end_fill()

Step 4: Final Touches

Aakhir mein, hum Turtle ko chhupate hain (optional) aur done() ka upyog karte hain takki window khuli rahe aur hum drawing ko dekh sakein.
hideturtle()
done()

Full Code: Ganpati Drawing using Turtle: A Python Tutorial

from turtle import*

title('www.programmingkakeeda.com')
bgcolor("#343434")
speed(4)
pencolor('red')
fillcolor('orange')

def misu(x,y):
    penup()
    goto(x,y)
    pendown()

# trunk    
misu(-130,150)
seth(-120)
begin_fill()
circle(100,90)
circle(280,10)
circle(-120,90)
circle(-60,150)
circle(-30,60)
seth(-120)
circle(30,60)
circle(55,150)
circle(120,77)
circle(-100,115)
end_fill()
misu(0,50)
seth(20)
begin_fill()
circle(-50,80)
circle(-200,70)
circle(-50,60)
seth(-20)
circle(50,70)
circle(205,70)
circle(50,85)
end_fill()
misu(70,10)
seth(15)
begin_fill()
circle(90,120)
seth(-52)
circle(-90,110)
end_fill()

# eyes
def eye():
    seth(-55)
    begin_fill()
    circle(20,120)
    seth(-90)
    circle(-17,165)
    end_fill()
misu(-100,110)    
eye()
misu(40,110)
eye()

# tilak
def cir(r):
    begin_fill()
    circle(r)
    end_fill()
misu(0,150)    
cir(10)
misu(-2,125)
cir(8)
misu(-4,105)
cir(5)

# crown
misu(-80,200)
seth(30)
begin_fill()
circle(-150,60)
seth(141)
circle(120,80)
end_fill()
misu(-70,225)
seth(30)
begin_fill()
circle(-120,60)
seth(141)
circle(95,80)
end_fill()
misu(-30,280)
seth(-120)
begin_fill()
circle(20,250)
circle(-50,40)
seth(-100)
circle(50,42)
circle(-15,240)
end_fill()
misu(-5,268)
cir(9)

# left ear
misu(-160,130)
seth(120)
begin_fill()
circle(70,60)
circle(15,100)
circle(90,30)
circle(-15,40)
circle(90,30)
circle(20,100)
seth(-130)
circle(-20,100)
circle(-90,30)
circle(15,35)
circle(-90,50)
circle(-18,80)
circle(-70,80)
end_fill()

# right ear
misu(140,130)
seth(60)
begin_fill()
circle(-70,60)
circle(-15,100)
circle(-90,30)
circle(15,40)
circle(-90,30)
circle(-20,100)
seth(-50)
circle(20,100)
circle(90,30)
circle(-15,35)
circle(90,50)
circle(18,80)
circle(70,80)
end_fill()

# belly
misu(-130,-20)
seth(-60)
begin_fill()
circle(-20,60)
circle(150,50)
circle(60,60)
seth(175)
circle(-70,70)
circle(-132,50)
circle(40,40)
end_fill()

# left leg
misu(-90,-250)
seth(180)
begin_fill()
circle(-100,60)
circle(20,90)
circle(40,40)
circle(20,60)
circle(120,40)
seth(178)
circle(-120,40)
circle(-25,60)
circle(-50,50)
circle(-30,90)
circle(70,50)
end_fill()

# right leg
misu(120,-260)
seth(15)
begin_fill()
circle(120,50)
circle(20,90)
circle(70,40)
circle(120,40)
circle(-60,60)
circle(70,60)
circle(20,90)
seth(-120)
circle(20,120)
circle(40,50)
circle(-70,40)
seth(180)
circle(65,40)
circle(-35,40)
circle(-17,120)
seth(120)
circle(-14,70)
circle(-65,60)
circle(40,70)
circle(-115,50)
circle(-60,20)
circle(-15,98)
circle(-110,50)
end_fill()

# left hand
misu(-170,-60)
seth(180)
begin_fill()
circle(20,80)
circle(-30,150)
circle(20,80)
seth(0)
circle(-20,80)
circle(32,170)
circle(-20,80)
end_fill()
misu(-205,-80)
seth(75)
begin_fill()
circle(40,60)
seth(-150)
circle(40,60)
seth(65)
circle(-40,40)
seth(-45)
circle(-40,35)
end_fill()

# right hand
misu(240,-60)
seth(180)
begin_fill()
circle(20,80)
circle(-30,150)
circle(20,80)
seth(0)
circle(-20,80)
circle(32,170)
circle(-20,80)
end_fill()
misu(205,-80)
seth(75)
begin_fill()
circle(40,60)
seth(-150)
circle(40,60)
seth(65)
circle(-40,40)
seth(-45)
circle(-40,35)
end_fill()
hideturtle()
done()
Output:
Ganpati Drawing using Python Turtle

Yeh tha ek sadharan tarah se Ganpati (Ganesha) ki representation banane wale Python ka Turtle graphics ka program. Aap ise apne creativity ke anurup aur adhik vistarit bana sakte hain.

Is tutorial mein humne dekha kaise Python ke Turtle graphics library ka upyog karke, hum ek Ganpati bana sakte hain. Aap ise apne ruchi ke anusar modify karke aur adhik details add karke ek alag prakar ki representation bana sakte hain.
Aap is article ko apne projects mein shaamil karke, Python aur Turtle graphics ke madhyam se kisi bhi prakar ki representation banaane ka tareeka sikhane ke liye ap humari website programming ka keeda ke sat joode rahe, Happy Coding!

एक टिप्पणी भेजें

0 टिप्पणियाँ
* Please Don't Spam Here. All the Comments are Reviewed by Admin.