def test_path_with_move_commands_only(self): path = PathElement() path.set_path("M 0 0 " "m 100 100 " "M 200 200") self.assert_bounding_box_is_equal(path, (0, 200), (0, 200))
def test_path_two_straight_lines_relative(self): path = PathElement() path.set_path("M 0 0 " "l 10 10 " "m -11 -9 " "l 12 12") self.assert_bounding_box_is_equal(path, (-1, 11), (0, 13))
def test_path_two_straight_lines_abosolute(self): path = PathElement() path.set_path("M 0 0 " "L 10 10 " "M -1 1 " "L 10 10") self.assert_bounding_box_is_equal(path, (-1, 10), (0, 10))
def test_path_horizontal_line_stroke_square_cap(self): path = PathElement() path.set_path("M 0 0 " "L 1 0") stroke_half_width = 1.0 path.style = Style("stroke-width:{};stroke:red".format(stroke_half_width * 2)) path.set("stroke-linecap", "square") self.assert_bounding_box_is_equal(path, (-stroke_half_width, 1 + stroke_half_width), (-stroke_half_width, stroke_half_width))
def test_path_straight_line_scaled(self): path = PathElement() scale_x = 2 scale_y = 3 path.set_path("M 10 10 " "L 20 20") path.transform = Transform(scale=(scale_x, scale_y)) self.assert_bounding_box_is_equal(path, (scale_x * 10, 20 * scale_x), (scale_y * 10, 20 * scale_y))
def test_path_straight_line(self): path = PathElement() path.set_path("M 0 0 " "L 10 10") self.assert_bounding_box_is_equal(path, (0, 10), (0, 10))