OpenVDB 14.0.0
Loading...
Searching...
No Matches
Rgba8 Class Reference

8-bit red, green, blue, alpha packed into 32 bit unsigned int More...

#include <nanovdb/math/Math.h>

Public Types

using ValueType = uint8_t

Public Member Functions

 Rgba8 (const Rgba8 &) noexcept=default
 Default copy constructor.
 Rgba8 (Rgba8 &&) noexcept=default
 Default move constructor.
Rgba8 & operator= (Rgba8 &&) noexcept=default
 Default move assignment operator.
Rgba8 & operator= (const Rgba8 &) noexcept=default
 Default copy assignment operator.
__hostdev__ constexpr Rgba8 () noexcept
 Default ctor initializes all channels to zero.
__hostdev__ constexpr Rgba8 (uint8_t r, uint8_t g, uint8_t b, uint8_t a=255u) noexcept
 integer r,g,b,a ctor where alpha channel defaults to opaque
__hostdev__ constexpr Rgba8 (uint8_t v) noexcept
 Ctor where all channels are initialized to the same value.
__hostdev__ constexpr Rgba8 (float r, float g, float b, float a=1.0f) noexcept
 floating-point r,g,b,a ctor where alpha channel defaults to opaque
__hostdev__ constexpr Rgba8 (const Vec3< float > &rgb) noexcept
 Construct from a Vec3<float> with rgb components (alpha set to opaque).
__hostdev__ constexpr Rgba8 (const Vec4< float > &rgba) noexcept
 Construct from a Vec4<float> with rgba components.
__hostdev__ bool operator< (const Rgba8 &rhs) const noexcept
 Compare on the 32-bit packed integer representation (lexicographic by byte).
__hostdev__ bool operator== (const Rgba8 &rhs) const noexcept
 Equality on the 32-bit packed integer representation.
__hostdev__ constexpr float lengthSqr () const noexcept
 Return the squared L2 length of the rgb channels in the [0, 1] range (alpha is ignored). 0.0000153787005f is 1/255^2.
__hostdev__ float length () const noexcept
 L2 length of the rgb channels (alpha ignored). Not constexpr — calls sqrtf.
__hostdev__ constexpr float asFloat (int n) const noexcept
 Return the n'th color channel as a float in the range 0 to 1.
__hostdev__ constexpr const uint8_t & operator[] (int n) const noexcept
 Indexed channel access. Asserts 0 <= n < 4 in debug builds.
__hostdev__ constexpr uint8_t & operator[] (int n) noexcept
 Mutable variant of operator[].
__hostdev__ const uint32_t & packed () const noexcept
 Const access to the 32-bit packed integer representation.
__hostdev__ uint32_t & packed () noexcept
 Mutable access to the 32-bit packed integer representation.
__hostdev__ constexpr const uint8_t & r () const noexcept
 Named channel accessors (r, g, b, a). Both const and non-const variants.
__hostdev__ constexpr const uint8_t & g () const noexcept
__hostdev__ constexpr const uint8_t & b () const noexcept
__hostdev__ constexpr const uint8_t & a () const noexcept
__hostdev__ constexpr uint8_t & r () noexcept
__hostdev__ constexpr uint8_t & g () noexcept
__hostdev__ constexpr uint8_t & b () noexcept
__hostdev__ constexpr uint8_t & a () noexcept
__hostdev__ constexpr operator Vec3< float > () const noexcept
 Implicit conversion to a Vec3<float> with channels in [0, 1] (alpha dropped).
__hostdev__ constexpr operator Vec4< float > () const noexcept
 Implicit conversion to a Vec4<float> with rgba channels in [0, 1].

Static Public Attributes

static const int SIZE = 4

Detailed Description

8-bit red, green, blue, alpha packed into 32 bit unsigned int

Member Typedef Documentation

◆ ValueType

using ValueType = uint8_t

Constructor & Destructor Documentation

◆ Rgba8() [1/8]

Rgba8 ( const Rgba8 & )
defaultnoexcept

Default copy constructor.

◆ Rgba8() [2/8]

Rgba8 ( Rgba8 && )
defaultnoexcept

Default move constructor.

◆ Rgba8() [3/8]

__hostdev__ constexpr Rgba8 ( )
inlineconstexprnoexcept

Default ctor initializes all channels to zero.

◆ Rgba8() [4/8]

__hostdev__ constexpr Rgba8 ( uint8_t r,
uint8_t g,
uint8_t b,
uint8_t a = 255u )
inlineconstexprnoexcept

integer r,g,b,a ctor where alpha channel defaults to opaque

Note
all values should be in the range 0u to 255u

◆ Rgba8() [5/8]

__hostdev__ constexpr Rgba8 ( uint8_t v)
inlineexplicitconstexprnoexcept

Ctor where all channels are initialized to the same value.

Note
value should be in the range 0u to 255u

◆ Rgba8() [6/8]

__hostdev__ constexpr Rgba8 ( float r,
float g,
float b,
float a = 1.0f )
inlineconstexprnoexcept

floating-point r,g,b,a ctor where alpha channel defaults to opaque

Note
all values should be in the range 0.0f to 1.0f

◆ Rgba8() [7/8]

__hostdev__ constexpr Rgba8 ( const Vec3< float > & rgb)
inlineconstexprnoexcept

Construct from a Vec3<float> with rgb components (alpha set to opaque).

Note
all values should be in the range 0.0f to 1.0f

◆ Rgba8() [8/8]

__hostdev__ constexpr Rgba8 ( const Vec4< float > & rgba)
inlineconstexprnoexcept

Construct from a Vec4<float> with rgba components.

Note
all values should be in the range 0.0f to 1.0f

Member Function Documentation

◆ a() [1/2]

__hostdev__ constexpr const uint8_t & a ( ) const
inlineconstexprnoexcept

◆ a() [2/2]

__hostdev__ constexpr uint8_t & a ( )
inlineconstexprnoexcept

◆ asFloat()

__hostdev__ constexpr float asFloat ( int n) const
inlinenodiscardconstexprnoexcept

Return the n'th color channel as a float in the range 0 to 1.

◆ b() [1/2]

__hostdev__ constexpr const uint8_t & b ( ) const
inlineconstexprnoexcept

◆ b() [2/2]

__hostdev__ constexpr uint8_t & b ( )
inlineconstexprnoexcept

◆ g() [1/2]

__hostdev__ constexpr const uint8_t & g ( ) const
inlineconstexprnoexcept

◆ g() [2/2]

__hostdev__ constexpr uint8_t & g ( )
inlineconstexprnoexcept

◆ length()

__hostdev__ float length ( ) const
inlinenodiscardnoexcept

L2 length of the rgb channels (alpha ignored). Not constexpr — calls sqrtf.

◆ lengthSqr()

__hostdev__ constexpr float lengthSqr ( ) const
inlinenodiscardconstexprnoexcept

Return the squared L2 length of the rgb channels in the [0, 1] range (alpha is ignored). 0.0000153787005f is 1/255^2.

◆ operator Vec3< float >()

__hostdev__ constexpr operator Vec3< float > ( ) const
inlinenodiscardconstexprnoexcept

Implicit conversion to a Vec3<float> with channels in [0, 1] (alpha dropped).

◆ operator Vec4< float >()

__hostdev__ constexpr operator Vec4< float > ( ) const
inlinenodiscardconstexprnoexcept

Implicit conversion to a Vec4<float> with rgba channels in [0, 1].

◆ operator<()

__hostdev__ bool operator< ( const Rgba8 & rhs) const
inlinenodiscardnoexcept

Compare on the 32-bit packed integer representation (lexicographic by byte).

◆ operator=() [1/2]

Rgba8 & operator= ( const Rgba8 & )
defaultnoexcept

Default copy assignment operator.

Returns
non-const reference to this instance

◆ operator=() [2/2]

Rgba8 & operator= ( Rgba8 && )
defaultnoexcept

Default move assignment operator.

Returns
non-const reference to this instance

◆ operator==()

__hostdev__ bool operator== ( const Rgba8 & rhs) const
inlinenodiscardnoexcept

Equality on the 32-bit packed integer representation.

◆ operator[]() [1/2]

__hostdev__ constexpr const uint8_t & operator[] ( int n) const
inlineconstexprnoexcept

Indexed channel access. Asserts 0 <= n < 4 in debug builds.

◆ operator[]() [2/2]

__hostdev__ constexpr uint8_t & operator[] ( int n)
inlineconstexprnoexcept

Mutable variant of operator[].

◆ packed() [1/2]

__hostdev__ const uint32_t & packed ( ) const
inlinenoexcept

Const access to the 32-bit packed integer representation.

◆ packed() [2/2]

__hostdev__ uint32_t & packed ( )
inlinenoexcept

Mutable access to the 32-bit packed integer representation.

◆ r() [1/2]

__hostdev__ constexpr const uint8_t & r ( ) const
inlineconstexprnoexcept

Named channel accessors (r, g, b, a). Both const and non-const variants.

◆ r() [2/2]

__hostdev__ constexpr uint8_t & r ( )
inlineconstexprnoexcept

Member Data Documentation

◆ c

uint8_t c[4]

◆ packed

uint32_t packed

◆ SIZE

const int SIZE = 4
static