728x90
반응형
mouse point
-
resize된 canvas위에 대한 mouse좌표 스케일링자바스크립트/Javascript 2021. 3. 18. 16:43
let rect = this.canvas.getBoundingClientRect(); let scaleX = this.canvas.width/rect.width; let scaleY = this.canvas.height/rect.height; //resize된 캔버스 마우스 pos 재정렬 this.mousePos.x = (e.clientX - rect.left)*scaleX this.mousePos.y = (e.clientY - rect.top)*scaleY