addToPath method

  1. @override
void addToPath(
  1. Path path
)
override

Add to a (standard) Path; for drawing

Implementation

@override
void addToPath(Path path) {
  double polarity = positive ? 1 : -1;
  final u = to - from;
  final d = u.magnitude;
  final m = from + u * 0.5;
  final perp = (u.rotate(-pi / 2)).normalised;
  final rotatedPerp = perp.rotate(curveAngle);
  final controlMid = m + rotatedPerp * curveSize * polarity * d * 0.5;
  final perpOfRot = rotatedPerp.rotate(-pi / 2 - twist).normalised;
  final control1 = controlMid + perpOfRot * ((bulbousness * d) / 2);
  final control2 = controlMid + perpOfRot * (-(bulbousness * d) / 2);

  path.cubicTo(control1.x, control1.y, control2.x, control2.y, to.x, to.y);
}