2016-11-17 00:02:07 +01:00
|
|
|
from PIL import ImageColor
|
|
|
|
|
|
|
|
|
|
class cell:
|
|
|
|
|
"""
|
|
|
|
|
A single cell that can be occupied in a given layer, blocked,
|
|
|
|
|
visited, etc.
|
|
|
|
|
"""
|
|
|
|
|
def __init__(self):
|
2016-11-17 01:47:31 +01:00
|
|
|
self.path = False
|
2016-11-17 00:02:07 +01:00
|
|
|
|
|
|
|
|
self.blocked = False
|
|
|
|
|
|
2016-11-17 01:47:31 +01:00
|
|
|
self.source = False
|
|
|
|
|
self.target = False
|
2016-11-17 00:02:07 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_color(self):
|
|
|
|
|
|
|
|
|
|
# Blues are horizontal
|
|
|
|
|
if self.blocked:
|
2016-11-17 01:47:31 +01:00
|
|
|
return ImageColor.getrgb("Green")
|
2016-11-17 00:02:07 +01:00
|
|
|
# Reds are source/sink
|
2016-11-17 01:47:31 +01:00
|
|
|
if self.source or self.target:
|
2016-11-17 00:02:07 +01:00
|
|
|
return ImageColor.getrgb("Red")
|
|
|
|
|
|
2016-11-17 01:47:31 +01:00
|
|
|
if self.path:
|
|
|
|
|
return ImageColor.getrgb("Blue")
|
2016-11-17 00:02:07 +01:00
|
|
|
|
|
|
|
|
return [255,255,255]
|
|
|
|
|
|
|
|
|
|
|