Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html><body>
- <script type="text/javascript">
- // Used to scale image according to aspect ratio
- function calculateAspectRatioFit(srcWidth, srcHeight, maxWidth, maxHeight) {
- var ratio = Math.min(maxWidth / srcWidth, maxHeight / srcHeight);
- return { width: srcWidth*ratio, height: srcHeight*ratio };
- }
- // Calculate aspect ratio
- function gcd (a, b) {
- return (b == 0) ? a : gcd (b, a%b);
- }
- var w = screen.width;
- var h = screen.height;
- var r = gcd (w, h);
- document.write ("<pre>");
- document.write ("Dimensions = ", w, " x ", h, "<br>");
- document.write ("Gcd = ", r, "<br>");
- document.write ("Aspect = ", w/r, ":", h/r);
- document.write ("</pre>");
- </script>
- </body></html>
- <!--
- Example :
- Dimensions = 1280 x 960
- Gcd = 320
- Aspect = 4:3
- Dimensions = 1920 x 1080
- Gcd = 120
- Aspect = 16:9
- -->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement