SDL Utility
Transformable Class Reference

A class that stores locational information. More...

#include <Transformable.hpp>

Inheritance diagram for Transformable:
Shape sdlu::Rectangle

Public Member Functions

 Transformable ()
 Default constructur. More...
 
virtual ~Transformable ()
 Deconstructor. More...
 
Vector2f GetPosition ()
 Returns the position of the object. More...
 
void SetPosition (const Vector2f &position)
 Sets a new position. More...
 
void SetPosition (float x, float y)
 Sets a new position. More...
 
void Move (const Vector2f &position)
 Adds to the current position. More...
 
void Move (float x, float y)
 Adds to the current position. More...
 
Vector2f GetOrigin ()
 Gets the current local origin. More...
 
void SetOrigin (const Vector2f &origin)
 Sets a new local origin. More...
 
void SetOrigin (float x, float y)
 Sets a new local origin. More...
 
Vector2f GetScale ()
 Gets the current scale of the object. More...
 
void SetScale (const Vector2f &scale)
 Sets a new scale. More...
 
void SetScale (float x, float y)
 Sets a new scale. More...
 
void Scale (const Vector2f &scale)
 Scales the object by some amount. More...
 
void Scale (float x, float y)
 Scales the object by some amount. More...
 
float GetRotation ()
 Gets the current rotation. More...
 
void SetRotation (float angle)
 Sets a new rotation. More...
 
void Rotate (float angle)
 Rotates by some amount. More...
 

Protected Attributes

Vector2f position
 Position of the object. More...
 
Vector2f origin
 Offset of the top-left corner from the position. More...
 
Vector2f scale
 Scale of the object. More...
 
float rotation
 Rotation of the object (in degrees) More...
 

Detailed Description

A class that stores locational information.

Stores position, rotation, scale and the origin of an object, and provides functions to get/set those values. "Origin" is the offset between the position and the top-left corner of the object.

Constructor & Destructor Documentation

◆ Transformable()

Transformable::Transformable ( )

Default constructur.

◆ ~Transformable()

virtual Transformable::~Transformable ( )
virtual

Deconstructor.

Member Function Documentation

◆ GetOrigin()

Vector2f Transformable::GetOrigin ( )

Gets the current local origin.

Returns
A 2D vector with the offset

◆ GetPosition()

Vector2f Transformable::GetPosition ( )

Returns the position of the object.

Returns
A 2D vector of the position

◆ GetRotation()

float Transformable::GetRotation ( )

Gets the current rotation.

Returns
The rotation in degrees

◆ GetScale()

Vector2f Transformable::GetScale ( )

Gets the current scale of the object.

Returns
A 2D vector with the scale in x- and y-direction

◆ Move() [1/2]

void Transformable::Move ( const Vector2f position)

Adds to the current position.

Parameters
[in]positionA 2D movement vector

◆ Move() [2/2]

void Transformable::Move ( float  x,
float  y 
)

Adds to the current position.

Parameters
[in]xThe offset in x direction
[in]yThe offset in y direction

◆ Rotate()

void Transformable::Rotate ( float  angle)

Rotates by some amount.

Parameters
[in]angleThe angle to rotate by in degrees

◆ Scale() [1/2]

void Transformable::Scale ( const Vector2f scale)

Scales the object by some amount.

Parameters
[in]scaleThe amount to scale by in x- and y-direction

◆ Scale() [2/2]

void Transformable::Scale ( float  x,
float  y 
)

Scales the object by some amount.

Parameters
[in]xThe amount to scale by in x direction
[in]yThe amount to scale by in y direction

◆ SetOrigin() [1/2]

void Transformable::SetOrigin ( const Vector2f origin)

Sets a new local origin.

Parameters
[in]originA 2D vector with the new origin

◆ SetOrigin() [2/2]

void Transformable::SetOrigin ( float  x,
float  y 
)

Sets a new local origin.

Parameters
[in]xThe new x component of the origin
[in]yThe new y component of the origin

◆ SetPosition() [1/2]

void Transformable::SetPosition ( const Vector2f position)

Sets a new position.

Parameters
[in]positionA 2D vector with the new position

◆ SetPosition() [2/2]

void Transformable::SetPosition ( float  x,
float  y 
)

Sets a new position.

Parameters
[in]xThe new x position
[in]yThe new y position

◆ SetRotation()

void Transformable::SetRotation ( float  angle)

Sets a new rotation.

Parameters
[in]angleThe new rotation in degrees

◆ SetScale() [1/2]

void Transformable::SetScale ( const Vector2f scale)

Sets a new scale.

Parameters
[in]scaleA 2D vector with the new scale

◆ SetScale() [2/2]

void Transformable::SetScale ( float  x,
float  y 
)

Sets a new scale.

Parameters
[in]xThe new scale in x direction
[in]yThe new scale in y direction

Member Data Documentation

◆ origin

Vector2f Transformable::origin
protected

Offset of the top-left corner from the position.

◆ position

Vector2f Transformable::position
protected

Position of the object.

◆ rotation

float Transformable::rotation
protected

Rotation of the object (in degrees)

◆ scale

Vector2f Transformable::scale
protected

Scale of the object.


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