Color Class Reference

#include <color.hpp>

List of all members.

Public Member Functions

 Color ()
 Color (float red_, float green_, float blue_, float alpha_=1.0)
 Color (const std::vector< float > &vals)
bool operator== (const Color &other) const
float greyscale () const
bool operator< (const Color &other) const

Public Attributes

float red
float green
float blue
float alpha

Static Public Attributes

static const Color BLACK
static const Color RED
static const Color GREEN
static const Color BLUE
static const Color CYAN
static const Color MAGENTA
static const Color YELLOW
static const Color WHITE


Detailed Description

Definition at line 25 of file color.hpp.


Constructor & Destructor Documentation

Color::Color (  )  [inline]

Definition at line 28 of file color.hpp.

00028           :
00029     red(0), 
00030     green(0), 
00031     blue(0), 
00032     alpha(1.0f)
00033   {}

Color::Color ( float  red_,
float  green_,
float  blue_,
float  alpha_ = 1.0 
) [inline]

Definition at line 35 of file color.hpp.

References blue, green, and red.

00035                                                                    :
00036     red(red_),
00037     green(green_), 
00038     blue(blue_), 
00039     alpha(alpha_)
00040   {
00041     assert(0 <= red   && red <= 1.0);
00042     assert(0 <= green && green <= 1.0);
00043     assert(0 <= blue  && blue <= 1.0);
00044   }

Color::Color ( const std::vector< float > &  vals  )  [inline]

Definition at line 46 of file color.hpp.

References alpha, blue, green, and red.

00046                                       :
00047     red(),
00048     green(),
00049     blue(),
00050     alpha()
00051   {
00052     assert(vals.size() >= 3);
00053     red   = vals[0];
00054     green = vals[1];
00055     blue  = vals[2];
00056     if(vals.size() > 3)
00057       alpha = vals[3];
00058     else
00059       alpha = 1.0;
00060     assert(0 <= red   && red <= 1.0);
00061     assert(0 <= green && green <= 1.0);
00062     assert(0 <= blue  && blue <= 1.0);
00063   }


Member Function Documentation

bool Color::operator== ( const Color other  )  const [inline]

Definition at line 65 of file color.hpp.

References alpha, blue, green, and red.

00066   {
00067     return red == other.red && green == other.green && blue == other.blue
00068       && alpha == other.alpha;
00069   }

float Color::greyscale (  )  const [inline]

Definition at line 71 of file color.hpp.

References blue, green, and red.

Referenced by operator<().

00072   {
00073     return red * 0.30 + green * 0.59 + blue * 0.11;
00074   }

bool Color::operator< ( const Color other  )  const [inline]

Definition at line 76 of file color.hpp.

References greyscale().

00077   {
00078     return greyscale() < other.greyscale();
00079   }


Member Data Documentation

float Color::red

Definition at line 81 of file color.hpp.

Referenced by Color(), colorize(), DrawingContext::do_drawing(), SDLRenderer::draw_filled_rect(), SDLLightmap::draw_filled_rect(), GLRenderer::draw_filled_rect(), GLLightmap::draw_filled_rect(), GLRenderer::draw_inverse_ellipse(), SDLLightmap::draw_surface(), Sector::get_ambient_red(), DrawingContext::get_light(), greyscale(), SDLTexture::ColorCache::hash(), intern_draw(), GhostTree::is_color_deadly(), Lantern::is_open(), MagicBlock::MagicBlock(), operator==(), Sector::parse_old_format(), Sector::set_ambient_light(), Gradient::set_gradient(), SDLLightmap::start_draw(), GLLightmap::start_draw(), MagicBlock::update(), and Lantern::updateColor().

float Color::green

Definition at line 81 of file color.hpp.

Referenced by Color(), colorize(), DrawingContext::do_drawing(), SDLRenderer::draw_filled_rect(), SDLLightmap::draw_filled_rect(), GLRenderer::draw_filled_rect(), GLLightmap::draw_filled_rect(), GLRenderer::draw_inverse_ellipse(), SDLLightmap::draw_surface(), Sector::get_ambient_green(), DrawingContext::get_light(), greyscale(), SDLTexture::ColorCache::hash(), intern_draw(), GhostTree::is_color_deadly(), Lantern::is_open(), MagicBlock::MagicBlock(), operator==(), Sector::parse_old_format(), Sector::set_ambient_light(), Gradient::set_gradient(), SDLLightmap::start_draw(), GLLightmap::start_draw(), MagicBlock::update(), and Lantern::updateColor().

float Color::blue

Definition at line 81 of file color.hpp.

Referenced by Color(), colorize(), DrawingContext::do_drawing(), SDLRenderer::draw_filled_rect(), SDLLightmap::draw_filled_rect(), GLRenderer::draw_filled_rect(), GLLightmap::draw_filled_rect(), GLRenderer::draw_inverse_ellipse(), SDLLightmap::draw_surface(), Sector::get_ambient_blue(), DrawingContext::get_light(), greyscale(), SDLTexture::ColorCache::hash(), intern_draw(), GhostTree::is_color_deadly(), Lantern::is_open(), MagicBlock::MagicBlock(), operator==(), Sector::parse_old_format(), Sector::set_ambient_light(), Gradient::set_gradient(), SDLLightmap::start_draw(), GLLightmap::start_draw(), MagicBlock::update(), and Lantern::updateColor().

float Color::alpha

Definition at line 81 of file color.hpp.

Referenced by Color(), FadeOut::draw(), PulsingLight::draw(), SDLRenderer::draw_filled_rect(), SDLLightmap::draw_filled_rect(), GLRenderer::draw_filled_rect(), GLLightmap::draw_filled_rect(), DrawingContext::draw_filled_rect(), GLRenderer::draw_inverse_ellipse(), DrawingContext::draw_inverse_ellipse(), SDLLightmap::draw_surface(), intern_draw(), MagicBlock::MagicBlock(), operator==(), Gradient::set_gradient(), and MagicBlock::update().

const Color Color::BLACK [static]

Definition at line 83 of file color.hpp.

const Color Color::RED [static]

Definition at line 84 of file color.hpp.

const Color Color::GREEN [static]

Definition at line 85 of file color.hpp.

const Color Color::BLUE [static]

Definition at line 86 of file color.hpp.

const Color Color::CYAN [static]

Definition at line 87 of file color.hpp.

const Color Color::MAGENTA [static]

Definition at line 88 of file color.hpp.

const Color Color::YELLOW [static]

Definition at line 89 of file color.hpp.

const Color Color::WHITE [static]

Definition at line 90 of file color.hpp.

Referenced by SDLTexture::get_transform(), and SDLTexture::SDLTexture().


The documentation for this class was generated from the following files:
Generated on Mon Jun 9 03:38:29 2014 for SuperTux by  doxygen 1.5.1