diff --git a/hudes/hudes_client.py b/hudes/hudes_client.py index 02bedba..3660dd6 100644 --- a/hudes/hudes_client.py +++ b/hudes/hudes_client.py @@ -144,7 +144,6 @@ def run_loop(self): self.view.draw() logging.debug("hudes_client: redraw done") else: - logging.debug("hudes_client: sleep") sleep(0.01) logging.debug("hudes_client: sleep up") diff --git a/hudes/view.py b/hudes/view.py index a52960a..632aaa3 100644 --- a/hudes/view.py +++ b/hudes/view.py @@ -6,20 +6,13 @@ from hudes.opengl_func import ( create_grid_indices, - create_grid_points, create_grid_points_with_colors, - create_matplotlib_texture, create_matplotlib_texture_rgba, create_surface_grid_indices, create_surface_grid_points, - create_texture, create_texture_rgba, - draw_arrow, - draw_red_plane, draw_red_sphere, - render_text, render_text_2d, - render_texture, render_texture_rgba, update_grid_cbo, update_grid_vbo, @@ -27,9 +20,7 @@ matplotlib.use("Agg") -import time -import matplotlib.backends.backend_agg as agg import matplotlib.pyplot as plt import numpy as np import pygame as pg @@ -165,6 +156,9 @@ def __init__(self, use_midi=False): figsize=(12, 8), ) + # self.canvas = agg.FigureCanvasAgg(self.fig) + self.canvas = self.fig.canvas + self.renderer = self.canvas.get_renderer() self.fig.subplots_adjust( left=0.07, right=0.95, hspace=0.8, top=0.92, bottom=0.07, wspace=0.5 # 0.5 ) @@ -296,11 +290,9 @@ def plot_train_and_val( self.axd["D"].set_xlabel("Step") def draw(self): - canvas = agg.FigureCanvasAgg(self.fig) - canvas.draw() - surf = pg.image.frombytes( - canvas.get_renderer().tostring_rgb(), self.window_size, "RGB" - ) + + self.canvas.draw() + surf = pg.image.frombytes(self.renderer.tostring_rgb(), self.window_size, "RGB") self.screen.blit(surf, (0, 0)) pg.display.flip() # draws whole screen vs update that draws a parts @@ -451,7 +443,6 @@ def __init__(self, grid_size, grids): # init plt plt.style.use("dark_background") self.fig = plt.figure(figsize=(12, 2), facecolor="none") - self.fig.subplots_adjust( left=0.07, right=0.95, hspace=0.8, top=0.80, bottom=0.1, wspace=0.5 # 0.5 )