def get_maxed_or_zeroed_out(x : float, c_m : float, end_region_width: float):
    """
    Gets c(x), where it's assumed 0 < x < 1, and c(x) is a piecewise function such that:
     c(x) = c_m for end_region_width < x < (1 - end_region_width),
            and goes linearly to c(0) = 0 and c(1) = 1 at the ends

            In other words like this:
            1
               ______/
              /
            0 0       1
    """

    if x <= end_region_width:
        return x * (c_m / end_region_width)
    elif x < (1 - end_region_width):
        return c_m
    else:
        x_ = x - 1
        c_ = x_ * ((1 - c_m) / end_region_width)
        return c_ + 1