Transform - Ren'Py Visual Novel Engine

documentation index ◦ reference manual ◦ function index

# Transform

Function: | Transform | (child=None, function=None, alpha=1, rotate=None, zoom=1, xzoom=1, yzoom=1, style='transform', **properties):

A transform applies rotation, zooming, and alpha-blending to its child, in that order. These operations, along with positioning of the transformed object, are controlled by fields on the Transform object. Transform objects can be composed with minimal overhead.

Parameters. A transform takes these parameters:

child is the child of the Transform. This can be left None, in which case the Transform will act as a Position and Motion function.

function is a callback function that is called before the Transform is rendered, with the Transform object, the shown timebase, and the animation timebase. It can set any of the fields described below, to cause the Transform to alter how it is displayed. It is expected to return a floating-point number giving the amount of time before the Transform should be re-rendered, in seconds. If 0 is returned, the Transform will be re-rendered on the next frame.

Fields. The following are the fields of a Transform object that are expected to be assigned to by user code:

xpos, ypos, xanchor, and yanchor correspond to the Position Properties of the same names.

rotate is the amount by which the child is rotated, in clockwise degrees. This can be None, for no rotation. If not None, then the width and height of the Transform will be equal to the diagonal of the child displayable.

zoom, xzoom, and yzoom control the zoom of the child, both in toto and by axis.

alpha controls the opacity of the child. It should remain between 0.0 and 1.0.

Many of these fields are also available as parameters.

Methods. A transform has the following method:

Method: | update | ():

The update method should be called on a transform after one or more fields have been changed outside of the callback function of that Transform.

    init python:
        def move_rotate_zoom(d, st, at):
             d.xpos = st / 5.0
             d.zoom = 1.0 + st / 5.0
             d.alpha = max(0.0, 1.0 - st / 5.0)

             return 0

    show logo base at Transform(function=move_rotate_zoom)

### See Also

documentation index ◦ reference manual ◦ function index