Fix iOS cursor offset

This commit is contained in:
Andras Schmelczer 2026-06-11 20:32:14 +01:00
parent 3f73f30f2d
commit 3b807a968c

View file

@ -38,6 +38,14 @@ class CanvasHandler {
return unit * Math.sqrt(this.width * this.height); return unit * Math.sqrt(this.width * this.height);
} }
clientToCanvas(clientX, clientY) {
const rect = this.canvas.getBoundingClientRect();
return [
((clientX - rect.left) / rect.width) * this.width,
((clientY - rect.top) / rect.height) * this.height,
];
}
get width() { get width() {
return this.canvas.width / window.devicePixelRatio; return this.canvas.width / window.devicePixelRatio;
} }