UNPKG

lazy-widgets

Version:

Typescript retained mode GUI for the HTML canvas API

18 lines 596 B
/** * Extracts the position of a DOM MouseEvent and normalises it. Useful for * implementing mouse input. * * @returns Returns a 2-tuple containing the normalised coordinates; the first * element contains the normalised x axis, and the second element contains the * normalised y axis * * @category Helper */ export function getPointerEventNormPos(event, domElem) { const rect = domElem.getBoundingClientRect(); return [ (event.clientX - rect.left) / rect.width, (event.clientY - rect.top) / rect.height, ]; } //# sourceMappingURL=getPointerEventNormPos.js.map