diff --git a/flatland/utils/graphics_pil.py b/flatland/utils/graphics_pil.py index 7408e76c2084ec117d6855803491a328a7f28623..09dab97ca7402d07382aa22cf8836f84e4169e44 100644 --- a/flatland/utils/graphics_pil.py +++ b/flatland/utils/graphics_pil.py @@ -38,10 +38,11 @@ class PILGL(GraphicsLayer): window = tk.Tk() RAIL_LAYER = 0 - AGENT_LAYER = 1 - PREDICTION_PATH_LAYER = 2 - SELECTED_AGENT_LAYER = 3 - SELECTED_TARGET_LAYER = 4 + PREDICTION_PATH_LAYER = 1 + TARGET_LAYER = 2 + AGENT_LAYER = 3 + SELECTED_AGENT_LAYER = 4 + SELECTED_TARGET_LAYER = 5 def __init__(self, width, height, jupyter=False): self.yxBase = (0, 0) @@ -187,6 +188,7 @@ class PILGL(GraphicsLayer): def begin_frame(self): # Create a new agent layer self.create_layer(iLayer=PILGL.AGENT_LAYER, clear=True) + self.create_layer(iLayer=PILGL.PREDICTION_PATH_LAYER, clear=True) def show(self, block=False): img = self.alpha_composite_layers() @@ -263,6 +265,7 @@ class PILGL(GraphicsLayer): def create_layers(self, clear=True): self.create_layer(PILGL.RAIL_LAYER, clear=clear) # rail / background (scene) self.create_layer(PILGL.AGENT_LAYER, clear=clear) # agents + self.create_layer(PILGL.TARGET_LAYER, clear=clear) # agents self.create_layer(PILGL.PREDICTION_PATH_LAYER, clear=clear) # drawing layer for agent's prediction path self.create_layer(PILGL.SELECTED_AGENT_LAYER, clear=clear) # drawing layer for selected agent self.create_layer(PILGL.SELECTED_TARGET_LAYER, clear=clear) # drawing layer for selected agent's target @@ -492,9 +495,6 @@ class PILSVG(PILGL): return pil - def clear_set_predicion_path_layer(self): - self.clear_layer(PILGL.PREDICTION_PATH_LAYER, 0) - def set_predicion_path_at(self, row, col, binary_trans, agent_rail_color): colored_rail = self.recolor_image(self.pil_rail_org[binary_trans], [61, 61, 61], [agent_rail_color], @@ -505,7 +505,9 @@ class PILSVG(PILGL): if binary_trans in self.pil_rail: pil_track = self.pil_rail[binary_trans] if target is not None: - pil_track = Image.alpha_composite(pil_track, self.station_colors[target % len(self.station_colors)]) + target_img = self.station_colors[target % len(self.station_colors)] + target_img = Image.alpha_composite(pil_track, target_img) + self.draw_image_row_col(target_img, (row, col), layer=PILGL.TARGET_LAYER) if binary_trans == 0: if self.background_grid[col][row] <= 4: diff --git a/flatland/utils/rendertools.py b/flatland/utils/rendertools.py index 14c49add9fe03ba90f2691b9f00de32cb0863330..984357a166d10d5498c1f4cecd6d0def1f577f1d 100644 --- a/flatland/utils/rendertools.py +++ b/flatland/utils/rendertools.py @@ -292,9 +292,6 @@ class RenderTool(object): """ rt = self.__class__ - if type(self.gl) is PILSVG: - self.gl.clear_set_predicion_path_layer() - for agent in agent_handles: color = self.gl.get_agent_color(agent) for visited_cell in prediction_dict[agent]: