from gds_key import *

logo_intec_prefix = 'logo_intec_'
logo_imec_prefix = 'logo_imec_'
logo_rug_prefix = 'logo_rug_'

def str_intec_logo (layer, size= (50.0,50.0)):
    ret_str = ""
    logo_size = (1.0, 1.1)
    scale = min([size[0]/logo_size[0],size[1]/logo_size[1]])
    line_width = scale * 0.05
    name = logo_intec_prefix + str(int(scale))
    #check is structure already exists
    if structure_exists(name):
        return ret_str

    ret_str += str_header(name, 'Logo INTEC')
    ret_str += el_polygon_text(layer,'INTEC', (scale/2, 0.0), (TEXT_ALIGN_CENTER, TEXT_ALIGN_BOTTOM), 1, scale * 0.19)
    ret_str += el_line(layer, (0.0,0.3*scale), (scale, 0.3 * scale), line_width, PATH_TYPE_ROUNDED)
    ret_str += el_line(layer, (0.0,0.4*scale), (scale, 0.4 * scale), line_width, PATH_TYPE_ROUNDED)
    ret_str += el_line(layer, (0.0,0.5*scale), (0.4 * scale, 0.5 * scale), line_width, PATH_TYPE_ROUNDED)
    ret_str += el_line(layer, (0.6 * scale ,0.5*scale), (scale, 0.5 * scale), line_width, PATH_TYPE_ROUNDED)
    ret_str += el_arc_path(layer, (0.5 * scale ,0.6 * scale), 0.1 * scale, line_width, 0.0, 180.0, 10.0, PATH_TYPE_ROUNDED)
    ret_str += el_arc_path(layer, (0.5 * scale ,0.6 * scale), 0.2 * scale, line_width, 0.0, 180.0, 10.0, PATH_TYPE_ROUNDED)
    ret_str += el_arc_path(layer, (0.5 * scale ,0.6 * scale), 0.3 * scale, line_width, 0.0, 180.0, 10.0, PATH_TYPE_ROUNDED)
    ret_str += el_arc_path(layer, (0.5 * scale ,0.6 * scale), 0.4 * scale, line_width, 0.0, 180.0, 10.0, PATH_TYPE_ROUNDED)
    ret_str += el_arc_path(layer, (0.5 * scale ,0.6 * scale), 0.5 * scale, line_width, 0.0, 180.0, 10.0, PATH_TYPE_ROUNDED)
    ret_str += str_footer(name)

    return ret_str

def name_intec_logo (size = (50.0, 50.0)):
    ret_str = ""
    logo_size = (1.0, 1.1)
    scale = min([size[0]/logo_size[0],size[1]/logo_size[1]])
    return logo_intec_prefix + str(int(scale))
    

def str_rug_logo (layer, size= (50.0,50.0)):
    ret_str = ""
    logo_size = (1.0, 1.05)
    scale = min([size[0]/logo_size[0],size[1]/logo_size[1]])
    line_width = scale * 0.025
    name = logo_rug_prefix + str(int(scale))
    #check is structure already exists
    if structure_exists(name):
        return ret_str

    ret_str += str_header(name, 'Logo RUG')
    ret_str += el_polygon_text(layer,'UNIVERSITEIT', (scale/2, scale* 0.25), (TEXT_ALIGN_CENTER, TEXT_ALIGN_BOTTOM), 1,  scale * 0.12)
    ret_str += el_polygon_text(layer,'GENT', (scale/2, scale*  0.05), (TEXT_ALIGN_CENTER, TEXT_ALIGN_BOTTOM), 1,  scale * 0.12)
    ret_str += el_line(layer, (0.0,0.0), (scale, 0.0), line_width)
    ret_str += el_line(layer, (0.15*scale,0.45*scale), (0.85*scale, 0.45 * scale), line_width)
    ret_str += el_line(layer, (0.18*scale,0.5*scale), (0.82*scale, 0.5 * scale), line_width)
    ret_str += el_line(layer, (0.15*scale,0.85*scale), (0.85*scale, 0.85 * scale), line_width)
    ret_str += el_line(layer, (0.18*scale,0.8*scale), (0.82*scale, 0.8 * scale), line_width)
    ret_str += el_path(layer, [(0.14*scale,0.9*scale),(scale/2.0,1.05*scale),(0.86*scale, 0.9 * scale)], line_width)
    ret_str += el_boundary(layer, [(0.20 * scale, 0.88*scale), (0.8*scale, 0.88 * scale), (0.8*scale, 0.89*scale), (scale/2.0, 1.0* scale), (0.2 * scale, 0.89 * scale), (0.20 * scale, 0.88 * scale)])
    ret_str += el_wedge(layer, (scale * 0.25,scale * 0.53), (scale * 0.25, scale * 0.77), scale * 0.06, scale * 0.04)
    ret_str += el_wedge(layer, (scale * 0.35,scale * 0.53), (scale * 0.35, scale * 0.77), scale * 0.06, scale * 0.04)
    ret_str += el_wedge(layer, (scale * 0.45,scale * 0.53), (scale * 0.45, scale * 0.77), scale * 0.06, scale * 0.04)
    ret_str += el_wedge(layer, (scale * 0.55,scale * 0.53), (scale * 0.55, scale * 0.77), scale * 0.06, scale * 0.04)
    ret_str += el_wedge(layer, (scale * 0.65,scale * 0.53), (scale * 0.65, scale * 0.77), scale * 0.06, scale * 0.04)
    ret_str += el_wedge(layer, (scale * 0.75,scale * 0.53), (scale * 0.75, scale * 0.77), scale * 0.06, scale * 0.04)
    ret_str += str_footer(name)
    return ret_str

def name_rug_logo (size = (50.0, 50.0)):
    ret_str = ""
    logo_size = (1.0, 1.05)
    scale = min([size[0]/logo_size[0],size[1]/logo_size[1]])
    return logo_rug_prefix + str(int(scale))
    
def str_imec_logo (layer, size= (50.0,50.0)):
    ret_str = ""
    logo_size = (0.9, 1.4)
    scale = min([size[0]/logo_size[0],size[1]/logo_size[1]])
    line_width = scale * 0.1
    name = logo_imec_prefix + str(int(scale))
    #check is structure already exists
    if structure_exists(name):
        return ret_str
    ret_str += str_header(name, 'Logo IMEC')
    ret_str += el_polygon_text(layer,'IMEC', (scale*0.45, 0.0), (TEXT_ALIGN_CENTER, TEXT_ALIGN_BOTTOM), 1, scale * 0.2)
    ret_str += el_path(layer, [(0.3 * scale, 0.4*scale),(0.3 * scale, 1.0*scale), (0.75 * scale, 1.0*scale),(0.75 * scale, 0.4*scale)], line_width)
    ret_str += el_path(layer, [(0.9 * scale, 0.55*scale),(0.15 * scale, 0.55*scale), (0.15 * scale, 1.2*scale)], line_width)
    ret_str += el_path(layer, [(0.9 * scale, 0.55*scale),(0.15 * scale, 0.55*scale), (0.15 * scale, 1.2*scale)], line_width)
    ret_str += el_line(layer, (0.0 * scale, 0.85*scale), (0.75 * scale, 0.85*scale), line_width)
    ret_str += el_line(layer, (0.5 * scale, 0.55*scale), (0.5 * scale, 1.2*scale), line_width)
    ret_str += el_rect(layer, (0.15 * scale, 1.2*scale), (0.15*scale, 0.15*scale))
    ret_str += el_rect(layer, (0.75 * scale, 0.85*scale), (0.15*scale, 0.15*scale))
    ret_str += el_rect(layer, (0.5 * scale, 0.6*scale), (0.15*scale, 0.25*scale))
    ret_str += el_boundary(layer, [(0.37 * scale, 1.15*scale),(0.63 * scale, 1.15*scale), (0.5 * scale, 1.4*scale), (0.37* scale, 1.15 * scale)])
    ret_str += str_footer(name)

    return ret_str

def name_imec_logo (size = (50.0, 50.0)):
    ret_str = ""
    logo_size = (0.9, 1.4)
    scale = min([size[0]/logo_size[0],size[1]/logo_size[1]])
    return logo_imec_prefix + str(int(scale))
