View on GitHub

DSFML

dsfml.graphics.transformable



interface Transformable;
Decomposed transform defined by a position, a rotation, and a scale.

This interface is provided for convenience, on top of Transform.

Authors:
Laurent Gomila, Jeremy DeHaan

See Also:


http:
//www.sfml-dev.org/documentation/2.0/classsf_1_1Transformable.php#details

abstract @property Vector2f origin(Vector2f newOrigin);
The local origin of the object.

The origin of an object defines the center point for all transformations (position, scale, ratation).

The coordinates of this point must be relative to the top-left corner of the object, and ignore all transformations (position, scale, rotation). The default origin of a transformable object is (0, 0).

abstract const @property Vector2f origin();
The local origin of the object.

The origin of an object defines the center point for all transformations (position, scale, ratation).

The coordinates of this point must be relative to the top-left corner of the object, and ignore all transformations (position, scale, rotation). The default origin of a transformable object is (0, 0).

abstract @property Vector2f position(Vector2f newPosition);
The position of the object. The default is (0, 0).

abstract const @property Vector2f position();
The position of the object. The default is (0, 0).

abstract @property float rotation(float newRotation);
The orientation of the object, in degrees. The default is 0 degrees.

abstract const @property float rotation();
The orientation of the object, in degrees. The default is 0 degrees.

abstract @property Vector2f scale(Vector2f newScale);
The scale factors of the object. The default is (1, 1).

abstract const @property Vector2f scale();
The scale factors of the object. The default is (1, 1).

abstract const(Transform) getTransform();
Get the inverse of the combined transform of the object.

Returns:
Inverse of the combined transformations applied to the object.

abstract const(Transform) getInverseTransform();
Get the combined transform of the object.

Returns:
Transform combining the position/rotation/scale/origin of the object.

abstract void move(Vector2f offset);
Move the object by a given offset.

This function adds to the current position of the object, unlike the position property which overwrites it.

Params:
Vector2f offset The offset.

template NormalTransformable()
Decomposed transform defined by a position, a rotation, and a scale.

This template is provided for convenience, on top of Transformable (and Transform).

Transform, as a low-level class, offers a great level of flexibility but it is not always convenient to manage. Indeed, one can easily combine any kind of operation, such as a translation followed by a rotation followed by a scaling, but once the result transform is built, there's no way to go backward and, let's say, change only the rotation without modifying the translation and scaling.

The entire transform must be recomputed, which means that you need to retrieve the initial translation and scale factors as well, and combine them the same way you did before updating the rotation. This is a tedious operation, and it requires to store all the individual components of the final transform.

That's exactly what Transformable was written for: it hides these variables and the composed transform behind an easy to use interface. You can set or get any of the individual components without worrying about the others. It also provides the composed transform (as a Transform), and keeps it up-to-date.

Authors:
Laurent Gomila, Jeremy DeHaan

See Also:


http:
//www.sfml-dev.org/documentation/2.0/classsf_1_1Transformable.php#details

Vector2f origin(Vector2f newOrigin);
The local origin of the object.

The origin of an object defines the center point for all transformations (position, scale, ratation).

The coordinates of this point must be relative to the top-left corner of the object, and ignore all transformations (position, scale, rotation). The default origin of a transformable object is (0, 0).

const Vector2f origin();
The local origin of the object.

The origin of an object defines the center point for all transformations (position, scale, ratation).

The coordinates of this point must be relative to the top-left corner of the object, and ignore all transformations (position, scale, rotation). The default origin of a transformable object is (0, 0).

Vector2f position(Vector2f newPosition);
The position of the object. The default is (0, 0).

const Vector2f position();
The position of the object. The default is (0, 0).

float rotation(float newRotation);
The orientation of the object, in degrees. The default is 0 degrees.

const float rotation();
The orientation of the object, in degrees. The default is 0 degrees.

Vector2f scale(Vector2f newScale);
The scale factors of the object. The default is (1, 1).

const Vector2f scale();
The scale factors of the object. The default is (1, 1).

const(Transform) getInverseTransform();
Get the inverse of the combined transform of the object.

Returns:
Inverse of the combined transformations applied to the object.

const(Transform) getTransform();
Get the combined transform of the object.

Returns:
Transform combining the position/rotation/scale/origin of the object.

void move(Vector2f offset);
Move the object by a given offset.

This function adds to the current position of the object, unlike the position property which overwrites it.

Params:
Vector2f offset The offset.