1 #include "palette.h"
2 
Palette(const QColor & color,qreal shift)3 Palette::Palette(const QColor &color, qreal shift)
4 {
5 	_h = 0; _s = 0; _v = 0; _a = 1.0;
6 
7 	setColor(color);
8 	setShift(shift);
9 
10 	_state = _h;
11 }
12 
setColor(const QColor & color)13 void Palette::setColor(const QColor &color)
14 {
15 	if (color.isValid())
16 		color.getHsvF(&_h, &_s, &_v, &_a);
17 }
18 
setShift(qreal shift)19 void Palette::setShift(qreal shift)
20 {
21 	if (shift >= 0 && shift <= 1.0)
22 		_shift = shift;
23 }
24 
nextColor()25 QColor Palette::nextColor()
26 {
27 	QColor ret = QColor::fromHsvF(_state, _s, _v, _a);
28 
29 	_state += _shift;
30 	_state -= (int) _state;
31 
32 	return ret;
33 }
34 
reset()35 void Palette::reset()
36 {
37 	_state = _h;
38 }
39 
40 #ifndef QT_NO_DEBUG
operator <<(QDebug dbg,const Palette & palette)41 QDebug operator<<(QDebug dbg, const Palette &palette)
42 {
43 	dbg.nospace() << "Palette(" << palette.color() << ", " << palette.shift()
44 	  << ")";
45 	return dbg.space();
46 }
47 #endif // QT_NO_DEBUG
48