Skip to content
Snippets Groups Projects
Commit 5f6c1fa3 authored by Belkacemi Melissa's avatar Belkacemi Melissa
Browse files

blocs

parent 32761ca5
Branches
No related tags found
No related merge requests found
#Belkacemi Melissa
#13/03/2024
import couleur
from couleur import couleur_moyenne
class Bloc:
""" une classe représentant des blocs
"""
def __init__(self,couleur:tuple[int,int,int],pixel_hg:tuple[int,int],pixel_bd:tuple[int,int],*sous_blocs:list["Bloc"])->"Bloc":
def __init__(self,couleur:tuple[int,int,int],
pixel_hg:tuple[int,int],
pixel_bd:tuple[int,int],
*sous_blocs)->"Bloc":
"""
Précondition :
......@@ -21,12 +24,19 @@ class Bloc:
"""
self.pixel_hg=pixel_hg
self.pixel_bd=pixel_bd
self.couleur=couleur
self.sous_blocs=[]
if len(sous_blocs)!=0:
for i in range(4):
(self.sous_blocs).append(sous_blocs[i])
if len(sous_blocs)==0:
self.couleur=couleur
else:
self.sous_blocs=sous_blocs
couleurs=[sous_blocs[0].couleur,sous_blocs[1].couleur,sous_blocs[2].couleur,sous_blocs[3].couleur]
self.couleur=couleur_moyenne(couleurs)
def sont_proches(c1:tuple[int,int,int],c2:tuple[int,int,int],c3:tuple[int,int,int],c4:tuple[int,int,int]) ->bool:
"""Renvoie True si les 4 couleurs sont proches
"""
cm=couleur_moyenne([c1,c2,c3,c4])
return coul_sont_proches(c1,cm)and coul_sont_proches(c2,cm) and coul_sont_proches(c3,cm) and coul_sont_proches(c4,cm)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment