def test_multiple_segments(self): p = Path() p.curve4_to((4, 0), (1, 2), (3, 2)) p.line_to((6, 0)) p.curve3_to((8, 0), (7, 1)) result = list(to_bsplines_and_vertices(p)) assert len(result) == 3, "expected three segments"
def test_one_quadratic_bezier(self): p = Path() p.curve3_to((4, 0), (2, 2)) result = list(to_bsplines_and_vertices(p)) assert len(result) == 1, "expected one B-spline" cpnts = result[0].control_points # A quadratic bezier should be converted to cubic bezier curve, which # has a precise cubic B-spline representation. assert len(cpnts) == 4, "expected 4 control vertices" assert cpnts[0] == (0, 0) assert cpnts[3] == (4, 0)
def test_adjacent_cubic_beziers_without_G1_continuity(self): p = Path() p.curve4_to((4, 0), (1, 2), (3, 2)) p.curve4_to((8, 0), (5, 2), (7, 2)) result = list(to_bsplines_and_vertices(p)) assert len(result) == 2, "expected two B-splines"
def test_one_cubic_bezier(self): p = Path() p.curve4_to((4, 0), (1, 2), (3, 2)) result = list(to_bsplines_and_vertices(p)) assert len(result) == 1, "expected one B-spline"
def test_only_vertices(self): p = Path.from_vertices([(1, 0), (2, 0), (3, 1)]) result = list(to_bsplines_and_vertices(p)) assert len(result) == 1, "expected one list of vertices" assert len(result[0]) == 3, "expected 3 vertices"
def test_empty_path(self): result = list(to_bsplines_and_vertices(Path())) assert result == []