Python Turtle Animation with Programming Ka Keeda

Hello Friends! Python me Turtle Animation banana ek majedaar aur interesting tarika hai, yaha apko ek screen ke upar romanchkari tarike se niyantritt karne aur alag-alag aakaro ko banane ki suvidha pradan karta he, niche diye gaye basic concepts aur functions ki samj di gayi hai, jo Python Turtle Animation me use hote hai.
Python Turtle Animation

Python Turtle Animation with Programming Ka Keeda

1. Turtle Screen banana:

Puthon Turtle Animation banane ki suruyat me apko turtle screen banani hoti hai, iske liye ‘turtle.Screen()’ class ka use karenge, screen ek drawing window ki tarah hoti he jisme hum turtle ko move aur draw karwa sakte hai, ap screen object k dyara video ka title aur background color set kar sakte hai.

2. Turtle Object banana:

Jab apke pas tutle screen hoti hai, to ap ek turtle object bana sakte hai, turtle object virtual turtle ko represent karta he jo screen me move karta hai aur alag-alag shape ko draw karta he, ap turtle ke like shape, color, aur speed ko set kar sakte hai.

3. Turtle ko move karna:

Turtle ka use screen par draw lines and shape banane ke liye bhi kiya jata hai, aamtaur par use ki jane wali kuch drawing methods.
  • ‘penup()’: turtle ke pen ko uthaata he, taki chalte samay ye koi nishan na chhode.
  • ‘pendown()’: turtle ke pen ko down karta he, jisse wo fir se drawing banana suru karta hai.
  • ‘color(color)’: turtle pen ka color set karta hai.
  • ‘width(width)’: turtle pen ki width set kar sakta hai.
  • ‘circle(radius)’: apki batai hui radius par circle banata hai.
  • ‘goto(x,y)’: specified coordinates par turtle ko move karta hai.

4. Loop ke sat Animation karna:

Animation banane k liye, ap turtle ki movements ya drawing operations ki sequence ko repeat karne ke liye loop ka use kar sakte hai, example ke liye ap instructions ke ek sat ko ek specific number me repeat karne k liye for loop ka use kar sakte hai.

First Image Code:
from turtle import*
from time import*

title("Python Turtle Animation")
bgcolor("black")
pencolor("orange")
width(3)
speed(0)
sleep(2)

def flower(x):
    circle(100, x)
    penup()
    goto(0,0)
    pendown()
    circle(-100, x)

def leaf():
    for i in range(0,95,7):
      flower(i)        

leaf()    
setheading(50)
leaf()
setheading(100)
leaf()
setheading(150)
leaf()    
setheading(200)
leaf()
setheading(250)
leaf()
setheading(300)
leaf()
done()
Output:
Python Turtle Animation
Video Link:- Click me
Second Image Code:
import turtle
import colorsys
s=turtle.Screen()
t=turtle.Turtle()
turtle.bgcolor('black')
m=0.9
t.shape('turtle')

for i in range(130):
    c = colorsys.hsv_to_rgb(m,1, 0.99)
    m +=0.33
    turtle.tracer(i-150)
    t.pensize(5)
    t.pencolor(c)
    t.forward(0+i)
    t.right(20)
    t.forward(1+i)
    t.right(40)
    t.forward(2+i)
    t.right(60)
    t.forward(3+i)
    t.right(80)
    t.forward(4+i)
    t.forward(5+i)  
turtle.done()
Output:
Python Turtle Animation
Video Link:- Click me
In concepts aur functions ko mila kar, ap Python me Turtle Module ka use karke interactive animations bana sakte hai, ap turtle module ka use karke simple design aur games tak bana sakte hai.
Mere Website me aane ke liye Dhanyawaad!

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

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