Pt conversion px

Source: Internet
Author: User
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;
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.