def snap(point, shape, snapRange=20):
    """ snap 'point' if within 'snapRange' from the border defined by 'shape' """
    snapped = list(point)
    if snapped[0] < snapRange:
        snapped[0] = 0
    if snapped[0] > shape[1] - snapRange:
        snapped[0] = shape[1]
    if snapped[1] < snapRange:
        snapped[1] = 0
    if snapped[1] > shape[0] - snapRange:
        snapped[1] = shape[0]
    return tuple(snapped)
