@SdkSuppress(minSdkVersion = 26) @Test public void flatten() { Path p = new Path(); p.lineTo(10.0f, 10.0f); assertEquals( new PathSegment(new PointF(), 0.0f, new PointF(10.0f, 10.0f), 1.0f), PathUtils.flatten(p).iterator().next()); p.reset(); p.moveTo(10.0f, 10.0f); p.moveTo(20.0f, 20.0f); for (PathSegment segment : PathUtils.flatten(p)) { fail("A path with only moves should not have segments: " + segment); } p.reset(); p.moveTo(10.0f, 10.0f); p.lineTo(20.0f, 20.0f); p.lineTo(60.0f, 20.0f); int count = 0; for (PathSegment segment : PathUtils.flatten(p)) { count++; assertNotEquals(segment.getStartFraction(), segment.getEndFraction()); } assertEquals(2, count); p.reset(); p.moveTo(5.0f, 5.0f); p.moveTo(10.0f, 10.0f); p.lineTo(20.0f, 20.0f); p.lineTo(30.0f, 10.0f); p.moveTo(40.0f, 10.0f); p.moveTo(50.0f, 10.0f); p.lineTo(60.0f, 20.0f); p.moveTo(10.0f, 10.0f); p.moveTo(30.0f, 30.0f); count = 0; for (PathSegment segment : PathUtils.flatten(p)) { count++; assertNotEquals(segment.getStartFraction(), segment.getEndFraction()); } assertEquals(3, count); }
@RequiresApi(26) @NonNull public static Collection<PathSegment> flatten(@NonNull Path path) { return flatten(path, 0.5f); }
PathUtils { @RequiresApi(26) @NonNull public static Collection<PathSegment> flatten(@NonNull Path path) { return flatten(path, 0.5f); } }
PathUtils { @RequiresApi(26) @NonNull public static Collection<PathSegment> flatten(@NonNull Path path) { return flatten(path, 0.5f); } private  PathUtils(); }
PathUtils { @RequiresApi(26) @NonNull public static Collection<PathSegment> flatten(@NonNull Path path) { return flatten(path, 0.5f); } private  PathUtils(); @RequiresApi(26) @NonNull static Collection<PathSegment> flatten(@NonNull Path path); @RequiresApi(26) @NonNull static Collection<PathSegment> flatten(@NonNull final Path path,
            @FloatRange(from = 0) final float error); }
PathUtils { @RequiresApi(26) @NonNull public static Collection<PathSegment> flatten(@NonNull Path path) { return flatten(path, 0.5f); } private  PathUtils(); @RequiresApi(26) @NonNull static Collection<PathSegment> flatten(@NonNull Path path); @RequiresApi(26) @NonNull static Collection<PathSegment> flatten(@NonNull final Path path,
            @FloatRange(from = 0) final float error);  }