Skip to content
Snippets Groups Projects
Commit 6b62d7b8 authored by Antonio MATTAR's avatar Antonio MATTAR
Browse files
parent 91b1e2ff
No related branches found
No related tags found
No related merge requests found
from ast import Raise
from logging import exception
from PIL import Image
from PIL import ImageDraw
from PIL import ImageFont
import logic
import parsing
......@@ -87,11 +89,21 @@ def createOldAlligatorFamily(terme):
old_alligator_fam.paste(family_img.image, ( 0 , old_alli_img.height))
return old_alligator_fam
def addNumberToImage(image,number):
draw = ImageDraw.Draw(image.image)
# font = ImageFont.truetype(<font-file>, <font-size>)
font = ImageFont.truetype("AllerDisplay.ttf", 150)
# draw.text((x, y),"Sample Text",(r,g,b))
draw.text((0, 0),str(number+2),(0,0,0),font=font)
return image
def createAppImage(terme):
assert (logic.isApplication(terme))
left = logic.getFirstTerm(terme)
right = logic.getSecondTerm(terme)
im1 = createImage(left)
if len(terme) == 5:
im1 = addNumberToImage(im1,terme[-1])
if logic.isApplication(right):
im2 = createOldAlligatorFamily(right)
application = get_concat_h_multi_resize([im1.image,im2])
......
......@@ -409,14 +409,17 @@ def beta_reduction_interactive(terme):
return terme
def beta_reduction_interactive_totale(terme):
captureImage(terme)
if beta_reduction((terme)) != None:
print(to_string(terme))
choix=int(input("voulez-vous faire la reduction tapez sur 1 pour oui tapez sur 2 pour non "))
if choix==1:
captureImage(annotate_beta_reduction((terme)))
return beta_reduction_interactive_totale(beta_reduction_interactive(terme))
else:
captureImage(terme)
print("C'est fini, le terme obtenu est : "+to_string(terme))
else:
captureImage(terme)
return (terme)
......
......@@ -6,7 +6,7 @@ def run():
# x = image_maker.createImage(parsing.parseTerm(input("Enter a term: ")))
# image_maker.saveImage(x, "terme")
# x.show()
logic.beta_reduction_totale(parsing.parseTerm(input("Enter a term: ")))
logic.beta_reduction_interactive_totale(parsing.parseTerm(input("Enter a term: ")))
# x = logic.new_var('x')
# y = logic.new_var('y')
# print(logic.to_string(logic.new_app(y,logic.new_app(x,logic.new_app(x,x)))))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment