nCine  2025.04.r498-9d36345
A cross-platform 2D game engine
Public Member Functions | Static Public Attributes | List of all members
ncine::Color Class Reference

A four channels unsigned char color. More...

#include <Color.h>

Collaboration diagram for ncine::Color:
Collaboration graph
[legend]

Public Member Functions

 Color ()
 Default constructor (white color)
 
 Color (unsigned int red, unsigned int green, unsigned int blue)
 Three channels constructor.
 
 Color (unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha)
 Four channels constructor.
 
 Color (unsigned int hex)
 Three channels constructor from a hexadecimal code.
 
 Color (const unsigned int channels[NumChannels])
 Four channels constructor from an array.
 
 Color (const Colorf &color)
 Constructor taking a normalized float color.
 
unsigned char r () const
 Gets the red channel of the color.
 
unsigned char g () const
 Gets the green channel of the color.
 
unsigned char b () const
 Gets the blue channel of the color.
 
unsigned char a () const
 Gets the alpha channel of the color.
 
unsigned int rgba () const
 Returns the color as a single RGBA unsigned integer.
 
unsigned int argb () const
 Returns the color as a single RGBA unsigned integer.
 
unsigned int abgr () const
 Returns the color as a single ABGR unsigned integer.
 
unsigned int bgra () const
 Returns the color as a single BGRA unsigned integer.
 
const unsigned char * data () const
 Gets the color array.
 
unsigned char * data ()
 Gets the color array.
 
void set (unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha)
 Sets four color channels.
 
void set (unsigned int red, unsigned int green, unsigned int blue)
 Sets three color channels.
 
void set (unsigned int hex)
 Sets three color channels from a hexadecimal code.
 
void setVec (const unsigned int channels[NumChannels])
 Sets four color channels from an array.
 
void setAlpha (unsigned int alpha)
 Sets the alpha channel.
 
Coloroperator= (const Colorf &color)
 Assignment operator from a normalized float color.
 
bool operator== (const Color &color) const
 Equality operator.
 
Coloroperator+= (const Color &v)
 
Coloroperator-= (const Color &v)
 
Coloroperator*= (const Color &color)
 
Coloroperator*= (float scalar)
 Multiplication by a constant scalar.
 
Color operator+ (const Color &color) const
 
Color operator- (const Color &color) const
 
Color operator* (const Color &color) const
 
Color operator* (float scalar) const
 Multiplication by a constant scalar.
 

Static Public Attributes

static const int NumChannels = 4
 
static const Color Black
 
static const Color White
 
static const Color Red
 
static const Color Green
 
static const Color Blue
 
static const Color Yellow
 
static const Color Magenta
 
static const Color Cyan
 

Detailed Description

A four channels unsigned char color.


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