Skip to main content

Transform

Allows you to translate / rotate / scale all your drawings at once.

Summary

Functions

Name
voidtranslate(glm::vec2 translation)
Applies a translation to all the future drawings. To undo this, see [push_transform()](/reference/transform#push_transform) and [pop_transform()](/reference/transform#pop_transform).
voidrotate([p6::Angle](/reference/Types/angle) angle)
Applies a rotation to all the future drawings. To undo this, see [push_transform()](/reference/transform#push_transform) and [pop_transform()](/reference/transform#pop_transform).
voidscale(glm::vec2 scale_factor)
Applies a scale to all the future drawings. To undo this, see [push_transform()](/reference/transform#push_transform) and [pop_transform()](/reference/transform#pop_transform).
voidreset_transform()
Undoes all the translate / rotate / scale / apply_transform / set_transform.
voidapply_transform(glm::mat3 additional_transform)
Applies a custom transform matrix to all the future drawings. To undo this, see [push_transform()](/reference/transform#push_transform) and [pop_transform()](/reference/transform#pop_transform).
voidset_transform(glm::mat3 transform)
Sets the current transform matrix. This will override all the previous translate / rotate / scale / apply_transform. To undo this, see [push_transform()](/reference/transform#push_transform) and [pop_transform()](/reference/transform#pop_transform).
voidpush_transform()
Saves the current transform state.
voidpop_transform()
Restores the transform to the state it had during the last [push_transform()](/reference/transform#push_transform) that has not been popped yet.
TransformScopeGuardtransform_scope_guard()
Will call push_transform() and pop_transform() automatically.
glm::mat3current_transform() const
Returns the current transform matrix that is the combination of all the translate / rotate / scale / apply_transform / set_transform that have been applied.

Functions

translate()

void translate(glm::vec2 translation);

Applies a translation to all the future drawings. To undo this, see [push_transform()](/reference/transform#push_transform) and [pop_transform()](/reference/transform#pop_transform).

rotate()

void rotate([p6::Angle](/reference/Types/angle) angle);

Applies a rotation to all the future drawings. To undo this, see [push_transform()](/reference/transform#push_transform) and [pop_transform()](/reference/transform#pop_transform).

scale()

void scale(glm::vec2 scale_factor);

Applies a scale to all the future drawings. To undo this, see [push_transform()](/reference/transform#push_transform) and [pop_transform()](/reference/transform#pop_transform).

reset_transform()

void reset_transform();

Undoes all the translate / rotate / scale / apply_transform / set_transform.

apply_transform()

void apply_transform(glm::mat3 additional_transform);

Applies a custom transform matrix to all the future drawings. To undo this, see [push_transform()](/reference/transform#push_transform) and [pop_transform()](/reference/transform#pop_transform).

set_transform()

void set_transform(glm::mat3 transform);

Sets the current transform matrix. This will override all the previous translate / rotate / scale / apply_transform. To undo this, see [push_transform()](/reference/transform#push_transform) and [pop_transform()](/reference/transform#pop_transform).

push_transform()

void push_transform();

Saves the current transform state.

pop_transform()

void pop_transform();

Restores the transform to the state it had during the last [push_transform()](/reference/transform#push_transform) that has not been popped yet.

transform_scope_guard()

TransformScopeGuard transform_scope_guard();

Will call push_transform() and pop_transform() automatically.

Assign the result of this function to a variable and pop_transform() will be called when the variable goes out of scope. push_transform() is called when transform_scope_guard() is called.

current_transform()

glm::mat3 current_transform() const;

Returns the current transform matrix that is the combination of all the translate / rotate / scale / apply_transform / set_transform that have been applied.


Updated on 2024 October 24