Reference Manual: (offline | online) Quickstart: (offline | online)

# Motion

Function: Motion( | function, period, repeat=False, bounce=False, time_warp=None, add_sizes=False, anim_timebase=False, **properties)

Motion, when given the appropriate arguments, returns an object that when given as the `at` clause of an image causes an image to be moved on the screen.

function is a function that takes one or two arguments. The first argument is a fraction of the period, a number between 0 and 1. If add_sizes is true, function should take a second argument, a 4-tuple giving the width and height of the area in which the child will be shown, and the width and height of the child itself.

function should return a tuple containing two or four values. The first two values are interpreted as the xpos and the ypos of the motion. (Please note that if these values are floating point numbers, they are interpreted as a fraction of the screen. If they are integers, they are interpreted as the absolute position of the anchor of the motion.) If four values are returned, the third and fourth values are interpreted as an xanchor and yanchor.

Please note that the function may be pickled, which means that it cannot be an inner function or a lambda, but must be a function defined in an init block of your script. In general, it's better to use a Pan or a Move , rather than defining your own motion.

period is the time, in seconds, it takes to complete one cycle of a motion. If repeat is True, then the cycle repeats when it finishes, if False, the motion stops after one period. If bounce is True, the argument to the function goes from 0 to 1 to 0 in a single period, if False, it goes from 0 to 1.

time_warp, if given, is a function that takes a fractional time period (a number between 0.0 and 1.0) and returns a fractional time period. This allows non-linear motions. This function may also be pickled.

anim_timebase is true to use the animation timebase, false to use the displayable timebase.

add_sizes was added in 5.6.6.

## Example

    init:
        python:
            import math
            def Trampoline(n):
                return (0.5, 1 - math.sin(math.pi * n), 0.5, 0)

    show eileen happy at Motion(Trampoline, 5.0, repeat=True, bounce=True)

    e "Custom motions are also possible, for those times when
       you don't want to move linearly."

    e "Don't mind me, I'm feeling a little bouncy."

    show eileen happy

    e "Ahem."

Reference Manual: (offline | online) Quickstart: (offline | online)