The screen coordinate is taken as the origin coordinate, and the positive direction of the coordinate axis is right and down. Px is the unit of screen pixels. Pt is in the unit of 1/72 inch. Therefore, the idea of conversion is: 1. Create a static element with a length of 1 inch. 2. Test the number of pixels in the length of 3. If the above test is completed... SyntaxHighlighter. all ();
The screen coordinate is taken as the origin coordinate, and the positive direction of the coordinate axis is right and down.
Px is the unit of screen pixels.
Pt is in the unit of 1/72 inch.
Therefore, the conversion logic is as follows:
1. Create a static element with a length of 1 inch
2. Test the number of pixels in length.
3. If the above test result is a, then y = x * a/72 y is the pixel value converted from x (pt.
4. If the above test result is a, then y = x * 72/a y is the result of converting x (px) to pt.
Code:
Function px2pt (pxValue ){
A = $ (""). width ();
Return pxValue * 72/;
}
Function pt2px (pxValue ){
A = $ (""). width ();
Return pxValue * a/72;
}