____                _       __
    / __ )____  _____   | |     / /___ ___________
   / __  / __ \/ ___/   | | /| / / __ `/ ___/ ___/
  / /_/ / /_/ (__  )    | |/ |/ / /_/ / /  (__  )
 /_____/\____/____/     |__/|__/\__,_/_/  /____/

       A futuristic real-time strategy game.
          This file is part of Bos Wars.
(C) Copyright 2001-2007 by the Bos Wars and Stratagus Project. Distributed under the "GNU General Public License"

gcn::Color Class Reference

#include <color.h>

List of all members.

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.

Definition at line 65 of file color.h.


Constructor & Destructor Documentation

gcn::Color::Color (  ) 

Constructor. Initializes the color to black.

Definition at line 63 of file color.cpp.

References a, b, g, and r.

gcn::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:
color the color.

Definition at line 71 of file color.cpp.

References a, b, g, and r.

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

Constructor.

Parameters:
r Red color component (range 0-255).
g Green color component (range 0-255).
b Blue color component (range 0-255).
a Color alpha, used for transparency. A value of 0 means totaly transparent, 255 is totaly opaque (the default).

Definition at line 79 of file color.cpp.


Member Function Documentation

Color gcn::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:
color a color to add to this color.
Returns:
the resulting color with alpha set to 255.

Definition at line 87 of file color.cpp.

References a, b, g, and r.

Color gcn::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:
color a color to subtract from this color.
Returns:
the resulting color with alpha set to 255.

Definition at line 102 of file color.cpp.

References a, b, g, and r.

Color gcn::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:
value the value to multiply the color with.
Returns:
the resulting color with alpha untouched.

Definition at line 117 of file color.cpp.

References a, b, g, int(), and r.

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

Compares two colors.

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

Definition at line 132 of file color.cpp.

References a, b, g, and r.

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

Compares two colors.

Returns:
true if the two colors have different RGBA components.

Definition at line 137 of file color.cpp.

References a, b, g, and r.


Member Data Documentation


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

Generated on Sat Feb 21 00:28:26 2009 for Bos Wars by  doxygen 1.5.6