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

#include <ttauri/geometry/axis_aligned_rectangle.hpp>

Public Member Functions

 axis_aligned_rectangle (axis_aligned_rectangle const &rhs) noexcept=default
 
axis_aligned_rectangleoperator= (axis_aligned_rectangle const &rhs) noexcept=default
 
 axis_aligned_rectangle (axis_aligned_rectangle &&rhs) noexcept=default
 
axis_aligned_rectangleoperator= (axis_aligned_rectangle &&rhs) noexcept=default
 
 axis_aligned_rectangle (f32x4 const &other) noexcept
 
 axis_aligned_rectangle (float x, float y, float width, float height) noexcept
 Create a box from the position and size.
 
 axis_aligned_rectangle (extent2 const &extent) noexcept
 Create a rectangle from the size.
 
 axis_aligned_rectangle (point2 const &p0, point2 const &p3) noexcept
 Create a rectangle from the left-bottom and right-top points.
 
 axis_aligned_rectangle (point2 const &p0, extent2 const &extent) noexcept
 Create a rectangle from the size.
 
bool is_valid () const noexcept
 Make sure p0 is left/bottom from p3.
 
bool empty () const noexcept
 Check if the rectangle has no area.
 
 operator bool () const noexcept
 True when the rectangle has an area.
 
axis_aligned_rectangleoperator|= (axis_aligned_rectangle const &rhs) noexcept
 Expand the current rectangle to include the new rectangle.
 
axis_aligned_rectangleoperator|= (point2 const &rhs) noexcept
 Expand the current rectangle to include the new rectangle.
 
constexpr point2 operator[] (size_t i) const noexcept
 
extent2 extent () const noexcept
 Get size of the rectangle.
 
float width () const noexcept
 
float height () const noexcept
 
float bottom () const noexcept
 
float top () const noexcept
 
float left () const noexcept
 
float right () const noexcept
 
float middle () const noexcept
 The middle on the y-axis between bottom and top.
 
float center () const noexcept
 The center on the x-axis between left and right.
 
axis_aligned_rectangleset_width (float newWidth) noexcept
 
axis_aligned_rectangleset_height (float newHeight) noexcept
 
bool contains (point2 const &rhs) const noexcept
 Check if a 2D coordinate is inside the rectangle.
 

Static Public Member Functions

static axis_aligned_rectangle _align (axis_aligned_rectangle outside, axis_aligned_rectangle inside, alignment alignment) noexcept
 Need to call the hiden friend function from within another class.
 

Friends

class sfloat_rgba32
 
template<int I>
constexpr friend point2 get (axis_aligned_rectangle const &rhs) noexcept
 
axis_aligned_rectangle align (axis_aligned_rectangle haystack, axis_aligned_rectangle needle, alignment alignment) noexcept
 Align a rectangle within another rectangle.
 
bool operator== (axis_aligned_rectangle const &lhs, axis_aligned_rectangle const &rhs) noexcept
 
bool operator!= (axis_aligned_rectangle const &lhs, axis_aligned_rectangle const &rhs) noexcept
 
bool overlaps (axis_aligned_rectangle const &lhs, axis_aligned_rectangle const &rhs) noexcept
 
axis_aligned_rectangle operator| (axis_aligned_rectangle const &lhs, axis_aligned_rectangle const &rhs) noexcept
 
axis_aligned_rectangle operator| (axis_aligned_rectangle const &lhs, point2 const &rhs) noexcept
 
point2 center (axis_aligned_rectangle const &rhs) noexcept
 Get the center of the rectangle.
 
axis_aligned_rectangle scale (axis_aligned_rectangle const &lhs, float rhs) noexcept
 Expand the rectangle for the same amount in all directions.
 
axis_aligned_rectangle expand (axis_aligned_rectangle const &lhs, float rhs) noexcept
 Expand the rectangle for the same amount in all directions.
 
axis_aligned_rectangle shrink (axis_aligned_rectangle const &lhs, float rhs) noexcept
 Shrink the rectangle for the same amount in all directions.
 
axis_aligned_rectangle round (axis_aligned_rectangle const &rhs) noexcept
 
axis_aligned_rectangle ceil (axis_aligned_rectangle const &rhs) noexcept
 Round rectangle by expanding to pixel edge.
 
axis_aligned_rectangle floor (axis_aligned_rectangle const &rhs) noexcept
 Round rectangle by shrinking to pixel edge.
 
axis_aligned_rectangle intersect (axis_aligned_rectangle const &lhs, axis_aligned_rectangle const &rhs) noexcept
 Return the overlapping part of two rectangles.
 
axis_aligned_rectangle fit (axis_aligned_rectangle const &bounds, axis_aligned_rectangle const &rectangle) noexcept
 Make a rectangle fit inside bounds.
 

Detailed Description

Class which represents an axis-aligned rectangle.

Constructor & Destructor Documentation

◆ axis_aligned_rectangle() [1/4]

tt::axis_aligned_rectangle::axis_aligned_rectangle ( float x,
float y,
float width,
float 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.

◆ axis_aligned_rectangle() [2/4]

tt::axis_aligned_rectangle::axis_aligned_rectangle ( extent2 const & extent)
inlineexplicitnoexcept

Create a rectangle from the size.

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

Parameters
extentThe size of the box.

◆ axis_aligned_rectangle() [3/4]

tt::axis_aligned_rectangle::axis_aligned_rectangle ( point2 const & p0,
point2 const & p3 )
inlinenoexcept

Create a rectangle from the left-bottom and right-top points.

Parameters
p0The left bottom point.
p3The right opt point.

◆ axis_aligned_rectangle() [4/4]

tt::axis_aligned_rectangle::axis_aligned_rectangle ( point2 const & p0,
extent2 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 axis_aligned_rectangle tt::axis_aligned_rectangle::_align ( axis_aligned_rectangle outside,
axis_aligned_rectangle inside,
alignment alignment )
inlinestaticnoexcept

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

◆ center()

float tt::axis_aligned_rectangle::center ( ) const
inlinenoexcept

The center on the x-axis between left and right.

◆ contains()

bool tt::axis_aligned_rectangle::contains ( point2 const & rhs) const
inlinenoexcept

Check if a 2D coordinate is inside the rectangle.

Parameters
rhsThe coordinate of the point to test.

◆ empty()

bool tt::axis_aligned_rectangle::empty ( ) const
inlinenoexcept

Check if the rectangle has no area.

◆ extent()

extent2 tt::axis_aligned_rectangle::extent ( ) const
inlinenoexcept

Get size of the rectangle.

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

◆ is_valid()

bool tt::axis_aligned_rectangle::is_valid ( ) const
inlinenoexcept

Make sure p0 is left/bottom from p3.

Returns
True is p0 is left and below p3.

◆ middle()

float tt::axis_aligned_rectangle::middle ( ) const
inlinenoexcept

The middle on the y-axis between bottom and top.

◆ operator bool()

tt::axis_aligned_rectangle::operator bool ( ) const
inlinenoexcept

True when the rectangle has an area.

◆ operator|=() [1/2]

axis_aligned_rectangle & tt::axis_aligned_rectangle::operator|= ( axis_aligned_rectangle 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]

axis_aligned_rectangle & tt::axis_aligned_rectangle::operator|= ( point2 const & rhs)
inlinenoexcept

Expand the current rectangle to include the new rectangle.

This is mostly used for extending bounding a bounding box.

Parameters
rhsA new point to include in the current rectangle.

Friends And Related Symbol Documentation

◆ align

axis_aligned_rectangle align ( axis_aligned_rectangle haystack,
axis_aligned_rectangle 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.

◆ ceil

axis_aligned_rectangle ceil ( axis_aligned_rectangle const & rhs)
friend

Round rectangle by expanding to pixel edge.

◆ center

point2 center ( axis_aligned_rectangle const & rhs)
friend

Get the center of the rectangle.

◆ expand

axis_aligned_rectangle expand ( axis_aligned_rectangle 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.

◆ fit

axis_aligned_rectangle fit ( axis_aligned_rectangle const & bounds,
axis_aligned_rectangle const & rectangle )
friend

Make a rectangle fit inside bounds.

This algorithm will try to first move the rectangle and resist resizing it.

Parameters
boundsThe bounding box.
rectangleThe rectangle to fit inside the bounds.
Returns
A rectangle that fits inside the bounds

◆ floor

axis_aligned_rectangle floor ( axis_aligned_rectangle const & rhs)
friend

Round rectangle by shrinking to pixel edge.

◆ intersect

axis_aligned_rectangle intersect ( axis_aligned_rectangle const & lhs,
axis_aligned_rectangle const & rhs )
friend

Return the overlapping part of two rectangles.

When the rectangles are not overlapping, the width and height are zero.

◆ scale

axis_aligned_rectangle scale ( axis_aligned_rectangle 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

axis_aligned_rectangle shrink ( axis_aligned_rectangle 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: