percentPath function

Path percentPath(
  1. Path path,
  2. double percent
)

给定一个Path和路径百分比返回给定百分比路径

Implementation

Path percentPath(Path path, double percent) {
  PathMetrics metrics = path.computeMetrics();
  Path newPath = Path();
  for (PathMetric metric in metrics) {
    Path tmp = metric.extractPath(0, metric.length * percent);
    newPath.addPath(tmp, Offset.zero);
  }
  return newPath;
}