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

#include <TTauri/Foundation/aarect.hpp>

Public Member Functions

tt_force_inline aarect (aarect const &rhs) noexcept=default
 
tt_force_inline aarectoperator= (aarect const &rhs) noexcept=default
 
tt_force_inline aarect (aarect &&rhs) noexcept=default
 
tt_force_inline aarectoperator= (aarect &&rhs) noexcept=default
 
template<typename X , typename Y , typename W = float, typename H = float, std::enable_if_t< std::is_arithmetic_v< X > &&std::is_arithmetic_v< Y > &&std::is_arithmetic_v< W > &&std::is_arithmetic_v< H >, int > = 0>
tt_force_inline aarect (X x, Y y, W width, H height) noexcept
 Create a box from the position and size.
 
tt_force_inline aarect (vec const &position, vec const &extent) noexcept
 Create a rectangle from the position and size.
 
tt_force_inline aarect (vec const &extent) noexcept
 Create a rectangle from the size.
 
 operator bool () const noexcept
 
aarectoperator|= (aarect const &rhs) noexcept
 Expand the current rectangle to include the new rectangle.
 
aarectoperator|= (vec const &rhs) noexcept
 Expand the current rectangle to include the new point.
 
aarectoperator+= (vec const &rhs) noexcept
 Translate the box to a new position.
 
aarectoperator-= (vec const &rhs) noexcept
 Translate the box to a new position.
 
aarectoperator*= (float rhs) noexcept
 Scale the box by moving the positions (scaling the vectors).
 
template<size_t I>
tt_force_inline vec corner () const noexcept
 Get coordinate of a corner.
 
tt_force_inline vec p0 () const noexcept
 Get coordinate of a corner.
 
tt_force_inline vec p3 () const noexcept
 
tt_force_inline vec offset () const noexcept
 Get vector from origin to the bottom-left corner.
 
vec extent () const noexcept
 Get size of the rectangle.
 
tt_force_inline float x () const noexcept
 
tt_force_inline float y () const noexcept
 
tt_force_inline float width () const noexcept
 
tt_force_inline float height () const noexcept
 
template<typename T , std::enable_if_t< std::is_arithmetic_v< T >, int > = 0>
tt_force_inline aarectwidth (T newWidth) noexcept
 
template<typename T , std::enable_if_t< std::is_arithmetic_v< T >, int > = 0>
tt_force_inline aarectheight (T newHeight) noexcept
 
bool contains (vec const &rhs) const noexcept
 Check if a 2D coordinate is inside the rectangle.
 

Static Public Member Functions

static tt_force_inline aarect p0p3 (vec const &v) noexcept
 Create aarect from packed p0p3 coordinates.
 
static tt_force_inline aarect p0p3 (vec const &p0, vec const &p3) noexcept
 
static aarect _align (aarect outside, aarect inside, Alignment alignment) noexcept
 Need to call the hiden friend function from within another class.
 

Friends

class R32G32B32A32SFloat
 
aarect align (aarect haystack, aarect needle, Alignment alignment) noexcept
 Align a rectangle within another rectangle.
 
bool operator== (aarect const &lhs, aarect const &rhs) noexcept
 
bool operator!= (aarect const &lhs, aarect const &rhs) noexcept
 
bool overlaps (aarect const &lhs, aarect const &rhs) noexcept
 
aarect operator| (aarect const &lhs, aarect const &rhs) noexcept
 
aarect operator| (aarect const &lhs, vec const &rhs) noexcept
 
aarect operator+ (aarect const &lhs, vec const &rhs) noexcept
 
aarect operator- (aarect const &lhs, vec const &rhs) noexcept
 
aarect operator* (aarect const &lhs, float rhs) noexcept
 
aarect scale (aarect const &lhs, float rhs) noexcept
 Expand the rectangle for the same amount in all directions.
 
aarect expand (aarect const &lhs, float rhs) noexcept
 Expand the rectangle for the same amount in all directions.
 
aarect shrink (aarect const &lhs, float rhs) noexcept
 Shrink the rectangle for the same amount in all directions.
 
aarect round (aarect const &rhs) noexcept
 

Detailed Description

Class which represents an axis-aligned rectangle.

Constructor & Destructor Documentation

◆ aarect() [1/3]

template<typename X , typename Y , typename W = float, typename H = float, std::enable_if_t< std::is_arithmetic_v< X > &&std::is_arithmetic_v< Y > &&std::is_arithmetic_v< W > &&std::is_arithmetic_v< H >, int > = 0>
tt_force_inline tt::aarect::aarect ( X x,
Y y,
W width,
H 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.

◆ aarect() [2/3]

tt_force_inline tt::aarect::aarect ( vec const & position,
vec const & extent )
inlinenoexcept

Create a rectangle from the position and size.

Parameters
positionThe position of the left-bottom corner of the box
extentThe size of the box.

◆ aarect() [3/3]

tt_force_inline tt::aarect::aarect ( vec const & extent)
inlinenoexcept

Create a rectangle from the size.

The rectangle's left bottom corner is at the origin.

Parameters
extentThe size of the box.

Member Function Documentation

◆ _align()

static aarect tt::aarect::_align ( aarect outside,
aarect inside,
Alignment alignment )
inlinestaticnoexcept

Need to call the hiden friend function from within another class.

◆ contains()

bool tt::aarect::contains ( vec 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 vec tt::aarect::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 homogeneous coordinate of the corner.

◆ extent()

vec tt::aarect::extent ( ) const
inlinenoexcept

Get size of the rectangle.

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

◆ offset()

tt_force_inline vec tt::aarect::offset ( ) const
inlinenoexcept

Get vector from origin to the bottom-left corner.

Returns
The homogeneous coordinate of the bottom-left corner.

◆ operator*=()

aarect & tt::aarect::operator*= ( float rhs)
inlinenoexcept

Scale the box by moving the positions (scaling the vectors).

Parameters
rhsBy how much to scale the positions of the two points

◆ operator+=()

aarect & tt::aarect::operator+= ( vec const & rhs)
inlinenoexcept

Translate the box to a new position.

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

◆ operator-=()

aarect & tt::aarect::operator-= ( vec const & rhs)
inlinenoexcept

Translate the box to a new position.

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

◆ operator|=() [1/2]

aarect & tt::aarect::operator|= ( aarect 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.

◆ operator|=() [2/2]

aarect & tt::aarect::operator|= ( vec const & rhs)
inlinenoexcept

Expand the current rectangle to include the new point.

This is mostly used for extending bounding a bounding box.

Parameters
rhsThe new rectangle to include in the current rectangle.

◆ p0()

tt_force_inline vec tt::aarect::p0 ( ) const
inlinenoexcept

Get coordinate of a corner.

Parameters
ICorner number: 0 = left-bottom, 1 = right-bottom, 2 = left-top, 3 = right-top.
zThe z coordinate to insert in the resulting coordinate.
Returns
The homogeneous coordinate of the corner.

◆ p0p3()

static tt_force_inline aarect tt::aarect::p0p3 ( vec const & v)
inlinestaticnoexcept

Create aarect from packed p0p3 coordinates.

Parameters
vp0 = (x, y), p3 = (z, w)

Friends And Related Symbol Documentation

◆ align

aarect align ( aarect haystack,
aarect needle,
Alignment alignment )
friend

Align a rectangle within another rectangle.

Parameters
haystackThe outside rectangle
needleThe inside rectangle; to be aligned.
alignmentHow the inside rectangle should be aligned.
Returns
The needle rectangle repositioned and aligned inside the haystack.

◆ expand

aarect expand ( aarect const & lhs,
float 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.

◆ scale

aarect scale ( aarect const & lhs,
float rhs )
friend

Expand the rectangle for the same amount in all directions.

Parameters
lhsThe original rectangle.
rhsHow much the width and height should be scaled by.
Returns
A new rectangle expanded on each side.

◆ shrink

aarect shrink ( aarect const & lhs,
float rhs )
friend

Shrink 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 shrank on each side.

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