bn::sprite_affine_mat_ptr class

std::shared_ptr like smart pointer that retains shared ownership of a sprite affine transformation matrix.

Several sprite_affine_mat_ptr objects may own the same sprite affine transformation matrix.

The sprite affine transformation matrix is released when the last remaining sprite_affine_mat_ptr owning it is destroyed.

Public static functions

static auto create() -> sprite_affine_mat_ptr
Creates an identity affine transformation matrix.
static auto create(const affine_mat_attributes& attributes) -> sprite_affine_mat_ptr
Creates an affine transformation matrix with the specified attributes.
static auto create_optional() -> optional<sprite_affine_mat_ptr>
Creates an identity affine transformation matrix.
static auto create_optional(const affine_mat_attributes& attributes) -> optional<sprite_affine_mat_ptr>
Creates an affine transformation matrix with the specified attributes.

Constructors, destructors, conversion operators

sprite_affine_mat_ptr(const sprite_affine_mat_ptr& other)
Copy constructor.
sprite_affine_mat_ptr(sprite_affine_mat_ptr&& other) noexcept
Move constructor.
~sprite_affine_mat_ptr()
Releases the referenced sprite affine transformation matrix if no more sprite_affine_mat_ptr objects reference to it.

Public functions

auto operator=(const sprite_affine_mat_ptr& other) -> sprite_affine_mat_ptr&
Copy assignment operator.
auto operator=(sprite_affine_mat_ptr&& other) -> sprite_affine_mat_ptr& noexcept
Move assignment operator.
auto id() const -> int
Returns the internal id.
auto rotation_angle() const -> fixed
Returns the rotation angle in degrees.
void set_rotation_angle(fixed rotation_angle)
Sets the rotation angle in degrees.
void set_rotation_angle_safe(fixed rotation_angle)
Sets the rotation angle in degrees.
auto horizontal_scale() const -> fixed
Returns the horizontal scale.
void set_horizontal_scale(fixed horizontal_scale)
Sets the horizontal scale.
auto vertical_scale() const -> fixed
Returns the vertical scale.
void set_vertical_scale(fixed vertical_scale)
Sets the vertical scale.
void set_scale(fixed scale)
Sets the scale.
void set_scale(fixed horizontal_scale, fixed vertical_scale)
Sets the scale.
auto horizontal_shear() const -> fixed
Returns the horizontal shear.
void set_horizontal_shear(fixed horizontal_shear)
Sets the horizontal shear.
auto vertical_shear() const -> fixed
Returns the vertical shear.
void set_vertical_shear(fixed vertical_shear)
Sets the vertical shear.
void set_shear(fixed shear)
Sets the shear.
void set_shear(fixed horizontal_shear, fixed vertical_shear)
Sets the shear.
auto horizontal_flip() const -> bool
Indicates if this matrix is flipped in the horizontal axis or not.
void set_horizontal_flip(bool horizontal_flip)
Sets if this matrix is flipped in the horizontal axis or not.
auto vertical_flip() const -> bool
Indicates if this matrix is flipped in the vertical axis or not.
void set_vertical_flip(bool vertical_flip)
Sets if this matrix is flipped in the vertical axis or not.
auto attributes() const -> const affine_mat_attributes&
Returns the attributes of this matrix.
void set_attributes(const affine_mat_attributes& attributes)
Sets the attributes of this matrix.
auto identity() const -> bool
Indicates if this matrix is equal to the identity matrix or not.
auto flipped_identity() const -> bool
Indicates if this matrix is equal to the identity matrix or not, ignoring flip attributes.
void swap(sprite_affine_mat_ptr& other)
Exchanges the contents of this sprite_affine_mat_ptr with those of the other one.

Friends

void swap(sprite_affine_mat_ptr& a, sprite_affine_mat_ptr& b)
Exchanges the contents of a sprite_affine_mat_ptr with those of another one.
auto operator==(const sprite_affine_mat_ptr& a, const sprite_affine_mat_ptr& b) -> bool defaulted
Default equal operator.

Function documentation

static sprite_affine_mat_ptr bn::sprite_affine_mat_ptr::create()

Creates an identity affine transformation matrix.

Returns The requested sprite_affine_mat_ptr.

static sprite_affine_mat_ptr bn::sprite_affine_mat_ptr::create(const affine_mat_attributes& attributes)

Creates an affine transformation matrix with the specified attributes.

Parameters
attributes affine_mat_attributes of the output matrix.
Returns The requested sprite_affine_mat_ptr.

static optional<sprite_affine_mat_ptr> bn::sprite_affine_mat_ptr::create_optional()

Creates an identity affine transformation matrix.

Returns The requested sprite_affine_mat_ptr if it could be allocated; bn::nullopt otherwise.

static optional<sprite_affine_mat_ptr> bn::sprite_affine_mat_ptr::create_optional(const affine_mat_attributes& attributes)

Creates an affine transformation matrix with the specified attributes.

Parameters
attributes affine_mat_attributes of the output matrix.
Returns The requested sprite_affine_mat_ptr if it could be allocated; bn::nullopt otherwise.

bn::sprite_affine_mat_ptr::sprite_affine_mat_ptr(const sprite_affine_mat_ptr& other)

Copy constructor.

Parameters
other sprite_affine_mat_ptr to copy.

bn::sprite_affine_mat_ptr::sprite_affine_mat_ptr(sprite_affine_mat_ptr&& other) noexcept

Move constructor.

Parameters
other sprite_affine_mat_ptr to move.

sprite_affine_mat_ptr& bn::sprite_affine_mat_ptr::operator=(const sprite_affine_mat_ptr& other)

Copy assignment operator.

Parameters
other sprite_affine_mat_ptr to copy.
Returns Reference to this.

sprite_affine_mat_ptr& bn::sprite_affine_mat_ptr::operator=(sprite_affine_mat_ptr&& other) noexcept

Move assignment operator.

Parameters
other sprite_affine_mat_ptr to move.
Returns Reference to this.

void bn::sprite_affine_mat_ptr::set_rotation_angle(fixed rotation_angle)

Sets the rotation angle in degrees.

Parameters
rotation_angle Rotation angle in degrees, in the range [0..360].

void bn::sprite_affine_mat_ptr::set_rotation_angle_safe(fixed rotation_angle)

Sets the rotation angle in degrees.

Parameters
rotation_angle Rotation angle in degrees, in any range.

void bn::sprite_affine_mat_ptr::set_scale(fixed horizontal_scale, fixed vertical_scale)

Sets the scale.

Parameters
horizontal_scale Horizontal scale.
vertical_scale Vertical scale.

void bn::sprite_affine_mat_ptr::set_shear(fixed horizontal_shear, fixed vertical_shear)

Sets the shear.

Parameters
horizontal_shear Horizontal shear.
vertical_shear Vertical shear.

void bn::sprite_affine_mat_ptr::swap(sprite_affine_mat_ptr& other)

Exchanges the contents of this sprite_affine_mat_ptr with those of the other one.

Parameters
other sprite_affine_mat_ptr to exchange the contents with.

void swap(sprite_affine_mat_ptr& a, sprite_affine_mat_ptr& b)

Exchanges the contents of a sprite_affine_mat_ptr with those of another one.

Parameters
a First sprite_affine_mat_ptr to exchange the contents with.
b Second sprite_affine_mat_ptr to exchange the contents with.