toQuadraticCurve method

Iterable<QuadraticCurve> toQuadraticCurve()

Implementation

Iterable<QuadraticCurve> toQuadraticCurve() sync* {
  final double x0 = point1.x;
  final double y0 = point1.y;
  final double x1 = handle1.x;
  final double y1 = handle1.y;
  final double x2 = handle2.x;
  final double y2 = handle2.y;
  final double x3 = point2.x;
  final double y3 = point2.y;

  final double x = ((x0 + 3 * x1 + 3 * x2 + x3 + 4) / 8).floorToDouble();
  final double y = ((y0 + 3 * y1 + 3 * y2 + y3 + 4) / 8).floorToDouble();

  yield QuadraticCurve.fromList([
    [x0, y0],
    [
      ((x0 + 3 * x1 + 2) / 4).floorToDouble(),
      ((y0 + 3 * y1 + 2) / 4).floorToDouble(),
    ],
    [x, y],
  ]);

  yield QuadraticCurve.fromList([
    [x, y],
    [
      ((3 * x2 + x3 + 2) / 4).floorToDouble(),
      ((3 * y2 + y3 + 2) / 4).floorToDouble(),
    ],
    [x3, y3]
  ]);
}