mirror of
https://gitlab.com/Hukuta47/cartrix.git
synced 2026-12-05 12:30:55 +00:00
59 lines
1.2 KiB
JavaScript
59 lines
1.2 KiB
JavaScript
window.signatureInterop = {
|
|
|
|
pad: null,
|
|
|
|
init: function (canvasId) {
|
|
|
|
const canvas = document.getElementById(canvasId);
|
|
|
|
canvas.style.touchAction = "none";
|
|
|
|
const resolutionScale = 2;
|
|
|
|
canvas.width = canvas.offsetWidth * resolutionScale;
|
|
canvas.height = canvas.offsetHeight * resolutionScale;
|
|
|
|
const ctx = canvas.getContext("2d");
|
|
|
|
ctx.scale(resolutionScale, resolutionScale);
|
|
|
|
ctx.imageSmoothingEnabled = true;
|
|
|
|
ctx.lineCap = "round";
|
|
ctx.lineJoin = "round";
|
|
|
|
this.pad = new SignaturePad(canvas, {
|
|
|
|
minWidth: 0.01,
|
|
maxWidth: 1.5,
|
|
penColor: "rgba(0, 91, 172, 1)",
|
|
dotSize: 1.5,
|
|
minDistance: 0,
|
|
throttle: 0,
|
|
velocityFilterWeight: 0,
|
|
});
|
|
|
|
canvas.addEventListener("pointerdown", (e) => {
|
|
e.preventDefault();
|
|
});
|
|
|
|
canvas.addEventListener("pointermove", (e) => {
|
|
e.preventDefault();
|
|
});
|
|
},
|
|
|
|
clear: function () {
|
|
|
|
this.pad.clear();
|
|
},
|
|
|
|
isEmpty: function () {
|
|
|
|
return this.pad.isEmpty();
|
|
},
|
|
|
|
getBase64: function () {
|
|
|
|
return this.pad.toDataURL("image/png").split(',')[1];
|
|
}
|
|
}; |