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

#include <hikogui/geometry/axis_aligned_rectangle.hpp>

Public Member Functions

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

Static Public Member Functions

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

Friends

template<int I>
constexpr friend point2 get (axis_aligned_rectangle const &rhs) noexcept
 
constexpr friend point2 midpoint (axis_aligned_rectangle const &rhs) noexcept
 Get the center of the rectangle.
 
constexpr axis_aligned_rectangle align (axis_aligned_rectangle haystack, extent2 needle, alignment alignment) noexcept
 Align a rectangle within another rectangle.
 
constexpr axis_aligned_rectangle align (axis_aligned_rectangle haystack, axis_aligned_rectangle needle, alignment alignment) noexcept
 Align a rectangle within another rectangle.
 
constexpr bool operator== (axis_aligned_rectangle const &lhs, axis_aligned_rectangle const &rhs) noexcept
 
constexpr bool overlaps (axis_aligned_rectangle const &lhs, axis_aligned_rectangle const &rhs) noexcept
 
constexpr axis_aligned_rectangle operator| (axis_aligned_rectangle const &lhs, axis_aligned_rectangle const &rhs) noexcept
 
constexpr axis_aligned_rectangle operator| (axis_aligned_rectangle const &lhs, point2 const &rhs) noexcept
 
constexpr axis_aligned_rectangle operator* (axis_aligned_rectangle const &lhs, float rhs) noexcept
 Expand the rectangle for the same amount in all directions.
 
constexpr axis_aligned_rectangle operator+ (axis_aligned_rectangle const &lhs, float rhs) noexcept
 Expand the rectangle for the same amount in all directions.
 
constexpr axis_aligned_rectangle operator- (axis_aligned_rectangle const &lhs, float rhs) noexcept
 Shrink the rectangle for the same amount in all directions.
 
constexpr axis_aligned_rectangle round (axis_aligned_rectangle const &rhs) noexcept
 
constexpr axis_aligned_rectangle ceil (axis_aligned_rectangle const &rhs) noexcept
 Round rectangle by expanding to pixel edge.
 
constexpr axis_aligned_rectangle ceil (axis_aligned_rectangle const &lhs, extent2 const &rhs) noexcept
 Round rectangle by expanding to a certain granularity.
 
constexpr axis_aligned_rectangle floor (axis_aligned_rectangle const &rhs) noexcept
 Round rectangle by shrinking to pixel edge.
 
constexpr axis_aligned_rectangle bounding_rectangle (axis_aligned_rectangle const &rhs) noexcept
 
constexpr 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.
 
constexpr friend float distance (axis_aligned_rectangle const &lhs, point2 const &rhs) noexcept
 

Detailed Description

Class which represents an axis-aligned rectangle.

Constructor & Destructor Documentation

◆ axis_aligned_rectangle() [1/4]

constexpr v1::axis_aligned_rectangle::axis_aligned_rectangle ( float x,
float y,
float width,
float height )
inlineconstexprnoexcept

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]

constexpr v1::axis_aligned_rectangle::axis_aligned_rectangle ( extent2 const & extent)
inlineexplicitconstexprnoexcept

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]

constexpr v1::axis_aligned_rectangle::axis_aligned_rectangle ( point2 const & p0,
point2 const & p3 )
inlineconstexprnoexcept

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]

constexpr v1::axis_aligned_rectangle::axis_aligned_rectangle ( point2 const & p0,
extent2 const & extent )
inlineconstexprnoexcept

Create a rectangle from the size.

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

Parameters
p0The left-bottom point where the rectangle starts.
extentThe size of the rectangle.

Member Function Documentation

◆ _align()

static constexpr axis_aligned_rectangle v1::axis_aligned_rectangle::_align ( axis_aligned_rectangle outside,
axis_aligned_rectangle inside,
alignment alignment )
inlinestaticconstexprnoexcept

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

◆ center()

constexpr float v1::axis_aligned_rectangle::center ( ) const
inlineconstexprnoexcept

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

◆ contains() [1/2]

constexpr bool v1::axis_aligned_rectangle::contains ( point2 const & rhs) const
inlineconstexprnoexcept

Check if a 2D coordinate is inside the rectangle.

Parameters
rhsThe coordinate of the point to test.

◆ contains() [2/2]

constexpr bool v1::axis_aligned_rectangle::contains ( point3 const & rhs) const
inlineconstexprnoexcept

Check if a 3D coordinate is inside the rectangle.

Parameters
rhsThe coordinate of the point to test. This point is converted to 2D by this function.

◆ empty()

constexpr bool v1::axis_aligned_rectangle::empty ( ) const
inlineconstexprnoexcept

Check if the rectangle has no area.

◆ holds_invariant()

constexpr bool v1::axis_aligned_rectangle::holds_invariant ( ) const
inlineconstexprnoexcept

Make sure p0 is left/bottom from p3.

Returns
True is p0 is left and below p3.

◆ middle()

constexpr float v1::axis_aligned_rectangle::middle ( ) const
inlineconstexprnoexcept

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

◆ operator bool()

constexpr v1::axis_aligned_rectangle::operator bool ( ) const
inlineexplicitconstexprnoexcept

True when the rectangle has an area.

◆ operator|=() [1/2]

constexpr axis_aligned_rectangle & v1::axis_aligned_rectangle::operator|= ( axis_aligned_rectangle const & rhs)
inlineconstexprnoexcept

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]

constexpr axis_aligned_rectangle & v1::axis_aligned_rectangle::operator|= ( point2 const & rhs)
inlineconstexprnoexcept

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.

◆ size()

constexpr extent2 v1::axis_aligned_rectangle::size ( ) const
inlineconstexprnoexcept

Get size of the rectangle.

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

Friends And Related Symbol Documentation

◆ align [1/2]

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.

◆ align [2/2]

constexpr axis_aligned_rectangle align ( axis_aligned_rectangle haystack,
extent2 needle,
alignment alignment )
friend

Align a rectangle within another rectangle.

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

◆ ceil [1/2]

Round rectangle by expanding to a certain granularity.

◆ ceil [2/2]

Round rectangle by expanding to pixel edge.

◆ fit

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

Round rectangle by shrinking to pixel edge.

◆ intersect

Return the overlapping part of two rectangles.

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

◆ midpoint

Get the center of the rectangle.

◆ operator*

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.

◆ operator+

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.

◆ operator-

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: