Advertisement
ulfben

scaleToFit

Feb 13th, 2016
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function scaleToFit(srcWidth, srcHeight, maxWidth, maxHeight) {
  2.     var ratio = Math.min(maxWidth/srcWidth, maxHeight/srcHeight);
  3.     return {width:srcWidth*ratio, height:srcHeight*ratio};
  4. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement