Graphs_dart/tex/dart/painter/arrow.dart

22 lines
709 B
Dart
Raw Normal View History

2021-11-24 20:35:55 +03:00
void _drawHArrow(Canvas canvas, Size size, Offset from, Offset to, [bool doubleSided = false]) {
Path path;
// The arrows usually looks better with rounded caps.
Paint paint = ... // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>
var length = sqrt((to.dx - from.dx) * (to.dx - from.dx) +
(to.dy - from.dy) * (to.dy - from.dy));
path = Path();
path.moveTo(from.dx, from.dy);
path.relativeCubicTo(
0,
0,
-(from.dx + to.dx + length) / (length) - 40,
-(from.dy + to.dy + length) / (length) - 40,
to.dx - from.dx,
to.dy - from.dy);
path =
ArrowPath.make(path: path, isDoubleSided: doubleSided, tipLength: 16);
canvas.drawPath(path, paint);
}