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

Method screenToNative

plugins/uiSystem.js:479–492  ·  view source on GitHub ↗

Convert a screen space position to native UI position * @param {Vector2} pos * @return {Vector2}

(pos)

Source from the content-addressed store, hash-verified

477 * @param {Vector2} pos
478 * @return {Vector2} */
479 screenToNative(pos)
480 {
481 if (!uiSystem.nativeHeight)
482 return pos;
483
484 const s = mainCanvasSize.y / uiSystem.nativeHeight;
485 const sInv = 1/s;
486 const p = pos.copy();
487 p.x += s*mainCanvasSize.x/2;
488 p.x *= sInv;
489 p.y *= sInv;
490 p.x -= sInv*mainCanvasSize.x/2;
491 return p;
492 }
493
494 /** Object to send keyboard input to (typically a UITextInput).
495 * The document keydown listener is only attached while this is set,

Callers 3

updateTransformsMethod · 0.80
isMouseOverlappingMethod · 0.80
updateMethod · 0.80

Calls 1

copyMethod · 0.45

Tested by

no test coverage detected