diff --git a/examples/demo.py b/examples/demo.py index 6e9f05389ce116c443090e7ee2e11867d0888fe3..2afc7828d43805d42ffe5333ecaf8f47bf271a49 100644 --- a/examples/demo.py +++ b/examples/demo.py @@ -199,16 +199,16 @@ if True: demo_flatland_000 = Demo(Scenario_Generator.load_scenario('./env-data/railway/example_flatland_000.pkl')) demo_flatland_000.renderer.resize() - demo_flatland_000.run_demo(300) + demo_flatland_000.run_demo(60) demo_flatland_000 = None demo_flatland_000 = Demo(Scenario_Generator.load_scenario('./env-data/railway/example_flatland_001.pkl')) demo_flatland_000.renderer.resize() - demo_flatland_000.run_demo(300) + demo_flatland_000.run_demo(60) demo_flatland_000 = None demo_flatland_000 = Demo(Scenario_Generator.load_scenario('./env-data/railway/example_network_003.pkl')) demo_flatland_000.renderer.resize() -demo_flatland_000.run_demo(1800) +demo_flatland_000.run_demo(60) demo_flatland_000 = None diff --git a/flatland/utils/graphics_pil.py b/flatland/utils/graphics_pil.py index cadc2e50e2cbddc7442537357c798c547dab494f..40e0a9270ede53de13174203a40972fdf540b61e 100644 --- a/flatland/utils/graphics_pil.py +++ b/flatland/utils/graphics_pil.py @@ -28,14 +28,17 @@ class PILGL(GraphicsLayer): self.screen_height = min(self.screen_height,m.height) self.screen_width = min(self.screen_width,m.width) - w = 0.95*self.screen_width/(self.width + 1 + self.linewidth) - h = 0.95*self.screen_height/(self.height + 1 + self.linewidth) - self.nPixCell = int(max(1,np.floor(min(w,h)))) - + w = (self.screen_width-self.width-10)/(self.width + 1 + self.linewidth) + h = (self.screen_height-self.height-10)/(self.height + 1 + self.linewidth) + self.nPixCell = int(max(1,np.ceil(min(w,h)))) # Total grid size at native scale self.widthPx = self.width * self.nPixCell + self.linewidth self.heightPx = self.height * self.nPixCell + self.linewidth + + self.xPx = int((self.screen_width - self.widthPx) / 2.0) + self.yPx = int((self.screen_height - self.heightPx) / 2.0) + self.layers = [] self.draws = [] @@ -99,6 +102,7 @@ class PILGL(GraphicsLayer): self.window = tk.Tk() self.window.title("Flatland") self.window.configure(background='grey') + self.window.geometry('%dx%d+%d+%d' % (self.widthPx, self.heightPx, self.xPx, self.yPx)) self.window_open = True def close_window(self):