#pragma once /// @file Rect.hpp /// For complete documentation, see src/Rect.cpp #include namespace hdk::sdl { class FRect; class Rect : public SDL_Rect { public: using SDL_Rect::SDL_Rect; Rect() : SDL_Rect { 0, 0, 0, 0 } { } Rect(SDL_Rect another) : SDL_Rect { another.x, another.y, another.w, another.h } { } Rect(SDL_FRect another) : SDL_Rect { static_cast(another.x), static_cast(another.y), static_cast(another.w), static_cast(another.h) } { } Rect(FRect another); Rect& scale(float scaleX, float scaleY) { x = static_cast(x * scaleX); y = static_cast(y * scaleY); w = static_cast(w * scaleX); h = static_cast(h * scaleY); return *this; } Rect& scale(float scale) { return this->scale(scale, scale); } Rect& operator*=(float scale) { return this->scale(scale); } operator SDL_FRect() const { return SDL_FRect { static_cast(x), static_cast(y), static_cast(w), static_cast(h) }; } }; class FRect : public SDL_FRect { public: using SDL_FRect::SDL_FRect; FRect() : SDL_FRect { 0.0f, 0.0f, 0.0f, 0.0f } { } FRect(SDL_FRect another) : SDL_FRect { another.x, another.y, another.w, another.h } { } FRect(SDL_Rect another) : SDL_FRect { static_cast(another.x), static_cast(another.y), static_cast(another.w), static_cast(another.h) } { } FRect(Rect another) : SDL_FRect { static_cast(another.x), static_cast(another.y), static_cast(another.w), static_cast(another.h) } { } FRect& scale(float scaleX, float scaleY) { x = x * scaleX; y = y * scaleY; w = w * scaleX; h = h * scaleY; return *this; } FRect& scale(float scale) { return this->scale(scale, scale); } FRect& operator*=(float scale) { return this->scale(scale); } operator SDL_Rect() const { return SDL_Rect { static_cast(x), static_cast(y), static_cast(w), static_cast(h) }; } }; inline Rect::Rect(FRect another) : SDL_Rect { static_cast(another.x), static_cast(another.y), static_cast(another.w), static_cast(another.h) } { } }