1 /***************************************************************************
2 copyright : (C) 2004 by amarok squad
4 ***************************************************************************/
6 /***************************************************************************
7 * This library is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU Lesser General Public License version *
9 * 2.1 as published by the Free Software Foundation. *
11 * This library is distributed in the hope that it will be useful, but *
12 * WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14 * Lesser General Public License for more details. *
16 * You should have received a copy of the GNU Lesser General Public *
17 * License along with this library; if not, write to the Free Software *
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 *
20 ***************************************************************************/
22 #ifndef COLORGENERATOR_H
23 #define COLORGENERATOR_H
30 class Color
: public QColor
32 static const int CONTRAST
= 130;
33 static const int SATURATION_TARGET
= 30;
36 Color( const QColor
&c
) : QColor( c
)
41 getHsv( &h
, &s1
, &v1
);
43 debug() << "Initial Color Properties: s:" << s1
<< " v:" << v1
<< endl
;
45 //we want the new colour to be low saturation
46 //TODO what if s is less than SATURATION_TARGET to start with
50 if ( s
< SATURATION_TARGET
) {
51 int remainingContrast
= SATURATION_TARGET
- s
;
52 s
= SATURATION_TARGET
;
54 debug() << "Unapplied Contrast: " << remainingContrast
<< endl
;
56 //we only add to the value to avoid the dreaded "grey-gradient"
57 v
+= remainingContrast
;
61 debug() << "Over-compensation: " << error
<< endl
;
63 //if the error is significant then this must be a pretty bright colour
64 //it would look better if the gradient was dark
65 if( error
> CONTRAST
/2 )
74 debug() << "Final Colour Properties: s:" << s
<< " v:" << v
<< endl
;