#import RPi.GPIO as GPIO
import time
import pygame
import math

pygame.init()
screen=pygame.display.set_mode((480,160))
mpos=(0,0)

#GPIO.setmode(GPIO.BOARD)

#GPIO.setup(3,GPIO.OUT)
#GPIO.setup(5,GPIO.OUT)
#GPIO.setup(7,GPIO.OUT)

white=(255,255,255)
red=(255,0,0)
green=(0,255,0)
blue=(0,0,255)
    
screen.fill(white)
pygame.draw.circle(screen,red,(80,80),60,0)
pygame.draw.circle(screen,green,(240,80),60,0)
pygame.draw.circle(screen,blue,(400,80),60,0)
pygame.display.update()

#GPIO.output(3,GPIO.LOW)
#GPIO.output(5,GPIO.LOW)
#GPIO.output(7,GPIO.LOW)

while True:
    ev=pygame.event.get()
    for event in ev:
     if event.type == pygame.MOUSEBUTTONUP:
        mpos=pygame.mouse.get_pos()
        print(mpos)
        if math.sqrt(math.pow(mpos[0]-80,2)+math.pow(mpos[1]-80,2))<60:
            print ("red")
            #GPIO.output(3,1^GPIO.input(3))
              
        if math.sqrt(math.pow(mpos[0]-240,2)+math.pow(mpos[1]-80,2))<60:
            print ("green")
            #GPIO.output(5,1^GPIO.input(5))
            
        if math.sqrt(math.pow(mpos[0]-400,2)+math.pow(mpos[1]-80,2))<60:
            print ("blue")
            #GPIO.output(7,1^GPIO.input(7))
                     
    pygame.event.pump()
#GPIO.cleanup()
