private static int distance(@NotNull Rectangle bounds, int x, int y) {
    x -= normalize(x, bounds.x, bounds.x + bounds.width);
    y -= normalize(y, bounds.y, bounds.y + bounds.height);
    return x * x + y * y;
  }
private static int distance(@NotNull Rectangle bounds, int x, int y)