Skip to content

Instantly share code, notes, and snippets.

@cdmz
Created January 4, 2016 11:28
Show Gist options
  • Save cdmz/da1b95ceb4e3af1f8530 to your computer and use it in GitHub Desktop.
Save cdmz/da1b95ceb4e3af1f8530 to your computer and use it in GitHub Desktop.
proportionalScale
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