1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
/***************************************************************************
color.h - description
-------------------
begin : Sun Jul 9 2000
copyright : (C) 2000 by Artur Rataj
email : art@zeus.polsl.gliwice.pl
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef COLOR_H
#define COLOR_H
#include "main.h"
/**A color class, holds its components and name
*@author Artur Rataj
*/
class Color {
public:
/** indices of components
*/
enum { RED_INDEX = 0,
GREEN_INDEX = 1,
BLUE_INDEX = 2,
COMPONENTS_NUM = 3 };
public:
/** constructs a color
*/
Color();
/** constructs a color with given components and a name
*/
Color(const int red, const int green, const int blue, const TQString& name);
~Color();
/** sets a component
*/
void setComponent(const int index, const int value);
/** sets components
*/
void setComponents(const int red, const int green, const int blue);
/** sets a name
*/
void setName(const TQString& name);
/** @return a component
*/
int component(const int index) const;
/** @return components
*/
const int* components() const;
/** @return a color name
*/
const TQString& name() const;
/** @return if is equal to color
*/
bool equals(const Color& color);
/** modifies a component, amount can be either positive or negative
*/
void modifyComponent(const int index, const int value, const double amount);
/** modifies components, amount can be either positive or negative
*/
void modifyComponents(const int red, const int green, const int blue, const double amount);
protected:
/** components table
*/
int m_components[COMPONENTS_NUM];
/** a color name
*/
TQString m_name;
};
#endif
|