Dearest StackOverflow community and my sincerest apologies for your losses.
This code I wrote does not work. I am very sorry to ask, but I need your help. I feel emberassed. I shouldn’t need to ask a question. I understand that you might be overwhelmed now, and that its hard to accept your fate. This question will be the only question I will ask, and I am very sorry to ask. I really feel emberassed. You need to believe me. This time, I will mention my code as expected from me. The code is written in JavaScript, a scripting language commonly used in Browsers. This code is supposed to do something very special. Thanks for reading this and attempting to fix my issue.
export const getCanvasMousePos = (canvas, evt) => {
var rect = canvas.getBoundingClientRect();
var scaleX = canvas.width / rect.width;
var scaleY = canvas.height / rect.height;
var ratioHW = canvas.height / canvas.width;
var ratioWH = canvas.height / canvas.width;
var rot = getCurrentRotation(canvas);
var pos = {
x: evt.offsetX,
y: evt.offsetY
}
if(rot == 90) {
pos = {
x: pos.x * scaleX * ratioHW,
y: (canvas.width - ((rect.width - (pos.y)) * scaleX)) * ratioWH
};
}else {
pos = {
x: pos.x * scaleX,
y: pos.y * scaleY
}
}
console.log(pos, ratioHW, ratioWH);
//canvas.getContext("2d").fillRect(pos.x, pos.y, 5, 5);
return pos;
throw "sbeve";
}