Closed sailei1 closed 5 years ago
dpi: 每英寸多少点,ppi是 Pixel per inch,每英寸像素数
// i 英寸 x 屏幕宽 y 屏幕高 function getDPI(i, x, y) { var d = Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2)) if (i > 0){ return d/i; } return 0; } function ES_round(v, accuracy) { if (isNaN(accuracy)){ accuracy = 0; } return Math.round(v * Math.pow(10, accuracy)) / Math.pow(10, accuracy); } var dpi = ES_round(getDPI(inch, screen.width, screen.height), 2);
dpi: 每英寸多少点,ppi是 Pixel per inch,每英寸像素数