Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AP-Dahmane-lynda
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
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lynda Dahmane
AP-Dahmane-lynda
Commits
5882464d
Commit
5882464d
authored
1 year ago
by
Lynda Dahmane
Browse files
Options
Downloads
Patches
Plain Diff
Delete Block.py
parent
4ae7bc96
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
projet/Block.py
+0
-84
0 additions, 84 deletions
projet/Block.py
with
0 additions
and
84 deletions
projet/Block.py
deleted
100644 → 0
+
0
−
84
View file @
4ae7bc96
class
Block
:
def
__init__
(
self
,
zone
,
couleur
=
None
,
sous_blocs
=
None
):
"""
Initialisation un objet Bloc avec une zone, une couleur et des sous_blocs
"""
self
.
zone
=
zone
self
.
couleur
=
couleur
self
.
sous_blocs
=
sous_blocs
if
self
.
sous_blocs
:
if
len
(
self
.
sous_blocs
)
!=
4
:
raise
ValueError
()
if
couleur
is
not
None
:
raise
ValueError
()
self
.
couleur
=
self
.
moyenne_couleurs
()
def
moyenne_couleurs
(
self
):
"""
Renvoie la moyenne des couleurs des sous_blocs
"""
if
not
self
.
sous_blocs
:
return
self
.
couleur
else
:
r
,
g
,
b
=
0
,
0
,
0
for
blocs
in
self
.
sous_blocs
:
r
+=
bloc
.
couleur
[
0
]
g
+=
bloc
.
couleur
[
1
]
b
+=
bloc
.
couleur
[
2
]
return
[
r
/
len
(
self
.
sous_blocs
),
g
/
len
(
self
.
sous_blocs
),
b
/
len
(
self
.
sous_blocs
)]
def
est_uniforme
(
self
)
->
bool
:
"""
Renvoie True si le bloc est uniforme
"""
return
not
self
.
sous_blocs
def
est_dans_limites
(
self
,
limites_min
,
limites_max
):
"""
Renvoie True si la zone du bloc est dans les limites spécifiées
"""
x
,
y
=
self
.
zone
[:
2
]
width
,
height
=
self
.
zone
[
2
:]
return
(
x
>=
limites_min
[
0
]
and
x
+
width
<=
limites_max
[
0
]
and
y
>=
limites_min
[
1
]
and
x
+
height
<=
limites_max
[
1
])
def
__str__
(
self
):
"""
Renvoie une représentation en chaine de caractére du bloc
"""
if
self
.
est_uniforme
():
return
f
"
Bloc(uniforme, couleur=
{
self
.
couleur
}
)
"
else
:
return
f
"
Bloc(non_uniforme, couleur=
{
self
.
couleur
}
)
"
\ No newline at end of file
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