_________ __                 __
        /   _____//  |_____________ _/  |______     ____  __ __  ______
        \_____  \\   __\_  __ \__  \\   __\__  \   / ___\|  |  \/  ___/
        /        \|  |  |  | \// __ \|  |  / __ \_/ /_/  >  |  /\___ \
       /_______  /|__|  |__|  (____  /__| (____  /\___  /|____//____  >
               \/                  \/          \//_____/            \/
    ______________________                           ______________________
                          T H E   W A R   B E G I N S
                   Stratagus - A free fantasy real time strategy game engine

Public Member Functions | Public Attributes | List of all members
gcn::Color Class Reference

#include <color.h>

Public Member Functions

 Color ()
 
 Color (int color)
 
 Color (int r, int g, int b, int a=255)
 
Color operator+ (const Color &color) const
 
Color operator- (const Color &color) const
 
Color operator* (float value) const
 
bool operator== (const Color &color) const
 
bool operator!= (const Color &color) const
 

Public Attributes

int r
 
int g
 
int b
 
int a
 

Detailed Description

Represents a color with red, green, blue and alpha components.

Constructor & Destructor Documentation

◆ Color() [1/3]

Color::Color ( )

Constructor. Initializes the color to black.

◆ Color() [2/3]

Color::Color ( int  color)

Constructs a color from the bytes in an integer. Call it with a hexadecimal constant for HTML-style color representation. The alpha component will be set to 255.

EXAMPLE: Color(0xff50a0) constructs Gui-chan's favourite color.

NOTE: Because of this constructor, integers will be automatically casted to a color by your compiler.

Parameters
colorthe color.

◆ Color() [3/3]

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

Constructor.

Parameters
rRed color component (range 0-255).
gGreen color component (range 0-255).
bBlue color component (range 0-255).
aColor alpha, used for transparency. A value of 0 means totaly transparent, 255 is totaly opaque (the default).

Member Function Documentation

◆ operator!=()

bool Color::operator!= ( const Color color) const

Compares two colors.

Returns
true if the two colors have different RGBA components.

◆ operator*()

Color Color::operator* ( float  value) const

Multiplies the RGB values of a color with a float value. The values will be clamped if they go out of range.

Parameters
valuethe value to multiply the color with.
Returns
the resulting color with alpha untouched.

◆ operator+()

Color Color::operator+ ( const Color color) const

Adds the RGB values of two colors together. The values will be clamped if they go out of range.

Parameters
colora color to add to this color.
Returns
the resulting color with alpha set to 255.

◆ operator-()

Color Color::operator- ( const Color color) const

Subtracts the RGB values of one color from another. The values will be clamped if they go out of range.

Parameters
colora color to subtract from this color.
Returns
the resulting color with alpha set to 255.

◆ operator==()

bool Color::operator== ( const Color color) const

Compares two colors.

Returns
true if the two colors have the same RGBA components.

Member Data Documentation

◆ a

int gcn::Color::a

Color alpha, used for transparency. A value of 0 means totaly transparent, 255 is totaly opaque (the default)

◆ b

int gcn::Color::b

Blue color component (range 0-255).

◆ g

int gcn::Color::g

Green color component (range 0-255).

◆ r

int gcn::Color::r

Red color component (range 0-255).


The documentation for this class was generated from the following files:
(C) Copyright 1998-2012 by The Stratagus Project under the GNU General Public License.
All trademarks and copyrights on this page are owned by their respective owners.