import cv2
import numpy as np

class DrawingClass(object):
    def __init__(self):
        self.draw_command ='None'
        self.frame_count = 0
    def drawing(self, frame, fps, num_egg, htc_egg, state):
        cv2.putText(frame, 'FPS: {:.2f}'.format(fps),
                    (10, 30), cv2.FONT_HERSHEY_SIMPLEX, 1.0, (0, 255, 0), thickness=2)
    
        cv2.putText(frame, 'Possessed EGG: {}'.format(num_egg),
                    (10, 100), cv2.FONT_HERSHEY_SIMPLEX, 1.0, (0, 255, 255), thickness=2)
        cv2.putText(frame, 'Hatched EGG: {}'.format(htc_egg),
                    (10, 130), cv2.FONT_HERSHEY_SIMPLEX, 1.0, (0, 255, 255), thickness=2)
    
        cv2.putText(frame, 'State: {}'.format(state),
                    (250, 30), cv2.FONT_HERSHEY_SIMPLEX, 1.0, (0, 255, 255), thickness=2)
        return frame

    def draw_controler(self, frame, command):
        #print('draw',command)
        if command =='LX MIN':
            self.draw_command = 'LX MIN'
        elif command =='LX MAX':
            self.draw_command = 'LX MAX'
        elif command =='LY MIN':
            self.draw_command = 'LY MIN'
        elif command =='LY MAX':
            self.draw_command = 'LY MAX'
        elif command =='Button A':
            self.draw_command = 'Button A'
        elif command =='Button B':
            self.draw_command = 'Button B'
        elif command =='Button X':
            self.draw_command = 'Button X'
        elif command =='Button Y':
            self.draw_command = 'Button Y'
        elif command =='HAT TOP':
            self.draw_command = 'HAT TOP'
        elif command =='HAT RIGHT':
            self.draw_command = 'HAT RIGHT'
        elif command =='HAT BOTTOM':
            self.draw_command = 'HAT BOTTOM'
        elif command =='HAT LEFT':
            self.draw_command = 'HAT LEFT'
        elif command =='Button START':
            self.draw_command = 'Button START'
        elif command =='STOP':
            self.draw_command = 'STOP'

        #stick
        if self.draw_command =='LX MIN' or self.draw_command =='HAT LEFT':
            cv2.circle(frame, (970, 490), 20, (0, 0, 255), thickness=-1)
        elif self.draw_command =='LX MAX' or self.draw_command =='HAT RIGHT':
            cv2.circle(frame, (1030, 490), 20, (0, 0, 255), thickness=-1)
        elif self.draw_command =='LY MIN' or self.draw_command =='HAT TOP':
            cv2.circle(frame, (1000, 460), 20, (0, 0, 255), thickness=-1)
        elif self.draw_command =='LY MAX' or self.draw_command =='HAT BOTTOM':
            cv2.circle(frame, (1000, 520), 20, (0, 0, 255), thickness=-1)
        else:
            cv2.circle(frame, (1000, 490), 20, (0, 0, 255), thickness=-1)
        
        cv2.circle(frame, (1000, 490), 50, (0, 0, 255), thickness=2)

        #button
        if self.draw_command =='Button X':
            cv2.circle(frame, (1180, 460), 15, (0, 0, 255), thickness=-1)
            cv2.putText(frame, 'X',(1172, 468), cv2.FONT_HERSHEY_SIMPLEX, 0.8, (255, 255, 255), thickness=2)
            self.frame_count +=1
        elif self.frame_count == 6:
            cv2.circle(frame, (1180, 460), 15, (0, 0, 255), thickness=2)
            cv2.putText(frame, 'X',(1172, 468), cv2.FONT_HERSHEY_SIMPLEX, 0.8, (0, 0, 255), thickness=2)
            self.frame_count =0
            self.draw_command = 'None'
        else:
            cv2.circle(frame, (1180, 460), 15, (0, 0, 255), thickness=2)
            cv2.putText(frame, 'X',(1172, 468), cv2.FONT_HERSHEY_SIMPLEX, 0.8, (0, 0, 255), thickness=2)
        if self.draw_command =='Button B':
            cv2.circle(frame, (1180, 520), 15, (0, 0, 255), thickness=-1)
            cv2.putText(frame, 'B',(1172, 528), cv2.FONT_HERSHEY_SIMPLEX, 0.8, (255, 255, 255), thickness=2)
            self.frame_count +=1
        elif self.frame_count == 6:
            cv2.circle(frame, (1180, 520), 15, (0, 0, 255), thickness=2)
            cv2.putText(frame, 'B',(1172, 528), cv2.FONT_HERSHEY_SIMPLEX, 0.8, (0, 0, 255), thickness=2)
            self.frame_count =0
            self.draw_command = 'None'
        else:
            cv2.circle(frame, (1180, 520), 15, (0, 0, 255), thickness=2)
            cv2.putText(frame, 'B',(1172, 528), cv2.FONT_HERSHEY_SIMPLEX, 0.8, (0, 0, 255), thickness=2)
        if self.draw_command =='Button Y':
            cv2.circle(frame, (1150, 490), 15, (0, 0, 255), thickness=-1)
            cv2.putText(frame, 'Y',(1142, 498), cv2.FONT_HERSHEY_SIMPLEX, 0.8, (255, 255, 255), thickness=2)
            self.frame_count +=1
        elif self.frame_count == 6:
            cv2.circle(frame, (1150, 490), 15, (0, 0, 255), thickness=2)
            cv2.putText(frame, 'Y',(1142, 498), cv2.FONT_HERSHEY_SIMPLEX, 0.8, (0, 0, 255), thickness=2)
            self.frame_count =0
            self.draw_command = 'None'
        else:
            cv2.circle(frame, (1150, 490), 15, (0, 0, 255), thickness=2)
            cv2.putText(frame, 'Y',(1142, 498), cv2.FONT_HERSHEY_SIMPLEX, 0.8, (0, 0, 255), thickness=2)
        if self.draw_command =='Button A':
            cv2.circle(frame, (1210, 490), 15, (0, 0, 255), thickness=-1)
            cv2.putText(frame, 'A',(1202, 498), cv2.FONT_HERSHEY_SIMPLEX, 0.8, (255, 255, 255), thickness=2)
            self.frame_count +=1
        elif self.frame_count == 6:
            cv2.circle(frame, (1210, 490), 15, (0, 0, 255), thickness=2)
            cv2.putText(frame, 'A',(1202, 498), cv2.FONT_HERSHEY_SIMPLEX, 0.8, (0, 0, 255), thickness=2)
            self.frame_count =0
            self.draw_command = 'None'
        else:
            cv2.circle(frame, (1210, 490), 15, (0, 0, 255), thickness=2)
            cv2.putText(frame, 'A',(1202, 498), cv2.FONT_HERSHEY_SIMPLEX, 0.8, (0, 0, 255), thickness=2)
        if self.draw_command =='Button START':
            cv2.circle(frame, (1130, 423), 10, (0, 0, 255), thickness=-1)
            cv2.putText(frame, '+',(1120, 430), cv2.FONT_HERSHEY_SIMPLEX, 0.8, (255, 255, 255), thickness=2)
            self.frame_count +=1
        elif self.frame_count == 6:
            cv2.circle(frame, (1130, 423), 10, (0, 0, 255), thickness=1)
            cv2.putText(frame, '+',(1120, 430), cv2.FONT_HERSHEY_SIMPLEX, 0.8, (0, 0, 255), thickness=2)
            self.frame_count =0
            self.draw_command = 'None'
        else:
            cv2.circle(frame, (1130, 423), 10, (0, 0, 255), thickness=1)
            cv2.putText(frame, '+',(1120, 430), cv2.FONT_HERSHEY_SIMPLEX, 0.8, (0, 0, 255), thickness=2)


        return frame
[((2771, 2831), 'cv2.circle', 'cv2.circle', (['frame', '(1000, 490)', '(50)', '(0, 0, 255)'], {'thickness': '(2)'}), '(frame, (1000, 490), 50, (0, 0, 255), thickness=2)\n', (2781, 2831), False, 'import cv2\n'), ((2140, 2200), 'cv2.circle', 'cv2.circle', (['frame', '(970, 490)', '(20)', '(0, 0, 255)'], {'thickness': '(-1)'}), '(frame, (970, 490), 20, (0, 0, 255), thickness=-1)\n', (2150, 2200), False, 'import cv2\n'), ((2908, 2969), 'cv2.circle', 'cv2.circle', (['frame', '(1180, 460)', '(15)', '(0, 0, 255)'], {'thickness': '(-1)'}), '(frame, (1180, 460), 15, (0, 0, 255), thickness=-1)\n', (2918, 2969), False, 'import cv2\n'), ((2983, 3085), 'cv2.putText', 'cv2.putText', (['frame', '"""X"""', '(1172, 468)', 'cv2.FONT_HERSHEY_SIMPLEX', '(0.8)', '(255, 255, 255)'], {'thickness': '(2)'}), "(frame, 'X', (1172, 468), cv2.FONT_HERSHEY_SIMPLEX, 0.8, (255, \n    255, 255), thickness=2)\n", (2994, 3085), False, 'import cv2\n'), ((3656, 3717), 'cv2.circle', 'cv2.circle', (['frame', '(1180, 520)', '(15)', '(0, 0, 255)'], {'thickness': '(-1)'}), '(frame, (1180, 520), 15, (0, 0, 255), thickness=-1)\n', (3666, 3717), False, 'import cv2\n'), ((3731, 3833), 'cv2.putText', 'cv2.putText', (['frame', '"""B"""', '(1172, 528)', 'cv2.FONT_HERSHEY_SIMPLEX', '(0.8)', '(255, 255, 255)'], {'thickness': '(2)'}), "(frame, 'B', (1172, 528), cv2.FONT_HERSHEY_SIMPLEX, 0.8, (255, \n    255, 255), thickness=2)\n", (3742, 3833), False, 'import cv2\n'), ((4404, 4465), 'cv2.circle', 'cv2.circle', (['frame', '(1150, 490)', '(15)', '(0, 0, 255)'], {'thickness': '(-1)'}), '(frame, (1150, 490), 15, (0, 0, 255), thickness=-1)\n', (4414, 4465), False, 'import cv2\n'), ((4479, 4581), 'cv2.putText', 'cv2.putText', (['frame', '"""Y"""', '(1142, 498)', 'cv2.FONT_HERSHEY_SIMPLEX', '(0.8)', '(255, 255, 255)'], {'thickness': '(2)'}), "(frame, 'Y', (1142, 498), cv2.FONT_HERSHEY_SIMPLEX, 0.8, (255, \n    255, 255), thickness=2)\n", (4490, 4581), False, 'import cv2\n'), ((5152, 5213), 'cv2.circle', 'cv2.circle', (['frame', '(1210, 490)', '(15)', '(0, 0, 255)'], {'thickness': '(-1)'}), '(frame, (1210, 490), 15, (0, 0, 255), thickness=-1)\n', (5162, 5213), False, 'import cv2\n'), ((5227, 5329), 'cv2.putText', 'cv2.putText', (['frame', '"""A"""', '(1202, 498)', 'cv2.FONT_HERSHEY_SIMPLEX', '(0.8)', '(255, 255, 255)'], {'thickness': '(2)'}), "(frame, 'A', (1202, 498), cv2.FONT_HERSHEY_SIMPLEX, 0.8, (255, \n    255, 255), thickness=2)\n", (5238, 5329), False, 'import cv2\n'), ((5904, 5965), 'cv2.circle', 'cv2.circle', (['frame', '(1130, 423)', '(10)', '(0, 0, 255)'], {'thickness': '(-1)'}), '(frame, (1130, 423), 10, (0, 0, 255), thickness=-1)\n', (5914, 5965), False, 'import cv2\n'), ((5979, 6081), 'cv2.putText', 'cv2.putText', (['frame', '"""+"""', '(1120, 430)', 'cv2.FONT_HERSHEY_SIMPLEX', '(0.8)', '(255, 255, 255)'], {'thickness': '(2)'}), "(frame, '+', (1120, 430), cv2.FONT_HERSHEY_SIMPLEX, 0.8, (255, \n    255, 255), thickness=2)\n", (5990, 6081), False, 'import cv2\n'), ((2293, 2354), 'cv2.circle', 'cv2.circle', (['frame', '(1030, 490)', '(20)', '(0, 0, 255)'], {'thickness': '(-1)'}), '(frame, (1030, 490), 20, (0, 0, 255), thickness=-1)\n', (2303, 2354), False, 'import cv2\n'), ((3164, 3224), 'cv2.circle', 'cv2.circle', (['frame', '(1180, 460)', '(15)', '(0, 0, 255)'], {'thickness': '(2)'}), '(frame, (1180, 460), 15, (0, 0, 255), thickness=2)\n', (3174, 3224), False, 'import cv2\n'), ((3238, 3336), 'cv2.putText', 'cv2.putText', (['frame', '"""X"""', '(1172, 468)', 'cv2.FONT_HERSHEY_SIMPLEX', '(0.8)', '(0, 0, 255)'], {'thickness': '(2)'}), "(frame, 'X', (1172, 468), cv2.FONT_HERSHEY_SIMPLEX, 0.8, (0, 0, \n    255), thickness=2)\n", (3249, 3336), False, 'import cv2\n'), ((3432, 3492), 'cv2.circle', 'cv2.circle', (['frame', '(1180, 460)', '(15)', '(0, 0, 255)'], {'thickness': '(2)'}), '(frame, (1180, 460), 15, (0, 0, 255), thickness=2)\n', (3442, 3492), False, 'import cv2\n'), ((3506, 3604), 'cv2.putText', 'cv2.putText', (['frame', '"""X"""', '(1172, 468)', 'cv2.FONT_HERSHEY_SIMPLEX', '(0.8)', '(0, 0, 255)'], {'thickness': '(2)'}), "(frame, 'X', (1172, 468), cv2.FONT_HERSHEY_SIMPLEX, 0.8, (0, 0, \n    255), thickness=2)\n", (3517, 3604), False, 'import cv2\n'), ((3912, 3972), 'cv2.circle', 'cv2.circle', (['frame', '(1180, 520)', '(15)', '(0, 0, 255)'], {'thickness': '(2)'}), '(frame, (1180, 520), 15, (0, 0, 255), thickness=2)\n', (3922, 3972), False, 'import cv2\n'), ((3986, 4084), 'cv2.putText', 'cv2.putText', (['frame', '"""B"""', '(1172, 528)', 'cv2.FONT_HERSHEY_SIMPLEX', '(0.8)', '(0, 0, 255)'], {'thickness': '(2)'}), "(frame, 'B', (1172, 528), cv2.FONT_HERSHEY_SIMPLEX, 0.8, (0, 0, \n    255), thickness=2)\n", (3997, 4084), False, 'import cv2\n'), ((4180, 4240), 'cv2.circle', 'cv2.circle', (['frame', '(1180, 520)', '(15)', '(0, 0, 255)'], {'thickness': '(2)'}), '(frame, (1180, 520), 15, (0, 0, 255), thickness=2)\n', (4190, 4240), False, 'import cv2\n'), ((4254, 4352), 'cv2.putText', 'cv2.putText', (['frame', '"""B"""', '(1172, 528)', 'cv2.FONT_HERSHEY_SIMPLEX', '(0.8)', '(0, 0, 255)'], {'thickness': '(2)'}), "(frame, 'B', (1172, 528), cv2.FONT_HERSHEY_SIMPLEX, 0.8, (0, 0, \n    255), thickness=2)\n", (4265, 4352), False, 'import cv2\n'), ((4660, 4720), 'cv2.circle', 'cv2.circle', (['frame', '(1150, 490)', '(15)', '(0, 0, 255)'], {'thickness': '(2)'}), '(frame, (1150, 490), 15, (0, 0, 255), thickness=2)\n', (4670, 4720), False, 'import cv2\n'), ((4734, 4832), 'cv2.putText', 'cv2.putText', (['frame', '"""Y"""', '(1142, 498)', 'cv2.FONT_HERSHEY_SIMPLEX', '(0.8)', '(0, 0, 255)'], {'thickness': '(2)'}), "(frame, 'Y', (1142, 498), cv2.FONT_HERSHEY_SIMPLEX, 0.8, (0, 0, \n    255), thickness=2)\n", (4745, 4832), False, 'import cv2\n'), ((4928, 4988), 'cv2.circle', 'cv2.circle', (['frame', '(1150, 490)', '(15)', '(0, 0, 255)'], {'thickness': '(2)'}), '(frame, (1150, 490), 15, (0, 0, 255), thickness=2)\n', (4938, 4988), False, 'import cv2\n'), ((5002, 5100), 'cv2.putText', 'cv2.putText', (['frame', '"""Y"""', '(1142, 498)', 'cv2.FONT_HERSHEY_SIMPLEX', '(0.8)', '(0, 0, 255)'], {'thickness': '(2)'}), "(frame, 'Y', (1142, 498), cv2.FONT_HERSHEY_SIMPLEX, 0.8, (0, 0, \n    255), thickness=2)\n", (5013, 5100), False, 'import cv2\n'), ((5408, 5468), 'cv2.circle', 'cv2.circle', (['frame', '(1210, 490)', '(15)', '(0, 0, 255)'], {'thickness': '(2)'}), '(frame, (1210, 490), 15, (0, 0, 255), thickness=2)\n', (5418, 5468), False, 'import cv2\n'), ((5482, 5580), 'cv2.putText', 'cv2.putText', (['frame', '"""A"""', '(1202, 498)', 'cv2.FONT_HERSHEY_SIMPLEX', '(0.8)', '(0, 0, 255)'], {'thickness': '(2)'}), "(frame, 'A', (1202, 498), cv2.FONT_HERSHEY_SIMPLEX, 0.8, (0, 0, \n    255), thickness=2)\n", (5493, 5580), False, 'import cv2\n'), ((5676, 5736), 'cv2.circle', 'cv2.circle', (['frame', '(1210, 490)', '(15)', '(0, 0, 255)'], {'thickness': '(2)'}), '(frame, (1210, 490), 15, (0, 0, 255), thickness=2)\n', (5686, 5736), False, 'import cv2\n'), ((5750, 5848), 'cv2.putText', 'cv2.putText', (['frame', '"""A"""', '(1202, 498)', 'cv2.FONT_HERSHEY_SIMPLEX', '(0.8)', '(0, 0, 255)'], {'thickness': '(2)'}), "(frame, 'A', (1202, 498), cv2.FONT_HERSHEY_SIMPLEX, 0.8, (0, 0, \n    255), thickness=2)\n", (5761, 5848), False, 'import cv2\n'), ((6160, 6220), 'cv2.circle', 'cv2.circle', (['frame', '(1130, 423)', '(10)', '(0, 0, 255)'], {'thickness': '(1)'}), '(frame, (1130, 423), 10, (0, 0, 255), thickness=1)\n', (6170, 6220), False, 'import cv2\n'), ((6234, 6332), 'cv2.putText', 'cv2.putText', (['frame', '"""+"""', '(1120, 430)', 'cv2.FONT_HERSHEY_SIMPLEX', '(0.8)', '(0, 0, 255)'], {'thickness': '(2)'}), "(frame, '+', (1120, 430), cv2.FONT_HERSHEY_SIMPLEX, 0.8, (0, 0, \n    255), thickness=2)\n", (6245, 6332), False, 'import cv2\n'), ((6428, 6488), 'cv2.circle', 'cv2.circle', (['frame', '(1130, 423)', '(10)', '(0, 0, 255)'], {'thickness': '(1)'}), '(frame, (1130, 423), 10, (0, 0, 255), thickness=1)\n', (6438, 6488), False, 'import cv2\n'), ((6502, 6600), 'cv2.putText', 'cv2.putText', (['frame', '"""+"""', '(1120, 430)', 'cv2.FONT_HERSHEY_SIMPLEX', '(0.8)', '(0, 0, 255)'], {'thickness': '(2)'}), "(frame, '+', (1120, 430), cv2.FONT_HERSHEY_SIMPLEX, 0.8, (0, 0, \n    255), thickness=2)\n", (6513, 6600), False, 'import cv2\n'), ((2445, 2506), 'cv2.circle', 'cv2.circle', (['frame', '(1000, 460)', '(20)', '(0, 0, 255)'], {'thickness': '(-1)'}), '(frame, (1000, 460), 20, (0, 0, 255), thickness=-1)\n', (2455, 2506), False, 'import cv2\n'), ((2600, 2661), 'cv2.circle', 'cv2.circle', (['frame', '(1000, 520)', '(20)', '(0, 0, 255)'], {'thickness': '(-1)'}), '(frame, (1000, 520), 20, (0, 0, 255), thickness=-1)\n', (2610, 2661), False, 'import cv2\n'), ((2690, 2751), 'cv2.circle', 'cv2.circle', (['frame', '(1000, 490)', '(20)', '(0, 0, 255)'], {'thickness': '(-1)'}), '(frame, (1000, 490), 20, (0, 0, 255), thickness=-1)\n', (2700, 2751), False, 'import cv2\n')]