Created
January 4, 2016 11:28
-
-
Save cdmz/da1b95ceb4e3af1f8530 to your computer and use it in GitHub Desktop.
proportionalScale
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
function proportionalScale(originalSize, newSize){ | |
var ratio = originalSize[0] / originalSize[1]; | |
var maximizedToWidth = {width : newSize[0], height: (newSize[0] / ratio) }; | |
var maximizedToHeight = {width : newSize[1] * ratio, height: newSize[1]}; | |
if(maximizedToWidth[1] > newSize[1]) { | |
return maximizedToHeight; } | |
else { | |
return maximizedToWidth; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment