Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Alligators-python
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Benjamin Monmege
Alligators-python
Commits
00c56e32
Commit
00c56e32
authored
Jun 8, 2022
by
Antonio MATTAR
Browse files
Options
Downloads
Patches
Plain Diff
-Fixed bugs
parent
f60dfaa8
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
image_maker.py
+4
-7
4 additions, 7 deletions
image_maker.py
parser.py
+14
-3
14 additions, 3 deletions
parser.py
terme.png
+0
-0
0 additions, 0 deletions
terme.png
with
18 additions
and
10 deletions
image_maker.py
+
4
−
7
View file @
00c56e32
...
...
@@ -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
This diff is collapsed.
Click to expand it.
parser.py
+
14
−
3
View file @
00c56e32
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
]
==
''
:
...
...
This diff is collapsed.
Click to expand it.
terme.png
+
0
−
0
View replaced file @
f60dfaa8
View file @
00c56e32
4.68 KiB
|
W:
|
H:
141 KiB
|
W:
|
H:
2-up
Swipe
Onion skin
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment