private int getColumnHit(float x) {
        final float squareWidth = this.squareWidth;
        float hitSize = squareWidth * hitFactor;

        float offset = paddingLeft + (squareWidth - hitSize) / 2f;
        for (int i = 0; i < gridColumns; i++) {

            final float hitLeft = offset + squareWidth * i;
            if (x >= hitLeft && x <= hitLeft + hitSize) {
                return i;
            }
        }
        return -1;
    }
Helper method to find the column x fallis into.

@param x The x coordinate.
@return The column that x falls in, or -1 if it falls in no column.
android-patternview/src/main/java/com/eftimoff/patternview/PatternView.java