karbon

vcolor.h
1/* This file is part of the KDE project
2 Copyright (C) 2001, The Karbon Developers
3 Copyright (C) 2002, The Karbon Developers
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19*/
20
21#ifndef __VCOLOR_H__
22#define __VCOLOR_H__
23
24
25#include <tqcolor.h>
26#include <tqstring.h>
27#include <koffice_export.h>
28class TQDomElement;
29
30
40class KARBONBASE_EXPORT VColor
41{
42public:
44 {
45 rgb = 0,
46 cmyk = 1,
47 hsb = 2,
48 gray = 3
49 };
50
56 VColor( VColorSpace colorSpace = rgb );
57
63 VColor( const VColor& color );
64
70 VColor( const TQColor& color );
71
75 operator TQColor() const;
76
83 float operator[]( unsigned i ) const
84 { return m_value[i]; }
85
91 void set( float v1 )
92 { m_value[0] = v1; }
93
100 void set( float v1, float v2 )
101 { m_value[0] = v1; m_value[1] = v2; }
102
110 void set( float v1, float v2, float v3 )
111 { m_value[0] = v1; m_value[1] = v2; m_value[2] = v3; }
112
121 void set( float v1, float v2, float v3, float v4 )
122 { m_value[0] = v1; m_value[1] = v2; m_value[2] = v3; m_value[3] = v4; }
123
131 float opacity() const { return m_opacity; }
132
138 void setOpacity( float opacity ) { m_opacity = opacity; }
139
145 VColorSpace colorSpace() const { return m_colorSpace; }
146
155 void setColorSpace( const VColorSpace colorSpace, bool convert = true );
156
162 void save( TQDomElement& element ) const;
163
169 void load( const TQDomElement& element );
170
171private:
172 void convertToColorSpace( const VColorSpace colorSpace );
173
174 VColorSpace m_colorSpace;
175
176 float m_value[4];
177 float m_opacity;
178
179 TQString m_name;
180};
181
182#endif
This class keeps track of color properties.
Definition vcolor.h:41
float operator[](unsigned i) const
Index operator to access color components.
Definition vcolor.h:83
void set(float v1, float v2)
Sets the first and second color component.
Definition vcolor.h:100
void set(float v1)
Sets the first color component.
Definition vcolor.h:91
VColorSpace colorSpace() const
Returns the color's colorspace.
Definition vcolor.h:145
void setOpacity(float opacity)
Sets the color opacity.
Definition vcolor.h:138
float opacity() const
Returns the color opacity.
Definition vcolor.h:131
void set(float v1, float v2, float v3, float v4)
Sets the first, second, third and fourth color component.
Definition vcolor.h:121
void set(float v1, float v2, float v3)
Sets the first, second and third color component.
Definition vcolor.h:110
VColorSpace
Definition vcolor.h:44