Saturday, December 28, 2024

Happy Birthday Vaibhav(Love) Using Python Turtle


import turtle as tech_habit
ankita = tech_habit.Screen()
ankita.bgcolor("black")
tech_habit.pencolor("linen")
colors_design = ["#f5ac2f", "#279cf5", "#d820f5", "#a2f52f", "#f527c1"]
colors_heart = ["orange", "red", "dark blue", "green", "#fc037f", "gold", "ivory", "red", "pink",
"green", "blue", "light green", ]
def move(x, y):
tech_habit.up()
tech_habit.setposition(0, 0)
tech_habit.setheading(90)
tech_habit.rt(90)
tech_habit.fd(x)
tech_habit.lt(90)
tech_habit.fd(y)
tech_habit.pendown()

def mov(x, y):
tech_habit.up()
tech_habit.setposition(0, 0)
tech_habit.setheading(90)
tech_habit.lt(90)
tech_habit.fd(x)
tech_habit.rt(90)
tech_habit.fd(y)
tech_habit.pendown()


def draw_ankita(i, x, y):
tech_habit.pencolor("linen")
tech_habit.color(colors_design[i % 7])
tech_habit.lt(70)
tech_habit.penup()
tech_habit.goto(x, y)
tech_habit.pendown()
tech_habit.circle(22)
tech_habit.end_fill()

def curve():
for i in range(200):
tech_habit.right(1)
tech_habit.forward(1)
#
# def heart():
# tech_habit.fillcolor('red')
# tech_habit.begin_fill()
# tech_habit.left(140)
# tech_habit.forward(113)
# curve()
# tech_habit.left(120)
# curve()
# tech_habit.forward(112)
# tech_habit.end_fill()

def heart():
for i in range(43):
tech_habit.pencolor(colors_heart[i % 9])
tech_habit.rt(5)
tech_habit.fd(5)
tech_habit.pencolor("red")
tech_habit.fd(150)
tech_habit.penup()
tech_habit.rt(140)
tech_habit.fd(147)
tech_habit.pendown()
for i in range(43):
tech_habit.pencolor(colors_heart[i % 9])
tech_habit.lt(5)
tech_habit.fd(5)
tech_habit.pencolor("red")
tech_habit.lt(7)
tech_habit.fd(151)

def I(size):
tech_habit.rt(90)
tech_habit.fd(int(size/2))
tech_habit.bk(int(size/2)*2)
tech_habit.fd(int(size/2))
tech_habit.rt(270)
tech_habit.fd(size)
tech_habit.rt(90)
tech_habit.fd(size//2)
tech_habit.backward(size)


def U(size):
tech_habit.fd(size)
tech_habit.bk(size)
tech_habit.rt(90)
tech_habit.fd(size//1.8)
tech_habit.rt(90)
tech_habit.back(size)


def V(size):
tech_habit.right(20)
tech_habit.fd(size)
tech_habit.back(size)
tech_habit.lt(40)
tech_habit.fd(size)
tech_habit.back(size)

def A(size):
tech_habit.rt(19)
tech_habit.forward(size)
tech_habit.rt(141)
tech_habit.fd(size)
tech_habit.backward(size / 2)
tech_habit.rt(105)
tech_habit.fd(int(size / 3))


def B(size):
tech_habit.forward(size)
tech_habit.rt(90)
for i in range(18):
tech_habit.rt(9)
tech_habit.fd(size // 20)
for i in range(18):
tech_habit.rt(size // 5)
tech_habit.backward(size // 20)



def D(size):
tech_habit.fd(size)
tech_habit.rt(90)
tech_habit.fd(size // 10)
for i in range(13):
tech_habit.rt(13)
tech_habit.fd(size // 8)







def G(size):
tech_habit.pensize(10)
tech_habit.penup()
tech_habit.fd(size // 2)
tech_habit.pendown()
tech_habit.lt(90)
tech_habit.fd(size // 4)
tech_habit.backward(size // 1.5)
tech_habit.lt(90)
for _ in range(size):
tech_habit.rt(4)
tech_habit.fd(4)

def S(size):
tech_habit.rt(90)
for i in range(0,5):
if i<3:
tech_habit.fd(size/2)
tech_habit.lt(90)
if i==2:
tech_habit.rt(90)
else:
tech_habit.right(90)
tech_habit.fd(size/2)

def M(size):
tech_habit.fd(int(size/2))
tech_habit.rt(135)
tech_habit.fd(int(size/3))
tech_habit.lt(90)
tech_habit.fd(int(size/3))
tech_habit.rt(135)
tech_habit.fd(int(size/2))


def H(size):
tech_habit.fd(size)
tech_habit.backward(size // 2)
tech_habit.rt(90)
tech_habit.fd(size // 2)
tech_habit.lt(90)
tech_habit.fd(size // 2)
tech_habit.backward(size)


def P(size):
tech_habit.fd(size)
tech_habit.rt(90)
tech_habit.fd(size // 8)
for i in range(8):
tech_habit.rt(20)
tech_habit.fd(size // 9)

def R():
tech_habit.fd(60)
tech_habit.rt(90)
tech_habit.fd(7)
for i in range(15):
tech_habit.rt(12)
tech_habit.fd(3)
tech_habit.lt(120)
tech_habit.fd(40)

def T(size):
tech_habit.fd(size)
tech_habit.rt(90)
tech_habit.fd(size // 2)
tech_habit.backward(size // 2)


def Y(size):
tech_habit.fd(size)
tech_habit.left(60)
tech_habit.fd(size // 2)
tech_habit.backward(size // 2)
tech_habit.rt(90)
tech_habit.fd(size // 1.5)


def I_small(size):
tech_habit.fd(size)
tech_habit.rt(90)
tech_habit.circle(size//8)


def ballon(x, y):
tech_habit.pensize(4)
for i in range(5):
draw_ankita(i, x, y)


tech_habit.speed(0)
# Bottom Line 1
tech_habit.pensize(5)
tech_habit.penup()
tech_habit.goto(-180,-120)
tech_habit.color("brown")
tech_habit.pendown()
tech_habit.forward(300)

# Mid Line 2
tech_habit.penup()
tech_habit.goto(-160,-110)
tech_habit.color("brown")
tech_habit.pendown()
tech_habit.forward(250)

# First Line 3
tech_habit.penup()
tech_habit.goto(-130,-100)
tech_habit.color("brown")
tech_habit.pendown()
tech_habit.forward(200)

# Cake
tech_habit.penup()
tech_habit.goto(-100,-90)
tech_habit.color("skyblue")
tech_habit.begin_fill()
tech_habit.pendown()
tech_habit.forward(140)
tech_habit.left(90)
tech_habit.forward(95)
tech_habit.left(90)
tech_habit.forward(140)
tech_habit.left(90)
tech_habit.forward(95)
tech_habit.end_fill()

# Candles
tech_habit.pensize(3)
tech_habit.penup()
tech_habit.goto(-90,0)
tech_habit.color("#f5ac2f")
tech_habit.left(180)
tech_habit.pendown()
tech_habit.forward(20)


tech_habit.penup()
tech_habit.goto(-60,0)
tech_habit.color("#279cf5")
tech_habit.pendown()
tech_habit.forward(20)

tech_habit.penup()
tech_habit.goto(-30,0)
tech_habit.color("#d820f5")
tech_habit.pendown()
tech_habit.forward(20)

tech_habit.penup()
tech_habit.goto(0,0)
tech_habit.color("#a2f52f")
tech_habit.pendown()
tech_habit.forward(20)

tech_habit.penup()
tech_habit.goto(30,0)
tech_habit.color("#f527c1")
tech_habit.pendown()
tech_habit.forward(20)

colors = ["red", "orange", "yellow", "green", "black", "purple", "green"]
tech_habit.penup()
tech_habit.goto(-40,-50)
tech_habit.pendown()

for each_color in colors:
angle = 360 / len(colors)
tech_habit.color(each_color)
tech_habit.circle(10)
tech_habit.right(angle)
tech_habit.forward(10)

tech_habit.speed(0)
ballon(-300, 280)
ballon(300, 280)
ballon(300, -280)
ballon(-300, -280)
ballon(-300, 0)
ballon(300, 0)

tech_habit.pencolor("#2b92ed")
tech_habit.width(7)
mov(260,150)
H(100)
mov(190,150)
A(65)
mov(135,150)
P(60)
mov(100,150)
P(60)
mov(52,150)
Y(60)
mov(28,150)
B(60)
move(8,150)
I_small(60)
move(36,150)
R()
move(80,150)
T(100)
move(102,150)
H(60)
move(150,150)
tech_habit.pencolor('#c02bed')
D(180)
move(160,150)
A(60)
move(220,150)
Y(60)

tech_habit.pencolor('#f527c1')
mov(150,40)
V(60)
mov(130,40)
A(60)
mov(80,40)
I_small(60)
mov(60,40)
B(60)
mov(30,40)
H(60)
mov(-10,40)
A(60)
mov(-70,40)
V(60)

tech_habit.penup()
mov(180,-320)
tech_habit.pendown()
#tech_habit.pencolor('#984cf5')
tech_habit.pencolor("red")

tech_habit.pensize(10)
I(150)
tech_habit.penup()
mov(-20,-180)
tech_habit.pendown()
heart()
tech_habit.penup()
mov(-150,-320)
tech_habit.pendown()
U(150)

ankita.exitonclick()

No comments:

Post a Comment

Happy Birthday Vaibhav(Love) Using Python Turtle

import  turtle  as  tech_habit ankita = tech_habit.Screen() ankita.bgcolor( "black" ) tech_habit.pencolor( "linen" ) col...