initPath method

Path initPath (
  1. List<Point<num>> points
)

Implementation

static Path initPath(List<Point> points) {
  var targetPoints = List<Point>();
  targetPoints.addAll(points);
  targetPoints.add(Point(
      points[points.length - 1].x * 2, points[points.length - 1].y * 2));
  double x0, y0, x1, y1, t0;
  var path = Path();
  for (int i = 0; i < targetPoints.length; i++) {
    double t1;
    double x = targetPoints[i].x;
    double y = targetPoints[i].y;
    if (x == x1 && y == y1) continue;
    switch (i) {
      case 0:
        path.moveTo(x, y);
        break;
      case 1:
        break;
      case 2:
        t1 = _slope3(x0, y0, x1, y1, x, y);
        _point(path, x0, y0, x1, y1, _slope2(x0, y0, x1, y1, t1), t1);
        break;
      default:
        t1 = _slope3(x0, y0, x1, y1, x, y);
        _point(path, x0, y0, x1, y1, t0, t1);
    }
    x0 = x1;
    y0 = y1;
    x1 = x;
    y1 = y;
    t0 = t1;
  }
  return path;
}