# Allison Obourn
# CS 115, Autumn 2021
# Lecture 10

# This program draws the outline of a circle in the center of the
# screen. The circle gets wider as the mouse moves away from the center and
# thinner as it gets closer to the center. It also draws an animal face with
# two eyes and a nose that follows the mouse. This shape's size can be changed
# by altering the SHAPE_SIZE variable. 

# NOTE: These are the steps we used to figure out how to write this program:
#
# 1. draw the figure at one set size in one set location
# 2. alter x based on some variable
# 3. alter y based on some variable
# 4. altering size
#    a) create a variable to represnt size
#    b) incorporate variable into equations  m * variable + constant =>
#                                               2 * variable + 40
#    c) for each constant in the size equation - figure out the proportion of
#       that to the orignal size (constant / original size). Replace constant
#       with proportion * size variable
#    d) check if location looks wrong anywhere - alter any constants to
#       incorporate size variable

from ECGUI import *

# a constant variable (meaning we will not alter the value stored in it while
# our program is running) that can be changed between runs to alter the size
# of the bear face drawn.
SHAPE_SIZE = 50

def repeat():
    # clear off the canvas and redraw a circle
    canvas.clear()

    # draws an outline of a circle
    # upper_left = canvas_width / 2 - oval_width / 2
    # starting_x = upper_left - (mouse_x - upper_left) / 2)
    x = canvas.get_mouse_x() - 135
    canvas.draw_oval(135 - x / 2, 235, x, 30)


    # draw an animal face centered on the current position of the user's mouse
    x = canvas.get_mouse_x()
    y = canvas.get_mouse_y()

    # the bear's face
    half_width = SHAPE_SIZE // 2
    canvas.fill_oval(x - half_width, y - half_width, SHAPE_SIZE,
                     SHAPE_SIZE, "brown") # face

    # animal's eyes
    eye_size = 1 / 10 * SHAPE_SIZE
    eye_y = 2 / 5 * SHAPE_SIZE + y - half_width
    left_eye_x = 1 / 5 * SHAPE_SIZE + x - half_width
    right_eye_x = 35 / 50 * SHAPE_SIZE + x - half_width
    canvas.fill_oval(left_eye_x, eye_y, eye_size, eye_size, "black") # left
    canvas.fill_oval(right_eye_x, eye_y, eye_size, eye_size, "black")# right

    # anomal's nose
    nose_width = 1 / 5 * SHAPE_SIZE
    nose_x = x - nose_width / 2
    nose_y = 4 / 5 * SHAPE_SIZE + y - half_width
    canvas.fill_oval(nose_x, nose_y, nose_width, nose_width / 2, "black")


canvas = drawing_panel(300, 500, "white")
canvas.animate(50, repeat)
