00001 #ifndef Palette_H 00002 #define Palette_H 00003 /*######################################################################## 00004 File: Palette.h 00005 Creation date: 25th May 2002 00006 00007 Copyright 2002 Mark Williams, all rights reserved. 00008 Contact: mark@extrabit.com 00009 http://www.extrabit.com 00010 00011 This program is free software; you can redistribute it and/or 00012 modify it under the terms of the GNU General Public License 00013 as published by the Free Software Foundation; either version 2 00014 of the License, or (at your option) any later version. 00015 00016 This program is distributed in the hope that it will be useful, 00017 but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 GNU General Public License for more details. 00020 00021 ########################################################################*/ 00022 00023 /*######################################################################## 00024 Headers 00025 ########################################################################*/ 00026 00027 #include "rgbcolour.h" 00028 00029 /*######################################################################## 00030 Declarations 00031 ########################################################################*/ 00032 00033 /*######################################################################## 00034 Type Definitions 00035 ########################################################################*/ 00036 00040 enum palette_t 00041 { 00042 PALETTE_BRIGHT = 0, 00043 PALETTE_PASTEL, 00044 PALETTE_MONOCHROME, 00045 PALETTE_WHITE 00046 } ; 00047 00048 /*######################################################################## 00049 Class Definition 00050 ########################################################################*/ 00051 00054 class Palette 00055 { 00056 public: 00057 Palette (int ncolours) ; 00058 ~Palette (void) ; 00059 00060 int inq_ncolours (void) const { return m_ncolours ; } 00061 rgbcolour_t* inq_colours (void) const { return m_colours ; } 00062 float* inq_linear_colours (void) const { return m_linear_colours ; } 00063 00064 void resize (int) ; 00065 void randomise (void) ; 00066 00067 palette_t inq_type (void) const { return m_type ; } 00068 void set_type (palette_t type) { m_type = type ; } 00069 00070 rgbcolour_t inq_main_colour (void) const { return m_main_colour ; } 00071 void set_main_colour (rgbcolour_t col) ; 00072 00073 double gamma_correct (double linear_col) const ; 00074 00075 private: 00076 void init (int ncolours) ; 00077 void randomise_bright (void) ; 00078 void randomise_pastel (void) ; 00079 void randomise_monochrome (void) ; 00080 void set_white (void) ; 00081 void update_linear_colours (void) ; 00082 00083 private: 00087 palette_t m_type ; 00088 00092 rgbcolour_t m_main_colour ; 00093 00095 int m_ncolours ; 00096 00101 rgbcolour_t* m_colours ; 00102 00109 float* m_linear_colours ; 00110 } ; 00111 00112 00113 /*######################################################################## 00114 End 00115 ########################################################################*/ 00116 #endif
1.2.16