Exemplo n.º 1
0
 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"
Exemplo n.º 2
0
def test_approximate_curves():
    path = Path()
    path.curve3_to((2, 0), (1, 1))
    path.curve4_to((3, 0), (2, 1), (3, 1))
    vertices = list(path.approximate(20))
    assert len(vertices) == 41
    assert vertices[0] == (0, 0)
    assert vertices[-1] == (3, 0)
Exemplo n.º 3
0
 def test_one_path_curve4_to(self):
     path = Path()
     path.curve4_to((2, 0), (0, 1), (2, 1))
     result = transform_paths([path], Matrix44())
     path0 = result[0]
     assert path0[0].type == Command.CURVE4_TO
     assert len(path0[0]) == 3
     assert path0.start == (0, 0)
     assert path0.end == (2, 0)
Exemplo n.º 4
0
def test_has_clockwise_orientation():
    # basic has_clockwise_orientation() function is tested in:
    # test_617_clockwise_orientation
    path = converter.from_vertices([(0, 0), (1, 0), (1, 1), (0, 1)])
    assert path.has_clockwise_orientation() is False

    path = Path()
    path.line_to((2, 0))
    path.curve4_to((4, 0), (2, 1), (4, 1))  # end, ctrl1, ctrl2
    assert path.has_clockwise_orientation() is True
Exemplo n.º 5
0
    def test_one_path_multiple_command(self):
        path = Path()
        path.line_to((1, 0))
        path.curve3_to((2, 0), (2.5, 1))
        path.curve4_to((3, 0), (2, 1), (3, 1))
        result = transform_paths([path], Matrix44())

        path0 = result[0]
        assert path0[0].type == Command.LINE_TO
        assert path0[1].type == Command.CURVE3_TO
        assert path0[2].type == Command.CURVE4_TO
        assert path0.start == (0, 0)
        assert path0.end == (3, 0)
Exemplo n.º 6
0
    def test_two_paths_multiple_commands(self):
        path_a = Path()
        path_a.line_to((1, 0))
        path_a.curve3_to((2, 0), (2.5, 1))
        path_a.curve4_to((3, 0), (2, 1), (3, 1))

        path_b = path_a.transform(Matrix44.translate(4, 0, 0))
        result = transform_paths([path_a, path_b], Matrix44())

        path0 = result[0]
        assert path0[0].type == Command.LINE_TO
        assert path0[1].type == Command.CURVE3_TO
        assert path0[2].type == Command.CURVE4_TO
        assert path0.start == (0, 0)
        assert path0.end == (3, 0)

        path1 = result[1]
        assert path1[0].type == Command.LINE_TO
        assert path1[1].type == Command.CURVE3_TO
        assert path1[2].type == Command.CURVE4_TO
        assert path1.start == (4, 0)
        assert path1.end == (7, 0)
Exemplo n.º 7
0
def test_reversing_one_curve4():
    p = Path()
    p.curve4_to((3, 0), (1, 1), (2, 1))
    p2 = list(p.reversed().control_vertices())
    assert p2 == [(3, 0), (2, 1), (1, 1), (0, 0)]
Exemplo n.º 8
0
def p1():
    path = Path()
    path.line_to((2, 0))
    path.curve4_to((4, 0), (2, 1), (4, 1))  # end, ctrl1, ctrl2
    path.curve3_to((6, 0), (5, -1))  # end, ctrl
    return path
Exemplo n.º 9
0
def test_curve4_to():
    path = Path()
    path.curve4_to((1, 2, 3), (0, 1, 0), (0, 2, 0))
    assert path[0] == ((1, 2, 3), (0, 1, 0), (0, 2, 0))
    assert path.end == (1, 2, 3)
Exemplo n.º 10
0
 def path1(self):
     p = Path((0, 0, 1))
     p.curve4_to((4, 0, 1), (1, 1, 1), (3, 1, 1))
     return p
Exemplo n.º 11
0
 def path(self):
     p = Path()
     p.line_to((4, 0, 0))
     p.curve4_to((0, 0, 0), (3, 1, 1), (1, 1, 1))
     return p
Exemplo n.º 12
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"
Exemplo n.º 13
0
 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"