Handling different data structure from old signature plugin? #579
Unanswered
MichaelHeydon
asked this question in
Q&A
Replies: 1 comment 1 reply
-
I haven't tested it, but you could try something like this: function convertSig(sig) {
let prev = null;
const data = [];
function createPoint(x, y) {
return {
x,
y,
time: 0,
pressure: 0,
};
}
function createPointGroup(x, y) {
return {
dotSize: 0,
minWidth: 0.5,
maxWidth: 2.5,
penColor: 'black',
points: [createPoint(x, y)],
};
}
for (const point of sig) {
if (!prev || prev.lx !== point.mx || prev.ly !== point.my) {
// new line
data.push(createPointGroup(point.mx, point.my));
}
data[data.length - 1].points.push(createPoint(point.lx, point.ly));
prev = point;
}
return data;
} |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
We had previously used https://github.com/thread-pond/signature-pad but are looking to update to this plugin. The previous plugin used this example structure to save signatures:
var sig = [{lx:20,ly:34,mx:20,my:34},{lx:21,ly:33,mx:20,my:34},…];
. Are you aware of any techniques / methods to convert this format so it can be accepted and displayed correctly by your plugin?Thanks very much!
Beta Was this translation helpful? Give feedback.
All reactions