CSFML

- Main Page
- Data Structures
- Files

- File List
- Globals

Data Structures | Functions | Variables
Transform.h File Reference
`#include <SFML/Graphics/Export.h>`
`#include <SFML/Graphics/Rect.h>`
`#include <SFML/Graphics/Types.h>`
`#include <SFML/System/Vector2.h>`

Go to the source code of this file.

## Data Structures
struct | sfTransform
| Encapsulate a 3x3 transform matrix. More...

## Functions
CSFML_GRAPHICS_API 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. More...
CSFML_GRAPHICS_API void | sfTransform_getMatrix (const sfTransform *transform, float *matrix)
| Return the 4x4 matrix of a transform. More...
CSFML_GRAPHICS_API sfTransform | sfTransform_getInverse (const sfTransform *transform)
| Return the inverse of a transform. More...
CSFML_GRAPHICS_API sfVector2f | sfTransform_transformPoint (const sfTransform *transform, sfVector2f point)
| Apply a transform to a 2D point. More...
CSFML_GRAPHICS_API sfFloatRect | sfTransform_transformRect (const sfTransform *transform, sfFloatRect rectangle)
| Apply a transform to a rectangle. More...
CSFML_GRAPHICS_API void | sfTransform_combine (sfTransform *transform, const sfTransform *other)
| Combine two transforms. More...
CSFML_GRAPHICS_API void | sfTransform_translate (sfTransform *transform, float x, float y)
| Combine a transform with a translation. More...
CSFML_GRAPHICS_API void | sfTransform_rotate (sfTransform *transform, float angle)
| Combine the current transform with a rotation. More...
CSFML_GRAPHICS_API void | sfTransform_rotateWithCenter (sfTransform *transform, float angle, float centerX, float centerY)
| Combine the current transform with a rotation. More...
CSFML_GRAPHICS_API void | sfTransform_scale (sfTransform *transform, float scaleX, float scaleY)
| Combine the current transform with a scaling. More...
CSFML_GRAPHICS_API void | sfTransform_scaleWithCenter (sfTransform *transform, float scaleX, float scaleY, float centerX, float centerY)
| Combine the current transform with a scaling. More...

## Variables
CSFML_GRAPHICS_API const sfTransform | sfTransform_Identity
| Identity transform (does nothing) More...

## Function Documentation

CSFML_GRAPHICS_API 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
  right | Transform to combine to transform

CSFML_GRAPHICS_API 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

CSFML_GRAPHICS_API 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

CSFML_GRAPHICS_API 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);

Parameters

  transform | Transform object
  matrix | Pointer to the 16-element array to fill with the matrix

CSFML_GRAPHICS_API void sfTransform_rotate | ( | sfTransform * | transform,
|  | float | angle
| ) |  |

Combine the current transform with a rotation.

Parameters

  transform | Transform object
  angle | Rotation angle, in degrees

CSFML_GRAPHICS_API 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

  transform | Transform object
  angle | Rotation angle, in degrees
  centerX | X coordinate of the center of rotation
  centerY | Y coordinate of the center of rotation

CSFML_GRAPHICS_API void sfTransform_scale | ( | sfTransform * | transform,
|  | float | scaleX,
|  | float | scaleY
| ) |  |

Combine the current transform with a scaling.

Parameters

  transform | Transform object
  scaleX | Scaling factor on the X axis
  scaleY | Scaling factor on the Y axis

CSFML_GRAPHICS_API 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

  transform | Transform object
  scaleX | Scaling factor on X axis
  scaleY | Scaling factor on Y axis
  centerX | X coordinate of the center of scaling
  centerY | Y coordinate of the center of scaling

CSFML_GRAPHICS_API 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

CSFML_GRAPHICS_API 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

CSFML_GRAPHICS_API void sfTransform_translate | ( | sfTransform * | transform,
|  | float | x,
|  | float | y
| ) |  |

Combine a transform with a translation.

Parameters

  transform | Transform object
  x | Offset to apply on X axis
  y | Offset to apply on Y axis

## Variable Documentation

CSFML_GRAPHICS_API const sfTransform sfTransform_Identity

Identity transform (does nothing)

Definition at line 52 of file Transform.h.