Created basic outline of Displayer class

This commit is contained in:
Andreas Tsouchlos
2022-04-21 15:59:33 +02:00
parent f74f06f46f
commit 2141f7d833
11 changed files with 55 additions and 7 deletions

0
display/__init__.py Normal file
View File

BIN
display/__init__.pyc Normal file

Binary file not shown.

35
display/dislpay_2d.py Normal file
View File

@@ -0,0 +1,35 @@
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
import numpy as np
import matplotlib.gridspec as gridspec
from mpl_toolkits.axes_grid1.inset_locator import zoomed_inset_axes
import functools
class Displayer:
def __init__(self, width, height):
self._fig, self._ax = plt.subplots()
self._fig.set_figwidth(width)
self._fig.set_figheight(height)
self._xdata, self._ydata = [], []
self._obj, = plt.plot([], [], 'ro')
self._circle = plt.Circle((5, 5), 1, color='r', fill=False)
self._objects = [self._obj, self._circle]
def __init_animation(self):
self._ax.set_xlim(0, 20)
self._ax.set_ylim(0, 20)
self._ax.add_patch(self._circle)
return self._objects
def __update_animation(self, t):
self._obj.set_data([t, t])
self._circle.center = (t, t)
self._circle.radius = t*0.1
return self._objects
def animate(self, n_steps):
anim = FuncAnimation(self._fig, self.__update_animation, frames=np.linspace(0, n_steps-1, n_steps),
init_func=self.__init_animation, blit=True)
plt.show()

BIN
display/dislpay_2d.pyc Normal file

Binary file not shown.