GREM 3.12.0
Game/Rendering Engine Modules for C++
Loading...
Searching...
No Matches
grem::Extent< 2 > Struct Reference

#include <GREM/core/extents.hpp>

Public Member Functions

constexpr operator Offset< 2 > () const noexcept
 Convert this extent to an offset.
constexpr operator vec2 () const noexcept
 Convert this extent to a floating-point 2D vector.
constexpr operator dvec2 () const noexcept
 Convert this extent to a double-precision floating-point 2D vector.
constexpr operator ivec2 () const noexcept
 Convert this extent to an integer 2D vector.
constexpr operator u32vec2 () const noexcept
 Convert this extent to an unsigned integer 2D vector.
constexpr operator Extent< 3 > () const noexcept
 Convert this extent to a 3D extent.
constexpr bool operator== (const Extent2D &other) const =default
 Compare this extent to another for equality.
float getAspectRatio () const
 Get the aspect ratio of the extent (width / height).
uint32_t fitIntegerScaled (Extent targetSize)
 Fit the extents into a target size at the largest positive integer scale of its original size that still fits within the target.

Static Public Member Functions

static constexpr Extent< 2 > from (u32vec2 v) noexcept
 Create an extent from a vector of integers.
static Extent< 2 > round (vec2 v)
 Create an extent from a vector of floating-point numbers, rounded to their nearest integer values before conversion.
static Extent< 2 > floor (vec2 v)
 Create an extent from a vector of floating-point numbers, rounded down to their floor integer values before conversion.
static Extent< 2 > ceil (vec2 v)
 Create an extent from a vector of floating-point numbers, rounded up to their ceiling integer values before conversion.
static Extent< 2 > trunc (vec2 v)
 Create an extent from a vector of floating-point numbers, rounded to their truncated integer values before conversion.

Public Attributes

uint32_t width
 Horizontal extent of the region.
uint32_t height = width
 Vertical extent of the region.

Member Function Documentation

◆ from()

constexpr Extent< 2 > grem::Extent< 2 >::from ( u32vec2 v)
inlinestaticnodiscardconstexprnoexcept

Create an extent from a vector of integers.

Parameters
vvector to convert.
Returns
the corresponding extent.

◆ round()

Extent< 2 > grem::Extent< 2 >::round ( vec2 v)
inlinestaticnodiscard

Create an extent from a vector of floating-point numbers, rounded to their nearest integer values before conversion.

Parameters
vvector to convert.
Returns
the rounded extent.

◆ floor()

Extent< 2 > grem::Extent< 2 >::floor ( vec2 v)
inlinestaticnodiscard

Create an extent from a vector of floating-point numbers, rounded down to their floor integer values before conversion.

Parameters
vvector to convert.
Returns
the floor-rounded extent.

◆ ceil()

Extent< 2 > grem::Extent< 2 >::ceil ( vec2 v)
inlinestaticnodiscard

Create an extent from a vector of floating-point numbers, rounded up to their ceiling integer values before conversion.

Parameters
vvector to convert.
Returns
the ceiling-rounded extent.

◆ trunc()

Extent< 2 > grem::Extent< 2 >::trunc ( vec2 v)
inlinestaticnodiscard

Create an extent from a vector of floating-point numbers, rounded to their truncated integer values before conversion.

Parameters
vvector to convert.
Returns
the truncated extent.

◆ operator Offset< 2 >()

grem::Extent< 2 >::operator Offset< 2 > ( ) const
inlineexplicitconstexprnoexcept

Convert this extent to an offset.

Returns
an offset with the width and height of the extent as its x and y components, respectively.

◆ operator vec2()

grem::Extent< 2 >::operator vec2 ( ) const
inlineconstexprnoexcept

Convert this extent to a floating-point 2D vector.

Returns
a 2D vector holding the width and height of the extent in its x and y components, respectively.

◆ operator dvec2()

grem::Extent< 2 >::operator dvec2 ( ) const
inlineconstexprnoexcept

Convert this extent to a double-precision floating-point 2D vector.

Returns
a 2D vector holding the width and height of the extent in its x and y components, respectively.

◆ operator ivec2()

grem::Extent< 2 >::operator ivec2 ( ) const
inlineconstexprnoexcept

Convert this extent to an integer 2D vector.

Returns
a 2D vector holding the width and height of the extent in its x and y components, respectively.

◆ operator u32vec2()

grem::Extent< 2 >::operator u32vec2 ( ) const
inlineconstexprnoexcept

Convert this extent to an unsigned integer 2D vector.

Returns
a 2D vector holding the width and height of the extent in its x and y components, respectively.

◆ operator Extent< 3 >()

grem::Extent< 2 >::operator Extent< 3 > ( ) const
inlineconstexprnoexcept

Convert this extent to a 3D extent.

Returns
the equivalent 3D extent, with a depth of 1.

◆ operator==()

bool grem::Extent< 2 >::operator== ( const Extent2D & other) const
nodiscardconstexprdefault

Compare this extent to another for equality.

Parameters
otherthe extent to compare this one to.
Returns
true if the extents are equal, false otherwise.

◆ getAspectRatio()

float grem::Extent< 2 >::getAspectRatio ( ) const
inlinenodiscard

Get the aspect ratio of the extent (width / height).

Returns
width / height as a float.

◆ fitIntegerScaled()

uint32_t grem::Extent< 2 >::fitIntegerScaled ( Extent< 2 > targetSize)
inline

Fit the extents into a target size at the largest positive integer scale of its original size that still fits within the target.

Parameters
targetSizetarget size to fit the extents into.
Returns
the integer scale that was chosen.
Note
If the original size cannot fit within the target, then the chosen scale will be 1.

Member Data Documentation

◆ width

uint32_t grem::Extent< 2 >::width

Horizontal extent of the region.

◆ height

uint32_t grem::Extent< 2 >::height = width

Vertical extent of the region.


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