willowsystems / jSignature

jQuery plugin - draw signature in browser.
720 stars 266 forks source link

Would like to save data with canvas dimension - OR - make Undo work with canvas initialised with data #39

Open wavesource opened 11 years ago

wavesource commented 11 years ago

Hi - love your work with this script, many thanks, would happily pay for license if you took it commercial.

I am using jSignature in an online charting application. The canvas is loaded 600x700px, and users can draw anywhere on the canvas.

When loading jSignature output after saving (I am storing as data, not images as you recommend) the output, as you intend, does not store the canvas size, ie. x : [0] , y : [0] of input will be relative to the boundary of the saved input extent, not the actual original canvas.

I can hack jSignature to load with with a single point around line 970 as I have mentioned in a post elsewhere on this project, as such:

// setting up new dataEngine data = [ { x : [0] , y : [0] } ]

and by adding this single pixel on creation, this then sets the relative position of all subsequent input, and I can then load the output correctly into a 600x700px div as it was drawn, with all input position absolutely on the canvas as it was entered, regardless of where on the canvas input was made.

This is all great - ! Works like a dream.

However, this hack breaks the Undo script, as a single click on the Undo button will remove all input, rather than sequentially by stroke as intended.

Is there a way to either make the Undo script co-exist successfully with this hack to load jSignature with a single positioning pixel - or can jSignature be modified to accept some canvas data that can assist this type of accurate absolute positioning of input as per canvas?

I think jSignature is an immensely useful tool, and this would extend the script to effectively work in scenarios beyond just signature input recording. I ran into a Danish researcher on a holiday recently in Italy, and he was most interested in jSig's application in being able to record subjects' tracing a pathway through a maze in one of his studies, for example (Porteus Maze Test, I think - http://en.wikipedia.org/wiki/Porteus_Maze_Test). They are currently using paper records, and the opportunity to be able to use tablet input to replace this system, with all records stored digitally and accessible instantly, piqued his interest somewhat, to say the least. This is a good example of a similar application to the one I have developed that would benefit from absolute positioning on canvas of any input.

Many thanks for your time

David