Skip to content

Instantly share code, notes, and snippets.

@xhlwill
Last active April 28, 2017 07:49
Show Gist options
  • Save xhlwill/3e4dffe25eb5e885e6337a253d609fba to your computer and use it in GitHub Desktop.
Save xhlwill/3e4dffe25eb5e885e6337a253d609fba to your computer and use it in GitHub Desktop.
calculate the PPI of screen
const ppi = function(height, width, inch) {
return Math.round(Math.sqrt(height*height + width*width) / inch);
}
@xhlwill
Copy link
Author

xhlwill commented Nov 13, 2016

iPhone 4/4s: 330
iPhone 5/5s/se: 326
iPhone 6/6s/7: 326
iPhone 6 plus/6s plus/7 plus: 401

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment