2 Copyright 2004 John Tsiombikas <nuclear@siggraph.org>
4 This file is part of the graphics core library.
6 The graphics core library is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 The graphics core library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with the graphics core library; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * author: John Tsiombikas 2004
28 #include "3dengfx_config.h"
29 #include "color_bits.h"
31 #ifdef SINGLE_PRECISION_MATH
32 typedef float scalar_t;
34 typedef double scalar_t;
35 #endif // DOUBLE_PRECISION_MATH
41 Color(scalar_t intensity = 1.0f);
42 Color(scalar_t r, scalar_t g, scalar_t b, scalar_t a = 1.0f);
44 Color operator +(const Color &col) const;
45 Color operator -(const Color &col) const;
46 Color operator *(const Color &col) const;
47 Color operator *(scalar_t scalar) const;
49 void operator +=(const Color &col);
50 void operator -=(const Color &col);
51 void operator *=(const Color &col);
52 void operator *=(scalar_t scalar);
54 unsigned long get_packed32() const;
55 unsigned short get_packed16() const;
56 unsigned short get_packed15() const;
57 unsigned char get_nearest8(const unsigned char **pal) const;
60 inline Color int_color(int r, int g, int b, int a = 255);
62 inline unsigned long pack_color32(const Color &col);
63 inline unsigned short pack_color16(const Color &col);
64 inline unsigned short pack_color15(const Color &col);
65 unsigned char match_nearest8(const Color &col, const unsigned char **pal);
67 inline Color unpack_color32(unsigned long pcol);
68 inline Color unpack_color16(unsigned short pcol);
69 inline Color unpack_color15(unsigned short pcol);
70 inline Color lookup_color8(int index, const unsigned char **pal);
72 Color blend_colors(const Color &c1, const Color &c2, scalar_t t);