getArrowPath method

Path getArrowPath(
  1. double arrowSize,
  2. Offset point1,
  3. Offset point2,
  4. double scale,
  5. double pointed,
)

Implementation

Path getArrowPath(
  double arrowSize,
  Offset point1,
  Offset point2,
  double scale,
  double pointed,
) {
  Offset left = point2 +
      VectorUtils.normalizeVector(
            VectorUtils.getPerpendicularVector(point1, point2),
          ) *
          arrowSize *
          scale -
      VectorUtils.normalizeVector(
            VectorUtils.getDirectionVector(point1, point2),
          ) *
          pointed *
          arrowSize *
          scale;
  Offset right = point2 -
      VectorUtils.normalizeVector(
            VectorUtils.getPerpendicularVector(point1, point2),
          ) *
          arrowSize *
          scale -
      VectorUtils.normalizeVector(
            VectorUtils.getDirectionVector(point1, point2),
          ) *
          pointed *
          arrowSize *
          scale;

  Path path = Path();

  path.moveTo(point2.dx, point2.dy);
  path.lineTo(left.dx, left.dy);
  path.lineTo(right.dx, right.dy);
  path.close();

  return path;
}