transformable

class Transformable

Implements a number of functions that allow the parent class to spatially transform its entities and tiles lists. All of the following methods operate in-place, meaning that the original positions and directions of every entity and tile are modified each time they are called.

flip(direction: str = 'horizontal') None

Flip the blueprint across an axis, if possible. Flipping is done over the x or y axis, depeding on the input direction.

Warning

This function is currently under active development.

Parameters:

direction – The direction to flip by; either "horizontal" or "vertical"

rotate(angle: int) None

Rotate the blueprint by angle, if possible. Operates the same as pressing ‘r’ with a blueprint selected.

angle is specified in terms of Direction enum, meaning that a rotation of 2 is 90 degrees clockwise.

Because eight-way rotatable entities exist in a weird gray area, this function behaves like the feature in-game and only rotates on 90 degree intervals. Attempting to rotate the blueprint an odd amount raises an RotationError.

Warning

This function is currently under active development.

Parameters:

angle – The angle to rotate the blueprint by.

Raises:

RotationError – If the rotation is attempted with an odd value.

translate(x: int, y: int) None

Translates all entities and tiles in the blueprint by x and y. Raises RailAlignmentWarning if the parent class contains double-grid-aligned entities and the translation amount is an odd value on either x or y.

Parameters:
  • x – A number indicating how much to translate along x.

  • y – A number indicating how much to translate along y.