How to know if two lines in Canvas are intersecting?

Viewed 18

I just create two paths of straight lines which intersect, I use Path.combine to know if they intersect or not and it is always false, and I don't understand why, I would like to know what is wrong or if there is another way to know if two lines intersect or not:

final path = Path();
path.moveTo(100, 300);
path.lineTo(300, 300);

final path2 = Path();
path2.moveTo(200, 200);
path2.lineTo(200, 400);

canvas.drawPath(path, _pencilPaint);
canvas.drawPath(path2, _pencilPaintGreen);

final intersection = Path.combine(
  PathOperation.intersect,
  path,
  path2,
);
final pathsAreIntersecting = !(intersection.getBounds().isEmpty);

print(pathsAreIntersecting); // ALWAYS FALSE

enter image description here

0 Answers
Related