def test_bounding_box_curves(self): """ Test the bounding box calculations of a curve """ path = Path('M 85,14 C 104.63953,33.639531 104.71989,65.441157' ' 85,85 65.441157,104.71989 33.558843,104.71989 14,85' ' -5.7198883,65.441157 -5.6395306,33.639531 14,14' ' 33.639531,-5.6395306 65.360469,-5.6395306 85,14 Z') bb_tuple = path.bounding_box() expected = (-0.760, -0.760 + 100.520), (-0.730, -0.730 + 100.520) precision = 3 self.assertDeepAlmostEqual(tuple(bb_tuple.x), expected[0], places=precision) self.assertDeepAlmostEqual(tuple(bb_tuple.y), expected[1], places=precision)
def test_bounding_box_arcs(self): """ Test the bounding box calculations with arcs (currently is rough only) Bounding box around a circle with a radius of 50 it should be from 0,0 -> 100, 100 """ path = Path('M 85.355333,14.644651 ' 'A 50,50 0 0 1 85.355333,85.355341' ' 50,50 0 0 1 14.644657,85.355341' ' 50,50 0 0 1 14.644676,14.644651' ' 50,50 0 0 1 85.355333,14.644651 Z') bb_tuple = path.bounding_box() expected = (0, 100), (0, 100) precision = 4 self.assertDeepAlmostEqual(tuple(bb_tuple.x), expected[0], places=precision) self.assertDeepAlmostEqual(tuple(bb_tuple.y), expected[1], places=precision)