INNER CODE UNIT · Python
output_image
Kushal997-das/Project-Guidance · Desktop Application/Basic/Python/Maze Solver/main.py:114
def output_image(self, filename, show_solution=True, show_explored=False):
from PIL import Image, ImageDraw
cell_size = 50
cell_border = 2
img = Image.new("RGBA", (self.width * cell_size, self.height * cell_size), "black")
draw = ImageDraw.Draw(img)
solution = self.solution[1] if self.solution is not None else None
for i, row in enumerate(self.walls):
for j, col in enumerate(row):
if col:
fill = (40, 40, 40)
elif (i, j) == self.start:
fill = (38, 32, 224)
elif (i, j) == self.goal:
fill = (0, 171, 28)
elif solution is not None and show_solution and (i, j) in solution: