[sushi] utils: choose the scale direction according to the nearest aspect ratio



commit 3cae1977533d24d632df4bfc160aab9f87c86779
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Mon May 9 17:01:35 2011 -0400

    utils: choose the scale direction according to the nearest aspect ratio
    
    And not according to the width/height values only.

 src/js/ui/utils.js |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
---
diff --git a/src/js/ui/utils.js b/src/js/ui/utils.js
index 6f049c3..a010363 100644
--- a/src/js/ui/utils.js
+++ b/src/js/ui/utils.js
@@ -16,7 +16,10 @@ function getScaledSize(baseSize, allocSize, upscale) {
     if (((width <= allocW && height <= allocH) && upscale) ||
         (width > allocW && height > allocH)) {
         /* up/downscale both directions */
-        if (width > height)
+        let allocRatio = allocW / allocH;
+        let baseRatio = width / height;
+
+        if (baseRatio > allocRatio)
             scale = allocW / width;
         else
             scale = allocH / height;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]