Class OcsfmlGraphics.transform

class transform : [ `Copy of < rep__sf_Transform : Transform.t; .. >
| `Matrix of
float * float * float * float * float * float * float * float * float
| `None ] ->
object .. end
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).


method affect : 'a. (#const_transform as 'a) -> unit
method combine : 'b. (#const_transform as 'b) -> unit
Combine the current transform with another one.

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

method destroy : unit
method get_inverse : < affect : 'd. (#const_transform as 'd) -> unit;
combine : 'e. (#const_transform as 'e) -> unit;
destroy : unit; get_inverse : 'c;
rep__sf_Transform : Transform.t;
rotate : ?center_x:float -> ?center_y:float -> float -> unit;
rotate_v : ?center:float * float -> float -> unit;
scale : ?center_x:float -> ?center_y:float -> float -> float -> unit;
scale_v : ?center:float * float -> float * float -> unit;
transform_point : float -> float -> float * float;
transform_point_v : float * float -> float * float;
transform_rect : FloatRect.t -> FloatRect.t;
translate : float -> float -> unit; translate_v : float * float -> unit;
.. >
as 'c
Return the inverse of the transform.

If the inverse cannot be computed, an identity transform is returned.
Returns A new transform which is the inverse of self.

method rotate : ?center_x:float -> ?center_y:float -> float -> unit
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).

center_x : X coordinate of the center of rotation.
center_y : Y coordinate of the center of rotation.
method rotate_v : ?center:float * float -> float -> unit
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).

center : Center of rotation.
method scale : ?center_x:float -> ?center_y:float -> float -> float -> unit
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).

center_x : X coordinate of the center of scaling
center_y : Y coordinate of the center of scaling
method scale_v : ?center:float * float -> float * float -> unit
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).

center : Center of scaling.
method transform_point : float -> float -> float * float
Transform a 2D point.
Returns Transformed point.
method transform_point_v : float * float -> float * float
Transform a 2D point.
Returns Transformed point.
method transform_rect : FloatRect.t -> FloatRect.t
Transform 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.
Returns Transformed rectangle

method translate : float -> float -> unit
Combine the current transform with a translation.
method translate_v : float * float -> unit
Combine the current transform with a translation.