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

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

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 24 25 26                                      919x   919x   919x    
import getTransform from './getTransform';
 
import { Point2, CPUFallbackEnabledElement } from '../../../../types';
 
/**
 * Converts a point in the canvas coordinate system to the pixel coordinate system
 * system.  This can be used to reset tools' image coordinates after modifications
 * have been made in canvas space (e.g. moving a tool by a few cm, independent of
 * image resolution).
 *
 * @param element - The Cornerstone element within which the input point lies
 * @param pt - The input point in the canvas coordinate system
 *
 * @returns The transformed point in the pixel coordinate system
 */
export default function (
  enabledElement: CPUFallbackEnabledElement,
  pt: Point2
): Point2 {
  const transform = getTransform(enabledElement);
 
  transform.invert();
 
  return transform.transformPoint(pt);
}