From 02a739a0d5f110c15fdb6a13237089e143250471 Mon Sep 17 00:00:00 2001 From: Just Date: Sun, 23 Jan 2000 19:10:27 +0000 Subject: [PATCH] new functions: unionRect() and rectCenter() git-svn-id: svn://svn.code.sf.net/p/fonttools/code/trunk@67 4cde692c-a291-49d1-8350-778aa11640f8 --- Lib/fontTools/misc/arrayTools.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Lib/fontTools/misc/arrayTools.py b/Lib/fontTools/misc/arrayTools.py index f56f93f3e..9e8d59fce 100644 --- a/Lib/fontTools/misc/arrayTools.py +++ b/Lib/fontTools/misc/arrayTools.py @@ -50,6 +50,13 @@ def sectRect((l1, t1, r1, b1), (l2, t2, r2, b2)): 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])