libSDL2pp
C++ bindings/wrapper for SDL2
Loading...
Searching...
No Matches
Public Member Functions | List of all members
SDL2pp::Color Class Reference

RGB color with Alpha. More...

#include <SDL2pp/Color.hh>

Inheritance diagram for SDL2pp::Color:

Public Member Functions

constexpr Color ()
 Default constructor.
 
constexpr Color (const SDL_Color &color)
 Construct a color from existing SDL_Color.
 
constexpr Color (Uint8 r, Uint8 g, Uint8 b)
 Construct the color from given RGB, alpha is opaque.
 
constexpr Color (Uint8 r, Uint8 g, Uint8 b, Uint8 a)
 Construct the color from given RGB and alpha values.
 
 Color (const Color &) noexcept=default
 Copy constructor.
 
 Color (Color &&) noexcept=default
 Move constructor.
 
Coloroperator= (const Color &) noexcept=default
 Assignment operator.
 
Coloroperator= (Color &&) noexcept=default
 Move assignment operator.
 
constexpr Uint8 GetRed () const
 Get the red component from the color.
 
ColorSetRed (int nr)
 Set the red component from the color.
 
constexpr Uint8 GetGreen () const
 Get the green component from the color.
 
ColorSetGreen (int ng)
 Set the green component from the color.
 
constexpr Uint8 GetBlue () const
 Get the blue component from the color.
 
ColorSetBlue (int nb)
 Set the blue component from the color.
 
constexpr Uint8 GetAlpha () const
 Get the alpha component from the color.
 
ColorSetAlpha (int na)
 Set the alpha component from the color.
 

Detailed Description

RGB color with Alpha.

This class is public-derived from SDL_Color structure, may generally used as it if passed via pointer or reference. It also supports direct access to r, g, b and a members.

See also
http://wiki.libsdl.org/SDL_Color

Constructor & Destructor Documentation

◆ Color() [1/6]

constexpr SDL2pp::Color::Color ( )
inlineconstexpr

Default constructor.

Creates a Color(0, 0, 0, 0)

◆ Color() [2/6]

constexpr SDL2pp::Color::Color ( const SDL_Color &  color)
inlineconstexpr

Construct a color from existing SDL_Color.

Parameters
[in]colorExisting SDL_Color

◆ Color() [3/6]

constexpr SDL2pp::Color::Color ( Uint8  r,
Uint8  g,
Uint8  b 
)
inlineconstexpr

Construct the color from given RGB, alpha is opaque.

Parameters
[in]rRed component in the range 0-255
[in]gGreen component in the range 0-255
[in]bBlue component in the range 0-255

◆ Color() [4/6]

constexpr SDL2pp::Color::Color ( Uint8  r,
Uint8  g,
Uint8  b,
Uint8  a 
)
inlineconstexpr

Construct the color from given RGB and alpha values.

Parameters
[in]rRed component in the range 0-255
[in]gGreen component in the range 0-255
[in]bBlue component in the range 0-255
[in]aAlpha component in the range 0-255

◆ Color() [5/6]

SDL2pp::Color::Color ( const Color )
defaultnoexcept

Copy constructor.

◆ Color() [6/6]

SDL2pp::Color::Color ( Color &&  )
defaultnoexcept

Move constructor.

Member Function Documentation

◆ GetAlpha()

constexpr Uint8 SDL2pp::Color::GetAlpha ( ) const
inlineconstexpr

Get the alpha component from the color.

Returns
The alpha component from the color

◆ GetBlue()

constexpr Uint8 SDL2pp::Color::GetBlue ( ) const
inlineconstexpr

Get the blue component from the color.

Returns
The blue component from the color

◆ GetGreen()

constexpr Uint8 SDL2pp::Color::GetGreen ( ) const
inlineconstexpr

Get the green component from the color.

Returns
The green component from the color

◆ GetRed()

constexpr Uint8 SDL2pp::Color::GetRed ( ) const
inlineconstexpr

Get the red component from the color.

Returns
The red component from the color

◆ operator=() [1/2]

Color & SDL2pp::Color::operator= ( Color &&  )
defaultnoexcept

Move assignment operator.

Returns
Reference to self

◆ operator=() [2/2]

Color & SDL2pp::Color::operator= ( const Color )
defaultnoexcept

Assignment operator.

Returns
Reference to self

◆ SetAlpha()

Color & SDL2pp::Color::SetAlpha ( int  na)
inline

Set the alpha component from the color.

Parameters
[in]naNew alpha component value
Returns
Reference to self

◆ SetBlue()

Color & SDL2pp::Color::SetBlue ( int  nb)
inline

Set the blue component from the color.

Parameters
[in]nbNew blue component value
Returns
Reference to self

◆ SetGreen()

Color & SDL2pp::Color::SetGreen ( int  ng)
inline

Set the green component from the color.

Parameters
[in]ngNew green component value
Returns
Reference to self

◆ SetRed()

Color & SDL2pp::Color::SetRed ( int  nr)
inline

Set the red component from the color.

Parameters
[in]nrNew red component value
Returns
Reference to self

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