#Name: Laraib Shaikh

#Student Number: 1205628

#Lab Section: L09

#Lab:09

#Date: November 9, 2012



#This program creates a simple interactive graphical user interface



#importing librarires

from random import randint

import math

from graphics import*



#defining the function

def distanceBetweenPoints(x,y):



    #ask the user to input the values

    #x1, x2, y1, y2 = input ("Please enter the values of (x1, x2, y1, y2):")



    #Get the x coordinates for points

    x1=x.getX()

    y1=x.getY()



    #Get the y coordinates for points 

    x2=y.getX()

    y2=y.getY()



    #to get the difference between the x-coordinates of the two points 

    a = 0

    a = x2 - x1

    

    #to get the difference between the y-coordinates of the two points

    b = 0

    b = y2 - y1



    #to make sure that we have a positive value for the distance 

    if a > 0 and b>0:

        distance = math.sqrt((a**2)+(b**2))



    return distance



#drawing the circle

def drawCircle (w,c,r,s):

    circ=Circle(c,r)

    circ.setFill(s)

    circ.draw(w)



    return circ



#setting up the coordinates for the graphics window

def main():

    win = GraphWin ("Simple GUI", 500,500)

    win.setCoords(0,0,100,100)



    #center point of the circle

    c=Point(50,50)

    circ = drawCircle (w,c)



    return circ



#allowing the user to locate the values in different places

def circleGame():

    circ=Circle(c,r)

    circ.setFill("red")

    circ.draw(w)



    

    win = GraphWin ("Simple GUI", 500,500)

    win.setCoords(0,0,100,100)





    #setting the conditions

    while True:

        c = win.getMouse()

        if distanceBetweenPoints(c,circ.getCenter())<circ.getRadius()and distanceBetweenPoints(c,circ.getCenter())<(1/4.0)*circ.getRadius():

            win.close ()



        elif distanceBetweenPoints(c,circ.getCenter())>(1/4.0)circ.getRadius():

            r=circ.getRadius()-circ.getRadius()*0.2

            circ.undraw()

            circ.drawCircle(w,r)

            g.undraw()

            g.draw(win)



        elif distanceBetweenPoints(c,circ.getCenter())>circ.getRadius():

            r=circ.getRadius()-circ.getRadius()*0.1

            circ.undraw()

            circ.drawCircle(w,r)

            g.undraw()

            g.draw(win)



            

            

            

            



        circ.undraw()

        circ = drawCirlcle (win,c)





"""

no, it is not possible to write a program without an indefinite loop beacause the user can type in any values therefore it is necessary to design the program 

with infinite loop so that it could take in any value 

"""    

