aboutsummaryrefslogtreecommitdiff
path: root/Lib/fontTools/misc/arrayTools.py
diff options
context:
space:
mode:
authorjvr <jvr@4cde692c-a291-49d1-8350-778aa11640f8>2003-06-29 18:18:54 +0000
committerjvr <jvr@4cde692c-a291-49d1-8350-778aa11640f8>2003-06-29 18:18:54 +0000
commit182a7ba7be9a961dd71e477473af0083d5884a15 (patch)
treef24948d8e27faed86fa564fb873cab2b4908ea20 /Lib/fontTools/misc/arrayTools.py
parentb19141e48930ddd3106a6fe303fa2e6b76d35f47 (diff)
downloadfonttools-182a7ba7be9a961dd71e477473af0083d5884a15.tar.gz
two new functions
git-svn-id: svn://svn.code.sf.net/p/fonttools/code/trunk@395 4cde692c-a291-49d1-8350-778aa11640f8
Diffstat (limited to 'Lib/fontTools/misc/arrayTools.py')
-rw-r--r--Lib/fontTools/misc/arrayTools.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/fontTools/misc/arrayTools.py b/Lib/fontTools/misc/arrayTools.py
index fde004f4..02ace991 100644
--- a/Lib/fontTools/misc/arrayTools.py
+++ b/Lib/fontTools/misc/arrayTools.py
@@ -16,6 +16,16 @@ def calcBounds(array):
xmax, ymax = Numeric.maximum.reduce(array)
return xmin, ymin, xmax, ymax
+def updateBounds(bounds, (x, y), min=min, max=max):
+ """Return the bounding recangle of rectangle bounds and point (x, y)."""
+ xMin, yMin, xMax, yMax = bounds
+ return min(xMin, x), min(yMin, y), max(xMax, x), max(yMax, y)
+
+def pointInRect((x, y), rect):
+ """Return True when point (x, y) is inside rect."""
+ xMin, yMin, xMax, yMax = rect
+ return (xMin <= x <= xMax) and (yMin <= y <= yMax)
+
def pointsInRect(array, rect):
"""Find out which points or array are inside rect.
Returns an array with a boolean for each point.