diff --git a/dmp/my_sol/.run_dmp.py.swp b/dmp/my_sol/.run_dmp.py.swp deleted file mode 100644 index 362c6bac7ccaa4eac41286b03a9e5bfb24526142..0000000000000000000000000000000000000000 Binary files a/dmp/my_sol/.run_dmp.py.swp and /dev/null differ diff --git a/drawing_gen/.draw_path.py.swp b/drawing_gen/.draw_path.py.swp new file mode 100644 index 0000000000000000000000000000000000000000..26bbfd9be5319d2a72f37da9da24071c9bd03b1f Binary files /dev/null and b/drawing_gen/.draw_path.py.swp differ diff --git a/drawing_gen/.example_draw.py.swp b/drawing_gen/.example_draw.py.swp new file mode 100644 index 0000000000000000000000000000000000000000..9b10bb278d92b8826460e0aae659d6cd2025bd69 Binary files /dev/null and b/drawing_gen/.example_draw.py.swp differ diff --git a/drawing_gen/draw_path.py b/drawing_gen/draw_path.py new file mode 100644 index 0000000000000000000000000000000000000000..5e9e22c4ce712c3006157f596e7d6a8fdf7966fe --- /dev/null +++ b/drawing_gen/draw_path.py @@ -0,0 +1,44 @@ +import numpy as np +import matplotlib.pyplot as plt +# used for drawing +# it's hacked from lasso where there's drawing +from matplotlib.path import Path +from matplotlib.widgets import LassoSelector + + +class DrawPath: + + def __init__(self, ax): + self.canvas = ax.figure.canvas + self.lasso = LassoSelector(ax, onselect=self.onselect) + + def onselect(self, verts): + # verts is a list of tuples + self.path = np.array( [ [i[0], i[1]] for i in verts ] ) + #self.canvas.draw_idle() + + def disconnect(self): + self.lasso.disconnect_events() + self.canvas.draw_idle() + + +if __name__ == '__main__': + + subplot_kw = dict(xlim=(0, 1), ylim=(0, 1), autoscale_on=False) + fig, ax = plt.subplots(subplot_kw=subplot_kw) + + selector = DrawPath(ax) + + def accept(event): + if event.key == "enter": + print("path points:") + print(selector.path) + selector.disconnect() + ax.set_title("") + print("TODO: run clik on me") + exit() + + fig.canvas.mpl_connect("key_press_event", accept) + ax.set_title("Press 'Enter' to accept drawn path.") + + plt.show()