Skip to content
Snippets Groups Projects
Commit 00c56e32 authored by Antonio MATTAR's avatar Antonio MATTAR
Browse files

-Fixed bugs

parent f60dfaa8
No related branches found
No related tags found
No related merge requests found
......@@ -5,8 +5,6 @@ from PIL import Image
import processor
import parser
img = Image.new("RGB", (1280, 800), (255, 255, 255))
img.save("terme.png", "PNG")
colors = ['black','blue','green','orange','pink','purple','red','yellow']
variables_colors_couple = {}
......@@ -23,14 +21,12 @@ def createVarImage(variable):
assert (processor.isVariable(variable))
associateVariableWithColor(variable)
egg_img = Image.open("figures/egg_"+variables_colors_couple[str(variable)]+".png")
egg_img.save('egg_'+str(variable[1])+".png")
return egg_img
def createAlligator(terme):
assert (processor.isVariable(terme))
associateVariableWithColor(terme)
alligator_img = Image.open("figures/alligator_"+variables_colors_couple[str(terme)]+".png")
alligator_img.save('alligator_'+str(terme[1])+".png")
return alligator_img
def createAbsImage(terme):
......@@ -42,7 +38,6 @@ def createAbsImage(terme):
abstraction = Image.new('RGB', (max(im1.width, im2.width), im1.height + im2.height), (255, 255, 255))
abstraction.paste(im1, ((max(im1.width, im2.width)-im1.width) // 2, 0))
abstraction.paste(im2, ( 0 , im1.height))
abstraction.save('abs.png')
return abstraction
def get_concat_h_multi_resize(im_list, resample=Image.BICUBIC):
......@@ -65,7 +60,6 @@ def createAppImage(terme):
im2 = createImage(right)
space = Image.open("figures/space.png")
application = get_concat_h_multi_resize([im1,space,im2])
application.save('application.png')
return application
def createImage(terme):
......@@ -78,4 +72,7 @@ def createImage(terme):
else:
raise Exception("Unsupported term type")
(createImage(parser.parseTerm(input("Enter a term: "))))
\ No newline at end of file
def saveImage(image,name):
image.save( name+".png", "PNG")
saveImage(createImage(parser.parseTerm(input("Enter a term: "))), "terme")
\ No newline at end of file
from processor import *
import processor
# TERME = input('Please enter a Lambda-Term: ')
#renvoie conteur le nombre de parentheses ouvertes et indexes la liste des indices des parenthese)
......@@ -66,8 +67,17 @@ def getTermFromParantheses(terme,i):
def getTermsFromParantheses(terme):
terms = []
for i in (open_parantheses_counter(terme)[1]):
# indexes_of_open_parantheses = open_parantheses_counter(terme)[1]
# for i in range(len(indexes_of_open_parantheses)):
# if findClosingParanthesesIndex(terme,indexes_of_open_parantheses[i]) > findClosingParanthesesIndex(terme,indexes_of_open_parantheses[i-1]):
# terms.append(getTermFromParantheses(terme,indexes_of_open_parantheses[i]))
i = 0
while i < len(terme):
if terme[i] == '(':
terms.append(getTermFromParantheses(terme,i))
i = findClosingParanthesesIndex(terme,i)
else:
i+=1
return terms
#fonction qui enleve les espaces successifs et laisse un seul espace
......@@ -163,6 +173,7 @@ def buildApp(terme):
return t
else:
liste_de_termes = getTermsFromParantheses(terme)
print(liste_de_termes)
t = buildTerm(liste_de_termes[0])
for k in range(1, len(liste_de_termes)):
if liste_de_termes[k] == '':
......
terme.png

4.68 KiB | W: | H:

terme.png

141 KiB | W: | H:

terme.png
terme.png
terme.png
terme.png
  • 2-up
  • Swipe
  • Onion skin
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment