forked from cornerstonejs/cornerstone
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcanvasToPixel.js
More file actions
25 lines (21 loc) · 803 Bytes
/
Copy pathcanvasToPixel.js
File metadata and controls
25 lines (21 loc) · 803 Bytes
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
(function (cornerstone) {
"use strict";
/**
* 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
* @param pt
* @returns {x: number, y: number}
*/
function canvasToPixel(element, pt) {
var enabledElement = cornerstone.getEnabledElement(element);
var transform = cornerstone.internal.getTransform(enabledElement);
transform.invert();
return transform.transformPoint(pt.x, pt.y);
}
// module/private exports
cornerstone.canvasToPixel = canvasToPixel;
}(cornerstone));