sandbox
Loading...
Searching...
No Matches
sbx::math::color Class Reference

RGBA color value type. More...

#include <color.hpp>

Public Member Functions

 color () noexcept
 Constructs a white color with full opacity.
 
 color (std::uint32_t rgba) noexcept
 Constructs a color from a packed 32-bit RGBA value. More...
 
 color (std::uint8_t red, std::uint8_t green, std::uint8_t blue, std::uint8_t alpha=255u) noexcept
 
template<std::floating_point Type>
 color (Type red, Type green, Type blue, Type alpha=Type{1}) noexcept
 Constructs a color from individual components. More...
 
auto r () const noexcept -> const std::float_t &
 Returns the red component (const). More...
 
auto r () noexcept -> std::float_t &
 Returns the red component. More...
 
auto g () const noexcept -> const std::float_t &
 Returns the green component (const). More...
 
auto g () noexcept -> std::float_t &
 Returns the green component. More...
 
auto b () const noexcept -> const std::float_t &
 Returns the blue component (const). More...
 
auto b () noexcept -> std::float_t &
 Returns the blue component. More...
 
auto a () const noexcept -> const std::float_t &
 Returns the alpha component (const). More...
 
auto a () noexcept -> std::float_t &
 Returns the alpha component. More...
 

Static Public Member Functions

static auto black () noexcept -> color
 Returns a black color. More...
 
static auto white () noexcept -> color
 Returns a white color. More...
 
static auto red () noexcept -> color
 Returns a red color. More...
 
static auto green () noexcept -> color
 Returns a green color. More...
 
static auto blue () noexcept -> color
 Returns a blue color. More...
 
static auto magenta () noexcept -> color
 Returns a magenta color. More...
 
static auto yellow () noexcept -> color
 Returns a yellow color. More...
 
static auto cyan () noexcept -> color
 Returns a cyan color. More...
 
static auto orange () noexcept -> color
 Returns an orange color. More...
 

Detailed Description

RGBA color value type.

Represents a color using four floating-point components: red, green, blue, and alpha. Each component is expected to be in the range [0, 1].

The class is trivially copyable and designed for use in rendering pipelines, configuration files, and hashing contexts.

Constructor & Destructor Documentation

◆ color() [1/2]

sbx::math::color::color ( std::uint32_t  rgba)
noexcept

Constructs a color from a packed 32-bit RGBA value.

Parameters
rgbaPacked RGBA value in 0xRRGGBBAA layout.

◆ color() [2/2]

template<std::floating_point Type>
sbx::math::color::color ( Type  red,
Type  green,
Type  blue,
Type  alpha = Type{1} 
)
noexcept

Constructs a color from individual components.

Parameters
redRed component.
greenGreen component.
blueBlue component.
alphaAlpha component.

Member Function Documentation

◆ a() [1/2]

auto sbx::math::color::a ( ) const -> const std::float_t&
noexcept

Returns the alpha component (const).

Returns
Reference to the alpha component.

◆ a() [2/2]

auto sbx::math::color::a ( ) -> std::float_t&
noexcept

Returns the alpha component.

Returns
Reference to the alpha component.

◆ b() [1/2]

auto sbx::math::color::b ( ) const -> const std::float_t&
noexcept

Returns the blue component (const).

Returns
Reference to the blue component.

◆ b() [2/2]

auto sbx::math::color::b ( ) -> std::float_t&
noexcept

Returns the blue component.

Returns
Reference to the blue component.

◆ black()

auto sbx::math::color::black ( ) -> color
staticnoexcept

Returns a black color.

Returns
Black color (0, 0, 0, 1).

◆ blue()

auto sbx::math::color::blue ( ) -> color
staticnoexcept

Returns a blue color.

Returns
Blue color (0, 0, 1, 1).

◆ cyan()

auto sbx::math::color::cyan ( ) -> color
staticnoexcept

Returns a cyan color.

Returns
Cyan color (0, 1, 1, 1).

◆ g() [1/2]

auto sbx::math::color::g ( ) const -> const std::float_t&
noexcept

Returns the green component (const).

Returns
Reference to the green component.

◆ g() [2/2]

auto sbx::math::color::g ( ) -> std::float_t&
noexcept

Returns the green component.

Returns
Reference to the green component.

◆ green()

auto sbx::math::color::green ( ) -> color
staticnoexcept

Returns a green color.

Returns
Green color (0, 1, 0, 1).

◆ magenta()

auto sbx::math::color::magenta ( ) -> color
staticnoexcept

Returns a magenta color.

Returns
Magenta color (1, 0, 1, 1).

◆ orange()

auto sbx::math::color::orange ( ) -> color
staticnoexcept

Returns an orange color.

Returns
Orange color (1, 0.5, 0, 1).

◆ r() [1/2]

auto sbx::math::color::r ( ) const -> const std::float_t&
noexcept

Returns the red component (const).

Returns
Reference to the red component.

◆ r() [2/2]

auto sbx::math::color::r ( ) -> std::float_t&
noexcept

Returns the red component.

Returns
Reference to the red component.

◆ red()

auto sbx::math::color::red ( ) -> color
staticnoexcept

Returns a red color.

Returns
Red color (1, 0, 0, 1).

◆ white()

auto sbx::math::color::white ( ) -> color
staticnoexcept

Returns a white color.

Returns
White color (1, 1, 1, 1).

◆ yellow()

auto sbx::math::color::yellow ( ) -> color
staticnoexcept

Returns a yellow color.

Returns
Yellow color (1, 1, 0, 1).

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