refactor function

from math import pi
import numpy as np
Define the number of stars, arms, and waves

numstars = 1000
numarms = 100
num_waves = 10
Calculate the angles for the arms and waves

startangle = 0
endangle = 2 * pi
Define the star size

star_size = 5
Generate the spiral galaxy

def generategalaxy(numstars, numarms, numwaves, startangle, endangle, starsize):
# Create the Pygame window
pygame.init()
screen = pygame.display.setmode((600, 600))

# Define the colors for the stars and arms
red = (255, 0, 0)
green = (0, 255, 0)
blue = (0, 0, 255)

# Create the spiral arms
for i in range(num_arms):
    # Calculate the angle of the spiral arm
    theta = 2 * pi * i / num_arms
    # Calculate the radius of the spiral arm
    r = start_angle + (end_angle - start_angle) * i / num_arms
    # Add a spiral arm to the Pygame window
    pygame.draw.circle(screen, blue, (int(r * np.cos(theta)), int(r * np.sin(theta))), 5)

# Create the stars
for i in range(num_stars):
    # Calculate the position of the star
    x = start_angle + (2 * pi * i / num_stars)
    y = (1 / 3) * (1 - (i / num_stars) ** 3)
    # Add a star to the Pygame window
    pygame.draw.circle(screen, red, (int(x), int(y)), 5)

# Set the screen size
screen.set_mode((screen.get_width(), screen.get_height()))

# Start the game
running = True
while running:
    # Handle events
    for event in pygame.event.get
