Handle 2x scaling in plot drawing

old-commit-hash: e816467eb5a6fb7b933225a871dc8ad339a17e68
This commit is contained in:
Willem Melching
2020-04-14 12:51:09 -07:00
parent 746600dfb3
commit f821def1eb
+8 -2
View File
@@ -173,8 +173,14 @@ def init_plots(arr, name_to_arr_idx, plot_xlims, plot_ylims, plot_names, plot_co
fig.canvas.flush_events()
raw_data = renderer.tostring_rgb()
#print fig.canvas.get_width_height()
plot_surface = pygame.image.frombuffer(raw_data, fig.canvas.get_width_height(), "RGB").convert()
x, y = fig.canvas.get_width_height()
# Handle 2x scaling
if len(raw_data) == 4 * x * y * 3:
plot_surface = pygame.image.frombuffer(raw_data, (2*x, 2*y), "RGB").convert()
plot_surface = pygame.transform.scale(plot_surface, (x, y))
else:
plot_surface = pygame.image.frombuffer(raw_data, fig.canvas.get_width_height(), "RGB").convert()
return plot_surface
return draw_plots