From be7163c428f7a191ba92373a4b61dc00acd14e98 Mon Sep 17 00:00:00 2001 From: Just Date: Tue, 18 Jan 2000 22:29:39 +0000 Subject: [PATCH] added a bunch of rectangle tools that mimic some Qd.*Rect functions, like Qd.InsetRect. git-svn-id: svn://svn.code.sf.net/p/fonttools/code/trunk@62 4cde692c-a291-49d1-8350-778aa11640f8 --- Lib/fontTools/misc/arrayTools.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Lib/fontTools/misc/arrayTools.py b/Lib/fontTools/misc/arrayTools.py index 9792b7378..220650d49 100644 --- a/Lib/fontTools/misc/arrayTools.py +++ b/Lib/fontTools/misc/arrayTools.py @@ -40,3 +40,14 @@ def scaleRect((l, t, r, b), x, y): def offsetRect((l, t, r, b), dx, dy): return l+dx, t+dy, r+dx, b+dy + +def insetRect((l, t, r, b), dx, dy): + return l+dx, t+dy, r-dx, b-dy + +def sectRect((l1, t1, r1, b1), (l2, t2, r2, b2)): + l, t, r, b = max(l1, l2), max(t1, t2), min(r1, r2), min(b1, b2) + if l >= r or t >= b: + return 0, (0, 0, 0, 0) + return 1, (l, t, r, b) + +