def scale(w, h, x, y, maximum=True):
nw = y * w / h
nh = x * h / w
if maximum ^ (nw >= x):
return nw or 1, y
return x, nh or 1
Diff to Previous Revision
--- revision 1 2011-02-17 18:28:20
+++ revision 2 2011-02-20 22:36:39
@@ -1,6 +1,6 @@
def scale(w, h, x, y, maximum=True):
nw = y * w / h
nh = x * h / w
- if maximum ^ (nw >= nh):
- return nw, y
- return x, nh
+ if maximum ^ (nw >= x):
+ return nw or 1, y
+ return x, nh or 1