pointsToPixels for rect

This commit is contained in:
Vadim Lopatin 2016-11-09 14:14:15 +03:00
parent d3724205df
commit 9789897d1d
1 changed files with 6 additions and 1 deletions

View File

@ -309,11 +309,16 @@ private __gshared int PRIVATE_SCREEN_DPI = 96;
/// one point is 1/72 of inch
enum POINTS_PER_INCH = 72;
/// convert points (1/72in units) to pixels according to SCREEN_DPI
/// convert length in points (1/72in units) to pixels according to SCREEN_DPI
int pointsToPixels(int pt) {
return pt * SCREEN_DPI / POINTS_PER_INCH;
}
/// rectangle coordinates in points (1/72in units) to pixels according to SCREEN_DPI
Rect pointsToPixels(Rect rc) {
return Rect(rc.left.pointsToPixels, rc.top.pointsToPixels, rc.right.pointsToPixels, rc.bottom.pointsToPixels);
}
/// convert points (1/72in units) to pixels according to SCREEN_DPI
int pixelsToPoints(int px) {
return px * POINTS_PER_INCH / SCREEN_DPI;