getBlackPointOnSegment method

ResultPoint? getBlackPointOnSegment(
  1. double aX,
  2. double aY,
  3. double bX,
  4. double bY,
)

Implementation

ResultPoint? getBlackPointOnSegment(
  double aX,
  double aY,
  double bX,
  double bY,
) {
  final dist = MathUtils.round(MathUtils.distance(aX, aY, bX, bY));
  final xStep = (bX - aX) / dist;
  final yStep = (bY - aY) / dist;

  for (int i = 0; i < dist; i++) {
    final x = MathUtils.round(aX + i * xStep);
    final y = MathUtils.round(aY + i * yStep);
    if (_image.get(x, y)) {
      return ResultPoint(x.toDouble(), y.toDouble());
    }
  }
  return null;
}