Transform Properties

Transform properties are used byTransforms to influence how adisplayable is drawn. They are usually set usingATL or theTransform class.

List of Transform Properties

The following transform properties exist.

When the type is given as aposition, its relative component isinterpreted as a fraction of the size of the containing area (forpos) or of the displayable (foranchor).

Note that not all properties are independent. For example,xalign andxpos both update some of the same underlying data. In aparallelstatement, not more than one block should adjust properties sharing the same data.The angle and radius properties set both horizontal and vertical positions.

Positioning

pos
Type:

(position, position)

Default:

(0, 0)

The position, relative to the top-left corner of the containing area.

xpos
Type:

position

Default:

0

The horizontal position, relative to the left side of the containing area.

ypos
Type:

position

Default:

0

The vertical position, relative to the top of the containing area.

anchor
Type:

(position, position)

Default:

(0, 0)

The anchor position, relative to the top-left corner of the displayable.

xanchor
Type:

position

Default:

0

The horizontal anchor position, relative to the left side of thedisplayable.

yanchor
Type:

position

Default:

0

The vertical anchor position, relative to the top of the displayable.

align
Type:

(float, float)

Default:

(0.0, 0.0)

Equivalent to setting pos and anchor to the same value.

xalign
Type:

float

Default:

0.0

Equivalent to setting xpos and xanchor to this value.

yalign
Type:

float

Default:

0.0

Equivalent to setting ypos and yanchor to this value.

offset
Type:

(absolute, absolute)

Default:

(0, 0)

The number of pixels the displayable is offset by in each direction.Positive values offset towards the bottom-right.

xoffset
Type:

absolute

Default:

0

The number of pixels the displayable is offset by in the horizontaldirection. Positive values offset toward the right.

yoffset
Type:

absolute

Default:

0

The number of pixels the displayable is offset by in the vertical direction.Positive values offset toward the bottom.

xycenter
Type:

(position, position)

Default:

(0.0, 0.0)

Equivalent to setting pos to the value of this property, and anchor to(0.5, 0.5).

xcenter
Type:

position

Default:

0.0

Equivalent to setting xpos to the value of this property, and xanchor to0.5.

ycenter
Type:

position

Default:

0.0

Equivalent to setting ypos to the value of this property, and yanchor to0.5.

subpixel
Type:

boolean

Default:

False

If True, causes the child to be placed using subpixel positioning.

Subpixel positioning effects the colors (including transparency) that aredrawn into pixels, but not which pixels are drawn. When subpixel positioningis used in combination with movement (the usual case), the image should havetransparent borders in the directions it might be moved in, if those edgesare visible on the screen.

For example, if a character sprite is being moved horizontally, it makessense to have transparent borders on the left and right. These might not benecessary when panning over a background that extends outside the visiblearea, as the edges will not be seen.

Rotation

rotate
Type:

float or None

Default:

None

If None, no rotation occurs. Otherwise, the image will be rotated by thismany degrees clockwise. Rotating the displayable causes it to be resized,according to the setting of rotate_pad, below. This can cause positioning tochange if xanchor and yanchor are not 0.5.

rotate_pad
Type:

boolean

Default:

True

If True, then a rotated displayable is padded such that the width and heightare equal to the hypotenuse of the original width and height. This ensuresthat the transform will not change size as its contents rotate. If False,the transform will be given the minimal size that contains the transformeddisplayable. This is more suited to fixed rotations.

transform_anchor
Type:

boolean

Default:

False

If true, the anchor point is located on the cropped child, and is scaled androtated as the child is transformed. Effectively, this makes the anchor thepoint that the child is rotated and scaled around.

Zoom and Flip

zoom
Type:

float

Default:

1.0

This causes the displayable to be zoomed by the supplied factor.

xzoom
Type:

float

Default:

1.0

This causes the displayable to be horizontally zoomed by the suppliedfactor. A negative value causes the image to be flipped horizontally.

yzoom
Type:

float

Default:

1.0

This causes the displayable to be vertically zoomed by the suppliedfactor. A negative value causes the image to be flipped vertically.

Pixel Effects

nearest
Type:

boolean

Default:

None

If True, the displayable and its children are drawn using nearest-neighborfiltering. If False, the displayable and its children are drawn usingbilinear filtering. If None, this is inherited from the parent, orconfig.nearest_neighbor, which defaults to False.

alpha
Type:

float

Default:

1.0

This controls the opacity of the displayable.

The alpha transform is applied to each image comprising the child of thetransform independently. This can lead to unexpected results when thechildren overlap, such as seeing a character through clothing. TheFlatten() displayable can help with these problems.

additive
Type:

float

Default:

0.0

This controls how much additive blending Ren'Py performs. When 1.0, Ren'Pydraws using the ADD operator. When 0.0, Ren'Py draws using the OVERoperator.

Additive blending is performed on each child of the transform independently.

Fully additive blending doesn't alter the alpha channel of the destination,and additive images may not be visible if they're not drawn directly onto anopaque surface. (Complex operations, like viewport,Flatten(),Frame(), and certain transitions may cause problems with additiveblending.)

matrixcolor
Type:

None or Matrix or MatrixColor

Default:

None

If not None, the value of this property is used to recolor everything thatchildren of this transform draw. Interpolation is only supported whenMatrixColors are used, and the MatrixColors are structurally similar. SeeMatrixcolor for more information.

blur
Type:

None or float

Default:

None

This blurs the child of this transform byblur pixels, up to the borderof the displayable. The precise details of the blurring may change betweenRen'Py versions, and the blurring may exhibit artifacts, especially when theimage being blurred is changing.

Blurring causes its child to be flattened, with the child drawn onto a transparentbackground before the blurring happens.

Polar Positioning

around
Type:

(position, position)

Default:

(0.0, 0.0)

This specifies the starting point, relative to the upper-left corner of thecontaining area, from where the polar vector (computed fromangleandradius) will be drawn. The sum of the two gives the resultingpos.

angle
Type:

float

This gives the angle component of a position specified in polar coordinates.This is measured in degrees, with 0 being to the top of the screen, and 90being to the right.

Ren'Py clamps this angle to between 0 and 360 degrees, including 0 butnot 360. If a value is set outside this range, it will be set to theequivalent angle in this range before being used. (Setting this to -10 isthe equivalent of setting it to 350.)

radius
Type:

position

The radius component of the position given in polar coordinates.

If a float, this will be scaled to the smaller of the width and heightavailable to the transform.

Polar Positioning of the Anchor

Note

While using polar coordinates to position the anchor is possible, it's oftenmore convenient to simply setanchor to (0.5, 0.5), and positionthe center of your displayable.

anchoraround
Type:

(position, position)

This specifies the starting point, relative to the upper-left corner of thedisplayable, from where the polar vector (computed fromanchorangleandanchorradius) will be drawn. The sum of the two gives theresultinganchor.

anchorangle
Type:

(float)

The angle component of the polar coordinates of the anchor. This isspecified in degrees, with 0 being to the top and 90 being to the right.

Ren'Py clamps this angle to between 0 and 360 degrees, including 0 butnot 360. If a value is set outside this range, it will be set to theequivalent angle in this range before being used. (Setting this to -10 isthe equivalent of setting it to 350.)

anchorradius
Type:

(position)

The radius component of the polar coordinates of the anchor.

If a float, it is scaled horizontally and vertically to the size and shapeof the displayable: if the height is not equal to the width, a radius thatis not strictly absolute will result in elliptical motion when varying theanchorangle. For that reason, it is recommended to only passint orabsolute() values to this property.

Cropping and Resizing

crop
Type:

None or (position, position, position, position)

Default:

None

If not None, causes the displayable to be cropped to the given box. The boxis specified as a tuple of (x, y, width, height), with x and y being thecoordinates of the box's top-left corner relative to the top-left corner ofthe child. All values can expand outside of the bounds of the originalimage, with the area outside being transparent, though width and height mustbe positive.

If corners and crop are given, crop takes priority over corners.

corner1
Type:

None or (position, position)

Default:

None

If not None, gives the upper-left corner of the crop box. The values canexpand outside of the bounds of the original image. Crop takes priority overcorners.

corner2
Type:

None or (position, position)

Default:

None

If not None, gives the lower-right corner of the crop box. The values canexpand outside of the bounds of the original image, but they should not beinferior tocorner1. Crop takes priority over corners.

xysize
Type:

None or (position, position)

Default:

None

If not None, causes the displayable to be scaled to the given size. This isequivalent to setting thexsize andysize properties tothe first and second components.

This is affected by thefit property.

xsize
Type:

None or position

Default:

None

If not None, causes the displayable to be scaled to the given width.

This is affected by thefit property.

ysize
Type:

None or position

Default:

None

If not None, causes the displayable to be scaled to the given height.

This is affected by thefit property.

fit
Type:

None or string

Default:

None

Causes the displayable to be sized according to the table below. In thecontext of the table below, the "dimensions" are:

  • If bothxsize andysize are not None, both sizes areused as the dimensions.

  • If only one of those properties is not None, it is used as the soledimension.

  • Otherwise, if fit is not None the area that the Transform is contained inis used as the dimensions.

If fit, xsize, and ysize are all None, this property does not apply.

Value

Description

contain

As large as possible, without exceeding any dimensions. Maintainsaspect ratio.

cover

As small as possible, while matching or exceeding all dimensions.Maintains aspect ratio.

None orfill

Stretches/squashes displayable to exactly match dimensions.

scale-down

As forcontain, but will never increase the size of thedisplayable.

scale-up

As forcover, but will never decrease the size of thedisplayable.

Panning and Tiling

xpan
Type:

None or float

Default:

None

If not None, this interpreted as an angle that is used to pan horizontallyacross a 360 degree panoramic image. The center of the image is used as thezero angle, while the left and right edges are -180 and 180 degrees,respectively.

ypan
Type:

None or float

Default:

None

If not None, this interpreted as an angle that is used to pan verticallyacross a 360 degree panoramic image. The center of the image is used as thezero angle, while the top and bottom edges are -180 and 180 degrees,respectively.

xtile
Type:

int

Default:

1

The number of times to tile the image horizontally.

ytile
Type:

int

Default:

1

The number of times to tile the image vertically.

Transitions

SeeATL Transitions.

delay
Type:

float

Default:

0.0

If this transform is being used as a transition, then this is the durationof the transition. SeeATL Transitions.

events
Type:

boolean

Default:

True

If True, events are passed to the child of this transform. If False, eventsare blocked. (This can be used in ATL transitions to prevent events fromreaching the old_widget.)

Other

fps
Type:

float or None

Default:

None

If not None, this alters time inside the transform so that it is discrete.For example, if a transform has an fps of 10, then times inside thetransform will be rounded down to the nearest multiple of 0.1. This can beused to simulate a lower frame rate.

show_cancels_hide
Type:

boolean

Default:

True

Normally, when a displayable or screen with the same tag or name as one thatis hiding is shown, the hiding displayable or screen is removed, cancellingthe hide transform. If this property is False in the hide transform, thiscancellation will not occur, and the hide transform will proceed tocompletion.

There are also several sets of transform properties that are documentedelsewhere:

3D Stage properties:

perspective,point_to,orientation,xrotate,yrotate,zrotate,matrixanchor,matrixtransform,zpos,zzoom

Model-based rendering properties:

blend,mesh,mesh_pad,shader

GL Properties:

TheGL properties.

Uniforms:

Properties beginning withu_ are uniforms that can be used bycustom shaders.

Property Order

Transform properties are applied in the following order:

  1. fps

  2. mesh, blur

  3. tile

  4. pan

  5. crop, corner1, corner2

  6. xysize, size, maxsize

  7. zoom, xzoom, yzoom

  8. point_to

  9. orientation

  10. xrotate, yrotate, zrotate

  11. rotate

  12. zpos

  13. matrixtransform, matrixanchor

  14. zzoom

  15. perspective

  16. nearest, blend, alpha, additive, shader

  17. matrixcolor

  18. GL Properties, Uniforms

  19. position properties

  20. show_cancels_hide

Deprecated Transform Properties

Warning

The following properties should not be used in modern games, as they mayconflict with more recent features. They are only kept here forcompatibility, along with the new way of achieving the same behavior.

alignaround
Type:

(float, float)

This setsanchor,around, andanchoraround to thesame value.

crop_relative
Type:

boolean

Default:

True

If False, float components ofcrop,corner1 andcorner2 are interpreted as an absolute number of pixels, instead ofa fraction of the width and height of the source image.

If an absolute number of pixel is to be expressed,absolute()instances should be provided to these properties instead of using thecrop_relative property. If necessary, values of dubious type can be wrappedin theabsolute() callable.

size
Type:

None or (int, int)

Default:

None

This is an older version ofxysize interpreting floating-pointvalues as an absolute number of pixels.

maxsize
Type:

None or (int, int)

Default:

None

If not None, causes the displayable to be scaled so that it fits within abox of this size, while preserving aspect ratio. (Note that this means thatone of the dimensions may be smaller than the size of this box.)

To achieve the same result, give the values to thexysize property,and set thefit property to the value "contain".