Initial release
This commit is contained in:
32
Hercule 5 Les écuries d'Augias.py
Normal file
32
Hercule 5 Les écuries d'Augias.py
Normal file
@@ -0,0 +1,32 @@
|
||||
from PIL import Image
|
||||
|
||||
image = Image.open("stables.png")
|
||||
|
||||
width, height = image.size
|
||||
|
||||
def fill(x, y):
|
||||
global image
|
||||
global width
|
||||
global height
|
||||
image.putpixel((x,y), 127)
|
||||
if x < width-1 and image.getpixel((x+1,y)) == 255:
|
||||
fill(x+1, y)
|
||||
if x > 0 and image.getpixel((x-1,y)) == 255:
|
||||
fill(x-1, y)
|
||||
if y < height-1 and image.getpixel((x,y+1)) == 255:
|
||||
fill(x, y+1)
|
||||
if y > 0 and image.getpixel((x,y-1)) == 255:
|
||||
fill(x, y-1)
|
||||
|
||||
zones = 0
|
||||
for x in range(width):
|
||||
for y in range(height):
|
||||
if image.getpixel((x,y)) == 255:
|
||||
fill(x,y)
|
||||
# image.show()
|
||||
zones += 1
|
||||
|
||||
print(zones)
|
||||
image.show()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user