// Copyright (C) 2012 Jérôme Leclercq // This file is part of the "Nazara Engine - Mathematics module" // For conditions of distribution and use, see copyright notice in Config.hpp #pragma once #ifndef NAZARA_RECT_HPP #define NAZARA_RECT_HPP #include #include template class NzRect { public: NzRect() = default; NzRect(T X, T Y, T Width, T Height); NzRect(const T rect[4]); NzRect(const NzVector2& vec1, const NzVector2& vec2); template explicit NzRect(const NzRect& rect); NzRect(const NzRect& rect) = default; ~NzRect() = default; bool Contains(T X, T Y) const; bool Contains(const NzVector2& point) const; bool Contains(const NzRect& rect) const; NzRect& ExtendTo(T X, T Y); NzRect& ExtendTo(const NzVector2& point); NzRect& ExtendTo(const NzRect& rect); NzVector2 GetCenter() const; NzVector2 GetNegativeVertex(const NzVector2& normal) const; NzVector2 GetPosition() const; NzVector2 GetPositiveVertex(const NzVector2& normal) const; NzVector2 GetSize() const; bool Intersect(const NzRect& rect, NzRect* intersection = nullptr) const; bool IsValid() const; NzRect& MakeZero(); NzRect& Set(T X, T Y, T Width, T Height); NzRect& Set(const T rect[4]); NzRect& Set(const NzRect& rect); NzRect& Set(const NzVector2& vec1, const NzVector2& vec2); template NzRect& Set(const NzRect& rect); NzString ToString() const; T& operator[](unsigned int i); T operator[](unsigned int i) const; NzRect operator*(T scalar) const; NzRect& operator*=(T scalar); bool operator==(const NzRect& rect) const; bool operator!=(const NzRect& rect) const; static NzRect Lerp(const NzRect& from, const NzRect& to, T interpolation); static NzRect Zero(); T x, y, width, height; }; template std::ostream& operator<<(std::ostream& out, const NzRect& rect); typedef NzRect NzRectd; typedef NzRect NzRectf; typedef NzRect NzRecti; typedef NzRect NzRectui; #include #endif // NAZARA_RECT_HPP