SHARE
TWEET

scaleToFit

ulfben Feb 13th, 2016 56 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. }
RAW Paste Data
Top