CSFML 3.0.0
Loading...
Searching...
No Matches
Classes | Functions | Variables
Transform.h File Reference
`#include <CSFML/Graphics/Export.h>`
`#include <CSFML/Graphics/Rect.h>`
`#include <CSFML/Graphics/Types.h>`
`#include <CSFML/System/Vector2.h>`

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, sfVector2f offset)
| 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, sfVector2f center)
| Combine the current transform with a rotation.
void | sfTransform_scale (sfTransform *transform, sfVector2f scale)
| Combine the current transform with a scaling.
void | sfTransform_scaleWithCenter (sfTransform *transform, sfVector2f scale, sfVector2f center)
| Combine the current transform with a scaling.
bool | 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

  transform | Transform object
  other | Transform to combine to transform

## ◆ sfTransform_equal()

bool 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

  left | Left operand (the first transform)
  right | Right 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

  a00 | Element (0, 0) of the matrix
  a01 | Element (0, 1) of the matrix
  a02 | Element (0, 2) of the matrix
  a10 | Element (1, 0) of the matrix
  a11 | Element (1, 1) of the matrix
  a12 | Element (1, 2) of the matrix
  a20 | Element (2, 0) of the matrix
  a21 | Element (2, 1) of the matrix
  a22 | Element (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

  transform | Transform 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);
sfTransform_getMatrix
void sfTransform_getMatrix(const sfTransform *transform, float *matrix)
Return the 4x4 matrix of a transform.
sfTransform
Encapsulate a 3x3 transform matrix.
Definition Transform.h:42

Parameters

  transform | Transform object
  matrix | Pointer 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

  transform | Transform object
  angle | Rotation angle, in degrees

## ◆ sfTransform_rotateWithCenter()

void sfTransform_rotateWithCenter | ( | sfTransform * | transform,
|  | float | angle,
|  | sfVector2f | center )

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

  transform | Transform object
  angle | Rotation angle, in degrees
  center | Coordinates of the center of rotation

## ◆ sfTransform_scale()

void sfTransform_scale | ( | sfTransform * | transform,
|  | sfVector2f | scale )

Combine the current transform with a scaling.

Parameters

  transform | Transform object
  scale | Scaling factor

## ◆ sfTransform_scaleWithCenter()

void sfTransform_scaleWithCenter | ( | sfTransform * | transform,
|  | sfVector2f | scale,
|  | sfVector2f | center )

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

  transform | Transform object
  scale | Scaling factor
  center | Coordinates of the center of scaling

## ◆ sfTransform_transformPoint()

sfVector2f sfTransform_transformPoint | ( | const sfTransform * | transform,
|  | sfVector2f | point )

Apply a transform to a 2D point.

Parameters

  transform | Transform object
  point | Point 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

  transform | Transform object
  rectangle | Rectangle to transform

Returns
  Transformed rectangle

## ◆ sfTransform_translate()

void sfTransform_translate | ( | sfTransform * | transform,
|  | sfVector2f | offset )

Combine a transform with a translation.

Parameters

  transform | Transform object
  offset | Offset to apply

## Variable Documentation

## ◆ sfTransform_Identity

const sfTransform sfTransform_Identity

Identity transform (does nothing)

Definition at line 51 of file Transform.h.