Randomly Colored Circle Generator

  • Share this:

Code introduction


This function uses the Arcade library to create a window and draw a circle with a random color inside it.


Technology Stack : Arcade, Random number generation

Code Type : Graphical interface application

Code Difficulty : Intermediate


                
                    
def random_circle_color(x, y):
    import arcade
    import random
    
    # Create a window with a 500x500 size
    arcade.open_window(500, 500, "Random Circle Color")
    
    # Start the rendering process. This is the first step in rendering.
    arcade.start_render()
    
    # Generate a random color
    color = (random.randint(0, 255), random.randint(0, 255), random.randint(0, 255))
    
    # Draw a circle at the given x and y coordinates
    arcade.draw_circle_filled(x, y, 50, color)
    
    # Finish the rendering
    arcade.finish_draw()
    
    # Keep the window open until the user closes it
    arcade.run()