def test_line_coordinates(self): pathdata = 'M0 0 H3' horizontal_line = SvgPath(pathdata=pathdata) coordinates = horizontal_line.get_coordinates(3) expected_coordinates = [ (0.0, 0.0), (1.5, 0.0), (3.0, 0.0) ] self.assertEqual(len(coordinates), 3) for coordinate_pair, expected_coordinate_pair in zip(coordinates, expected_coordinates): self.assertTrue(tuplesAlmostEqual(coordinate_pair, expected_coordinate_pair, places=8))
def test_diagonal_line_coordinate(self): pathdata = 'M0 0 L1 1' diagonal_line = SvgPath(pathdata=pathdata) coordinates = diagonal_line.get_coordinates(5) expected_coordinates = [ (0.00, 0.00), (0.25, 0.25), (0.50, 0.50), (0.75, 0.75), (1.00, 1.00) ] self.assertEqual(len(coordinates), 5) for coordinate_pair, expected_coordinate_pair in zip(coordinates, expected_coordinates): self.assertTrue(tuplesAlmostEqual(coordinate_pair, expected_coordinate_pair, places=8))
def test_box_coordinates(self): pathdata = 'M10 10 h2 v2, h-2, z' box = SvgPath(pathdata=pathdata) coordinates = box.get_coordinates(9) expected_coordinates = [ (10.0, 10.0), (11.0, 10.0), (12.0, 10.0), (12.0, 11.0), (12.0, 12.0), (11.0, 12.0), (10.0, 12.0), (10.0, 11.0), (10.0, 10.0) ] self.assertEqual(len(coordinates), 9) for coordinate_pair, expected_coordinate_pair in zip(coordinates, expected_coordinates): self.assertTrue(tuplesAlmostEqual(coordinate_pair, expected_coordinate_pair, places=8))