support panoramas
[booh] / lib / booh / booh-lib.rb
index 6f87d900ab4bdfdd86a38a3d870e69e7b0c83c0b..b6608463db13d8f5684f1b7de0d0509361468d1f 100644 (file)
@@ -404,6 +404,22 @@ module Booh
         a > b ? a : b
     end
 
+    def clamp(n, a, b)
+        n < a ? a : n > b ? b : n
+    end
+
+    def pano_amount(elem)
+        if pano_amount = elem.attributes['pano-amount']
+            if $N_per_row
+                return clamp(pano_amount.to_f, 1, $N_per_row.to_i)
+            else
+                return clamp(pano_amount.to_f, 1, $default_N.to_i)
+            end
+        else
+            return nil
+        end
+    end
+
     def substInFile(name)
         newcontent = IO.readlines(name).collect { |l| yield l }
         ios = File.open(name, "w")