containsBlackPoint method

bool containsBlackPoint(
  1. int a,
  2. int b,
  3. int fixed,
  4. bool horizontal,
)

Determines whether a segment contains a black point

@param a min value of the scanned coordinate @param b max value of the scanned coordinate @param fixed value of fixed coordinate @param horizontal set to true if scan must be horizontal, false if vertical @return true if a black point has been found, else false.

Implementation

bool containsBlackPoint(int a, int b, int fixed, bool horizontal) {
  if (horizontal) {
    for (int x = a; x <= b; x++) {
      if (_image.get(x, fixed)) {
        return true;
      }
    }
  } else {
    for (int y = a; y <= b; y++) {
      if (_image.get(fixed, y)) {
        return true;
      }
    }
  }

  return false;
}