# Allison Obourn
# CS 115, Autumn 2021
# Lecture 7

# This program opens a window that is taller than it is wide and has
# a greyish-blue background. It displays a yellow oval on top of a green
# rectangle in the upper left. When the user moves the mouse over the window
# the outline of a bright blue circle is drawn under the mouse.


from ECGUI import *

# NOTE: we placed all the drawing commands that we want to repeat for each
#       frame of animation in here. This way we can have a nice short name
#       to refer to all the commands we want to complete
def repeat():
    # first get rid of everything we have drawn before so we don't see old
    # places the circle following the mouse was drawn
    canvas.clear()
    canvas.fill_rect(0, 0, 100, 200, "yellow")
    canvas.fill_oval(0, 0, 100, 200, "green")
    canvas.draw_oval(0, 0, 1000, 2000, "black")

    # draw the circle wherever our mouse is
    x = canvas.get_mouse_x()
    y = canvas.get_mouse_y()
    canvas.draw_oval(x, y, 20, 20, "blue")


# opens a new window with a particular width, height and background color
# and tells it to execute the commands in the function with the passed in name
# every passed in amount of miliseconds
canvas = drawing_panel(300, 500, "#687ea6")
canvas.animate(50, repeat)

