import matplotlib.pyplot as plt from PIL import Image #Creation d'une image blanche RGB 10x10 dessin5 = Image.new("RGB",(600,400),(0,0,204)) #Definitions des couleurs blanc = (255, 255, 255) rouge = (255, 0, 0) jaune = (255, 255, 0) #On parcourt tous les pixels de l'image: for col in range(0, 600): for ligne in range(0, 400): #un quadrilatère (4 conditions): if ligne >= (2/3)*col - 50 and ligne <= (2/3)*col + 50 and ligne >= (-2/3)*col + 350 and ligne <= 300: dessin5.putpixel((col, ligne), blanc) #Un triangle (3 conditions): if ligne >= (-2/3)*col + 500 and ligne >= (2/3)*col + 100 and ligne <= 350: dessin5.putpixel((col, ligne), rouge) #Un triangle (2 conditions): if ligne >= (50/200)*col + 50 and ligne <= (-50/200)*col + 150: dessin5.putpixel((col, ligne), jaune) plt.imshow(dessin5) plt.show()