def test_draw_scaled_path(self, backend): p1 = Path((1, 2)) p1.line_to((2, 3)) backend.draw_path(p1, Properties()) f = backend.factor expected_p2 = p1.transform(Matrix44.scale(f, f, f)) p2 = backend.collector[0][1] for v1, v2 in zip(p2.control_vertices(), expected_p2.control_vertices()): assert v1.isclose(v2)
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)
def draw_path(self, path: Path, properties: Properties) -> None: self._backend.draw_path( path.transform(self._scaling_matrix), properties )
def test_transformed_path_preserves_user_data(): path = Path() path.user_data = "data" path.line_to((1, 2, 3)) assert path.transform(Matrix44()).user_data == "data"