All files / packages/core/src/RenderingEngine/helpers/cpuFallback/rendering pixelToCanvas.ts

100% Statements 2/2
100% Branches 0/0
100% Functions 1/1
100% Lines 2/2

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23                                    384x   384x    
import getTransform from './getTransform';
import { CPUFallbackEnabledElement, Point2 } from '../../../../types';
 
/**
 * Converts a point in the pixel coordinate system to the canvas coordinate system
 * system.  This can be used to render using canvas context without having the weird
 * side effects that come from scaling and non square pixels
 *
 * @param {HTMLDivElement} element An HTML Element enabled for Cornerstone
 * @param {{x: Number, y: Number}} pt The transformed point in the pixel coordinate system
 *
 * @returns {{x: Number, y: Number}} The input point in the canvas coordinate system
 * @memberof PixelCoordinateSystem
 */
export default function (
  enabledElement: CPUFallbackEnabledElement,
  pt: Point2
): Point2 {
  const transform = getTransform(enabledElement);
 
  return transform.transformPoint(pt);
}