#pragma once

#include <types/base/types.h>

namespace extra2d {

struct Size {
    float w, h;

    Size() : w(0.0f), h(0.0f) {}
    Size(float w, float h) : w(w), h(h) {}
    explicit Size(float v) : w(v), h(v) {}

    Size operator+(const Size& o) const { return {w + o.w, h + o.h}; }
    Size operator-(const Size& o) const { return {w - o.w, h - o.h}; }
    Size operator*(float s) const { return {w * s, h * s}; }
    Size operator/(float s) const { return {w / s, h / s}; }

    Size& operator+=(const Size& o) { w += o.w; h += o.h; return *this; }
    Size& operator-=(const Size& o) { w -= o.w; h -= o.h; return *this; }
    Size& operator*=(float s) { w *= s; h *= s; return *this; }
    Size& operator/=(float s) { w /= s; h /= s; return *this; }

    bool operator==(const Size& o) const { return w == o.w && h == o.h; }
    bool operator!=(const Size& o) const { return !(*this == o); }

    float area() const { return w * h; }
    bool empty() const { return w <= 0.0f || h <= 0.0f; }

    static const Size Zero;
    static const Size One;
};

inline Size operator*(float s, const Size& sz) { return sz * s; }

} // namespace extra2d
