Rewritten to elimate the numpy dependency


Return the bounding rectangle of a 2D points array as a tuple: (xMin, yMin, xMax, yMax)

robofab.misc.arrayTools.updateBounds(bounds, (x, y), min=<built-in function min>, max=<built-in function max>)

Return the bounding recangle of rectangle bounds and point (x, y).

robofab.misc.arrayTools.pointInRect((x, y), rect)

Return True when point (x, y) is inside rect.

robofab.misc.arrayTools.pointsInRect(array, rect)

Find out which points or array are inside rect. Returns an array with a boolean for each point.


Return the length of the given vector.


Round and cast to 16 bit integer.

robofab.misc.arrayTools.normRect((xMin, yMin, xMax, yMax))

Normalize the rectangle so that the following holds: xMin <= xMax and yMin <= yMax

robofab.misc.arrayTools.scaleRect((xMin, yMin, xMax, yMax), x, y)

Scale the rectangle by x, y.

robofab.misc.arrayTools.offsetRect((xMin, yMin, xMax, yMax), dx, dy)

Offset the rectangle by dx, dy.

robofab.misc.arrayTools.insetRect((xMin, yMin, xMax, yMax), dx, dy)

Inset the rectangle by dx, dy on all sides.

robofab.misc.arrayTools.sectRect((xMin1, yMin1, xMax1, yMax1), (xMin2, yMin2, xMax2, yMax2))

Return a boolean and a rectangle. If the input rectangles intersect, return True and the intersecting rectangle. Return False and (0, 0, 0, 0) if the input rectangles don’t intersect.

robofab.misc.arrayTools.unionRect((xMin1, yMin1, xMax1, yMax1), (xMin2, yMin2, xMax2, yMax2))

Return the smallest rectangle in which both input rectangles are fully enclosed. In other words, return the total bounding rectangle of both input rectangles.

robofab.misc.arrayTools.rectCenter((xMin, yMin, xMax, yMax))

Return the center of the rectangle as an (x, y) coordinate.

robofab.misc.arrayTools.intRect((xMin, yMin, xMax, yMax))

Return the rectangle, rounded off to integer values, but guaranteeing that the resulting rectangle is NOT smaller than the original.