new functions: unionRect() and rectCenter()
git-svn-id: svn://svn.code.sf.net/p/fonttools/code/trunk@67 4cde692c-a291-49d1-8350-778aa11640f8
diff --git a/Lib/fontTools/misc/arrayTools.py b/Lib/fontTools/misc/arrayTools.py
index f56f93f..9e8d59f 100644
--- a/Lib/fontTools/misc/arrayTools.py
+++ b/Lib/fontTools/misc/arrayTools.py
@@ -50,6 +50,13 @@
return 0, (0, 0, 0, 0)
return 1, (l, t, r, b)
+def unionRect((l1, t1, r1, b1), (l2, t2, r2, b2)):
+ l, t, r, b = min(l1, l2), min(t1, t2), max(r1, r2), max(b1, b2)
+ return (l, t, r, b)
+
+def rectCenter((l, t, r, b)):
+ return (l+r)/2, (t+b)/2
+
def intRect(rect):
rect = Numeric.array(rect)
l, t = Numeric.floor(rect[:2])