isInTheSameColumn method

bool isInTheSameColumn(
  1. Line l1,
  2. Line l2,
  3. Strictness strictness
)

Checks if words are vertically in the same Column! //So important and useful

Implementation

bool isInTheSameColumn(Line l1, Line l2, Strictness strictness) {
  bool isInSameLines = true;
  //this is more accurate
  if (strictness == Strictness.hard) {
    var i1 = (l1.cornerList![0].y + l1.cornerList![2].y) / 2;
    var i2 = (l2.cornerList![0].y + l2.cornerList![2].y) / 2;
    if (i1 > l2.cornerList![0].y ||
        i1 < l2.cornerList![2].y ||
        i2 > l1.cornerList![0].y ||
        i2 < l1.cornerList![2].y) {
      isInSameLines = false;
    }
  } else if (l1.cornerList![0].y <
          l2.cornerList![2]
              .y || //strictness == Strictness.medium, more sensitive
      l1.cornerList![2].y > l2.cornerList![0].y) {
    //this is the first and the most important layer of filter
    isInSameLines = false;
  }
  if (l1.cornerList![0].x < l2.cornerList![2].x &&
      l1.cornerList![2].x > l2.cornerList![0].x) {
    //if they have any vertical sharing in space they must not be in the same line
    isInSameLines = false;
  }
  if ((l1.cornerList![2].x - l1.cornerList![0].x) >
          3 * (l2.cornerList![2].x - l2.cornerList![0].x) ||
      (l2.cornerList![2].x - l2.cornerList![0].x) >
          3 * (l1.cornerList![2].x - l1.cornerList![0].x)) {
    //sometimes a really big font is near a small font which doesn't mean they meant to be in the same line
    isInSameLines = false;
  }
  return isInSameLines;
}