MCPcopy
hub / github.com/KilledByAPixel/LittleJS / mouseEventToScreen

Function mouseEventToScreen

src/engineInput.js:594–600  ·  view source on GitHub ↗
(mousePos)

Source from the content-addressed store, hash-verified

592
593 // convert a mouse or touch event position to screen space
594 function mouseEventToScreen(mousePos)
595 {
596 const rect = mainCanvas.getBoundingClientRect();
597 const px = percent(mousePos.x, rect.left, rect.right);
598 const py = percent(mousePos.y, rect.top, rect.bottom);
599 return vec2(px*mainCanvas.width, py*mainCanvas.height);
600 }
601}
602
603function inputUpdate()

Callers 4

onMouseDownFunction · 0.85
onMouseMoveFunction · 0.85
handleTouchFunction · 0.85
handleTouchGamepadFunction · 0.85

Calls 2

percentFunction · 0.85
vec2Function · 0.85

Tested by

no test coverage detected