Initial release

This commit is contained in:
Francois JUMELLE
2021-05-03 22:32:40 +02:00
commit 20526d93c8
928 changed files with 452368 additions and 0 deletions

40
Le Code de Rattata.py Normal file
View File

@@ -0,0 +1,40 @@
from PIL import Image
img = Image.open("CodeCamembert.png")
# img = Image.open("exemple_codecamembert.png")
dim_camembert = 30
width, height = img.size
x_max = width // dim_camembert
y_max = height // dim_camembert
def fill(image, x, y, base, new):
global width
global height
image.putpixel((x,y), new)
if x < width-1 and image.getpixel((x+1,y)) == base:
fill(image, x+1, y, base, new)
if x > 0 and image.getpixel((x-1,y)) == base:
fill(image, x-1, y, base, new)
if y < height-1 and image.getpixel((x,y+1)) == base:
fill(image, x, y+1, base, new)
if y > 0 and image.getpixel((x,y-1)) == base:
fill(image, x, y-1, base, new)
res = ""
for y in range(y_max):
for x in range(x_max):
img_tmp = Image.new(img.mode, (dim_camembert, dim_camembert))
img_tmp.paste(img.crop((x*dim_camembert, y*dim_camembert, x*dim_camembert+dim_camembert, y*dim_camembert+dim_camembert)))
zones = 0
for a in range(dim_camembert):
for b in range(dim_camembert):
if img_tmp.getpixel((a,b)) == 0:
fill(img_tmp, a,b,0,255)
zones += 1
res += str(zones-1)
for i in range(0, len(res), 2):
c = chr(ord('A') + int(res[i:i+2], 5))
print(c, end="")