two new functions
git-svn-id: svn://svn.code.sf.net/p/fonttools/code/trunk@395 4cde692c-a291-49d1-8350-778aa11640f8
diff --git a/Lib/fontTools/misc/arrayTools.py b/Lib/fontTools/misc/arrayTools.py
index fde004f..02ace99 100644
--- a/Lib/fontTools/misc/arrayTools.py
+++ b/Lib/fontTools/misc/arrayTools.py
@@ -16,6 +16,16 @@
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.