A rendering transformation, which can scale, flip, and rotate.
A Transform can be given to Sprite_set::add_sprite(const Sprite&, Posn<int>, int, const Transform&) to specify how a Sprite should be rendered.
To construct a transform that does just one thing, you can use one of the static factory functions:
It is also possible to modify a transform with the setter functions such as set_rotation(double) and set_scale(double). This can be used to configure a transform that does more than one thing:
Definition at line 792 of file ge211_geometry.hxx.
Public Member Functions | |
Setters | |
Transform & | set_rotation (double) |
Modifies this transform to have the given rotation, in degrees. | |
Transform & | set_flip_h (bool) |
Modifies this transform to determine whether to flip horizontally. | |
Transform & | set_flip_v (bool) |
Modifies this transform to determine whether to flip vertically. | |
Transform & | set_scale (double) |
Modifies this transform to scale the sprite by the given amount in both dimensions. More... | |
Transform & | set_scale_x (double) |
Modifies this transform to scale the sprite horizontally. More... | |
Transform & | set_scale_y (double) |
Modifies this transform to scale the sprite vertically. More... | |
Getters | |
double | get_rotation () const |
Returns the rotation that will be applied to the sprite. | |
bool | get_flip_h () const |
Returns whether the sprite will be flipped horizontally. | |
bool | get_flip_v () const |
Returns whether the sprite will be flipped vertically. | |
double | get_scale_x () const |
Returns how much the sprite will be scaled horizontally. | |
double | get_scale_y () const |
Returns how much the sprite will be scaled vertically. | |
Combining transforms | |
bool | is_identity () const |
Is this transformation the identity transformation that does nothing? Because floating point is approximate, this may answer false for transforms that are nearly the identity. More... | |
Transform | operator* (const Transform &other) const |
Composes two transforms to combine both of their effects. | |
Transform | inverse () const |
Returns the inverse of this transform. More... | |
Comparing transforms | |
bool | operator== (const Transform &other) const |
Equality for Transform s. | |
bool | operator!= (const Transform &other) const |
Disequality for Transform s. | |
Constructor and factory functions | |
Transform () | |
Constructs the identity transform, which has no effect. | |
static Transform | rotation (double) |
Constructs a rotating transform, given the rotation in degrees clockwise. | |
static Transform | flip_h () |
Constructs a transform that flips the sprite horizontally. | |
static Transform | flip_v () |
Constructs a transform that flips the sprite vertically. | |
static Transform | scale (double) |
Constructs a transform that scales the sprite in both dimensions. | |
static Transform | scale_x (double) |
Constructs a transform that scales the sprite in the x dimension. | |
static Transform | scale_y (double) |
Constructs a transform that scales the sprite in the y dimension. | |
Transform inverse | ( | ) | const |
Returns the inverse of this transform.
Composing a transform with its inverse should result in the identity transformation, though because floating point is approximate, is_identity() const may not actually answer true
.
Definition at line 123 of file ge211_geometry.cxx.
bool is_identity | ( | ) | const |
Is this transformation the identity transformation that does nothing? Because floating point is approximate, this may answer false
for transforms that are nearly the identity.
But it should answer true
for any transform constructed by the default constructor Transform().
Definition at line 107 of file ge211_geometry.cxx.
Transform & set_scale | ( | double | scale | ) |
Modifies this transform to scale the sprite by the given amount in both dimensions.
This overwrites the effect of previous calls to set_scale_x(double) and set_scale_y(double).
Definition at line 63 of file ge211_geometry.cxx.
Transform & set_scale_x | ( | double | scale_x | ) |
Modifies this transform to scale the sprite horizontally.
This overwrites the effect of previous calls to set_scale(double)
as well as itself.
Definition at line 70 of file ge211_geometry.cxx.
Transform & set_scale_y | ( | double | scale_y | ) |
Modifies this transform to scale the sprite vertically.
This overwrites the effect of previous calls to set_scale(double)
as well as itself.
Definition at line 76 of file ge211_geometry.cxx.