Porytiles
Loading...
Searching...
No Matches
porytiles::Rgba32 Class Reference

Represents a 32-bit RGBA color. More...

#include <rgba32.hpp>

Public Member Functions

constexpr Rgba32 ()
 
constexpr Rgba32 (std::uint8_t red, std::uint8_t green, std::uint8_t blue, std::uint8_t alpha=alpha_opaque)
 
auto operator<=> (const Rgba32 &rgba) const =default
 
bool operator== (const Rgba32 &rgba) const =default
 
bool is_intrinsically_transparent () const
 Checks if this color is intrinsically transparent based on its alpha channel.
 
bool is_extrinsically_transparent (const Rgba32 &extrinsic) const
 Checks if this color matches the extrinsic transparency color.
 
bool is_transparent (const Rgba32 &extrinsic) const
 Checks if this color should be treated as transparent.
 
std::string to_jasc_str () const
 
std::string to_csv_str () const
 
bool equals_ignoring_alpha (const Rgba32 &other) const
 
std::uint8_t red () const
 
std::uint8_t green () const
 
std::uint8_t blue () const
 
std::uint8_t alpha () const
 

Static Public Attributes

static constexpr std::uint8_t alpha_transparent = 0
 
static constexpr std::uint8_t alpha_opaque = 255
 

Detailed Description

Represents a 32-bit RGBA color.

RGBA32 stores color values as four 8-bit components: red, green, blue, and alpha. Alpha of 0 indicates full transparency, while alpha of 255 indicates full opacity.

Invariant
Default-constructed Rgba32 is transparent (satisfies SupportsTransparency design invariant). That is, Rgba32{} produces a transparent color with all components set to 0, including alpha.

Definition at line 23 of file rgba32.hpp.

Constructor & Destructor Documentation

◆ Rgba32() [1/2]

constexpr porytiles::Rgba32::Rgba32 ( )
inlineconstexpr

Definition at line 28 of file rgba32.hpp.

◆ Rgba32() [2/2]

constexpr porytiles::Rgba32::Rgba32 ( std::uint8_t  red,
std::uint8_t  green,
std::uint8_t  blue,
std::uint8_t  alpha = alpha_opaque 
)
inlineconstexpr

Definition at line 30 of file rgba32.hpp.

Member Function Documentation

◆ alpha()

std::uint8_t porytiles::Rgba32::alpha ( ) const
inline

Definition at line 96 of file rgba32.hpp.

◆ blue()

std::uint8_t porytiles::Rgba32::blue ( ) const
inline

Definition at line 91 of file rgba32.hpp.

◆ equals_ignoring_alpha()

bool porytiles::Rgba32::equals_ignoring_alpha ( const Rgba32 other) const

Definition at line 34 of file rgba32.cpp.

◆ green()

std::uint8_t porytiles::Rgba32::green ( ) const
inline

Definition at line 86 of file rgba32.hpp.

◆ is_extrinsically_transparent()

bool porytiles::Rgba32::is_extrinsically_transparent ( const Rgba32 extrinsic) const

Checks if this color matches the extrinsic transparency color.

A color is extrinsically transparent if its RGB components match the extrinsic transparency color, regardless of alpha values.

Parameters
extrinsicThe extrinsic transparency color to check against
Returns
True if this color's RGB components match the extrinsic color, false otherwise

Definition at line 14 of file rgba32.cpp.

◆ is_intrinsically_transparent()

bool porytiles::Rgba32::is_intrinsically_transparent ( ) const

Checks if this color is intrinsically transparent based on its alpha channel.

A color is intrinsically transparent if its alpha value is 0.

Returns
True if alpha == alpha_transparent, false otherwise

Definition at line 9 of file rgba32.cpp.

◆ is_transparent()

bool porytiles::Rgba32::is_transparent ( const Rgba32 extrinsic) const

Checks if this color should be treated as transparent.

An RGBA32 color is considered transparent if either the color matches the extrinsic transparency color (ignoring alpha values) or if this color's intrinsic alpha value indicates transparency (alpha == 0).

Parameters
extrinsicThe extrinsic transparency color to check against
Returns
True if this color should be treated as transparent, false otherwise

Definition at line 19 of file rgba32.cpp.

◆ operator<=>()

auto porytiles::Rgba32::operator<=> ( const Rgba32 rgba) const
default

◆ operator==()

bool porytiles::Rgba32::operator== ( const Rgba32 rgba) const
default

◆ red()

std::uint8_t porytiles::Rgba32::red ( ) const
inline

Definition at line 81 of file rgba32.hpp.

◆ to_csv_str()

std::string porytiles::Rgba32::to_csv_str ( ) const

Definition at line 29 of file rgba32.cpp.

◆ to_jasc_str()

std::string porytiles::Rgba32::to_jasc_str ( ) const

Definition at line 24 of file rgba32.cpp.

Member Data Documentation

◆ alpha_opaque

constexpr std::uint8_t porytiles::Rgba32::alpha_opaque = 255
staticconstexpr

Definition at line 26 of file rgba32.hpp.

◆ alpha_transparent

constexpr std::uint8_t porytiles::Rgba32::alpha_transparent = 0
staticconstexpr

Definition at line 25 of file rgba32.hpp.


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