this is my code-
import turtle
import random
# Set up the turtle
t = turtle.Turtle()
t.speed(0)
t.hideturtle()
turtle.bgcolor("black")
# Define a function to draw a starburst (one arm of the supernova)
def starburst(size, angle, color):
hex_color = '#' + ''.join(format(c, '02x') for c in color)
t.pencolor(hex_color)
for i in range(30):
t.forward(size)
t.backward(size)
t.right(angle)
# Define a function to draw a transparent star
def transparent_star(x, y, size, color, alpha):
t.penup()
t.goto(x, y)
t.pendown()
t.pencolor(color)
t.fillcolor(color[0], color[1], color[2], alpha)
t.begin_fill()
for i in range(5):
t.forward(size)
t.right(144)
t.end_fill()
# Draw the supernova endlessly
while True:
x = random.randint(-200, 200)
y = random.randint(-200, 200)
t.penup()
t.goto(x, y)
t.pendown()
size = random.randint(50, 200)
angle = random.randint(10, 80)
r = random.randint(0, 255)
g = random.randint(0, 255)
b = random.randint(0, 255)
color = (r, g, b)
starburst(size, angle, color)
# Draw a random number of transparent stars
num_stars = random.randint(10, 20)
for i in range(num_stars):
r = random.randint(0, 255)
g = random.randint(0, 255)
b = random.randint(0, 255)
color = (r, g, b)
alpha = 200
star_size = random.randint(5, 20)
star_x = random.randint(x-int(size/2), x+int(size/2))
star_y = random.randint(y-int(size/2), y+int(size/2))
transparent_star(star_x, star_y, star_size, color, alpha)
# Fade out the transparent stars
for alpha in range(200, 0, -10):
for star in t.turtles():
if star.pencolor() != (0.0, 0.0, 0.0):
color = star.fillcolor()
hex_color = '#' + ''.join(format(c, '02x') for c in color[:3])
star.fillcolor(hex_color, alpha)
star.pencolor(hex_color, alpha)
turtle.delay(20)
# Erase the transparent stars
for star in t.turtles():
if star.pencolor() != (0.0, 0.0, 0.0):
star.clear()
# Draw new transparent stars with different colors and positions
for i in range(num_stars):
r = random.randint(0, 255)
g = random.randint(0, 255)
b = random.randint(0, 255)
color = (r, g, b)
alpha = 0
star_size = random.randint(5, 20)
star_x = random.randint(-300, 300)
star_y = random.randint(-300, 300)
transparent_star(star_x, star_y, star_size, color, alpha)
# Fade in the transparent stars
for alpha in range(0, 200, 10):
for star in t.turtles():
if star.pencolor() != (0.0, 0.0, 0.0):
color = star.fillcolor()
hex_color = '#' + ''.join