00001 // $Id: color.hxx,v 1.6 2003/01/05 15:29:15 grumbel Exp $ 00002 // 00003 // Construo - A wire-frame construction game 00004 // Copyright (C) 2002 Ingo Ruhnke <[email protected]> 00005 // 00006 // This program is free software; you can redistribute it and/or 00007 // modify it under the terms of the GNU General Public License 00008 // as published by the Free Software Foundation; either version 2 00009 // of the License, or (at your option) any later version. 00010 // 00011 // This program is distributed in the hope that it will be useful, 00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 // GNU General Public License for more details. 00015 // 00016 // You should have received a copy of the GNU General Public License 00017 // along with this program; if not, write to the Free Software 00018 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00019 00020 #ifndef HEADER_CONSTRUO_COLOR_HXX 00021 #define HEADER_CONSTRUO_COLOR_HXX 00022 00024 struct Color 00025 { 00026 float r; 00027 float g; 00028 float b; 00029 float a; 00030 00031 Color (int i) { 00032 r = ((i & 0xFF000000) >> 24) / 255.0f; 00033 g = ((i & 0x00FF0000) >> 16) / 255.0f; 00034 b = ((i & 0x0000FF00) >> 8) / 255.0f; 00035 a = ((i & 0x000000FF) >> 0) / 255.0f; 00036 } 00037 00038 Color (float r, float g, float b, float a = 1.0f) 00039 : r (r), g (g), b (b), a (a) {} 00040 00042 inline unsigned int get_rgb () { return int(255 * b) | (int((255 * g)) << 8) | (int((255 * r)) << 16); } 00043 }; 00044 00045 #endif 00046 00047 /* EOF */