Loading...
Searching...
No Matches
Transform.h File Reference

Go to the source code of this file.

Classes

struct  sfTransform
 Encapsulate a 3x3 transform matrix. More...
 

Functions

sfTransform sfTransform_fromMatrix (float a00, float a01, float a02, float a10, float a11, float a12, float a20, float a21, float a22)
 Create a new transform from a matrix.
 
void sfTransform_getMatrix (const sfTransform *transform, float *matrix)
 Return the 4x4 matrix of a transform.
 
sfTransform sfTransform_getInverse (const sfTransform *transform)
 Return the inverse of a transform.
 
sfVector2f sfTransform_transformPoint (const sfTransform *transform, sfVector2f point)
 Apply a transform to a 2D point.
 
sfFloatRect sfTransform_transformRect (const sfTransform *transform, sfFloatRect rectangle)
 Apply a transform to a rectangle.
 
void sfTransform_combine (sfTransform *transform, const sfTransform *other)
 Combine two transforms.
 
void sfTransform_translate (sfTransform *transform, float x, float y)
 Combine a transform with a translation.
 
void sfTransform_rotate (sfTransform *transform, float angle)
 Combine the current transform with a rotation.
 
void sfTransform_rotateWithCenter (sfTransform *transform, float angle, float centerX, float centerY)
 Combine the current transform with a rotation.
 
void sfTransform_scale (sfTransform *transform, float scaleX, float scaleY)
 Combine the current transform with a scaling.
 
void sfTransform_scaleWithCenter (sfTransform *transform, float scaleX, float scaleY, float centerX, float centerY)
 Combine the current transform with a scaling.
 
sfBool sfTransform_equal (sfTransform *left, sfTransform *right)
 Compare two transforms for equality.
 

Variables

const sfTransform sfTransform_Identity
 Identity transform (does nothing)
 

Function Documentation

◆ sfTransform_combine()

void sfTransform_combine ( sfTransform transform,
const sfTransform other 
)

Combine two transforms.

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

Parameters
transformTransform object
otherTransform to combine to transform

◆ sfTransform_equal()

sfBool sfTransform_equal ( sfTransform left,
sfTransform right 
)

Compare two transforms for equality.

Performs an element-wise comparison of the elements of the left transform with the elements of the right transform.

Parameters
leftLeft operand (the first transform)
rightRight operand (the second transform)
Returns
true if the transforms are equal, false otherwise

◆ sfTransform_fromMatrix()

sfTransform sfTransform_fromMatrix ( float  a00,
float  a01,
float  a02,
float  a10,
float  a11,
float  a12,
float  a20,
float  a21,
float  a22 
)

Create a new transform from a matrix.

Parameters
a00Element (0, 0) of the matrix
a01Element (0, 1) of the matrix
a02Element (0, 2) of the matrix
a10Element (1, 0) of the matrix
a11Element (1, 1) of the matrix
a12Element (1, 2) of the matrix
a20Element (2, 0) of the matrix
a21Element (2, 1) of the matrix
a22Element (2, 2) of the matrix
Returns
A new sfTransform object

◆ sfTransform_getInverse()

sfTransform sfTransform_getInverse ( const sfTransform transform)

Return the inverse of a transform.

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

Parameters
transformTransform object
Returns
The inverse matrix

◆ sfTransform_getMatrix()

void sfTransform_getMatrix ( const sfTransform transform,
float *  matrix 
)

Return the 4x4 matrix of a transform.

This function fills an array of 16 floats with the transform converted as a 4x4 matrix, which is directly compatible with OpenGL functions.

sfTransform transform = ...;
float matrix[16];
sfTransform_getMatrix(&transform, matrix)
glLoadMatrixf(matrix);
void sfTransform_getMatrix(const sfTransform *transform, float *matrix)
Return the 4x4 matrix of a transform.
Encapsulate a 3x3 transform matrix.
Definition Transform.h:43
Parameters
transformTransform object
matrixPointer to the 16-element array to fill with the matrix

◆ sfTransform_rotate()

void sfTransform_rotate ( sfTransform transform,
float  angle 
)

Combine the current transform with a rotation.

Parameters
transformTransform object
angleRotation angle, in degrees

◆ sfTransform_rotateWithCenter()

void sfTransform_rotateWithCenter ( sfTransform transform,
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)].

Parameters
transformTransform object
angleRotation angle, in degrees
centerXX coordinate of the center of rotation
centerYY coordinate of the center of rotation

◆ sfTransform_scale()

void sfTransform_scale ( sfTransform transform,
float  scaleX,
float  scaleY 
)

Combine the current transform with a scaling.

Parameters
transformTransform object
scaleXScaling factor on the X axis
scaleYScaling factor on the Y axis

◆ sfTransform_scaleWithCenter()

void sfTransform_scaleWithCenter ( sfTransform transform,
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)]

Parameters
transformTransform object
scaleXScaling factor on X axis
scaleYScaling factor on Y axis
centerXX coordinate of the center of scaling
centerYY coordinate of the center of scaling

◆ sfTransform_transformPoint()

sfVector2f sfTransform_transformPoint ( const sfTransform transform,
sfVector2f  point 
)

Apply a transform to a 2D point.

Parameters
transformTransform object
pointPoint to transform
Returns
Transformed point

◆ sfTransform_transformRect()

sfFloatRect sfTransform_transformRect ( const sfTransform transform,
sfFloatRect  rectangle 
)

Apply a transform to 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.

Parameters
transformTransform object
rectangleRectangle to transform
Returns
Transformed rectangle

◆ sfTransform_translate()

void sfTransform_translate ( sfTransform transform,
float  x,
float  y 
)

Combine a transform with a translation.

Parameters
transformTransform object
xOffset to apply on X axis
yOffset to apply on Y axis

Variable Documentation

◆ sfTransform_Identity

const sfTransform sfTransform_Identity

Identity transform (does nothing)

Definition at line 52 of file Transform.h.