View on GitHub

# dsfml.graphics.transform

struct Transform;
Define a 3x3 transform matrix.

A Transform specifies how to translate, rotate, scale, shear, project, whatever things.

In mathematical terms, it defines how to transform a coordinate system into another.

For example, if you apply a rotation transform to a sprite, the result will be a rotated sprite. And anything that is transformed by this rotation transform will be rotated the same way, according to its initial position.

Transforms are typically used for drawing. But they can also be used for any computation that requires to transform points between the local and global coordinate systems of an entity (like collision detection).

Authors:
Laurent Gomila, Jeremy DeHaan

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

this(float a00, float a01, float a02, float a10, float a11, float a12, float a20, float a21, float a22);
Construct a 3x3 matrix.

Params:
 float a00 Element (0, 0) of the matrix float a01 Element (0, 1) of the matrix float a02 Element (0, 2) of the matrix float a10 Element (1, 0) of the matrix float a11 Element (1, 1) of the matrix float a12 Element (1, 2) of the matrix float a20 Element (2, 0) of the matrix float a21 Element (2, 1) of the matrix float a22 Element (2, 2) of the matrix

const Transform getInverse();
Return the inverse of the transform.

If the inverse cannot be computed, an identity transform is returned.

Returns:
A new transform which is the inverse of self.

const(float)[] getMatrix();
Return the transform as a 4x4 matrix.

This function returns a pointer to an array of 16 floats containing the transform elements as a 4x4 matrix, which is directly compatible with OpenGL functions.

Returns:
A 4x4 matrix.

void combine(Transform otherTransform);
Combine the current transform with another one.

The result is a transform that is equivalent to applying this followed by transform. Mathematically, it is equivalent to a matrix multiplication.

Params:
 transform Transform to combine with this one.

Returns:
Reference to this.

const Vector2f transformPoint(Vector2f point);
Transform a 2D point.

Params:
 x X coordinate of the point to transform. y Y coordinate of the point to transform.

Returns:
Transformed point.

const FloatRect transformRect(const(FloatRect) rect);
Transform a rectangle.

Since SFML doesn't provide support for oriented rectangles, the result of this function is always an axis-aligned rectangle. Which means that if the transform contains a rotation, the bounding rectangle of the transformed rectangle is returned.

Params:
 rectangle Rectangle to transform.

Returns:
Transformed rectangle.

void translate(float x, float y);
Combine the current transform with a translation.

This function returns a reference to this, so that calls can be chained.

Params:
 offset Translation offset to apply.

Returns:
this

void rotate(float angle);
Combine the current transform with a rotation.

This function returns a reference to this, so that calls can be chained.

Params:
 float angle Rotation angle, in degrees.

Returns:
this

void rotate(float angle, float centerX, float centerY);
Combine the current transform with a rotation.

The center of rotation is provided for convenience as a second argument, so that you can build rotations around arbitrary points more easily (and efficiently) than the usual translate(-center).rotate(angle).translate(center).

This function returns a reference to this, so that calls can be chained.

Params:
 float angle Rotation angle, in degrees. center Center of rotation

Returns:
this

void scale(float scaleX, float scaleY);
Combine the current transform with a scaling.

This function returns a reference to this, so that calls can be chained.

Params:
 float scaleX Scaling factor on the X-axis. float scaleY Scaling factor on the Y-axis.

Returns:
this

void scale(float scaleX, float scaleY, float centerX, float centerY);
Combine the current transform with a scaling.

The center of scaling is provided for convenience as a second argument, so that you can build scaling around arbitrary points more easily (and efficiently) than the usual translate(-center).scale(factors).translate(center).

This function returns a reference to this, so that calls can be chained.

Params:
 float scaleX Scaling factor on the X-axis. float scaleY Scaling factor on the Y-axis. float centerX X coordinate of the center of scaling float centerY Y coordinate of the center of scaling

Returns:
this

static const const(Transform) Identity;
Indentity transform (does nothing).