import jupyter_drawing_pad as jd
import matplotlib.pyplot as plt

"""
Explanation: Demo for jupyter-drawing-pad widget
End of explanation
"""


widget = jd.CustomBox()
widget.drawing_pad

print(widget.drawing_pad.data)

"""
Explanation: The widget is a box containing a drawing pad (main widget) and buttons (related to functionalities described below). Here is the drawing pad. You can draw whatever you want and data will be synchronised with the Python.
End of explanation
"""


widget.drawing_pad.data = [ [100,200,300], [100,20,30], [1,2,3]]

"""
Explanation: Synchronisation works both ways !
End of explanation
"""


widget

"""
Explanation: You can display the entiere widget. There are four additionnal elements:
+ a text-field : to enter a name related to a signature (drawn in the drawing pad)
+ a Clear button
+ a Save button : to save a signature (related to the name written in the text field)
+ a Login button : you can try to reproduce a signature previously registered. If this signature is close enough to one of the saved ones, a message  Welcome (name)  should appear
End of explanation
"""


print(widget.get_saved())

"""
Explanation: Accessing registered signatures
End of explanation
"""


plt.figure(figsize=(10,5))
plt.plot(widget.drawing_pad.data[0], widget.drawing_pad.data[1])
plt.xlim(0,500)
plt.ylim(0,250)
plt.show()

"""
Explanation: Reproducing the content of the drawing pad in a figure using matplotlib
End of explanation
"""


