Transform


Object Hierarchy:

Object hierarchy for Transform

Description:

[ SimpleType ]
[ CCode ( cname = "sfTransform" , cprefix = "sfTransform_" ) ]
public struct Transform

Define a 3x3 transform matrix.

A sf.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).

Example:

// define a translation transform
sf.Transform translation = {};
translation.translate(20, 50);

// define a rotation transform
sf.Transform rotation = {};
rotation.rotate(45);

// combine them
var transform = translation.combine(rotation);

// use the result to transform stuff...
var point = transform.transformPoint(10, 20);
var rect = transform.transformRect(sf.FloatRect(0, 0, 10, 100));

See also:

sf.Transformable, sf.RenderStates


Namespace: sf
Package: sfml

Content:

Static methods:

Methods:

Fields: