API Documentation
Public Member Functions | List of all members
nkWinUi::Color Class Referencefinal

Represents a color, with 4 channels. More...

Public Member Functions

 Color () noexcept
 
 Color (unsigned char r, unsigned char g, unsigned char b, unsigned char a=255) noexcept
 
 Color (float r, float g, float b, float a=1.f) noexcept
 
 Color (double r, double g, double b, double a=1.0) noexcept
 
 Color (unsigned int r, unsigned int g, unsigned int b, unsigned int a=255u) noexcept
 
 Color (unsigned long long r, unsigned long long g, unsigned long long b, unsigned long long a=255ull) noexcept
 
 Color (int r, int g, int b, int a=255) noexcept
 
 Color (long long r, long long g, long long b, long long a=255ll) noexcept
 
 ~Color ()
 
float getR () const
 
float getG () const
 
float getB () const
 
float getA () const
 
unsigned int getR255 () const
 
unsigned int getG255 () const
 
unsigned int getB255 () const
 
unsigned int getA255 () const
 
Color getAssociateColor (float factor=1.5f) const
 
Color mix (const Color &other, float factor) const
 
Color getColorForDepth (unsigned int depth) const
 
Color operator* (float factor) const
 

Detailed Description

Represents a color, with 4 channels.

Constructor & Destructor Documentation

◆ Color() [1/8]

nkWinUi::Color::Color ( )
noexcept

Default constructor. Will default to a full black color.

◆ Color() [2/8]

nkWinUi::Color::Color ( unsigned char  r,
unsigned char  g,
unsigned char  b,
unsigned char  a = 255 
)
explicitnoexcept

Unsigned char constructor.

Parameters
rThe red component of the color.
gThe green component of the color.
bThe blue component of the color.
aThe alpha component of the color.
Remarks
Values should scale from 0 to 255.

◆ Color() [3/8]

nkWinUi::Color::Color ( float  r,
float  g,
float  b,
float  a = 1.f 
)
explicitnoexcept

Float constructor.

Parameters
rThe red component of the color.
gThe green component of the color.
bThe blue component of the color.
aThe alpha component of the color.
Remarks
Values should scale from 0.f to 1.f.

◆ Color() [4/8]

nkWinUi::Color::Color ( double  r,
double  g,
double  b,
double  a = 1.0 
)
explicitnoexcept

Double constructor.

Parameters
rThe red component of the color.
gThe green component of the color.
bThe blue component of the color.
aThe alpha component of the color.
Remarks
Values should scale from 0.0 to 1.0.

◆ Color() [5/8]

nkWinUi::Color::Color ( unsigned int  r,
unsigned int  g,
unsigned int  b,
unsigned int  a = 255u 
)
explicitnoexcept

Unsigned int constructor.

Parameters
rThe red component of the color.
gThe green component of the color.
bThe blue component of the color.
aThe alpha component of the color.
Remarks
Values should scale from 0 to 255.

◆ Color() [6/8]

nkWinUi::Color::Color ( unsigned long long  r,
unsigned long long  g,
unsigned long long  b,
unsigned long long  a = 255ull 
)
explicitnoexcept

Unsigned long long constructor.

Parameters
rThe red component of the color.
gThe green component of the color.
bThe blue component of the color.
aThe alpha component of the color.
Remarks
Values should scale from 0 to 255.

◆ Color() [7/8]

nkWinUi::Color::Color ( int  r,
int  g,
int  b,
int  a = 255 
)
explicitnoexcept

Int constructor.

Parameters
rThe red component of the color.
gThe green component of the color.
bThe blue component of the color.
aThe alpha component of the color.
Remarks
Values should scale from 0 to 255.

◆ Color() [8/8]

nkWinUi::Color::Color ( long long  r,
long long  g,
long long  b,
long long  a = 255ll 
)
explicitnoexcept

Long long constructor.

Parameters
rThe red component of the color.
gThe green component of the color.
bThe blue component of the color.
aThe alpha component of the color.
Remarks
Values should scale from 0 to 255.

◆ ~Color()

nkWinUi::Color::~Color ( )

Destructor.

Member Function Documentation

◆ getR()

float nkWinUi::Color::getR ( ) const
Returns
The r channel component value, as stored internally (scaled over 0.f - 1.f).

◆ getG()

float nkWinUi::Color::getG ( ) const
Returns
The g channel component value, as stored internally (scaled over 0.f - 1.f).

◆ getB()

float nkWinUi::Color::getB ( ) const
Returns
The b channel component value, as stored internally (scaled over 0.f - 1.f).

◆ getA()

float nkWinUi::Color::getA ( ) const
Returns
The a channel component value, as stored internally (scaled over 0.f - 1.f).

◆ getR255()

unsigned int nkWinUi::Color::getR255 ( ) const
Returns
The r channel component value, rescaled to the range 0 - 255.
Remarks
The value will be clamped to 255, should the component have a value above 1.f.

◆ getG255()

unsigned int nkWinUi::Color::getG255 ( ) const
Returns
The g channel component value, rescaled to the range 0 - 255.
Remarks
The value will be clamped to 255, should the component have a value above 1.f.

◆ getB255()

unsigned int nkWinUi::Color::getB255 ( ) const
Returns
The b channel component value, rescaled to the range 0 - 255.

◆ getA255()

unsigned int nkWinUi::Color::getA255 ( ) const
Returns
The a channel component value, rescaled to the range 0 - 255.
Remarks
The value will be clamped to 255, should the component have a value above 1.f.

◆ getAssociateColor()

Color nkWinUi::Color::getAssociateColor ( float  factor = 1.5f) const

Returns the "associate" color.

Parameters
factorThe factor to apply to this color.
Returns
The "associate" color, after application of the factor.
Remarks
Depending on the luminance factor of the color, this can result in either a darker, or a lighter associated color.

◆ mix()

Color nkWinUi::Color::mix ( const Color other,
float  factor 
) const

Mixes with another color.

Parameters
otherThe color to mix with.
factorThe factor, [0.f, 1.f], between this color (0.f) and the other one (1.f).
Returns
The color mix requested.

◆ getColorForDepth()

Color nkWinUi::Color::getColorForDepth ( unsigned int  depth) const

Automatically creates the color associated to the color, to give a sense of "depth" within the interface.

Parameters
depthThe depth that should be associated to the color returned. Currently, between [0, 10].
Returns
The color expressed for given depth.
Remarks
This function will adapt its behavior based on the channel having the highest intensity. It will dim the color for intensity > 0.5 (or 127). It will lighten the color else.

◆ operator*()

Color nkWinUi::Color::operator* ( float  factor) const

Overridden operator for fast scalar application.

Parameters
factorThe factor to multiply with.
Returns
The color with all of its component multiplied by the factor.

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