

def _mouseMoveDrag(moveOrDrag, x, y, xOffset, yOffset, duration, tween, button=None):
    'Handles the actual move or drag event, since different platforms\n    implement them differently.\n\n    On Windows & Linux, a drag is a normal mouse move while a mouse button is\n    held down. On OS X, a distinct "drag" event must be used instead.\n\n    The code for moving and dragging the mouse is similar, so this function\n    handles both. Users should call the moveTo() or dragTo() functions instead\n    of calling _mouseMoveDrag().\n\n    Args:\n      moveOrDrag (str): Either \'move\' or \'drag\', for the type of action this is.\n      x (int, float, None, optional): How far left (for negative values) or\n        right (for positive values) to move the cursor. 0 by default.\n      y (int, float, None, optional): How far up (for negative values) or\n        down (for positive values) to move the cursor. 0 by default.\n      xOffset (int, float, None, optional): How far left (for negative values) or\n        right (for positive values) to move the cursor. 0 by default.\n      yOffset (int, float, None, optional): How far up (for negative values) or\n        down (for positive values) to move the cursor. 0 by default.\n      duration (float, optional): The amount of time it takes to move the mouse\n        cursor to the new xy coordinates. If 0, then the mouse cursor is moved\n        instantaneously. 0.0 by default.\n      tween (func, optional): The tweening function used if the duration is not\n        0. A linear tween is used by default. See the tweens.py file for\n        details.\n      button (str, int, optional): The mouse button clicked. Must be one of\n        \'left\', \'middle\', \'right\' (or 1, 2, or 3) respectively. \'left\' by\n        default.\n\n    Returns:\n      None\n    '
    assert (moveOrDrag in ('move', 'drag')), ("moveOrDrag must be in ('move', 'drag'), not %s" % moveOrDrag)
    if (sys.platform != 'darwin'):
        moveOrDrag = 'move'
    xOffset = (int(xOffset) if (xOffset is not None) else 0)
    yOffset = (int(yOffset) if (yOffset is not None) else 0)
    if ((x is None) and (y is None) and (xOffset == 0) and (yOffset == 0)):
        return
    (startx, starty) = position()
    x = (int(x) if (x is not None) else startx)
    y = (int(y) if (y is not None) else starty)
    x += xOffset
    y += yOffset
    (width, height) = size()
    x = max(0, min(x, (width - 1)))
    y = max(0, min(y, (height - 1)))
    steps = [(x, y)]
    if (duration > MINIMUM_DURATION):
        num_steps = max(width, height)
        sleep_amount = (duration / num_steps)
        if (sleep_amount < MINIMUM_SLEEP):
            num_steps = int((duration / MINIMUM_SLEEP))
            sleep_amount = (duration / num_steps)
        steps = [getPointOnLine(startx, starty, x, y, tween((n / num_steps))) for n in range(num_steps)]
        steps.append((x, y))
    for (tweenX, tweenY) in steps:
        if (len(steps) > 1):
            time.sleep(sleep_amount)
        _failSafeCheck()
        tweenX = int(round(tweenX))
        tweenY = int(round(tweenY))
        if (moveOrDrag == 'move'):
            platformModule._moveTo(tweenX, tweenY)
        elif (moveOrDrag == 'drag'):
            platformModule._dragTo(tweenX, tweenY, button)
        else:
            raise NotImplementedError('Unknown value of moveOrDrag: {0}'.format(moveOrDrag))
    _failSafeCheck()

dataset/ETHPy150Open asweigart/pyautogui/pyautogui/__init__.py _mouseMoveDrag/original