Public Types | Public Member Functions | List of all members
ime::Transform Class Reference

Transform defined by a position, a rotation and a scale. More...

#include <Transform.h>

Public Types

template<typename... Args>
using Callback = std::function< void(Args...)>
 Event listener. More...
 

Public Member Functions

 Transform ()
 Default constructor. More...
 
void setPosition (float x, float y)
 Set the position of the object. More...
 
void setPosition (Vector2f position)
 Set the position of the object. More...
 
Vector2f getPosition () const
 Get the position of the object. More...
 
void setRotation (float angle)
 Set the orientation of the object. More...
 
void rotate (float angle)
 Rotate the object. More...
 
float getRotation () const
 Get the orientation of the object. More...
 
void setScale (float factorX, float factorY)
 Set the scale factors of the object. More...
 
void setScale (Vector2f scale)
 Set the scale factor of the object. More...
 
void scale (float factorX, float factorY)
 Scale the object by an offset. More...
 
void scale (Vector2f offset)
 Scale the object by an offset. More...
 
Vector2f getScale () const
 Get the current scale of the object. More...
 
void setOrigin (float x, float y)
 Set the local origin of the object. More...
 
void setOrigin (Vector2f origin)
 Set the local origin of the object. More...
 
Vector2f getOrigin () const
 Get the local origin of the object. More...
 
void move (float offsetX, float offsetY)
 Move the object by a given offset. More...
 
void move (Vector2f offset)
 Move the object by a given offset. More...
 
void onPropertyChange (Callback< const Property & > callback)
 Add an event listener to a property change event. More...
 

Detailed Description

Transform defined by a position, a rotation and a scale.

Definition at line 38 of file Transform.h.

Member Typedef Documentation

◆ Callback

template<typename... Args>
using ime::Transform::Callback = std::function<void(Args...)>

Event listener.

Definition at line 41 of file Transform.h.

Constructor & Destructor Documentation

◆ Transform()

ime::Transform::Transform ( )

Default constructor.

Member Function Documentation

◆ getOrigin()

Vector2f ime::Transform::getOrigin ( ) const

Get the local origin of the object.

Returns
Local origin of the object

◆ getPosition()

Vector2f ime::Transform::getPosition ( ) const

Get the position of the object.

Returns
Current position of the object

◆ getRotation()

float ime::Transform::getRotation ( ) const

Get the orientation of the object.

Returns
Current rotation, in degrees

The rotation is always in the range [0, 360]

◆ getScale()

Vector2f ime::Transform::getScale ( ) const

Get the current scale of the object.

Returns
Current scale of the object

◆ move() [1/2]

void ime::Transform::move ( float  offsetX,
float  offsetY 
)

Move the object by a given offset.

Parameters
offsetXHorizontal offset
offsetYVertical offset

This function adds to the current position of the object, unlike setPosition which overwrites it

See also
setPosition

◆ move() [2/2]

void ime::Transform::move ( Vector2f  offset)

Move the object by a given offset.

Parameters
offsetOffset to apply

This function adds to the current position of the object, unlike setPosition which overwrites it

See also
setPosition

◆ onPropertyChange()

void ime::Transform::onPropertyChange ( Callback< const Property & >  callback)

Add an event listener to a property change event.

Parameters
callbackThe function to be executed when a property changes

Note that only one callback may be registered at a time. The new callback overwrites the previous one. The callback is passed the property that changed on invocation. Pass nullptr to cancel the callback.

◆ rotate()

void ime::Transform::rotate ( float  angle)

Rotate the object.

Parameters
angleAngle of rotation, in degrees

This function adds to the current rotation of the object, unlike setRotation which overwrites it

See also
setRotation

◆ scale() [1/2]

void ime::Transform::scale ( float  factorX,
float  factorY 
)

Scale the object by an offset.

Parameters
factorXHorizontal scale factor
factorYVertical scale factor

This function multiplies the current scale of the object, unlike setScale which overwrites it

See also
setScale

◆ scale() [2/2]

void ime::Transform::scale ( Vector2f  offset)

Scale the object by an offset.

Parameters
offsetOffset to apply

This function multiplies the current scale of the object, unlike setScale which overwrites it

See also
setScale

◆ setOrigin() [1/2]

void ime::Transform::setOrigin ( float  x,
float  y 
)

Set the local origin of the object.

Parameters
xX coordinate of the new origin
yY coordinate of the new origin

The origin of an object defines the center point for all transformations (position, scale, rotation). The coordinates of this point must be relative to the top-left corner of the object, and ignore all transformations (position, scale, rotation).

The default origin of a transformable object is (0, 0)

◆ setOrigin() [2/2]

void ime::Transform::setOrigin ( Vector2f  origin)

Set the local origin of the object.

Parameters
originNew origin

The origin of an object defines the center point for all transformations (position, scale, rotation). The coordinates of this point must be relative to the top-left corner of the object, and ignore all transformations (position, scale, rotation). The default origin of a transformable object is (0, 0)

◆ setPosition() [1/2]

void ime::Transform::setPosition ( float  x,
float  y 
)

Set the position of the object.

Parameters
xX coordinate of the new position
yY coordinate of the new position

This function completely overwrites the previous position. See the move function to apply an offset based on the previous position instead. The default position of a transformable object is (0, 0).

◆ setPosition() [2/2]

void ime::Transform::setPosition ( Vector2f  position)

Set the position of the object.

Parameters
positionNew position

This function completely overwrites the previous position. See the move function to apply an offset based on the previous position instead. The default position of a transformable object is (0, 0).

◆ setRotation()

void ime::Transform::setRotation ( float  angle)

Set the orientation of the object.

Parameters
angleNew rotation, in degrees

This function completely overwrites the previous rotation. See the rotate function to add an angle based on the previous rotation instead. The default rotation of a transformable object is 0

See also
rotate

◆ setScale() [1/2]

void ime::Transform::setScale ( float  factorX,
float  factorY 
)

Set the scale factors of the object.

Parameters
factorXNew horizontal scale factor
factorYNew vertical scale factor

This function completely overwrites the previous scale

See also
scale

◆ setScale() [2/2]

void ime::Transform::setScale ( Vector2f  scale)

Set the scale factor of the object.

Parameters
scaleNew scale

This function completely overwrites the previous scale

See also
scale

The documentation for this class was generated from the following file: