def _EnforceBounds(self, cur_time, new_pos):
    """The current x position defines the interval of time which
    stretches vertically from 0 to 'self._height'. As long as fixing
    'cur_time' at the current y position does not imply that the
    interval would fail to take up the entire screen, no adjustment
    is necessary.
    """
    interval = self._height * (self._roc_max + self._roc_slope * new_pos[0])
    y_ratio = float(new_pos[1]) / float(self._height)
    if cur_time - y_ratio * interval < self._min_time:
      cur_time = self._min_time + y_ratio * interval
    if cur_time + (1.0 - y_ratio) * interval >= self._max_time:
      cur_time = self._max_time - (1.0 - y_ratio) * interval
    return cur_time
dataset/ETHPy150Open viewfinderco/viewfinder/clients/experimental/viewfinder.py/VFTime._EnforceBounds/original