def iter_distance_from_camera(stroke, range_min, range_max, normfac):
    """
    Yields the distance to the camera relative to the maximum
    possible distance for every stroke vertex, constrained by
    given minimum and maximum values.
    """
    for svert in stroke:
        distance = svert.point_3d.length
        if range_min < distance < range_max:
            yield svert, (distance - range_min) / normfac
        else:
            yield (svert, 0.0) if range_min > distance else (svert, 1.0)
