Porytiles
Loading...
Searching...
No Matches
porytiles2::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_transparent (const Rgba32 &extrinsic) const
 Checks if this color should be treated as transparent.
 
std::string to_jasc_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 21 of file rgba32.hpp.

Constructor & Destructor Documentation

◆ Rgba32() [1/2]

constexpr porytiles2::Rgba32::Rgba32 ( )
inlineconstexpr

Definition at line 26 of file rgba32.hpp.

◆ Rgba32() [2/2]

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

Definition at line 28 of file rgba32.hpp.

Member Function Documentation

◆ alpha()

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

Definition at line 70 of file rgba32.hpp.

◆ blue()

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

Definition at line 65 of file rgba32.hpp.

◆ equals_ignoring_alpha()

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

Definition at line 23 of file rgba32.cpp.

◆ green()

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

Definition at line 60 of file rgba32.hpp.

◆ is_transparent()

bool porytiles2::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 9 of file rgba32.cpp.

◆ operator<=>()

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

◆ operator==()

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

◆ red()

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

Definition at line 55 of file rgba32.hpp.

◆ to_jasc_str()

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

Definition at line 18 of file rgba32.cpp.

Member Data Documentation

◆ alpha_opaque

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

Definition at line 24 of file rgba32.hpp.

◆ alpha_transparent

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

Definition at line 23 of file rgba32.hpp.


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