cpp_drawing/shapes/rectangle.hpp

37 lines
940 B
C++

#pragma once
#include "math/vector.hpp"
#include "shape.hpp"
namespace shapes
{
/**
* @brief Rectangle shape
*
* Represents a rectangle defined by a position, size and angle of rotation around it's left-top corner
*/
class Rectangle final : public Shape
{
public:
Rectangle(const math::Vector& pos, const math::Vector& size) : m_pos(pos), m_size(size), m_angle(0.0f) {}
const math::Vector& GetPosition() const { return m_pos; }
const math::Vector& GetSize() const { return m_size; }
const float GetAngle() const { return m_angle; }
void Translate(const math::Vector& offset) override;
void Rotate(const math::Vector& center, float angle) override;
void Scale(const math::Vector& center, float factor) override;
void Draw(Renderer& renderer) const override;
~Rectangle() override = default;
private:
math::Vector m_pos;
math::Vector m_size;
float m_angle;
};
} // namespace shapes