template struct geom::TRect — HIRO 0.7.0 documentation

# template struct geom::TRect

Template rectangle in an arbitrary dimension.

    #include <GeometryStructures.h>

    template <typename T>
    struct TRect {
        // typedefs

        typedef glm::tvec2<T> Vec2;

        // fields

        Vec2 position = Vec2((T)0);
        Vec2 position2 = Vec2((T)0);
        utils::PropertyByValue<TRect<T>, T,&TRect<T>::GetX,&TRect<T>::SetX> x;
        utils::PropertyByValue<TRect<T>, T,&TRect<T>::GetY,&TRect<T>::SetY> y;
        utils::PropertyByValue<TRect<T>, T,&TRect<T>::GetWidth,&TRect<T>::SetWidth> width;
        utils::PropertyByValue<TRect<T>, T,&TRect<T>::GetHeight,&TRect<T>::SetHeight> height;
        utils::PropertyByValue<TRect<T>, T,&TRect<T>::GetX2,&TRect<T>::SetX2> x2;
        utils::PropertyByValue<TRect<T>, T,&TRect<T>::GetY2,&TRect<T>::SetY2> y2;
        utils::Property<TRect<T>, Vec2,&TRect<T>::GetSize,&TRect<T>::SetSize> size;

        // construction

        TRect();
        TRect(const T x1, const T y1, const T x2, const T y2);
        TRect(const Vec2& point1, const Vec2& point2);
        TRect(const Vec2& top_left_origin, const T size_width, const T size_height);

        // methods

        void SetSize(const Vec2& new_size);
        void Set(const TRect& rect);
        void Set(const T t_x1, const T t_y1, const T t_x2, const T t_y2);
        void Set(const Vec2& point1, const Vec2& point2);
        Vec2 GetSize() const;
        T GetX() const;
        T GetY() const;
        T GetWidth() const;
        T GetHeight() const;
        T GetX2() const;
        T GetY2() const;
        void SetX(const T value);
        void SetY(const T value);
        void SetWidth(const T value);
        void SetHeight(const T value);
        void SetX2(const T value);
        void SetY2(const T value);
        Vec2 Center(void) const;
        bool Contains(const Vec2& point) const;
        T Area(void) const;
    };