calculate bounding box for shapes