toCubic method

  1. @override
CubicSegment toCubic(
  1. Offset start
)
override

Converts this segment to a CubicSegment.

This method is used for morphing.

The algrithoms are from https://github.com/thednp/svg-path-commander 2.0.2

Implementation

@override
CubicSegment toCubic(Offset start) {
  late final List<Offset> controlsRst;

  if (radius.x == 0 || radius.y == 0) {
    controlsRst = lineToCubicControls(start, end);
  } else {
    final xyRst = _arcToCubicControls(start.dx, start.dy, radius.x, radius.y,
        rotation, largeArc, clockwise, end.dx, end.dy, null);
    controlsRst = [
      Offset(xyRst[0], xyRst[1]),
      Offset(xyRst[2], xyRst[3]),
    ];
  }

  return CubicSegment(
    control1: controlsRst.first,
    control2: controlsRst.last,
    end: end,
    tag: tag,
  );
}