57 lines
842 B
C++
57 lines
842 B
C++
#include "Rect.hpp"
|
|
|
|
TSE::Rect::Rect()
|
|
{
|
|
p1 = {0,0};
|
|
p2 = {0,0};
|
|
}
|
|
|
|
TSE::Rect::Rect(float x1, float y1, float x2, float y2)
|
|
{
|
|
p1 = {x1, y1};
|
|
p2 = {x2, y2};
|
|
}
|
|
|
|
TSE::Rect::Rect(const Vector2 &_p1, const Vector2 &_p2)
|
|
{
|
|
p1 = Vector2(_p1);
|
|
p2 = Vector2(_p2);
|
|
}
|
|
|
|
TSE::Rect::Rect(const Vector4 &v)
|
|
{
|
|
p1 = {v.x, v.y};
|
|
p1 = {v.z, v.w};
|
|
}
|
|
|
|
TSE::Rect::Rect(const Rect &r)
|
|
{
|
|
p1 = Vector2(r.p1);
|
|
p2 = Vector2(r.p2);
|
|
}
|
|
|
|
float TSE::Rect::width() const
|
|
{
|
|
return std::abs(p2.x - p1.x);
|
|
}
|
|
|
|
float TSE::Rect::height() const
|
|
{
|
|
return std::abs(p2.y - p1.y);
|
|
}
|
|
|
|
float TSE::Rect::area() const
|
|
{
|
|
return width() * height();
|
|
}
|
|
|
|
bool TSE::Rect::operator==(const Rect &other) const
|
|
{
|
|
return p1 == other.p1 && p2 == other.p2;
|
|
}
|
|
|
|
bool TSE::Rect::operator!=(const Rect &other) const
|
|
{
|
|
return !(*this == other);
|
|
}
|