def get_pixel_fraction_square(x, xmin, xmax):
    """
    Return the fraction of the length
    from xmin to x.::

           A            B
       +-----------+---------+
       xmin        x         xmax

    :param x: x-value
    :param xmin: minimum x for the length considered
    :param xmax: minimum x for the length considered
    :return: (x-xmin)/(xmax-xmin) when xmin < x < xmax

    """
    if x <= xmin:
        return 0.0
    if x > xmin and x < xmax:
        return (x - xmin) / (xmax - xmin)
    else:
        return 1.0