Created
February 26, 2019 14:38
-
-
Save thecotne/d7630dec23ebb1aad24a5d5d0e355a4c to your computer and use it in GitHub Desktop.
This file contains 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
function fit ([wi, hi], [ws, hs]) { | |
const ri = wi / hi | |
const rs = ws / hs | |
return rs > ri ? [wi * hs / hi, hs] : [ws, hi * ws / wi] | |
} | |
// usage | |
const [width, height] = fit([16, 9], [2560, 1600]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment