diff --git a/image_maker.py b/image_maker.py index f92a303a28b9dc82b6a29bc2a99270f6c126829a..16233d4073b447e644a20f2df4f637d2fef3425e 100644 --- a/image_maker.py +++ b/image_maker.py @@ -55,18 +55,24 @@ def createAbsImage(terme): abstraction.paste(im2.image, ( 0 , im1.height)) return abstraction +space_width = 0 + +def get_space_wdith(): + return space_width def get_concat_h_multi_resize(im_list, resample=Image.BICUBIC): + global space_width max_height=max(im.height for im in im_list) min_height = min(im.height for im in im_list) max_width = sum(im.width for im in im_list) min_width=min(im.width for im in im_list) - space_width=int(min_width*0.3) - total_init_width = sum(im.width for im in im_list) + space_width * (len(im_list) - 1) + if space_width == 0: + space_width=(int(min_width*0.3)) + else: + space_width=min(get_space_wdith(),int(min_width*0.3)) + total_init_width = sum(im.width for im in im_list) + get_space_wdith() * (len(im_list) - 1) im_list_resize = [im.resize((int(im.width * min_height / im.height), min_height), resample=resample) for im in im_list] - - total_width = sum(im.width for im in im_list_resize) + (len(im_list_resize) -1) * space_width dst = Image.new('RGB', (total_init_width, max_height),(255,255,255)) pos_x = 0 diff --git a/logic.py b/logic.py index 957226b8b8340b526604163b18e460e0768bdeb5..f8ce1e95d047c7b71d63b98cc519cec0f8094584 100644 --- a/logic.py +++ b/logic.py @@ -185,7 +185,7 @@ def beta_reduction(t): else: terme=A1 for var in communBoundVars: - terme=alpha_rename(terme,new_var(var)) + terme=alpha_rename(terme,(var)) return substitute(getInputFromAbs(terme),B1,getOutputFromAbs(terme)) else: @@ -221,10 +221,10 @@ def to_string_var(terme): return (numbers_to_letters[terme[1]]) def to_string_abs(terme): assert (isAbstraction(terme)), 'The argument is not an Abstraction' - return "#"+to_string(getInputFromAbs(terme))+"."+to_string(getOutputFromAbs(terme)) + return "\u03BB"+to_string(getInputFromAbs(terme))+"."+to_string(getOutputFromAbs(terme)) def to_string_app(terme): - assert (isApplication(terme)), 'The argument is not an application' #() ons econd term if application / no () over variable/ if ABS inside APP () + assert (isApplication(terme)), 'The argument is not an application' #ons econd term if application / no () over variable/ if ABS inside APP () premier_terme = '' deuxieme_terme = '' if isVariable(getFirstTerm(terme)): @@ -280,7 +280,7 @@ def annotate_beta_reduction(terme): else: t=A1 for var in communBoundVars: - t=alpha_rename(t,new_var(var)) + t=alpha_rename(t,(var)) return new_app(annotate_beta_reduction(A1),annotate_beta_reduction(B1)) + [substitute(getInputFromAbs(t),B1,getOutputFromAbs(t))] + [counter()] if A2 != None and B2 == None: @@ -293,7 +293,7 @@ def annotate_beta_reduction(terme): else: t=A1 for var in communBoundVars: - t=alpha_rename(t,new_var(var)) + t=alpha_rename(t,(var)) return new_app(annotate_beta_reduction(A1),B1) + [substitute(getInputFromAbs(t),B1,getOutputFromAbs(t))] + [counter()] if A2 == None and B2 != None: @@ -306,7 +306,7 @@ def annotate_beta_reduction(terme): else: t=A1 for var in communBoundVars: - t=alpha_rename(t,new_var(var)) + t=alpha_rename(t,(var)) return new_app(A1,annotate_beta_reduction(B1)) + [substitute(getInputFromAbs(t),B1,getOutputFromAbs(t))] + [counter()] else: @@ -319,7 +319,7 @@ def annotate_beta_reduction(terme): else: t=A1 for var in communBoundVars: - t=alpha_rename(t,new_var(var)) + t=alpha_rename(t,(var)) return new_app(A1,B1) + [substitute(getInputFromAbs(t),B1,getOutputFromAbs(t))] + [counter()] else: @@ -337,7 +337,7 @@ def annotated_to_string(terme): if len(terme)==5: first=getFirstTerm(terme) second=getSecondTerm(terme) - String_term+="(#"+str(terme[4])+to_string(getInputFromAbs(first))+"."+annotated_to_string(getOutputFromAbs(first))+') ' + String_term+="(\u03BB"+str(terme[4])+to_string(getInputFromAbs(first))+"."+annotated_to_string(getOutputFromAbs(first))+') ' String_term+='('+ annotated_to_string(second)+ ')' else: if isApplication(terme): @@ -346,7 +346,7 @@ def annotated_to_string(terme): String_term+='(' + annotated_to_string(first) + ') ' String_term+= '('+ annotated_to_string(second) + ') ' elif isAbstraction(terme): - String_term+='#'+ to_string(getInputFromAbs(terme))+ '.' +annotated_to_string(getOutputFromAbs(terme)) + String_term+='\u03BB'+ to_string(getInputFromAbs(terme))+ '.' +annotated_to_string(getOutputFromAbs(terme)) else: String_term+=to_string(terme)