/** @internal NOTE: Internal APIs. Subject to change. Use of these APIs in production applications is not supported. */ /** */
import { boundingClientRectCache } from '../../BoundingClientRectCache';
/**
 * Converts screen coordinates to canvas coordinates.
 * @param scene Scene which utilizes the canvas we which to get coordinate for
 * @param c The coordinate in local (DOM content) coordinates
 * @param out canvas coordinate
 * @returns Reference to `out`.
 */
export function convertToCanvasCoordinatesToRef(scene, c, out) {
    const engine = scene.getEngine();
    const canvas = engine.getInputElement();
    const canvasRect = boundingClientRectCache.getOrAdd(canvas);
    out.x = Math.floor(c.x - canvasRect.left);
    out.y = Math.floor(c.y - canvasRect.top);
    return out;
}
/**
 * Get center coordinate of canvas used by `scene`
 * @param scene Scene which utilizes the canvas we which to get center coordinate for
 * @param out Canvas coordinates
 * @returns Reference to `out`.
 */
export function getCanvasCenterCoordinatesToRef(scene, out) {
    const engine = scene.getEngine();
    const canvas = engine.getInputElement();
    const canvasRect = boundingClientRectCache.getOrAdd(canvas);
    out.x = Math.floor(canvasRect.width * 0.5);
    out.y = Math.floor(canvasRect.height * 0.5);
    return out;
}
//# sourceMappingURL=input-utils.js.map