Example #1
0
def test_skia_path_roundtrip(shape, expected_segments, expected_path):
    # We round to 4 decimal places to confirm custom value works
    skia_path = svg_pathops.skia_path(shape.as_cmd_seq(), shape.fill_rule)
    rounded_segments = list(skia_path.segments)
    for idx, (cmd, points) in enumerate(rounded_segments):
        rounded_segments[idx] = (cmd, tuple(_round(pt, 4) for pt in points))
    assert tuple(rounded_segments) == expected_segments
    assert (SVGPath.from_commands(
        svg_pathops.svg_commands(skia_path)).round_floats(
            4, inplace=True).d == expected_path)
Example #2
0
def test_pathops_union(shapes, expected_result):
    assert (SVGPath.from_commands(
        svg_pathops.union([s.as_cmd_seq() for s in shapes],
                          [s.clip_rule for s in shapes])).d == expected_result)