HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Friends
tt::iaarect Class Reference

#include <TTauri/Foundation/iaarect.hpp>

Public Member Functions

tt_force_inline iaarect (iaarect const &rhs) noexcept=default
 
tt_force_inline iaarectoperator= (iaarect const &rhs) noexcept=default
 
tt_force_inline iaarect (iaarect &&rhs) noexcept=default
 
tt_force_inline iaarectoperator= (iaarect &&rhs) noexcept=default
 
 iaarect (__m128i rhs) noexcept
 
iaarectoperator= (__m128i rhs) noexcept
 
 operator __m128i () const noexcept
 
template<typename T , std::enable_if_t< std::is_integral_v< T >, int > = 0>
tt_force_inline iaarect (T x, T y, T width, T height) noexcept
 Create a box from the position and size.
 
tt_force_inline iaarect (ivec const &offset, ivec const &extent) noexcept
 Create a box from the position and size.
 
iaarectoperator|= (iaarect const &rhs) noexcept
 Expand the current rectangle to include the new rectangle.
 
iaarectoperator+= (ivec const &rhs) noexcept
 Translate the box to a new position.
 
iaarectoperator-= (ivec const &rhs) noexcept
 Translate the box to a new position.
 
template<size_t I>
tt_force_inline ivec corner () const noexcept
 Get coordinate of a corner.
 
tt_force_inline ivec offset () const noexcept
 Get coordinate of the bottom-left corner.
 
ivec extent () const noexcept
 Get size of the rectangle.
 
tt_force_inline int x1 () const noexcept
 
tt_force_inline int y1 () const noexcept
 
tt_force_inline int x2 () const noexcept
 
tt_force_inline int y2 () const noexcept
 
tt_force_inline int width () const noexcept
 
tt_force_inline int height () const noexcept
 
bool contains (ivec const &rhs) const noexcept
 Check if a 2D coordinate is inside the rectangle.
 

Static Public Member Functions

static tt_force_inline iaarect p0p3 (ivec const &p1, ivec const &p2) noexcept
 

Friends

bool operator== (iaarect const &lhs, iaarect const &rhs) noexcept
 
bool operator!= (iaarect const &lhs, iaarect const &rhs) noexcept
 
iaarect operator| (iaarect const &lhs, iaarect const &rhs) noexcept
 
iaarect operator+ (iaarect const &lhs, ivec const &rhs) noexcept
 
iaarect operator- (iaarect const &lhs, ivec const &rhs) noexcept
 
template<typename T , std::enable_if_t< std::is_integral_v< T >, int > = 0>
iaarect expand (iaarect const &lhs, T rhs) noexcept
 Expand the rectangle for the same amount in all directions.
 

Detailed Description

Class which represents an axis-aligned rectangle.

Constructor & Destructor Documentation

◆ iaarect() [1/2]

template<typename T , std::enable_if_t< std::is_integral_v< T >, int > = 0>
tt_force_inline tt::iaarect::iaarect ( T x,
T y,
T width,
T height )
inlinenoexcept

Create a box from the position and size.

Parameters
xThe x location of the left-bottom corner of the box
yThe y location of the left-bottom corner of the box
widthThe width of the box.
heightThe height of the box.

◆ iaarect() [2/2]

tt_force_inline tt::iaarect::iaarect ( ivec const & offset,
ivec const & extent )
inlinenoexcept

Create a box from the position and size.

Parameters
offsetThe position of the left-bottom corner of the box
extentThe size of the box (z and w must be zero).

Member Function Documentation

◆ contains()

bool tt::iaarect::contains ( ivec const & rhs) const
inlinenoexcept

Check if a 2D coordinate is inside the rectangle.

Parameters
rhsThe coordinate of the point to test.

◆ corner()

template<size_t I>
tt_force_inline ivec tt::iaarect::corner ( ) const
inlinenoexcept

Get coordinate of a corner.

Parameters
ICorner number: 0 = left-bottom, 1 = right-bottom, 2 = left-top, 3 = right-top.
Returns
The homogenious coordinate of the corner.

◆ extent()

ivec tt::iaarect::extent ( ) const
inlinenoexcept

Get size of the rectangle.

Returns
The (x, y) ivector representing the width and height of the rectangle.

◆ offset()

tt_force_inline ivec tt::iaarect::offset ( ) const
inlinenoexcept

Get coordinate of the bottom-left corner.

Returns
The homogenious coordinate of the bottom-left corner.

◆ operator+=()

iaarect & tt::iaarect::operator+= ( ivec const & rhs)
inlinenoexcept

Translate the box to a new position.

Parameters
rhsThe ivector to add to the coordinates of the rectangle.

◆ operator-=()

iaarect & tt::iaarect::operator-= ( ivec const & rhs)
inlinenoexcept

Translate the box to a new position.

Parameters
rhsThe ivector to subtract from the coordinates of the rectangle.

◆ operator|=()

iaarect & tt::iaarect::operator|= ( iaarect const & rhs)
inlinenoexcept

Expand the current rectangle to include the new rectangle.

This is mostly used for extending bounding a bounding box.

Parameters
rhsThe new rectangle to include in the current rectangle.

Friends And Related Symbol Documentation

◆ expand

template<typename T , std::enable_if_t< std::is_integral_v< T >, int > = 0>
iaarect expand ( iaarect const & lhs,
T rhs )
friend

Expand the rectangle for the same amount in all directions.

Parameters
lhsThe original rectangle.
rhsHow much should be added on each side of the rectangle, this value may be zero or negative.
Returns
A new rectangle expanded on each side.

The documentation for this class was generated from the following file: