possibleIntersectionVertices method

List<LineSegment> possibleIntersectionVertices(
  1. Rect? rect
)

Return all vertices as LineSegments that intersect rect, if rect is null return all vertices as LineSegments.

Implementation

List<LineSegment> possibleIntersectionVertices(Rect? rect) {
  final rectIntersections = <LineSegment>[];
  if ((rect?.width == 0 || false) ||
      (rect?.height == 0 || false) ||
      width == 0 ||
      height == 0) {
    return rectIntersections;
  }
  final vertices = globalVertices();
  for (var i = 0; i < vertices.length; i++) {
    final edge = getEdge(i, vertices: vertices);
    if (rect?.intersectsSegment(edge.from, edge.to) ?? true) {
      rectIntersections.add(edge);
    }
  }
  return rectIntersections;
}