Created
February 9, 2018 12:57
-
-
Save Sciss/9efbc2988ea869f16a9545b45dfebf34 to your computer and use it in GitHub Desktop.
test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// given w = width in pixels, h = height in pixels, inches = diagonal in inches, | |
// calculate display density in ppi | |
// ex. calcPPI(640, 384, 7.5) = 84 ppi | |
def calcPPI(w: Int, h: Int, inches: Double): Double = { | |
val aspect = w.toDouble / h | |
h / (inches.squared / (aspect + 1)).sqrt | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment