def linear(x, xmax, y1, y2):
    """Calculate a linear transition from y1 to y2 as x moves from 0 to xmax.

        >>> for x in range(10):
        ...     print('*' * int(linear(x, 9, 1, 10)))
        *
        **
        ***
        ****
        *****
        ******
        *******
        ********
        *********
        **********

    """
    return y1 + (y2 - y1) * float(x) / xmax
