Struct sfml::graphics::Transform

source ·
#[repr(C)]
pub struct Transform { /* private fields */ }
Expand description

Define a 3x3 transform matrix.

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

Implementations§

Creates a new transform from a 3x3 matrix.

Arguments
  • 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

Return the matrix

The identity transform (does nothing)

Return the inverse of a transform

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

Return the inverse matrix

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.

Arguments
  • other - Transform to combine to transform

Combine a transform with a translation

Arguments
  • x - Offset to apply on X axis
  • y - Offset to apply on Y axis

Combine the current transform with a rotation

Arguments
  • angle - Rotation angle, in degrees

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)].

Arguments
  • angle - Rotation angle, in degrees
  • center_x - X coordinate of the center of rotation
  • center_y - Y coordinate of the center of rotation

Combine the current transform with a scaling

Arguments
  • scale_x - Scaling factor on the X axis
  • scale_y - Scaling factor on the Y axis

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)]

Arguments
  • scale_x - Scaling factor on X axis
  • scale_y - Scaling factor on Y axis
  • center_x - X coordinate of the center of scaling
  • center_y - Y coordinate of the center of scaling

Apply a transform to a 2D point

Arguments
  • point - Point to transform

Return a transformed point

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.

Arguments

rectangle - Rectangle to transform

Return the transformed rectangle

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
Converts to this type from the input type.
Converts to this type from the input type.
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.