Skip to content

Commit

Permalink
blitting breaks pi
Browse files Browse the repository at this point in the history
  • Loading branch information
misko committed Oct 8, 2024
1 parent b7d1eb9 commit aff0405
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions hudes/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ def plot_train_and_val(
self.axd["D"].redraw = True

def draw_or_restore(self):
for _ax, ax in self.axd.items():
for _, ax in self.axd.items():
if ax.redraw:
ax.draw(self.renderer)
ax.cache = self.fig.canvas.copy_from_bbox(
Expand All @@ -338,9 +338,6 @@ def draw_or_restore(self):
self.fig.canvas.restore_region(ax.cache)

def draw(self):
class fake_ctx:
def save(self):
pass

logging.debug("hudes_client: redraw")
# cairo
Expand All @@ -349,22 +346,23 @@ def save(self):
if "cairo" in plt_backend.lower():

# self.renderer.gc.ctx = fake_ctx()
self.canvas.draw()
self.draw_or_restore()
surf = pygame.image.frombuffer(
self.surface.get_data(), self.window_size, "RGBA"
)
# self.canvas.draw()
# self.draw_or_restore()
# surf = pygame.image.frombuffer(
# self.surface.get_data(), self.window_size, "RGBA"
# )
# self.screen.blit(surf, (0, 0))
# self.draw_or_restore()
# self.renderer = self.canvas._renderer

# self.draw_or_restore()
# surf = pg.image.frombuffer(
# # self.renderer.tostring_rgb(),
# self.canvas._get_printed_image_surface().get_data(),
# self.window_size,
# "RGBA",
# )
self.canvas.draw()
surf = pg.image.frombuffer(
# self.renderer.tostring_rgb(),
self.canvas._get_printed_image_surface().get_data(),
self.window_size,
"RGBA",
)
self.screen.blit(surf, (0, 0))
else: # backend.lower()=='agg':
# self.canvas.draw()
Expand Down

0 comments on commit aff0405

Please sign in to comment.